Networking exercise
The Network Layer
While the OSI Reference Model refers to this layer as the Network Layer, TCP/IP refers to it as the Internet Layer. Commonly defined by the Internet Protocol (RFC 791)
• Provides the basic packet delivery service on which TCP/IP networks are built. • All TCP/IP data flows thru IP regardless of it’s final destination.
Internet Protocol
• Defines the Internet Addressing scheme • Moves data between the data link layer and the transport layer • Defines the datagram. • Performs fragmentation and re-assembly of datagrams • A connectionless protocol (unreliable), utilizing best effort delivery with some
control messages (ICMP). 1. Internet Addressing
• Allocation managed by the Internet Assigned numbers Authority (IANA) by Jon Postel until 1998 and the Internet Corporation for Assigned Names and Numbers (ICANN) since 1998. In the U.S, numbers are allocated through the American Registry of Internet Numbers (ARIN).
• Logical addresses
• 32 bit IP address expressed in dotted-decimal notation.
1000 0011 1011 0111 1101 1001 1111 1110 131 . 183 . 217 . 254
• Identifies the network and the host on the network.
• Local addresses are delivered directly.
• If the address is not local it is passed to gateway. A gateway is a device that switches packets between different physical networks. Deciding which gateway to use is called routing.
The IP address consists of a network portion and a host portion. How do we identify the network or the host? Where is the network boundary in the IP address? Looking at the decimal dot notation, one logical place to draw the boundary is after the first octet: Result: Not enough networks….. Looking at the decimal dot notation once again, a second logical place to draw the boundary is after the second octet: Result: Not enough networks….. Looking at the decimal dot notation yet again, a third logical place to draw the boundary is after the third octet: Result: Not enough hosts…… Possible solution: Use a combination of the three logical boundaries. This provides for a large number of networks for those with few hosts and a large number of hosts for big networks. Problem: Using an address of 131.183.217.1, which portion is the network portion and which portion is the host portion? Ugh, this is one ugly table to maintain! In order to simplify the tables, networks were divided into classes based on the three byte boundaries. In order to determine the class of a network, the First Octet Rule is applied:
First Octet Class Decimal Values Network bits Host bits 0xxx xxxx A 0 – 127 8 24 10xx xxxx B 128 – 191 16 16 110x xxxx C 192 – 223 24 8 1110 xxxx D 224 – 239 1111 xxxx E 240 – 255
Another method of specifying the boundary between the network and the host is to use a netmask. The netmask is 32 bits and a 1 bit marks the network portion and a 0 bit marks the host portion of an address. Class A addresses would have an 8 bit netmask (255.0.0.0).
2
Class B addresses would have a 16 bit netmask (255.255.0.0). Class C addresses would have a 24 bit netmask (255.255.255.0). Since the netmask coincides with the byte boundaries of each of the address classes, they are referred to as the “natural” mask.
131.183.0.0 16 bit network, 16 bit host 131.183.0.0 255.255.0.0 natural mask 205.133.127.0 24 bit network, 8 bit host 205.133.127.0 255.255.255.0 natural mask
The host portion on Class A networks is 24 bits. This means that there could be 2^24 hosts on this network. Class B networks will support 2^16 hosts, and Class C networks allow 2^8 hosts. In many instances, dividing a large network into smaller networks with fewer hosts is desirable. This process is called sub-netting and requires an increase in the netmask. U.T. Address Space: 131.183.0.0 Netmask: 255.255.0.0 Address Range: 131.183.0.0 - 131.183.255.255 Sub-dividing the space: Network: 131.183.217.0 Sub-netmask: 255.255.255.0 Range: 131.183.217.0 - 131.183.217.255 The use of a mask to determine the destination network is called Classless Inter-Domain Routing (CIDR). CIDR requires modification to routes and routing protocols
- Expressed as: o Address/prefix length (# of bits in network address) instead of network
and subnet via longhand. o 131.183.217.0/24 vs. 131.183.217.0 with a subnet mask of
255.255.255.0 - RFC 1878
Reserved Network Addresses
0.0.0.0/8 = default route 127.0.0.0/8 = loopback address
Private Networks (RFC1918)
3
10/8 172.16/12 = 172.16.0.0 thru 172.31.255.255 192.168/16 = 192.168.0.0 thru 192.255.255.255 169.254/16 = 169.254.0.0 thru 169.255.255.255
Reserved Host Addresses
0 the network, the wire 255 broadcast address, flooded to all hosts Thus, usable addresses = 2n-2
Gateways
If the destination host is not on the same network as the source host, the packet is delivered to a gateway (generally a “router”), which forwards the packet to the proper destination.
2. The Datagram
The compete information package from the transport layer is encapsulated in the data portion of the Ethernet frame. The Ethernet header identifies the target machine.
IP Header IP Data (payload)
Ethernet Data (payload) Ethernet Header
Once the frame reaches the target host and is extracted, the ethernet header is stripped and the packet is passed up to the transport layer.
4
A summary of the contents of the Internet header follows:
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |Version| IHL |Type of Service| Total Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Identification |Flags| Fragment Offset | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Time to Live | Protocol | Header Checksum | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Source Address | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Destination Address | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Options | Padding | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Example Internet Datagram Header
Version: 0100h (version 4) Internet Header Length: Type of Service: specifies the “priority” of the packet Total Length: of the IP datagram (up to 65,535 octets) Identification, Flags, Fragment Offset: Time to Live: Protocol: Header Checksum: Source Address: Destination Address:
5
6
3. Moving data between the data link layer and the transport layer.
Moving the data between the data link layer and the transport layer requires coordination of the addressing schemes in each of the layers. Recall:
• Transport layer: 32 bit IP addresses • Data-link layer: 48 bit MAC addresses
Two machines can communicate only if they know each other’s physical network address. Data from applications are transported between logical hosts. In other words, the “application” uses the IP address to identify the target machine, while the “network” uses the MAC address to identify the target machine.
The address resolution problem: How do you map an IP address to physical address.
• Keep tables. What if hardware fails and is replaced? How do you re-map? • Encode h/w address in high level address. However, you can’t do direct
mapping – IP address is 32 bits, the Ethernet address is 48 bits so it can’t be encapsulated in the IP address.
• Dynamic binding: address resolution protocol RFC 826: Address Resolution Protocol (ARP) ARP binds addresses dynamically (no direct or static mapping)
Checks cache table Broadcasts to all hosts Host answers MAC address is inserted into table
Why not broadcast all packets instead of asking? Efficiency Cache timeout –20 minutes. Why? No other way to determine downtime since no guarantee of delivery Delay in updates (20 minutes…) Improvements sender inserts it’s IP in it’s broadcast request both intended and other hosts can extract
arp broadcasts can be sent at boot to update arp tables.