Download as pdf or txt
Download as pdf or txt
You are on page 1of 28

Computer Networks

Lecture - 6

Dr. Abubaker Abushofa


Connecting the Network Layer to the
Data Link Layer
Under the network layer is the data link layer.
For the layers to communicate, they need some
protocols.
ARP (Address Resolution Protocol) is used to map
network layer addresses to data link layer addresses.
RARP (Reverse Address Resolution Protocol) is used
to map layer 2 addresses to layer 3 addresses.

Dr. Abubaker Abushofa {2022-2023} 2/27


IP Address Conflicts

The most commonly seen error produced by ARP is


caused by a conflicting IP address.
This is where two different stations claim to own the
same IP address.
IP addresses must be unique on any connected set of
networks.
IP address conflicts are happen when two replies come
in answer to an ARP request.

Dr. Abubaker Abushofa {2022-2023} 3/27


IP Address Conflicts

Each reply specifying a different hardware address.


This is a serious error, with no easy solution.
It is not known to which hardware address the
datagrams should be sent to?

Dr. Abubaker Abushofa {2022-2023} 4/27


IP Address Conflicts
To avoid IP address conflicts, when interface A is first
initialized it sends out an ARP request for its own IP
address.
If no response is sent back, interface A can assume that
the IP address is not in use.
However, suppose interface B is already using the IP
address in question: B sends an ARP reply with the
hardware address B-hard.
Interface A now knows that the IP address is already in
use - it must not use the address and must flag an error.

Dr. Abubaker Abushofa {2022-2023} 5/27


IP Addressing
In routable network layer protocol, the protocol address
must hold two pieces of information: the network
address and the host address.
The obvious way to store this information is in two
separate fields.
In the largest possible case in both fields, we may
allocate 16 bits for each field. Some protocols (such as
IPX) behave like this, and it works well for small- to
medium-sized networks.

Dr. Abubaker Abushofa {2022-2023} 6/27


IP Addressing

Another solution is to allocate 24 bits for the network


address and just 8 for the host address.
This would allow plenty of networks, but not many hosts
on each network.
However, for networks with more than 256 (28) hosts,
we could allocate multiple addresses.
The problem with this scheme is that the large number
of networks created tends to place a heavy load on the
network’s routers.
Dr. Abubaker Abushofa {2022-2023} 7/27
IP Addressing
IP packs the network address and host address
together into one 32-bit field.
Sometimes the host address portion is short,
sometimes it is long.
This allows very efficient use of the address space,
keeping IP addresses short, and the total number of
networks fairly low.
There are two different ways of splitting the address
back into its two parts - class-based addressing and
classless addressing.
Dr. Abubaker Abushofa {2022-2023} 8/27
Hosts Versus Gateways
A host is a device connected to one or more networks.
It can send and receive traffic on any of these networks,
but it never passes traffic from one network to another.
A gateway is a device connected to more than one
network.
It selectively forwards traffic from one network to
another.

Dr. Abubaker Abushofa {2022-2023} 9/27


Hosts Versus Gateways
Old computers were not powerful enough to act as host and
gateway as the modern computers.
Hence, hosts can be redefined as:
– A host is a device connected to one or more networks.
– It can send and receive traffic on any of these networks.
– It may function as a gateway, but this is not its sole
purpose.

Dr. Abubaker Abushofa {2022-2023} 10/27


Hosts Versus Gateways
A router is a dedicated gateway.
The hardware is specially designed to allow the router to
pass high volumes of traffic with little delay for each packet.
However, a gateway can also be a standard computer with
multiple network interfaces, where the operating system’s
network layer allows it to forward packets.

Dr. Abubaker Abushofa {2022-2023} 11/27


Hosts Versus Gateways
Now that dedicated routing hardware is becoming less
expensive, the use of computers as gateways is becoming
much less common.
At a very small site with only a cheap dial-up connection, a
user’s computer might be used as a nondedicated gateway.

Dr. Abubaker Abushofa {2022-2023} 12/27


Class-Based Addressing
When IP first designed, the address was split into its
composite parts according to the first byte of the address:

0 Reserved (for the network address)

1-126 Class A (network: 1 byte, host: 3 bytes)

127 Reserved (for the loopback address)

128-191 Class B (network: 2 bytes, host: 2 bytes)

192-223 Class C (network: 3 bytes, host: 1 byte)

224-225 Reserved (multicast or class D addresses)


Dr. Abubaker Abushofa {2022-2023} 13/27
Hosts Versus Gateways
If you needed a large network you were given a class A
address, but if you only had a few hosts, you were given a
class C address.

IP address Network address Host address

56.81.38.28 56 81.38.28

137.89.15.88 137.89 15.88

