TCP/IP Model: Addressing in Network layer
To properly learn something, we have to start at the beginning. We will be learning one concept at a time, process it, and move to the next.
The goal is consistent learning and absorbing information while feeling engaged and not overwhelmed.
I have divided the network layer articles into six parts.
- Introduction to Network layer
- Addressing in Network layer
- Decoupling the Router
- Routing and Routing Protocols in Network Layer
- Internet Protocol
- DHCP and NAT in Network layer
I will be discussing addressing the network layer of the TCP/IP Five-layer network model.
Before discussing IP addresses, however, we’ll need to say a few words about how hosts and routers are connected to the Internet.
A host typically has only a single link into the network; when IP in the host wants to send a datagram, it does so over this link.
The boundary between the host and the physical link is called an interface.
Now consider a router and its interfaces. Because a router’s job is to receive a datagram on one link and forward the datagram on some other link, a router necessarily has two or more links to which it is connected.
The boundary between the router and any one of its links is also called an interface.
A router thus has multiple interfaces, one for each of its links. Because every host and router is capable of sending and receiving IP datagrams, IP requires each host and router interface to have its IP address. Thus, an IP address is technically associated with an interface, rather than with the host or router containing that interface.
IP addresses are 32 bit (equivalently, 4 bytes) long numbers made up of four octets, and each octet is normally described in decimal numbers.
8 bits of data or a single octet can represent all decimal numbers from 0 to 255.
There are a total of
2^32(or approximately 4 billion) possible IP addresses.
IP addresses are written in dotted-decimal notation, in which each byte of the address is written in its decimal form and is separated by a period (dot) from other bytes in the address.
IP addresses are globally managed by Internet Assigned Numbers Authority(IANA) and regional Internet registries(RIR).
While finding the total number of host IP addresses, two IP addresses are not counted and are, therefore, decreased from the total count because the first IP address of any network is the network number and whereas the last IP address is reserved for broadcast IP.
Example: IP address
11000001 00100000 11011000 00001001
IPv4 addresses can be split into two sections, the network ID and the host ID.
The address class system is a way of defining how the global IP address space is split up.
There are three primary types of address classes.
- Class A
- Network ID - First octet
- Host ID - Last three octets
- Total unique addresses -
- Class B
- Network ID - First two octet
- Host ID - Last two octets
- Total unique addresses -
- Class C
- Network ID - First three octet
- Host ID - Last octet
- Total unique addresses -
- Class A
It's good to know that this also translates nicely to how these addresses
are represented in dotted-decimal notation.
- Classes D and E are reserved for multicast and experimental purposes respectively.
Millions of class A addresses are wasted.
Many of the class B address is wasted
Number of addresses available in class C is so small that it cannot cater to the needs of organizations.
Class D addresses are used for multicast routing and are therefore available as a single block only.
Class E addresses are reserved.
Let's say, we want to communicate with the IP address
220.127.116.11, core routers on the Internet know that this IP belongs to the 18.104.22.168 Class A Network. They then route the message to the gateway router responsible for the network by looking at the network ID.
A gateway router specifically serves as the entry and exit path to a certain network. We can contrast this with core internet routers, which might only speak to other core routers.
Once the packet gets to the gateway router for the 22.214.171.124 Class A network, that router is now responsible for getting that data to the proper system by looking at the host ID. This all makes sense until we remember that a single Class A network contains 16,777,216 individual IPs. That's just way too many devices to connect to the same router. This is where subnetting comes in.
Subnetting is the process of taking a large network and splitting it up into many individual smaller subnetworks or subnets.
These individual subnets will all have their gateway routers serving as the ingress and egress point for each subnet.
We've learned about network IDs, which are used to identify networks, and host IDs, which are used to identify individual hosts.
If we want to split things up even further, and we do, we'll need to introduce a third concept, the subnet ID. In a world with subnetting, some bits that would normally comprise the host ID are used for the subnet ID. Subnet IDs are calculated via a Subnet mask.
It is a 32-bit binary number that gives the network address in the address block when AND operation is bitwise applied on the mask and any IP address of the block.
The default mask in different classes:
- Class A –
- Class B –
- Class C –
- Class A –
For example, The subnet mask
255.255.255.224would translate to 27 ones followed by five zeros. This means that we have five bits of host ID space or a total of 32 addresses.
Some values calculated in subnetting:
- Number of subnets: Given bits for a mask – No. of bits in default mask
- Subnet address: AND the result of the subnet mask and the given IP address
- Broadcast address: Host bits as 1 and retaining network bits as in the IP address
- Number of hosts per subnet:
2^(32 – Given bits for mask) – 2
- First Host ID: Subnet address + 1 (adding one to the binary representation of the subnet address)
- Last Host ID: Subnet address + Number of Hosts
For example: Let's say we're dealing with our old friend
126.96.36.199with a subnet mask of
255.255.255.224. Since this subnet mask represents 27 ones followed by five zeros, a quicker way of referencing this is with the notation /27. The entire IP and subnet mask can be written now as
Subnetting was introduced when it became clear that address classes themselves weren't an efficient way of keeping everything organized. After reading the problems in classful addressing, that's a lot of entries in a routing table.
This is where CIDR or classless inter-domain routing comes into play.
CIDR is an even more flexible approach to describing blocks of IP addresses.
It expands on the concept of subnetting by using subnet masks to demarcate networks. To demarcate something means to set something off.
CIDR combines the network ID and subnet ID into one. CIDR is where we get shorthand slash notation.
CIDR abandons the concept of address classes entirely, allowing an address to be defined by only two Individual IDs. We give the IP address and define the number of bits for the mask along with it followed by a ‘/’ symbol (shorthand slash notation).
192.168.1.1/28. Here, the subnet mask is found by putting the given number of bits out of 32 as 1, like, in the given address, we need to put 28 out of 32 bits as 1 and the rest as 0, and so, the subnet mask would be
I would be grateful if you let me know by sharing it on Twitter!
Follow me @ParthS0007 for more tech and blogging content :)