IP Function and Implementation
Download
Report
Transcript IP Function and Implementation
IP Function and
Implementation
Chuck Davin
UPenn CSE 350
12 April 2001
OSI Reference Model
Application Layer
Presentation Layer
Session Layer
Transport Layer
Network Layer
Data Link Layer
Physical Layer
Unix Network Implementation
Application
Application
System Call Interface
Sockets
Protocols
Abstract Network Interface
Devices
Model vs. Implementation
Application Layer
Presentation Layer
Session Layer
Application
Application
System Call Interface
Sockets
Transport Layer
Network Layer
Protocols
Abstract Network Interface
Data Link Layer
Physical Layer
Devices
OSI Reference Model
Possible Points of Multiplexing
Application Layer
Presentation Layer
Session Layer
Transport Layer
Network Layer
Data Link Layer
Physical Layer
Unix Network Implementation
Possible Points of Multiplexing
Application
Application
System Call Interface
Sockets
Protocols
Abstract Network Interface
Devices
Protocol Layer Functions
Protocol-Specific Functions
– UDP
– TCP
– IP
Protocol Layer Service
Interface
XXX_usrreq (so, cmd, …)
XXX_input (data, …)
XXX_ctlinput (so, cmd, …)
XXX_ctloutput (so, cmd, …)
XXX_init ()
Protocol User Requests
PRU_ATTACH
PRU_DETACH
PRU_SEND
PRU_RECV
PRU_BIND
PRU_CONNECT
PRU_SHUTDOWN
And so forth
Generic Protocol Data
Structures
Application
System Call Interface
Application
Sockets
To ProtocolSpecific State
(if any)
Protocol
Control
Block
(PCB)
Protocol-Specific Links
Abstract Network Interface
Devices
IP Observations
Raw IP sockets are available
– But less often used
The most frequent “users” of IP services are
UDP and TCP
The most interesting data structures for IP
are unrelated to sockets
IP Data Flows
Application
System Call Interface
Application
Sockets
TCP
IP Packets
UDP
Ip_output()
XXX_input()
IP
IP Packets
Ifp->if_output()
Ip_input()
Devices
IP Input Processing
Remove packet from delivery queue
Validate IP header checksum, version
Check packet length for consistency
Is it for me?
– See if_withaddr()
Reassemble if packet is a fragment
Deliver entire packets to ULP based on
protocol number
IP Output Processing
Complete IP header, compute IP header
checksum
Determine outgoing interface and next hop
for this packet
Fragment if packet exceeds MTU of chosen
interface
Present packet(s) plus next hop IP address
to device via abstract network interface
IP Routing Table
Destination IP Address
Destination Netmask
Route Type (e.g., local or remote)
Route Metric
Next Hop IP
Cached MTU, Network Device, …
– See if_withaddr()
IP Forwarding Procedure
Find routing entries for which the masked
destination address matches the masked
destination address of the packet
Of these entries, pick the one with the
longest netmask
– Contiguous subnet masks
Forwarding table vs. routing table
Network Device Functions
Device congestion management
Protocol adaptation
Buffer management
Network Device Interface
Generic interface presented to ULPs (IP)
IF_ENQUEUE()
IF_QFULL()
Ifp->If_output()
Ifp->If_start()
…
Network Device Data
Structures
Application
System Call Interface
Application
Sockets
Protocols
Abstract Network Interface
Ifnet
Chain
Ifnet
Structure
Ifnet
Structure
Private
Device
Data
Private
Device
Data
…
Network Device Output
Procedure
ULP has already enqueued packets and next
hop addresses on the output queue
If the medium is multipoint, then resolve
the passed ULP address into a local medium
address (e.g., ARP)
If the device is currently idle, take a packet
from the output queue, frame it and start I/O
Network Device Input
Procedure
Received frame is checked for integrity and
length consistency
Frame is examined to identify ULP
Frame is stripped of data link header
Frame Payload plus notation of receiving
device are enqueued on ULP input queue
– E.g., ipintrq
Questions to Ponder
Private device data is stored contiguously
with generic ifnet data rather than according
to the linked PCB scheme in upper layers.
– What are the tradeoffs?
To what degree should/need a network
device do its own routing?
What must a network device do to properly
receive striped IP traffic?