CSC521 – Communication Protocols 網路通訊協定

Ch.8 Protocol: Forwarding IP Datagrams

吳俊興 國立高雄大學 資訊工程學系

Internetworking With TCP/IP, Vol I: Sixth Edition, Douglas E. Comer Outline

1 Introduction 2 Forwarding In An Internet 3 Direct And Indirect Delivery 4 Transmission Across A Single Network 5 Indirect Delivery 6 Table-Driven IP Forwarding 7 Next-Hop Forwarding 8 Default Routes And A Host Example 9 Host-Specific Routes 10 The IP Forwarding Algorithm 11 Longest-Prefix Match Paradigm 12 Forwarding Tables And IP Addresses 13 Handling Incoming Datagrams 14 Forwarding In The Presence Of Broadcast And Multicast 15 Software Routers And Sequential Lookup 16 Establishing Forwarding Tables 17 Summary 2 Forwarding In An Internet

• Two tasks – : refers to the process of choosing a path over which to send packets • : the packet switching device makes a routing choice – Forwarding: refers to the process of transmitting a packet to the chosen path • Router: refers to the system that performs forwarding • IP forwarding – Forwarding Information Base ( FIB) – Each IP module has its own FIB, and – Each has to make forwarding decisions • General Datagram Forwarding Paradigm – Source host sends to first router – Each router passes datagram to next router – Last router along path delivers datagram to destination host Only works if routers cooperate 3 Forwarding In An Internet Router

• A router: performs transit forwarding – In theory, any computer with multiple network connections can act as a router

4 Direct And Indirect Delivery

• Forwarding – Direct delivery • The transmission of a datagram from one machine across a single physical network directly to another • The basis on which all internet communication rests

– Indirect delivery • Occurs when the destination of a datagram is not on a directly attached network • The sending machine must identify an initial router to handle the datagram • The router must then forward the datagram on toward the destination network

5 Table-Driven IP Forwarding

• IP performs datagram forwarding – forwarding table – IP forwarding table – forwarding table • Both hosts and routers have a forwarding table

• Forwarding – based on network prefixes – IP addressing scheme controls the size of forwarding tables

6 Next-Hop Forwarding

• Entry of a forwarding table – a set of pairs (N , R ) •Nisthenetwork prefix • R is the IP address of the next router

7 Default Routes And A Host Example

• IP forwarding software – It looks in the forwarding table to find a next-hop – If no entry, then checks for a

8 Host-Specific Routes

• Host-specific route – Entry that must match entire 32-bit value in IP – Can be used to send traffic for a specific host along a specific path • (i.e., can differ from the network route) • Most IP forwarding software – allows a host-specific route to be specified as a special case • Special uses – Control over network use – Testing a new network – Security

9 The IP Forwarding Algorithm

10 Longest-Prefix Match Paradigm

11 Handling Outgoing Datagrams: Forwarding Tables And IP Addresses • Next-hop address – the IP address selected by the IP forwarding algorithm

IP_Send(TargetIP, Datagram) 140.112.28.160

Routing table uses IP addresses (network prefix), not physical addresses ARP_Send(NextHopIP, Frame) 192.168.0.1

12 Handling Incoming Datagrams

• The IP module – forwards the datagram to higher-level protocol software if the datagram’s destination address matches the host’s IP address (or one of the host’s addresses) – discards the datagram, otherwise

13 Forwarding In The Presence Of Broadcast And Multicast

• A machine

– a copy of the datagram must be passed to the local protocol stack for processing

• A router

– need to forward a copy on one or more of the other networks

14 Software Routers And Sequential Lookup

• Software router

– The router does not have special-purpose hardware to assist in forwarding

– A software router consists of a general-purpose computer with a processor, memory, and network interface cards

– All the IP forwarding is performed by software

15 Establishing Forwarding Tables

• IP software

– uses a forwarding table whenever it decides how to forward a datagram

• Changing the values in a forwarding table

– will change the paths that datagrams follow

16 Datagram Transmission

IPB IPA IPC MACB MACA MACC

IPR1 IPR1N IPR2N IPR2

MACR1 MACR1N MACR2N MACR2

• Host delivers datagrams to directly connected machines • Host sends datagrams that cannot be delivered directly to router – Routers forward datagrams to other routers – Final router delivers datagram directly

• Forwarding: choosing the path for a packet

17 Example Host That Must Choose How To Forward Datagrams Even Singly Homed

• route PRINT (route; netstat –r) ======Active Routes: Network Destination Netmask Gateway Interface Metric 0.0.0.0 0.0.0.0 192.168.0.1 192.168.0.158 20 (Default) 127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1 (Loopback) 192.168.0.158 255.255.255.255 127.0.0.1 127.0.0.1 20 (Local) 192.168.0.0 255.255.255.0 192.168.0.158 192.168.0.158 20 (LAN) 192.168.0.255 255.255.255.255 192.168.0.158 192.168.0.158 20 (Broadcast) Default Gateway: 192.168.0.1 18 Summary

• IP uses routing table to forward datagrams

– Table-driven, next-hop forwarding

• Routing table

– Stores pairs of network prefix and next hop

• Longest-prefix match

– Can contain host-specific routes and a default route

19