# Network Layer – Logical Addressing

In this lesson, you will learn about logical addressing scheme of networking layer, this layer deals with ipadderessing and has a class based and class addressing scheme. You will also learn concept of sub netting and super netting.

An IPv4 address is bit address that uniquely and universally defines the connection of a device.

Unique means no two devices can have same address at the same time on Internet.

\begin{aligned}
2^{32} = 42, 94,967,296
\end{aligned}

Notations

Binary Notation:

Decimal Notation:

Each of the octet range to .

In classful addressing, the address space is divided in to classes: and .

Binary Notation starting bits of first octet will tell the class.

In decimal notation, range of first octet tells the class to which the address belongs.

## Classes and Blocks

Each of the class is divided into fixed number of blocks and each block has a fixed size.

There is flaw with this classful addressing. Class is used by large organization with large number of hosts and routers, but it’s too big for any organization. Class for mid size organization, but this also too big for organization leading to waste of ipaddress.

Class is too small for organizations.

So, in classful addressing,
a large part of addresses was wasted.

In classful logical addressing, the address is divided into two parts – Netid and hosted

For example, Class address, the first byte is network id and the rest bytes are Hostid.

Default mask help us find the Netid and hosted of an ipaddress.

The class in the form is called CIDR (Classless Inter Domain Routing) which is used for classless logical addressing.

### Subnetting

Classful logical addressing is obsolete now. An organization would get large number of class or Class address and then these address would be subnetted means assign in logical groups to small networks called Subnets.

### Supernetting

Large number of addresses of class and were depleted. To create a larger network, organizations combined class address into one group called Supernets and process is known as Supernetting.

Classful Addressing is not obsolete,
is replaced with Classless addressing.

Due to depletion of addresses, classless logical addressing was introduced to connect more organizations to the Internet.

In classless logical addressing, size of the address block depends on size and nature of the entity. For example, may get thousands of address; home user may get addresses. To manage ipaddress, three restrictions were imposed

1. Address in a block must be contagious
2. Number of address in the block must be power of .
3. The first address must be evenly divisible by the number of addresses.
• – first
• – last

Condition 1: address must be contagious .It is contagious.

Condition 2: The number of addresses is .

Condition 3: first address when converted to decimal is divisible by .

\frac{3,412,334,368}{16}=213270898

### How to convert ipaddress to decimal equivalent?

\begin{aligned}
&129.15.14 .17\\ \\
&256^3 \times 129 + 256^2 \times 15 + 256^1 \times 14 + 2560 \times 17\\ \\
&= 16777216 \times129 + 65536 \times15 + 256 \times 14\\ \\
&= 216420864 + 983040 + 3584 + 17\\ \\
&= 217407505
\end{aligned}

In IPv4 addressing, a block of addresses can be defined as ,

In which defines one of the addresses and the defines the mask.

An ipaddress has network address of which we need to find the first and last address for two reasons – first address is address of routing or hub device and last address gives the total size of a block of addresses.

First address in the block can be found by setting rightmost 32-n bits to 0s.
The last address in the block can be found by setting rightmost bit to 1s.

Solution:

\begin{aligned}
&1100 1101. 0001 0000. 00100101. 0010 0101\\ \\

&32 – 28 = 4 \hspace{1mm}bit\\ \\

&1100 1101. 0001 0000. 00100101. 0010 0000\\ \\

&205.16.37.16/32 \hspace{1mm} is \hspace{1mm} the \hspace{1mm} first \hspace{1mm} address.

\end{aligned}

\begin{aligned}
&1100 1101. 0001 0000. 00100101. 0010 0101\\ \\
&32 – 28 = 4 \hspace{1mm} bit\\ \\
&1100 1101. 0001 0000. 00100101. 0010 1111 = 205.16.37.47/28\\ \\
&The \hspace{1mm} number \hspace{1mm}  of  \hspace{1mm} address  \hspace{1mm} in  \hspace{1mm} the  \hspace{1mm} block \hspace{1mm}  can \hspace{1mm}  \\ \\ &be  \hspace{1mm} found \hspace{1mm}  by \hspace{1mm}  using  \hspace{1mm} formula, \hspace{1mm} 2^{32-n}.
\end{aligned}

IInd Method

