資 管 Lee Lesson 5 IP Packets: Delivery and Routing IP Layer operation.
-
Upload
roberta-welch -
Category
Documents
-
view
214 -
download
0
Transcript of 資 管 Lee Lesson 5 IP Packets: Delivery and Routing IP Layer operation.
資 管 Lee <Lesson 5-1>
Lesson 5
IP Packets: Delivery and RoutingIP Layer operation
資 管 Lee <Lesson 5-2>
delivery◦Physical forwarding of the packets.◦Connectionless and connection-oriented◦IP protocol is a connectionless protocol.
routing◦Finding the route (next hop) for a datagram.◦Routing methods, types of routing, the
routing table, and the routing module.
資 管 Lee <Lesson 5-3>
Direct delivery Direct delivery
◦ Final destination of the packet is a host connected to the same physical network as the deliverer.
◦ Sender determine by filtering out the destination field of IP packet. IP destination first be masked with the mask field in the routing table compare the destination field in the routing table with the result.
◦ Case for direct delivery,: Case 1: MAC address is known, the sender sent the MAC frame to the
destination Case 2: Otherwise, it use ARP protocol to find the physical address of the
destination.
Network
Router
Host Host
Direct delivery
Direct delivery
To theRest of the Internet
資 管 Lee <Lesson 5-4>
Indirect delivery (by way of router)◦ Case of indirect delivery: [indirect delivery]
final destination of the packet is not connected to the same physical network as the deliverer.
the sender sent the MAC frame to the router’s destination if destination MAC address is available.
{The packet may go from router to router until it reaches the one connected to the same physical network as its final destination.}
Network
Router
Host (source)
Host (destination)
Indirect delivery
Direct delivery
Network
資 管 Lee <Lesson 5-5>
Routing Methods
Next-hop Routing◦ Routing table hold only the address of the next hop
instead of holding the complete route.
R1
Host A (source) Host B (destination)
NetworkNetwork NetworkR2
Destination Route
Host B R1, R2, Host B
Destination Route
Host B R2, Host B
Destination Route
Host B R1
Destination Route
Host B R2
Destination Route
Host B Host B
Destination Route
Host B __
資 管 Lee <Lesson 5-6>
Routing Methods
Network-Specific Routing◦ Instead of having an entry for every host connected to the
same physical networks. Treat all hosts connected to the same network as one single entry.
R1
Host (source)
N1
Destination Next Route
A R1
B R1
C R1
D R1
Destination Route
N2 R1
AB
C
D
N2
資 管 Lee <Lesson 5-7>
Routing Methods
Host-Specific Routing◦ Host address is given in the routing table.
R1Host A
R2
Destination Next Hop
Host B R3
N2 R1
N3 R3
… …
R3
N2
N1
N3
Host B
Routing table for host A
資 管 Lee <Lesson 5-8>
Routing Methods
Default Routing◦ Default entry (network address 0.0.0.0). For example, router
R1 for network N2, others, through router R2.
R1Host A
Destination Next Hop
N2 R1
… …
… …
Default R2
R2
N2
N1
Routing table for host A
Rest of the Internet
資 管 Lee <Lesson 5-9>
Static vs Dynamic Routing
Routing table, entries for all the destination, can be either static or dynamic◦Static routing contains information entered
manually, used in a small internet or in an experimental internet.
◦Dynamic routing table is updated periodically using one of the dynamic routing protocols such as RIP, OSPF, or BGP
資 管 Lee <Lesson 5-10>
Routing Module and Routing Table Design
Basic module for routing and routing table.
… …
… …
Routing module
Routing table
IP packet
IP packet
IP packet
FromIP Processingmodule
Tofragmentationmodule
IP Layer operation
Data Link Layer
資 管 Lee <Lesson 5-11>
Examples
R3
193.14.5.160/27 193.14.5.192/27
111.0.0.0/8
192.16.7.0/24 194.17.21.0/24
RestoftheINternet
R5
R4
193.14.5.165 193.14.5.197
111.25.19.20
R1
m2 m1
m0
R2
111.20.18.14
111.15.17.32
111.30.31.18
192.16.7.5
192.16.7.52 194.17.21.68
Host A:194.17.21.16
194.17.21.14
Host B:193.14.5.163
T0
T1
資 管 Lee <Lesson 5-12>
Routing table design
Seven basic fields:◦ mask, destination address, next-hop address, flags, reference-count,
use, and interface
Mask Dest.address
Next-hopaddress Flags Reference
count Use Interface
255.0.0.0……
124.0.0.0……
145.6.7.23……
UG……
4……
20……
m2……
Flags: 5 flags. U(up), G (gateway), H(host-specific), D(added by redirection), M(modified by redirection):
G flags mean another network or not.H flags means that the entry is a host-specific address.
Reference count: the user number that use this entry.Use: the total packets that use this entry.
資 管 Lee <Lesson 5-13>
Routing Module operation
Routing Module operationReceive: an IP packet 1. For each entry in the routing table
1. Apply the mask to packet destination address 2. If (the result matches the value in the destination field) 1. If (the G flags is absent) /* direct delivery */
use packet destination address as next hop address
else value in next hop fields as next hop address 2. Send packet to fragmentation module with next hop address
and interface ID.3. Return
2. If no match is found for all entries in the routing table , send an ICMP error message
3. return
資 管 Lee <Lesson 5-14>
Mask Dest.address
Next-hopaddress
Flags RC Use Interface
255.0.0.0 111.0.0.0 - U 0 0 m0
255.255.255.224 193.14.5.160 - U 0 0 m2
255.255.255.224 193.14.5.192 - U 0 0 m1
… … … … … … …
255.255.255.255 194.17.21.16 111.20.18.14 UGH 0 0 m0
255.255.255.0 192.16.7.0 111.15.17.32 UG 0 0 m0
255.255.255.0 194.17.21.0 111.20.18.14 UG 0 0 m0
0.0.0.0 0.0.0.0 111.30.31.18 UG 0 0 m0
Routing table for router R1
Example: Router R1 receives 500 packets for destination 192.16.7.14; the algorithm applies:1. Direct delivery a. 192.16.7.14& 255.0.0.0 192.0.0.0 no match b. 192.16.7.14& 255.255.255.224 192.16.7.0 no match c. 192.16.7.14& 255.255.255.224 192.16.7.0 no match2. Host-specific a.192.16.7.14& 255.255.255.255 192.16.7.14 no match3. Network-specific a. 192.16.7.14& 255.255.255.0 192.16.7.0 match
{ the router sends the packet through interface m0 along with the next-hop IP address (111,15.17.32) to the fragmentation module for further processing. It increments the use field by 500 and RC by 1. }
資 管 Lee <Lesson 5-15>
Example 2: Router R1 receives 100 packets for destination 193.14.5.176; the algorithm applies:
1. Direct delivery 2. Host-specific
3. Network-specific
Example 3: Router R1 receives 20 packets for destination 200.34.12.34: the algorithm applies:
1. Direct delivery 2. Host-specific
3. Network-specific
資 管 Lee <Lesson 5-16>
Practice Quiz(3)S1: Show the routing table for router R3S2: Router R3 receives 100 packets for destination 193.14.5.176;
the algorithm applies?
資 管 Lee <Lesson 5-17>
IP layer operation
資 管 Lee <Lesson 5-18>
An simplified, bare-bones design of IP
Eight components:
◦ 5 modules: header-adding module, a processing module, a routing module, a
fragmentation module, and reassembly module.
◦ 3 tables: routing table, MTU table, and a reassembly table.
資 管 Lee <Lesson 5-19>
Routing Module and Routing Table Design
… …Routing module
Routing table
IP packet
Reassembly module
Processingmodule
… …
Reassemble table
…
MTU table
IP packet IP packet
Header-addingmodule
IP packetIP packet
Fragmentationmodule
IP packet IP packet
DataDataaddress
From upper layer protocol
From data link layer To data link layer
To upper layer protocol
IP layer operation
資 管 Lee <Lesson 5-20>
Header-Adding Module
Header-Adding Module operation
Receive: data, destination address { 形成 IP 封包 } 1. Encapsulate the data in an IP datagram 2. Calculate the checksum and insert it in the checksum field. 3. Send the data to the corresponding input queue. 4. Return.
Processing Module operation 1. Remove one datagram from one of the input queues. 2. If (destination address is 127.X.Y.Z or matches one of the local addresses)
1) Send the datagram to the reassembly module, 2) Return 3. If (machine is a router)
Decrement TTL. 4. If (TTL less than or equal to zero)
1) discard the data gram, 2) Send an ICMP error message, 3) Return 5. Send the datagram to the routing module. 6. Return.
資 管 Lee <Lesson 5-21> 資 管
Fragmentation Module operation
Receive: an IP packet from routing module 1. Extract the size of the datagram. 2. If (size>MTU of the corresponding network)
1) If (D bit is set), discard the datagram, send an ICMP message, return.2) Else, Calculate the maximum size, Divide the datagram into fragments, add header to each fragments, send the datagram, return.
3. Else,1) Send the datagram.
4.Return.
Interface Number MTU
………
………
MTU table
資 管 Lee <Lesson 5-22> 資 管
Reassembly Module operationReceive: an IP datagram from the processing module 1. If (offset value is zero and the M bit is 0)
1) Send the datagram to the appropriate queue, return. 2. Search the reassembly table for the corresponding entry. 3. If (not found)
1) create a new entry. 4.Insert the fragment at the appropriate place in the link list.
1) If (all fragments have arrived), Reassemble the fragements, delivery the datagram to the corresponding upper layer protocol, return.2) Else, check the time-out, if (time-out expired), discard all fragments, send an ICMP error message
5. Return.
State Source Addr. Data ID Time out Fragments
Reassemble table