Shiva's Blog

IP Basics

Ipv4 Datagram header

Datagram : is a unit of data transfer in packet-switched network, containing header and the payload.

The Internet Protocol (IP) header contains fields to manage the logical addressing and forwarding function. The IP header contains two field for 32 bit source and destination addresses, plus other fields to support forwarding functions.

Image refrence: https://en.wikipedia.org/wiki/IPv4

Some network layer protocols run directly on IP. These IP protocol types include the following:

Layer 2 vs. Layer 3 Addressing and Forwarding


Address Resolution Protocol

Address Resolution protocol is the TCP protocol which is used to translate layer 3 Ip address to layer 2 MAC address, The layer 2 MAC address is also known as physical address, which is unique to each devices.

When a host or the node in a network needs to establish a connection with an IP address that is with in the same network an ARP request is generated. When an ARP request is sent the host broadcast the IP address with in the network, ARP is a broadcast request and each host with in the broadcast domain receives this request. When the ARP request is received by the host in the network with the IP address, it responds with its mac address, the rest of the hosts discard the ARP request.

The use of ARP request is to match the IP address with the MAC address, here the initiator asks who have this IP address and the host with that IP address responds to the request with its MAC address.

ARP request is a broadcast, but the ARP response is unicast.

Unicast and Broadcast Addressing

Unicast:

When a host in the network needs to send a packet to a single Node in the network the method of communication is Unicast. The host uses unicast packet to the IP address of the receiving host as a destination address. Unicast can be at layer 2 or layer 3 this depends upon the type of communication, when the host is using an IP address to create a communication it uses layer 3, similarly if the host uses layer 2 address (MAC) then the communication will be layer 2.

BroadCast:

When a single host is communicating to all the host with in the network or the same broadcast domain the communication is broadcast. When using an IP address the very last IP address within the network is called broadcast address. Similar to unicast broadcast also functions as both layers 2 and 3 depending upon the type of the communication. At layer 3 all the hosts in the same network receives the broadcast traffic, however when layer 2 broadcast is send all the devices with in the same broadcast domain or the devices in the same VLAN receives the broadcast traffic.

Layer 2 broadcast address is by default sent with the destination mac address ff.ff.ff.ff.ff.ff, this means all the devices. In general if the switch is not configured with VLAN, broadcast traffic is forwarded to all the ports except the port that the broadcast has received. In presence of VLAN broadcast traffic is only send to the same VLAN. Similar to VLAN the broadcast traffic is also blocked by the routers.

Multicast and Anycast Addressing

Multicast:

The method of transmitting data from one host to many hosts over a network is called Multicast. Unlike broadcast multicast is not sent to all the hosts with in the network, multicast traffic is only sent to the hosts if they are interested in receiving the traffic. Internet group management protocol (IGMP) is typically used to configure group memberships and IP addresses. In IPv4 224.0.0.0 to 239.255.255.255 is reserved for multicast addressing.

Anycast:

When a group of hosts in a network share the same IP address it is called as anycast. When the packet is forwarded to the anycast group the metric, priority or algorithm is used to identify which host will receive the anycast traffic. Anycast is mostly used for load balancing and failover between the server hosts sharing the IP address.

IPv4 Address Format

Network Masks

In binary 1 in the mask the corresponding binary digit in the IPv4 address is part of the network ID. The 1s in the mask are always contiguous.

eg: 11111111.11111111.11111111.00000000

In decimal: 255.255.255.0

Network masks can also be written as slash notation.

Subnet Masks

The subnet mask contains:

The purpose of subnetting is to create layer 3 broadcast domain segments with fewer hosts. The trick with subnet design is to fit the scheme to the requiements for number of subnetworks and number of hosts per subnet. Each bit added to the mask approximately halves the number of available host addresses.

reference: Comptia network plus(certmaster)