420 likes | 553 Views
IP - Internet Protocol. IP Service IP Addressing Datagram Format Routing (Forwarding) Subnetting Fragmentation. Orientation. IP (Internet Protocol) is a Network Layer Protocol. IP’s current version is Version 4 (IPv4). It is specified in RFC 891. Orientation.
E N D
IP - Internet Protocol IP Service IP Addressing Datagram Format Routing (Forwarding) Subnetting Fragmentation
Orientation • IP (Internet Protocol) is a Network Layer Protocol. • IP’s current version is Version 4 (IPv4). It is specified in RFC 891.
Orientation • IP layer processing occurs at both routers and hosts:
IP Service • IP provides an unreliable and connectionless service (“datagram service”). Unreliable: IP does not guarantee that a transmitted packet will be delivered. Connectionless: Each packet (“datagram”) is handled independently. IP is not aware that packets between hosts may be sent in a logical sequence. • Consequences of an unreliable, connectionless service • Lost packets • Packets delivered out-of-sequence • Can have duplicate packets because of TCP layer resends* • e.g. if packet is delivered but ACK is lost, TCP sender will resend packet buffered at the end host. *: The audio file says duplicate packets could occur because of router-buffered packets; this is not commonplace in today’s networks because common link-layer protocols do not have retransmissions, but if they did, this could be another cause of duplicate packets; for example, 802.11 wireless link layer has retransmissions.
IP Service • IP offers a best effort * service; i.e., IP does not make performance guarantees on: • the time until a packet is delivered • the packet loss rate • the throughput of traffic between two hosts • etc. • Performance guarantees are also called Quality-of-Service or QoS guarantees. • IP provides limited QoS support. This is done via the Type-of-Service (TOS) field. * “Best effort” may mean different things to different people.
IP Service • IP supports the following services: • one-to-one (unicast) • one-to-many (multicast) • one-to-all (broadcast) • IP multicast actually supports a many-to-many service. • IP multicast requires support of other protocols (IGMP, multicast routing). Multicast Unicast Broadcast
Internet Addresses • Each network interface on the Internet as a unique global address, called the IP address. • An IP address: - is 32 bits long. - encodes a network number and a host number • IP addresses are written in a dotted decimal notation : - 128.238.42.112 means 10000000 in 1st Byte11101110 in 2nd Byte00101010 in 3rd Byte 01110000 in 4th Byte
Internet Address Classes • IP distinguishes 5 classes of addresses.
IP Addresses • The end points of each range are not allowed because all zeros and all ones are disallowed for netid, subnetid and hostid (see pg. 42 of text and RFC791).
Trade-off of Address Classes • There are a total of 232 = 4,294,967,296 IP addresses Class A: 7 bits for netid only 128 Class A networks each net can have about 16 million (224-2) hosts. Class B: 14 bits for netid about 16,000 networks About 65,000 (216 -2) hosts per network Class C: 21 bits for netid about 2 million networks Only 254 hosts per network
Special case IP addresses (not complete) • 0: all zeros (means “this host” or “this net”); -1: all ones (this is reserved for broadcasts); netid, subnetid, hostid: anything else
IP Datagram Format • 20 bytes Header Size 24 * 32 bit-words = 60 bytes • 20 bytes Total Length 216 bytes = 65536 bytes
IP Datagram Transmission • Question: If you measure an IP datagram on the network, in which order are the fields transmitted? • Answer: • Transmission is row by row • For each row: 1. Transmit bits 0-7 2. Transmit bits 8-15 3. Transmit bits 16-23 4. Transmit bits 24-31 • This iscallednetwork byte order or big endian byte ordering. • Note: some computers store 32-bit words in little endian format. Which ones?
Fields of the IP Header • Version: current version is 4, next version will be 6. • Header length (4 bits): Number of 32-bit words in the IP header • Type of Service (TOS): contains 4 TOS bits, where each bit indicates a desired service. • minimize delay • maximize throughput • maximize reliability • minimize cost • Only one bit can be set! Not supported in all applications.
IP Header Fields Contd. • Total Length: Number of bytes in the IP datagram (header+payload) • Identification: unique identification of a datagram from a host. Incremented whenever a datagram is transmitted. • Flags and Fragment Offset: Associated with fragmentation • Time To Live (TTL): specifies longest path before datagram is dropped. • Used to prevent infinite looping of packets • TTL field is set at sending host and is decremented by 1 at each router • If a router gets a datagram whose TTL is either 0 or 1, the router will drop the packet. • If a destination host gets a datagram whose TTL is 1, the host will deliver the datagram to the higher layer.
Fields of the IP Header • Protocol: Specifies the higher-layer protocol. Used for demultiplexing to higher layers. • Header checksum: verifies correctness of header.
Fields of the IP Header • Source and Destination Addresses: identify the interfaces on the sending and receiving hosts • Options: • Security restrictions • Record Route: each router that processes the packet adds its IP address to the header. • Timestamp: each router that processes the packet adds its IP address and time to the header. • (loose) Source Routing: specifies a list of routers that must be traversed. • (strict) Source Routing: specifies a list of the only routers that can be traversed. • Padding: ensures that header ends on a 4-byte boundary
Routing • The routing functions at the network layer must be able to deliver a packet from a source host to a destination host. • There are two parts to the routing problem: 1. How to pass a packet from an input interface to the output interface of a router (“packet forwar- ding”) ? 2. How to create routing tables? • In this lecture, we only discuss the packet forwarding part. The other function is discussed in Lecture 6.
Major Tenets for Datagram Forwarding • Every IP datagram contains the IP address of an interface of a destination host. • The network id of an IP address uniquely identifies a single physical network that is part of the larger Internet. • All hosts and routers that have the same network id are connected to the same physical network and can directly communicate by sending MAC layer frames. • Every physical network of the Internet has at least one router, which is also connected to at least one other physical network.
IP Forwarding • A packet is typically forwarded to a large number of routers before reaching the destination host. • IP forwarding is done on a hop-by-hop basis, i.e., no one knows the complete route. The goal of forwarding is to bring the IP datagram closer to the destination.
IP Forwarding • IP forwarding is performed by both hosts and routers. • The difference between IP forwarding in a host and in a router is that a host’s IP module does not forward packets received on an interface to another interface (if it does then it is behaving as a router). In a host, IP forwarding is from the higher layers to an interface or vice versa • Both routers and hosts have a routing table. Routing table entries look like this and is looked up for each datagram:
Flags • H: Whether the destination address is the network ID of an IP address (H=0) or the complete IP address of a host interface (H=1). • G: Whether the next-hop router field is really a next-hop router (G=1) or a directly connected interface (G=0)
Forwarding Functions at Host • Forwarding an IP datagram at a host: DestNet = Network id in destination IP address If (DestNet == my Network id) Deliver datagram to destination directly; else Send datagram to default router; • Reception of an IP datagram at a host: Datagram is received on an interface If (Destination IP address == (my IP address || broadcast address)) Deliver datagram to higher layer; else Discard the datagram;
Forwarding Functions at Router • Reception of an IP datagram at a router: Packet is received on an interface If (Destination IP address != my IP address) Perform datagram forwarding; • Forwarding an IP datagram at a router: DestNet = Network id in destination IP address DestIP = destination IP address If (DestIP == Destination IP address in my routing table) Deliver datagram to the next-hop-router in the table; elseif (DestNet == Network id in my routing table) Deliver datagram to destination of the interface; else deliver packet to default router;
Example (from Textbook) Scenario 1: bsdi sends a datagram to sun Scenario 2: bsdi sends a datagram to ftp.uu.net
Scenario 1 Bsdi looks up its routing table and finds sun as being located on the same network. How ? The network address of sun and bsdi match. Bsdi issues an ARP request for 140.252.13.33 Sun replies with the MAC address for its interface Bsdi can then send the IP datagram encapsulated in an ethernet frame
Scenario 2 • bsdi sends a datagram to ftp.uu.net. 1. bsdi sees that its network ID differs from that of the destination address 2. So it sends the datagram to its default router (sun) (by using the MAC address of the 140.252.13.33 interface on sun - obtained by ARP)
Scenario 2, Part II 3. sun (is configured as router) forwards the packet to its default router (which is set to netb). 4. netb forwards the datagram to its default next-hop-router, set to Gateway (140.252.1.4). 5. Gateway forwards the packet to somewhere else (not known).
Subnetting • The address classes makes Class A and B addresses very attractive and Class C addresses not attractive: - The number of network id’s relates to the size of the routing table in IP routers. - The number of hosts on a network is limited to 255. - Organization must contact IANA for each new LAN. - Management of a large number of Class C addresses is cumbersome. • But: There are only few Class A and B addresses! • Solution: Subnetting
Subnetting • Goal: Reduce the need for a large number of network ids. • Basic Idea: - Split the host id portion of an IP address into a subnet id and a host id. - Assign one subnet id to each physical network. • Then: • Subnets can be freely assigned and be used for many physical networks. • Distant routers need not be aware of subnet id’s.
Subnet Masks • Routers and hosts use a subnet mask to separate the subnetwork id from the host id. Question: In the IP address 152.164.9.10 with subnet mask 255.255.255.128, what class does this IP address belong to and what are the 14 bits netid, subnet id and hostid? How many bits are in the subnet id and in the hostid? Answer: Class B; 14 bits netid = 24.164, subnet id (9 bits) = 9.0 hostid (7 bits) = 10
Subnetting: Host Processing • Each host has to know the IP address and the subnet mask of its interface • For each IP datagram received from the application, the IP layer at the host peforms: if ((Destination IP address & Subnet Mask) == (My IP address & Subnet Mask)) Deliver datagram directly (perform ARP if shared medium LAN); else Forward datagram to default router;
Subnetting: Router Processing • A router has a table: < SubnetNumber, SubnetMask, NextHop> • SubnetNumber is the <network id, subnet id> • SubnetMask is the subnet mask • NextHop is the IP address of a router. • The router perfoms the following algorithm: • Reception of an IP datagram at a router: Packet is received on an interface whose IP address is IP1. dest = destination IP address; If (dest == IP1) Deliver datagram to TL/application in router ;
Subnetting: Router processing Contd. Else for each entry <SubnetNumber, SubnetMask, NextHop> sub1 = dest & SubnetMask; if (sub1 == SubnetNumber) Forward datagram to NextHop; else Go to next entry in routing table;
Advantages of Subnetting • Improves efficiency of IP address usage by not consuming an entire Class B or Class C address for each physical network. • Reduces routing table sizes. Since external routers do not know about subnetting, the size of routing tables is reduced. • Networks become easier to manage. • Note that there are three levels of aggregation: • Network • Subnet • Host
IP Fragmentation Host A sends a large IP datagram to Host B. Any Problem with that? MTUs:FDDI: 4352Ethernet: 1500 • IP router splits the datagram into several fragments • Fragmentation requires that the data portion of every fragment except the last be a multiple of 8 bytes.
Where is Fragmentation done? • Fragmentation can be done at the sender or at intermediate routers. • The same datagram can be fragmented several times. • Reassembly of original datagram is only done at destination hosts.
What’s involved in Fragmentation? • The following fields in the IP header are involved: Identification is the same in all fragments. Flags contains a “more fragments” bit. (There is also a “don’t fragment bit” that can be set). Fragment offset contains the offset (in 8-byte units) of current fragment in the original datagram. Total length is changed to be the size of the fragment.
Multiple links • The ID field stays the same for all fragments of a datagram sent by a sender to allow for reassembly • The fragment offset is relative to the datagram sent by the sender. • Two fragments created on X.25 link (offsets 0, 69) • 576 – 20 (IP header) = 556; 552 divides by 8 as 69. • Each is fragmented further on the PPP link • ID stays the same on all fragments • Fragment offset on the second set of fragments is relative to the original (0, 34, 68, 69, 103) • 296-20=276; 272/8 = 34
Configuring a Network Interface • The ifconfig command is used for setting and testing network interfaces (in Unix systems) that run TCP/IP • Ifconfig must be run at boot time to initialize the network interfaces. • Ifconfig -a plots a report on all interfaces. : aida:/ ; ifconfig -a ed1: flags=8863<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX, MULTICAST> mtu 1500 inet 128.238.42.114 netmask 0xffffff00 broadcast 128.238.42.255 lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384 inet 127.0.0.1 netmask 0xff000000
Configuring a Network Interface • The netstat command plots (a lot of) network related data structures in the operating system. • Netstat -i plots information on the network interfaces. : aida:/ ; netstat -i Name Mtu Network Address Ipkts Ierrs Opkts Oerrs Coll ed1 1500 128.238.42.114 aida 2394482 35664 346880 223 119591 lo0 16384 your-net localhost 153 0 153 0 0