Transcript ppt
ECE 526 – Network
Processing Systems Design
Software-based Protocol Processing
Chapter 7: D. E. Comer
Goal
• Understand how the network processing protocol stack
─ Implemented
─ Executed
─ Organized
in software based network processing systems.
Ning Weng
ECE 526
2
Outline
• Protocol software on conventional processor
─ Possible implementations
─ Processing priority controlling mechanisms
• Software interrupts
• Software threads
─ Organization of software for layered systems
• Summary
Ning Weng
ECE 526
3
Protocols on Processor
• High performance network processing systems
─ Protocols with efficient data structures and algorithms
─ Powerful processor
─ Efficient implementation of protocols on processor
• Three possible implementations
─ In an application program
• Possible but not practical due lacking of speed
─ In an operating system kernel
•
•
•
•
Software system managing memory and I/O devices
Kernel resident in memory all time when processor on
Separate address space, highest privilege
Containing device driver and controlling device operations
─ In an embedded system
• Programmable hardware device dedicated for special tasks
Ning Weng
ECE 526
4
Implementation Comparison
Easy of
Programming
High
performance
Application
domain
Application
Program
Easy
poor
Less
performance
demanding
OS Kernel
Most difficult
good
Higher
performance and
shared by
applications
Embedded
Possibly
difficult
good
Stand-alone
device: bridge
Ning Weng
ECE 526
5
Data movement within protocols
Ning Weng
ECE 526
6
Interrupts
• What is interrupt?
─ Event signal to OS which results in context switch
• Interrupt mechanism
─
─
─
─
Operating asynchronously
Saving current processing state
Changing processor status
Branches to specified locations
• Types of interrupt
─ Hardware interrupt: raised by device
─ Software interrupt: raised by executing program
• Protocol stack operating as software interrupt
─ When packet arrives, hardware interrupts
─ Device drive raises software interrupt
─ Interrupts cleared and protocol processing invoked
• Multiple interrupts, how to determine who gets service first
─ Priority
Ning Weng
ECE 526
7
Priorities
•
•
•
•
•
Determining the code which CPU executing at any time
Interrupts have different priorities
Higher priority code can interrupt lower priority code
Kernel software can specify desired interrupt level
Possible outcome of priorities processing
─ Livelock: CPU has no efficient power to handle a higher priority load
• Packet processing:
─
─
─
─
Device (NIC): receiving packets
Protocol stack: processing packets
Applications: further processing packet if necessary
Question: who should has the highest priority
Ning Weng
ECE 526
8
Packet Processing Priority
• Packet processing
priorities:
─ Highest to device driver
─ Lowest to application
• Requires queues
between interrupt levels
─ Why?
─ What is inside queues?
• Processing in higher
interrupts should be kept
briefly
Ning Weng
ECE 526
9
Kernel Threads
• Thread: piece of software that runs in its own context
─ Similar to process but is light-weight
• Different threads can run in different priorities
─ More fine-grained than interrupt levels
─ Scheduling policy allocating CPU to threads
• Thread synchronization handles access to shared data
─ Multiple exclusion: only one thread has accesses to data structure
─ Notification: thread blocks until event occurs
• How should threads be assigned to layered protocol?
─
─
─
─
One thread per layer
One thread per protocol
Multiple threads per protocol
One thread per packet
Ning Weng
ECE 526
10
Timer Management
• Fundamental function
• Timers used for
─ Protocols
• ARP for retransmission and cache management
• IP for re-assembly
• TCP for retransmission
─ Scheduling
• Multiple independent timers required
─ Cost can be high
Ning Weng
ECE 526
11
One Thread per Layer
• Different layers have
different thread
• Allowing priority to be
assigned to each layer
• A packet is en-queued
once per layer
• Easy for programmer to
understand
Ning Weng
ECE 526
12
One Thread per Protocol
• Each protocol has its own thread and queue
• Advantage over one thread per layer
─ Easier for programmer to understand
─ Finer-grain control and each protocol has its own priority
Ning Weng
ECE 526
13
Multiple Threads per Protocol
• Further division of duties
• Finer-granularity control and easier for programming
• Example division
─ One thread for incoming packets
─ One thread for outgoing packets
─ Thread for management/timing
Ning Weng
ECE 526
14
One Thread per Packet
• Layers introducing overhead
─ Queuing
─ Context switching
─ Requiring many threads
• How about packet processed entirely by one thread?
─ “run to completion” programming mode
• One thread operation
─
─
─
─
Pre-allocating set of operations
Waiting for packet arrive
Moving through protocol stack
Returning to wait for next packet
Ning Weng
ECE 526
15
Asynchronous vs. Synchronous
• Synchronous programming: thread-structured
─ API using blocking
• Main flow-of-control
• Explicitly invokes functions as needed
─ API using polling
• Function call returns immediately
• Performs operations if available
• Returns error code otherwise
• Asynchronous programming: event-driven
─ Programmer specifying which function to invoke for each event
type
─ Programmer has no control over function invocation
─ Difficult to program
Ning Weng
ECE 526
16
Typical Implementations
• Application program
─ Synchronous API using blocking (e.g. socket API)
─ One application thread running while other blocks
• Embedded system
─ Synchronous API using polling
─ CPU dedicating to one task
• Operating systems
─ Asynchronous API
─ Built on interrupt mechanism
Ning Weng
ECE 526
17
Summary
• Protocol processing implementation on conventional
processor
─ Application
─ OS kernel
─ Embedded systems
• Packet processing priorities
• Two mechanism to control processing priorities
─ Software interrupt
─ Kernel thread abstraction
Ning Weng
ECE 526
18