200.77.32.61 200.77.32 61
Dr. Abubaker Abushofa {2022-2023} 14/27
Subnetting
Although the class-based addressing system worked well
for the Internet service provider, it was impossible to do any
routing inside a network.
The intention was that a network would use layer 2
(bridging/switching) to direct packets within a network.
The lack of routing was a particular problem if you had a
large class A network, as bridging/switching on a large
network becomes very difficult to manage.

Dr. Abubaker Abushofa {2022-2023} 15/27


Subnetting
The logical solution is to break down some larger networks
into smaller segments, but this was not possible within the
original confines of the class-based addressing system.
In the previous example, the network address 137.89 is
treated as a class B address, so it is not possible to route
different parts of this network to different sites.

Dr. Abubaker Abushofa {2022-2023} 16/27


Subnetting
To solve this problem, a new field called a subnet mask was
introduced and associated with every address.
The subnet mask indicated which portion of the address was
the network address, and which was the host address
(instead of deciding by the first byte).
In the subnet mask, binary 1 indicates a network address bit,
and binary 0 indicates a host address bit.

Dr. Abubaker Abushofa {2022-2023} 17/27


Subnetting
Thus for the 137.89.15.88 example given earlier, the format
would be:
1. Address:
10001001 – 01011001 – 00001111 - 01011000
(137.89.15.88)
2. Subnet mask:
11111111 – 11111111 – 00000000 - 00000000
(255.255.0.0)
The subnet mask given indicates that the first two bytes are
the network address, the second two bytes are the host
address.

Dr. Abubaker Abushofa {2022-2023} 18/27


Subnetting

Thus your traditional class addresses have subnet


masks:
1. Class A (network: 8 bits, host: 24 bits): 255.0.0.0
2. Class B (network: 16 bits, host: 16 bits): 255.255.0.0
3. Class C (network: 24 bits, host: 8 bits): 255.255.255.0

Dr. Abubaker Abushofa {2022-2023} 19/27


Routing Tables
When a host has several network interfaces, it decides
which interface to use for packets to a particular IP address
according to the routing table.
Ethernet

Destination Subnet mask Gateway Flags Interface

201.66.37.0 255.255.255.0 201.66.37.74 U eth0

201 .66.39.0 255.255.255.0 201.66.39.21 U eth1

Dr. Abubaker Abushofa {2022-2023} 20/27


Routing Tables

The host sends all traffic for hosts on network


201.66.37.0. For example:
– Host addresses 201.66.37.1 to 201.66.37.254 out through
interface eth0 which has IP address 201.66.37.74
– All traffic for hosts on network 201.66.39.0 out through
interface eth1 which has IP address 201.66.39.21.
The flag U just means that the route is “up” (active).

Dr. Abubaker Abushofa {2022-2023} 21/27


Routing Tables
This example only covers hosts that are connected
directly to our network.
But what if the host in question is on a remote network?
If we are connected to network 73.0.0.0 by way of a
router with an IP address of 201.66.37.254, we can add
an entry to the routing table:

Destination Subnet mask Gateway Flags Interface

73.0.0.0 255.0.0.0 201 .66.37.254 UG eth0

Dr. Abubaker Abushofa {2022-2023} 22/27


Routing Tables
This tells the machine to route packets for any hosts on
the 73.0.0.0 network through 201.66.37.254.
This means that there must be another entry in the table,
telling the host how to send packets to 201.66.37.254.
The G (gateway) flag means that this routing entry
directs traffic through an external gateway.

Dr. Abubaker Abushofa {2022-2023} 23/27


Routing Tables
Similarly, a route to a specific host through a gateway
can be added, and it receives the H (host) flag:

Destination Subnet mask Gateway Flags Interface

91.32.74.21 255.255.255.255 201.66.37.254 UGH eth0

Dr. Abubaker Abushofa {2022-2023} 24/27


Routing Tables
This example covers all the basics of the routing
table, apart from a few special entries:
Destination Subnet mask Gateway Flags Interface

127.0.0.1 255.255.255.255 127.0.0.1 UH lo0

default 0.0.0.0 201.66.39.254 UG eth1

 The first of these is the loop back interface, for traffic from
the host to itself. Loopback
Dr. Abubaker Abushofa {2022-2023} 25/27
Routing Tables

This is used for testing, and for communications for


applications that are designed to operate over IP but
that happen to be communicating locally.
It is a host route to the special address 127.0.0. 1 (the
interface lo0 refers to a “fake” network card internal to
the IP stack).

Dr. Abubaker Abushofa {2022-2023} 26/27


Routing Tables

The second entry is a default route to save having a


route defined on the host to every possible network on
the Internet.
If no other entry in the routing table matches the
destination address, the packet is sent to the default
gateway (given in the default route).

Dr. Abubaker Abushofa {2022-2023} 27/27


Thank you for watching!

Any questions? Please ask!

You might also like