The Network Layer 1
Network Layer Recall: The network layer is responsible for the routing of packets The network layer is responsible for congestion control 2
Contents Connection-Oriented (virtual circuit) and Connectionless Service (datagram service) The IP Protocol IP-Support Protocols Routing Algorithms Congestion Control 3
4.1.1 Connection-Oriented and Connectionless Service Network layers can offer two types of service to the transport layer: Connection-oriented service (virtual circuit) Connection setup required before communication begins Network layer provides the Transport layer with a reliable service: in-sequence delivery, flow control Connectionless service (datagram service) No prior connection setup required Packets are stored and forwarded one at a time by IMPs 4
4.1.1 Connection-Oriented Service How to provide connection-oriented service: Set up a route (virtual circuit) between source and destination That route is used for all traffic flowing over the virtual circuit Switch maintains an internal table to tell which outgoing line to forward packet on for each active virtual circuit Packets must contain a virtual circuit number so that the switch can figure out how to forward them 5
Connection-Oriented Service: Analogy Public Telephone Network Set up a virtual circuit (dial a number) Transmit data on the circuit (conversation) Close down the virtual circuit (hang up) Two users are provided with the illusion of a dedicated point-to-point channel Information is delivered to the receiver in the same order in which it is transmitted by the sender 6
Connectionless Service How to provide connectionless service: Send the packet into the network and allow the network to forward it however it likes Switches maintain routing tables to look up the next switch for each arriving packet Each packet must contain a destination address so the switches can make routing decisions 7
Connectionless Service: An Analogy Postal service: Each packet (letter) is transported as an individual entity Each packet (letter) must carry the complete destination address If a packet (letter) is lost, error control is the user s responsibility Packets (letters) do not necessarily arrive in the order sent 8
4.1.2 Comparison between Connectionless and Connection- Oriented Services Connection Setup Procedure: Connection-oriented service Explicit setup and tear-down required For short transaction oriented communication, the delay of connection setup may be expensive Connectionless service No setup or tear-down required For long continuous communication, the overhead of packet headers may be expensive 9
Comparison (cont d) Header Overhead Connection-oriented service Only the virtual circuit number Connectionless service The full destination address is required 10
Comparison (cont d) Message Sequence: Connection-oriented service Sequence of packets automatically maintained Connectionless service Destination may have to re-sequence out-oforder packets 11
Comparison (cont d) Robustness Connection-oriented service Vulnerable: If a switch crashes, all virtual circuits passing through it have to be aborted and re-established Connectionless service Robust: If a router goes down, only hosts whose packets were queued at the time of the crash are lost. Other packets will be rerouted dynamically. 12
Comparison (cont d) Guaranteed service: Connection-oriented service Can provide guarantees on the delays and throughput of packets being sent Connectionless service It is very difficult to provide guarantees for timely packet delivery 13
Summary Connection-oriented service Is useful for applications which prefer insequence delivery of packets. It is also preferable for applications that require guaranteed service Connectionless service Provides flexibility in the routing and handling of individual packets and is robust in the face of router crashes 14
4.4 The Internet Protocol (IP) Provides delivery of packets from one host in the Internet to any other host in the Internet, even if the hosts are on different networks Internet packets are called datagrams and may be up to 64 kilobytes in length (although they are typically much smaller) Internet IMPs are known as routers and they operate in a connectionless mode 15
4.4.1 IP Packet Format Ver. IHL Identification Type of Serv. 32 bits D F M F Fragment Offset Time to Live Protocol Header checksum Source address Destination address Options (0 or more 32-bit words) Total Length Data (0 to 65,515 bytes) 16
IP Packet Fields Version IHL The IP version number (currently 4) IP Header Length in 32-bit words Type of Service Contains priority information, rarely used Total Length The total length of the datagram in bytes Includes header 17
IP Packet Fields (cont d) Identification DF MF When an IP packet is segmented into multiple fragments, each fragment is given the same identification This field is used to reassembly fragments Don t Fragment More Fragments When a packet is fragmented, all fragments except the last one have this bit set 18
IP Packet Fields (cont d) Fragment offset The fragment s position within the original packet Time to Live Hop count, decremented each time the packet reaches a new router When hop count = 0, packet is discarded Protocol Identifies which transport layer protocol is being used for this packet Header Checksum Verifies the contents of the IP header Not polynomial-based 19
IP Packet Fields (cont d) Source and Destination Addresses Uniquely identify sender and receiver of the packet Options Up to 40 bytes in length Used to extend functionality of IP Examples: source routing, security, record route 20
IP Addresses 32 bits long Notation: Each byte is written in decimal in MSB order, separated by decimals Example: 128.195.1.80 Address Classes Class A, B, C, D, E Loopback Broadcast 21
IP Address Classes Class 32 bits A 0 Net 24 bit Type of Serv. Host B 16 bit 10 Net Host C 110 Net 8 bit Host D 1110 Multicast address E 11110 Reserved 22
IP Address Classes Class A: For very large organizations 16 million hosts allowed Class B: For large organizations 65 thousand hosts allowed Class C For small organizations 255 hosts allowed Class D Multicast addresses No network/host hierarchy 23
Example Class A 1.0.0.0 to 126.0.0.0 Class B 128.1.0.0 191.255.0.0 Class C 192.0.1.0 223.2555.255.0 Class D 224.0.0.0 239.255.255.255 Class E 240.0.0.0 to 255.255.255.254 All 0s, (this host) all 0 s for the network part All 1s, limited broadcast Net.id, host id all 1s directed broadcast for the network 127.x.y.z (often 1s) is used for loopback within the same host 24
IP Address Hierarchy Note that Class A, Class B, and Class C addresses only support two levels of hierarchy Each address contains a network and a host portion, meaning two levels of hierarchy However, the host portion can be further split into subnets by the address class owner This allows for more than 2 levels of hierarchy 25
Subnetting Example: Class B address with 8-bit subnetting 16 bits 8 bits 8 bits Network id Subnet id Host id Example Address: 165.230.24.8 26
Subnet Masks Subnet masks allow hosts to determine if another IP address is on the same subnet or the same network 16 bits 8 bits 8 bits Network id Subnet id Host id Mask: 1111111111111111 11111111 00000000 255.255.255.0 27
Subnet Masks (cont d) Assume IP addresses A and B share subnet mask M. Are IP addresses A and B on the same subnet? 1. Compute (A and M). 2. Compute (B and M). 3. If (A and M) = (B and M) then A and B are on the same subnet. Example: A and B are class B addresses A = 165.230.82.52 Same network? B = 165.230.24.93 Same subnet? M = 255.255.255.0 28
Example Default netmasks Class A 98.0.0.0 (16 M hosts for each address) 255.0.0.0 net mask Class B 140.14.0.0 (64K hosts for each address) 255.255.0.0 net mask Class C address 192.6.8.0 (256 hosts for each address) 255.255.255.0 29
Example Subnetting allows subdivision of a network A rotorouter company is given 201.70.64.0 wants 8 subnets What is the subnet mask? How many host per subnet? 30
Example A bachelorette company is granted an address 181.56.0.0 The company needs 1000 subnets What is the subnet mask How many host per subnet 31
Variable length subnetting Assume a company wants to have five subnets with 60, 60, 60, 30, 30 hosts Subnet masks allow power of 2 subnets Use a hierarchy of routers to allow subnets to be divided with different subnet masks Another approach: Variable length subnet masks or use two different subnet masks 255.255.255.192 for the first three and the fourth is subdivided into 2 more with 255.255.255.224 32
Variable length subnetting 64 (60) 64 (60) 64(60) 32 (60) 32 (60) 255.255.255.192 255.255.255.192 255.255.255.192 255.255.255.224 255.255.255.224 L0 L1 L2 L3 L4 33
2.3 IP Routing How do you get a packet from one network to another?? A B C D W X Y Z 34
IP Routing (cont d) Case 1: Single hop Answer: with a router (or a series of routers) R A B C D W X Y Z Case 2: Multi-hop R Network Cloud R A B C D W X Y Z 35
Example R1 R2 R3 N1 N2 N3 N4 Routing table @ R2 Dest N1 N2 N3 N4 Next hop R1 Deliver directly Deliver directly R3 Actual routing table contains IP addresses, Flags indicating type of entries, net mask etc. (see Stevens pg. 113, sect 9.2) 36
Searching the routing table First, search for a matching host address Flag H is set Second, search for a matching network address Need to know the number of bits to use for network ID Third, search for a default entry Execute netstat -rn on your machine and find the contents of the routing table Default entry allows for a single entry for a list of entries that have the same next-hop value 37
IP Support Protocols ARP RARP ICMP 38
ARP Address Resolution Protocol Returns a MAC sublayer address when given an Internet address Commonly used in broadcast LANs so that two hosts can communicate using IP addresses instead of MAC sublayer addresses 39
ARP (cont d) ARP packet containing 128.195.1.38? ARP Ethernet Address: 05:23:f4:3d:e1:04 IP Address: 128.195.1.20 Wants to transmit to 128.195.1.38 Ethernet Address: 12:04:2c:6e:11:9c IP Address: 128.195.1.122 Ignored Ethernet Address: 98:22:ee:f1:90:1a IP Address: 128.195.1.38 Answered 40
ARP (cont d) ARP response packet containing 98:22:ee:f1:90:1a Repl Ethernet Address: 05:23:f4:3d:e1:04 IP Address: 128.195.1.20 Ethernet Address: 12:04:2c:6e:11:9c IP Address: 128.195.1.122 Ethernet Address: 98:22:ee:f1:90:1a IP Address: 128.195.1.38 41
RARP Reverse Address Resolution Protocol RARP performs the inverse action of ARP RARP returns an IP address for a given MAC sublayer address Operationally, RARP is the same as ARP 42
ICMP Internet Control Message Protocol Handles special Internet control functions Responsibilities: Reporting unreachable destinations Reporting IP packet header problems Reporting routing problems Reporting echoes (pings) 43
ICMP Protocol for error detection and reporting tightly coupled with IP, unreliable ICMP messages delivered in IP packets ICMP functions: Announce network errors Announce network congestion Assist trouble shooting Announce timeouts 44
ICMP MSG IP header Source, Destination Address, TTL,... ICMP MSG Message type, Code, Checksum, Data Message type examples (Figure 6.3 in Stevens book): 0 (8) echo request (reply) 3 destination unreachable 4 source quench 11 time exceeded 45
Specific uses of ICMP Echo request reply Can be used to check if a host is alive Address mask request/reply Learn the subnet mask Destination unreachable Invalid address and/or port TTL expired Routing loops, or too far away 46
Ping Uses ICMP echo request/reply Source sends ICMP echo request message to the destination address Echo request packet contains sequence number and timestamp Destination replies with an ICMP echo reply message containing the data in the original echo request message Source can calculate round trip time (RTT) of packets If no echo reply comes back then the destination is unreachable 47
Ping (cont d) A R1 R2 R3 B Echo request Time Echo reply 48
Traceroute Traceroute records the route that packets take A clever use of the TTL field When a router receives a packet, it decrements TTL If TTL=0, it sends an ICMP time exceeded message back to the sender To determine the route, progressively increase TTL Every time an ICMP time exceeded message is received, record the sender s (router s) address Repeat until the destination host is reached or an error message occurs 49
Traceroute (cont d) A TTL=1, Dest = B, port = invalid Te (R1) R1 R2 R3 Te = Time exceeded Pu = Port unreachable B Time TTL=2, Dest = B TTL=3, Dest = B Te (R2) Te (R3) TTL=4, Dest = B Pu (B) 50