THE NETWORK LAYER Connections services • connectionless service : packets are injected into the network individually and routed independently of each other. – the network that uses this service is called a datagram network • connection-oriented service: a path from the source router all the way to the destination router must be established before any data packets can be sent. – the network that uses this service is called a virtualcircuit network 5.1.3 Implementation of Connectionless Service Figure 5-2. Routing within a datagram network. 5.1.4 Implementation of Connection-Oriented Service Figure 5-3. Routing within a virtual-circuit network. 5.1.5 Comparison of Virtual-Circuit and Datagram Networks 5.2 ROUTING ALGORITHMS • The routing algorithm is that part of the network layer software responsible for deciding which output line an incoming packet should be transmitted on. • Some of the ways of measuring path length: – the number of hops: number of routers from the source to the destination – the geographic distance in kilometers. – The propagation delay; so the shortest path is the fastest path (the least propagation delay). • the router can measure it directly by sending over the line special ECHO packets (timestamp packet) that the other side just timestamps it and sends back as fast as it can. 5.2.3 Flooding • Flooding : A simple local technique , in which every incoming packet is sent out on every outgoing line except the one it arrived on. • Flooding generates vast numbers of duplicate packets – some measures are taken to solve this problem: • to have a hop counter contained in the header of each packet that is decremented at each hop, with the packet being discarded when the counter reaches zero. – Ideally, the hop counter should be initialized to the length of the path from source to destination. – to have a sequence number in the header of each packet to avoid sending that packet out a second time. 5.2.4 Distance Vector Routing • Discover its neighbors and learn their network addresses. • Set the distance or cost metric to each of its neighbors. • Update routing table by exchanging information (routing tables) with the neighbors. – a routing table indexed by, and containing one entry for each router in the network. This entry has two parts: • the preferred outgoing line to use to get that destination • and an estimate of the best known distance to that destination. 5.2.4 Distance Vector Routing Figure 5-9. (a) A network. (b) Input from A, I, H, K, and the new routing table for J. The Count-to-Infinity Problem 5.2.5 Link State Routing Each router must do the following things to make it work: 1. Discover its neighbors and learn their network addresses. – by sending a special HELLO packet, the other end is expected to send back a reply giving its IP address. 2. Set the distance or cost metric to each of its neighbors. – by sending over the line special ECHO packets (timestamp packet) that the other side just timestamps it and sends back as fast as it can. 3. Construct a packet telling all it has just learned. 4. Send this packet to and receive packets from all other routers. 5. Compute the shortest path to every other router. 5.2.5 Link State Routing 3. Building Link State Packets Figure 5-12. (a) A network. (b) The link state packets for this network. 5.2.2 Shortest Path Algorithm Figure 5-7. The first six steps used in computing the shortest path from A to D. The arrows indicate the working node. 5.2.6 Hierarchical Routing • Each router knows all the details about how to route packets to destinations within its own region but knows nothing about the internal structure of other regions. • Advantage: reducing the routing tables size 5.2.6 Hierarchical Routing Figure 5-14. Hierarchical routing. 5.2.7 Broadcast Routing • broadcasting is Sending a packet to all destinations simultaneously. • Example on broadcasting Routing: – flooding – reverse path forwarding 5.2.7 Broadcast Routing Figure 5-15. Reverse path forwarding. (a) A network. (b) A sink tree. (c) The tree built by reverse path forwarding. 5.2.8 Multicast Routing Figure 5-16. (a) A network. (b) A spanning tree for the leftmost router. (c) A multicast tree for group 1. (d) A multicast tree for group 2.