Day-11: Introduction to IPv4.

By | May 7, 2022

IP resides in the network layer . basically the IP is used for identifying the devices in the network. IP is a routed protocol.

IP is a connectionless protocol, which means it does not check whether the destination has received the packet or not .and it does not check if the destination is exist or not .in simply whatever the information will come from the upper layers it will add the source and destination IP and it will send to the data link layer.

An IP address is a 32-bit address, and the IP is a logical IP address. The IP address is basically assigned by governance bodies which is IANA.

in IPv4, We have 2 portions, the Network, and the Host portion.

IPv4 has been designed in classes, And each and every class has its Network portion and Host portion.

Network Portion basically identifies the segment or a group of PC that has shared that network portion.

The host portion is basically unique to the individual device and that’s what is going to make them separate from each other.

Network devices internally understand the IP address in binary format. But we as a human write the IPv4 in decimal format. and each and every portion in the ip address we separate them with a dot.

In IPv4, each portion is 8 bit and 4 portions in IPv4.

IPv4 Classes

We have 5 classes of IPv4 addresses.

  1. Class A: 0.0.0.0 through 127.255.255.255
  2. Class B: 128.0.0.0 through 191.255.255.255
  3. Class C: 192.0.0.0 through 223.255.255.255
  4. Class D: 224.0.0.0 through 239.255.255.255
  5. Class E: 240.0.0.0 through 255.255.255.255
  • Class D isreserved for multicast purpose.
  • Class E is reserved for Experimental or future purposes.

Subnet Mask

Subnet Mask is basically determining how many bits are in-network portion and how many bits are in the host portion.

Types of IPv4 Addresses.

We have two types of IP addresses, namely public IP addresses and private IP addresses.

Public IP address: –These address are globally unique and it is used to route the Internet traffic. This is used on the Internet and is given out by Internet Service Providers (ISPs) to their customers.

Private IP address:– used in private networks for internal traffics within the LAN. Private addresses are not routable out the Internet.

Private addresses are defined in RFC 1918. The private address blocks are:

  • 10.0.0.0 /8: 10.0.0.0 to 10.255.255.255
  • 172.16.0.0 /12: 172.16.0.0 to 172.31.255.255
  • 192.168.0.0 /16: 192.168.0.0 to 192.168.255.255

Other Reserved IP Ranges.

Loopback address:127.0.0.0 – 127.255.255.255
Hosts use it to direct traffic to themselves to test the NIC functions.

Link-Local addresses:169.254.0.0 – 169.254.255.255
The host can automatically assign itself an address if it has none.

Default or Unknown Address :0.0.0.0

Network & Broadcast IP Address.

in each and every IPv4 network, there is 2 IP that we assign to the hosts.

There are 2 IP addresses we cannot use on our network.

  • Network address.
  • Broadcast address.

The network address cannot be used on a computer as an IP address because it’s being used to “define” the network.

The broadcast address cannot be used on a computer as an IP address because it’s used by broadcast applications. A broadcast is an IP packet that will be received by all devices in your network.

Public IPv4 Allocation.

Public addresses are required on the Internet and they must be unique. The use of public addresses is regulated and allocated to each organization separately. RIRs (Regional Internet Registries) typically provide public addresses to ISPs and ISP assigns the public IP to customers.

IPv4 Header

  • Version: the first field tells us which IP version we are using, only IPv4 uses this header so you will always find decimal value 4 here.
  • Header Length: this 4-bit field tells us the length of the IP header in 32-bit increments. The minimum length of an IP header is 20 bytes so, with 32-bit increments, you would see a value of 5 here. The maximum value we can create with 4 bits is 15 so with 32-bit increments, that would be a header length of 60 bytes. This field is also called the Internet Header Length (IHL).
  • Type of Service: this is used for QoS (Quality of Service). There are 8 bits that we can use to mark the packet which we can use to give the packet a certain treatment.
  • Total Length: this 16-bit field indicates the entire size of the IP packet (header and data) in bytes. The minimum size is 20 bytes (if you have no data) and the maximum size is 65.535 bytes, that’s the highest value you can create with 16 bits.
  • Identification: If the IP packet is fragmented then each fragmented packet will use the same 16-bit identification number to identify to which IP packet they belong to.
  • IP Flags: These 3 bits are used for fragmentation:
    • The first bit is always set to 0.
    • The second bit is called the DF (Don’t Fragment) bit and indicates that this packet should not be fragmented.
    • The third bit is called the MF (More Fragments) bit and is set on all fragmented packets except the last one.
  • Fragment Offset: this 13-bit field specifies the position of the fragment in the original fragmented IP packet.
  • Time to Live: Every time an IP packet passes through a router, the time to live field is decremented by 1. Once it hits 0 the router will drop the packet and sends an ICMP time exceeded message to the sender. The time to live field has 8 bits and is used to prevent packets from looping around forever (if you have a routing loop).
  • Protocol: this 8-bit field tells us which protocol is encapsulated in the IP packet, for example, TCP has a value of 6 and UDP has a value of 17.
  • Header Checksum: This 16-bit field is used to store a checksum of the header. The receiver can use the checksum to check if there are any errors in the header.
  • Source Address: here you will find the 32-bit source IP address.
  • Destination Address: here’s the 32-bit destination IP address.
  • IP Option: this field is not used often, is optional, and has a variable length based on the options that were used. When you use this field, the value in the header length field will increase. An example of a possible option is “source route” where the sender requests for a certain routing path.
  • Payload:-This is the original data.

Leave a Reply

Your email address will not be published. Required fields are marked *