\begin{aligned}
&11111111. 11111111.11111111. 11110000\\ \\
&1100 1101. 00010000.00100101. 00100101\\
&-----------------\\
&11001101 00010000 00100101 00100000 -> 205.16.27.32

\end{aligned}

The last address can be found by ORing any address in the block by complement of the mask.

\begin{aligned}
&00000000. 00000000. 00000000.00001111\\\\
&1100 1101.00010000.00100101. 00100101\\
&-----------------\\
&11001101. 00010000. 00100101. 00101111 -> 205.16.27.47/28
\end{aligned}

When an organization is given group of network addresses, then it is free to assign the address to any number of devices that want to connect to internet.

The first address is network address and used in the router and identifies the network in Internet

Two level hierarchy: no sub netting

Each ipaddress in the block has two level hierarchy structure, the leftmost, n bit defines the Network and rightmost bits defines the host.

### Three level hierarchy: subnetting

Large block of addresses are broken in subnet with small blocks of addresses and own subnet masks. The organization has a different address to receive information from the Internet and router routes the message to each subnet and receive from subnets.

For example,

,

• Mask for the first subnet be , then implies that because bits.

First address of Subnet1 is can be found using any address .

set right most bit to .

• Mask for the second subnet be , then implies that because bits.

First address of Subnet2 is can be found using any address .

set right most bit to .

• Mask for the Third subnet be , then implies that because bits.

First address of Subnet3 is can be found using any address .

set right most bit to .

.

### More levels of hierarchy

The structure of classless addressing does not prevent more hierarchy. For example, the International get lot of ipaddresses which is divided among the . The national then divide the ipaddress into and gives the ipaddress to the organization and which divides the group of ipaddress further.

The address allocation is responsibility of. It assigns large block of ipaddresses to ISPs and ISP divided these blocks into smaller sub-blocks and give it to Local ISP, and so on.

This is called address aggregation; many blocks of addresses aggregated into one block.

1st group wants customers and each want addresses.

2nd group wants customers and each customer want addresses.

Solution:

to covers customer. Now each customer has hosts then address must have bits for hosts.

to covers host for each customer.

Similarly,

to covers customer. Each customer has hosts then address must have bits for hosts.

to cover hosts each.

NAT enables one user to have large number of addresses internally and one address or a small set of address externally.

The Internet Authorities have reserved set of addresses for private networks which any one can use.

The site must have single connection to the global Internet through a router that runs the software.

[/latex]192.168.10.2[/latex]

[/latex]192.168.10.1[/latex]

The rest of the Internet only sees the global address which is but the private address is hidden.

All packets intended for Internet goes through the router which change the source address with the global address. Similarly, incoming packet goes through the router in which destination address is changed to private addresses.

### Translation table

The problem of sending packet with source address is solved by changing the source address at router. But routing to correct destination inside a private network from Internet is different problem.

This is done using a translation table.

In this scheme, the translation table has two columns, private address and external address. When a packet is sent to external address, the router change the source address and also make a note of private address in the translation table of the source along with external address. When a response from the same destination is received, it is used as for identifying the private address of the destination in side .

In the scheme above, the communication is always initiated by private network. The is used by the running many server programs, because the private network of organizations cannot run programs that need internet access.

For example, email server, etc.

### Using a pool of ipaddress

In this scheme, the router uses four global addresses. So four private network hosts can communicate with the same external host because each address pair defines one connection.

\begin{aligned}
192.168.100.1 -> 200.15.100.20 -> 200.33.23.22\\ \\
192.168.100.2 -> 200.15.100.21 -> 200.33.23.22
\end{aligned}

There is few drawbacks with connections, first no more than connection is allowed and second, a private network host cannot access two server programs at the same time.

### Using both ipaddress and port number

To allow many-to-many connections, we need more information in the translation table.

If the translation table also has information for about transport layer then we have not problem creating more connections.

When a response is received then a combination of source address and the destination port number decide the Host address of the destination private network.

The internal port number must be unique.

### NAT and ISP

Suppose the has addresses, but it has customers. To server customer it provide them with the private address and use to translate the addresses using one of the addresses.

## References

Andrew S. Tanenbaum, David Wetherall. n.d. Computer Networks. Pearson, 23-Jul-2013.

Behrouz A. Forouzan, Sophia Chung Fegan. n.d. Data Communications and Networking, Fourth Edition. McGraw hill education.