ip function and implementation chuck davin upenn cse 350 12 april 2001

22
IP Function and IP Function and Implementation Implementation Chuck Davin UPenn CSE 350 12 April 2001

Post on 20-Dec-2015

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: IP Function and Implementation Chuck Davin UPenn CSE 350 12 April 2001

IP Function and IP Function and ImplementationImplementation

Chuck Davin

UPenn CSE 350

12 April 2001

Page 2: IP Function and Implementation Chuck Davin UPenn CSE 350 12 April 2001

OSI Reference ModelOSI Reference Model

Application Layer

Presentation Layer

Session Layer

Transport Layer

Network Layer

Data Link Layer

Physical Layer

Page 3: IP Function and Implementation Chuck Davin UPenn CSE 350 12 April 2001

Unix Network ImplementationUnix Network Implementation

Application Application

Sockets

Protocols

Devices

System Call Interface

Abstract Network Interface

Page 4: IP Function and Implementation Chuck Davin UPenn CSE 350 12 April 2001

Model vs. ImplementationModel vs. Implementation

Application Application

Sockets

Protocols

Devices

System Call Interface

Abstract Network Interface

Application Layer

Presentation Layer

Session Layer

Transport Layer

Network Layer

Data Link Layer

Physical Layer

Page 5: IP Function and Implementation Chuck Davin UPenn CSE 350 12 April 2001

OSI Reference ModelOSI Reference Model

Possible Points of MultiplexingPossible Points of MultiplexingApplication Layer

Presentation Layer

Session Layer

Transport Layer

Network Layer

Data Link Layer

Physical Layer

Page 6: IP Function and Implementation Chuck Davin UPenn CSE 350 12 April 2001

Unix Network ImplementationUnix Network Implementation

Possible Points of MultiplexingPossible Points of Multiplexing

Application Application

Sockets

Protocols

Devices

System Call Interface

Abstract Network Interface

Page 7: IP Function and Implementation Chuck Davin UPenn CSE 350 12 April 2001

Protocol Layer FunctionsProtocol Layer Functions

Protocol-Specific Functions– UDP– TCP

– IP

Page 8: IP Function and Implementation Chuck Davin UPenn CSE 350 12 April 2001

Protocol Layer Service Protocol Layer Service InterfaceInterface

XXX_usrreq (so, cmd, …)XXX_input (data, …)XXX_ctlinput (so, cmd, …)XXX_ctloutput (so, cmd, …)XXX_init ()

Page 9: IP Function and Implementation Chuck Davin UPenn CSE 350 12 April 2001

Protocol User RequestsProtocol User Requests

PRU_ATTACH PRU_DETACH PRU_SEND PRU_RECV PRU_BIND PRU_CONNECT PRU_SHUTDOWN And so forth

Page 10: IP Function and Implementation Chuck Davin UPenn CSE 350 12 April 2001

Generic Protocol Data Generic Protocol Data StructuresStructures

Application Application

Sockets

Devices

System Call Interface

Abstract Network Interface

ProtocolControlBlock(PCB)

To Protocol-Specific State(if any)

Protocol-Specific Links

Page 11: IP Function and Implementation Chuck Davin UPenn CSE 350 12 April 2001

IP ObservationsIP 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

Page 12: IP Function and Implementation Chuck Davin UPenn CSE 350 12 April 2001

IP Data FlowsIP Data FlowsApplication Application

TCP

Sockets

Devices

System Call Interface

IP

UDP

Ip_output() XXX_input()

Ifp->if_output() Ip_input()

IP Packets

IP Packets

Page 13: IP Function and Implementation Chuck Davin UPenn CSE 350 12 April 2001

IP Input ProcessingIP Input Processing

Remove packet from delivery queueValidate IP header checksum, versionCheck packet length for consistencyIs it for me?

– See if_withaddr()Reassemble if packet is a fragmentDeliver entire packets to ULP based on

protocol number

Page 14: IP Function and Implementation Chuck Davin UPenn CSE 350 12 April 2001

IP Output ProcessingIP 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

Page 15: IP Function and Implementation Chuck Davin UPenn CSE 350 12 April 2001

IP Routing TableIP Routing Table

Destination IP AddressDestination NetmaskRoute Type (e.g., local or remote)Route MetricNext Hop IPCached MTU, Network Device, …

– See if_withaddr()

Page 16: IP Function and Implementation Chuck Davin UPenn CSE 350 12 April 2001

IP Forwarding ProcedureIP 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

Page 17: IP Function and Implementation Chuck Davin UPenn CSE 350 12 April 2001

Network Device FunctionsNetwork Device Functions

Device congestion managementProtocol adaptationBuffer management

Page 18: IP Function and Implementation Chuck Davin UPenn CSE 350 12 April 2001

Network Device InterfaceNetwork Device Interface

Generic interface presented to ULPs (IP)IF_ENQUEUE()IF_QFULL()Ifp->If_output()Ifp->If_start()…

Page 19: IP Function and Implementation Chuck Davin UPenn CSE 350 12 April 2001

Network Device Data Network Device Data StructuresStructures

Application Application

Sockets

Protocols

System Call Interface

Abstract Network Interface

IfnetChain

IfnetStructure

IfnetStructure

PrivateDeviceData

PrivateDeviceData

Page 20: IP Function and Implementation Chuck Davin UPenn CSE 350 12 April 2001

Network Device Output Network Device Output ProcedureProcedure

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

Page 21: IP Function and Implementation Chuck Davin UPenn CSE 350 12 April 2001

Network Device Input Network Device Input ProcedureProcedure

Received frame is checked for integrity and length consistency

Frame is examined to identify ULPFrame is stripped of data link headerFrame Payload plus notation of receiving

device are enqueued on ULP input queue– E.g., ipintrq

Page 22: IP Function and Implementation Chuck Davin UPenn CSE 350 12 April 2001

Questions to PonderQuestions 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?