Basics

IPv4 Addressing & Fragmentation- Basics of Networking – Part III

Addressing:

A distinction is made between names, addresses, and routes.   A name indicates what we seek.  An address indicates where it is.  A route indicates how to get there.  The internet protocol deals primarily with addresses.  It is the task of higher level (i.e., host-to-host or application) protocols to make the mapping from names to addresses.  The internet module maps internet addresses to local net addresses.  It is the task of lower level (i.e., local net or gateways) procedures to make the mapping from local net addresses to routes.

Addresses are fixed length of four octets (32 bits). Just like Phone numbers are divided into area code and subscriber number, an IP address begins with a network number, followed by host address. Each octet/byte is divided by a dot.

Example: 10.10.10.10/24

00001010.00001010.00001010.      00001010       /24

  • The subnet mask (/24 in this example) depicts the count of bits on network side.
  • So here the first three octets are Network Address and last octet is the host address in that particular network.
  • Network bits are counted from left most bit and host bits are counted from right most bit.

Types of Addresses:

  • Network Address : It defines the particular network and is the first address in the network with all host bits to be 0.
  • Broadcast Address : As name suggests, this address is used to send a broadcast in the particular network. This is the last address of the network with all host bits set to 1.
  • Host Address: All the addresses in the range between Network and Broadcast address are Host addresses. These are the only usable addresses in the network as Network and Broadcast address cannot be assigned, except when subnet mask is /31. So the number of hosts can be 2^(no. of hosts) -2

Before going into the classification of IP address, lets take a look on how to find the network, broadcast and host address from the mentioned IP address.

  • First identify the number of network and host bits using subnet mask.
  • Write down the network bits as it is and turn the host bits to 0. The IP address then formed is your Network Address.
  • Turn the host bits to 1 and that address formed will be your broadcast address.
  • Turn the network bits to 1 and host bits to 0, this will be your subnet mask in 32 bit format.

Classification of IP address:

Class Fixed bits in 1st octet Range of 1st octet Subnet Mask Subnet Prefix Hosts per network
A 0 1-126 255.0.0.0 /8 2^24-2
B 10 128-191 255.255.0.0 /16 2^16-2
C 110 192-223 255.255.255.0 /24 2^8-2
D 1110 224-239 Reserved for Multicast groups /1-32
E 11110 240-255 Reserved for future use , or R&D purpose /1-32
  • First octet of an address defines the class of an IP address. When the classes were defined, each class was bind to its default subnet mask like to class A, mask other than /8 can not be used. This is called classful.
  • With this, IP addresses cannot be used efficiently. Think of a network where we have only around thousands of devices, so assigning a Class A address will be wastage of IP addresses.
  • IANA association is responsible for IP assignments to the organizations. To overcome the above situation, IANA removed the concept of binding between class and subnet mask. This made the classes classless.
  • 127.0.0.0/8 address space is reserved for universal loopback functionality.

Private IP address Range:

  • This is explained in RFC 1918 as Address Allocation for Private Internets.
  • The Internet has grown beyond anyone’s expectations. Sustained exponential growth continues to introduce new challenges.  One challenge is a concern within the community that globally unique address space will be exhausted.
  • The hosts in the enterprise network, may not need an access to outside network so there is no need of assigning them a universally unique IP address as they are not going to interact with other devices over the internet.
  • The Internet Assigned Numbers Authority (IANA) has reserved the following three blocks of the IP address space for private internets. These addresses cannot be used to access internet.

                             10.0.0.0        –   10.255.255.255  (10/8 prefix)

                             172.16.0.0      –   172.31.255.255  (172.16/12 prefix)

                             192.168.0.0     –   192.168.255.255 (192.168/16 prefix)

Classification of Mask:

  1. Default Mask: The mask which belongs to the classfull class is called default class.
  2. Subnet Mask: The mask greater than the default mask of a class is known as subnet mask.
  3. Supernet Mask: The mask less than the default mask of a class is a supernet mask.

For Class A address, any mask greater that default mask 8 is subnet and less than that is supernet.

Subnetting:

A subnetwork or subnet is a logical subdivision of an IP network. The practice of dividing a network into two or more networks is called subnetting. It can be done based on two requirements : number of hosts or networks required.

  • Based on number of hosts: Suppose I have a network 16.20.20.0/24 and I want to divide it to host 30 devices
    • Find out the maximum number of hosts required- So the number is 30 in our example.
    • Add 2 to that number as in each network, two addresses are reserved for network and broadcast, that makes it 30+2 = 32.
    • Calculate the number of bits required to meet upto the number: 2^5 = 32, so last 5 bits of octet will be used for host and rest for the network.
    • Calculate the subnet mask based on the number of bits required.

So subnet mask will be: 11111111.11111111.11111111.11100000 which is 255.255.255.224.

Hence subnetted network will be 16.20.20.0/27

Network address: 16.20.20.20.0/27 –All host bits 0

Broadcast Address: 16.20.20.31/27 — All host bits 1

Host Address Range: 16.20.20.1/27 to 16.20.20.30/27

  • This is the first block of the subnet. To calculate next block, network address will be last broadcast plus one and broadcast will network address plus block size.
  • To calculate the block size, turn network bits to 0 and host bits to 1. So here: 00000000.00000000.00000000.00011111: block size is 31.
    • Network Address = Subnet + Block size + 1
    • Broadcast Address = Network Address + Block Size
    • Number of networks: 2no. Of network bits. So here 23=8 networks can be made from 16.20.20.0/24 to host 30 devices per network.
Block Network to Broadcast Address
1 16.20.20.0/27  to 16.20.20.31/27
2 16.20.20.32/27  to 16.20.20.63/27
3 16.20.20.64/27 to 16.20.20.95/27
4 16.20.20.96/27 to 16.20.20.127/27
Last 16.20.20.224/27 to 16.20.20.255/27
  • Based on the number of networks: Suppose I have a network 10.0.0.0/24 and want to divide it into 10 networks.
    • Calculate number of networks required. Here it is 10.
    • Calculate number of network bits required to get the required networks. So for 10 networks, 4 bits are used (2^4=16). First 4 bits of the last octet will be used which will give 16 networks.
    • Calculate the subnet mask based on the number of subnet masks required. 11111111.11111111.11111111.11110000 = 255.255.255.240 hence the subnetted network is 10.0.0.0/28
    • Calculate the block size: Last octet= 00001111 = 15
    • Calculate the blocks of network, as we did in above section.
Block Network & Broadcast  Address
1 10.0.0.0/28 to 10.0.0.15/28
2 10.0.0.16/28 to 10.0.0.31/28
3 10.0.0.32/28 to 10.0.0.47/28
Last 10.0.0.240/28 to 10.0.0.255/28

Identification of IP Address:

  • Network Address
    • Calculate the number of host bits from subnet mask.
    • Find the number of hosts from host bits.
    • Divide the last octet by number of hosts.
    • If the remainder is 0, then its network address.
    • Quotient will be the number of network in the network block.
      • Example: 10.0.0.152/30
        • 2 bits on host side
        • No of hosts : 2^2=4
        • 152/4 is completely divisible with quotient as 38 and remainder 0.
        • So it’s a network address.
    • 2nd method is to convert to binary and if all the bits on host side are zero then its network address.
      • 00001010.0.0.10011000: last two bits are zero, so its network address.
  • Broadcast Address
    • When the remainder is one less that number of hosts that is divisor, then its broadcast address.
      • Example: 10.0.0.151/30
        • 151/4 gives 37 as quotient and 3 as remainder.
        • 3 is one less than 4 (divisor, no of hosts), so its broadcast address.
    • 2nd method is to convert to binary and if all the bits on host side are one then its broadcast address.
      • 00001010.0.0.10010111: last two bits are one hence its broadcast address.
  • Host Address
    • If remainder is other than 0 or one less than divisor, then it’s a host address.
    • Remainder tells the position of host in the network block.
    • Network address is calculated by subtracting remainder from dividend.
    • Broadcast address is calculated by subtracting remainder from (divisor-1) and add to dividend.
      • Example: 10.0.0.100/27
        • 5 bits on host side, so number of hosts will be 32.
        • 100/32 leaves 4 as remainder and 3 as quotient.
        • It means it’s the 3rd subnet block and 4th ip address in that block.
        • Network address: 100-4 =96 so that makes 10.0.0.96/27 as network address.
        • Broadcast address: (32-1)-4+100=127 which makes 10.0.0.127/27 as broadcast address.
    • 2nd method is to convert to binary and if host bits are mixture of 1&0, then its host address. Turning all host bits to 0 will make network address and to 1 will give you broadcast address.

Fragmentation:

In the routing of messages from one internet module to another, datagrams may need to traverse a network whose maximum packet size is smaller than the size of the datagram.  To overcome this difficulty, a fragmentation mechanism is provided in the internet protocol.

  • The internet fragmentation and reassembly procedure needs to be able to break a datagram into an almost arbitrary number of pieces that can be later reassembled.
  • The receiver of the fragments uses the identification field to ensure that fragments of different datagrams are not mixed.
  • The fragment offset field tells the receiver the position of a fragment in the original datagram.
  • The fragment offset and length determine the portion of the original datagram covered by this fragment.
  • The more-fragments flag indicates (by being reset) the last fragment.  These fields provide sufficient information to reassemble datagrams.
  • The data of the long  datagram is divided into two portions on a 8 octet (64 bit) boundary (the second portion might not be an integral multiple of 8 octets, but the first must be).  Call the number of 8 octet blocks in the first portion NFB (for Number of Fragment Blocks).
  • Every internet module must be able to forward a datagram of 68 octets without further fragmentation.  This is because an internet header may be up to 60 octets, and the minimum fragment is 8 octets.
  • Every internet destination must be able to receive a datagram of 576 octets either in one piece or in fragments to be reassembled.
  • The fields which may be affected by fragmentation include:

(1) options field
(2) more fragments flag
(3) fragment offset
(4) internet header length field
(5) total length field
(6) header checksum

  • The maximum sized datagram that can be transmitted through the next network is called the maximum transmission unit (MTU).
  • The 16-bit identification field is displayed in Hex and has a few different uses, most importantly:
    • Identifies fragmented packets.
    • Identifies the individual packets that the sender transmits.
  • The IP Identification field will increase by ‘1’ for every packet from the sender.
  • Remember the IP ID Value is specific to each individual and not to a specific conversation.
  • If the packets get fragmented they will have the same IP ID number, the Fragment Offset field will also be set as well. This is helpful in following a conversation over particular link changes.

Lets take a look at the below capture:

  1. We can see two fragments (252613 and 252614) of a packet. The ID field is 2122 for both the packets to identify the unique packet for every datagram for a given source address, destination address, and protocol, such that it does not repeat within the maximum datagram lifetime (MDL)
  2. The fragment offset of first packet is 0 and second is 1480, which means the second fragment starts after 1480.
  3. The More fragment field is set in 1st packet , which means we have more segments to follow.

ip-frag

IP header for 1st fragment:

frag-1

IP header for last fragment

frag-2JPG

 

To be continued…

Advertisements

Categories: Basics, General, IPv4

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s