Chapter 4
Chapter 4
Chapter 4
Introduction
The role of the network layer is simple—to move packets from a sending host to a
receiving host. To do so, two important network-layer functions can be identified:
• Forwarding: When a packet arrives at a router’s input link, the router must
move the packet to the appropriate output link. For example, a packet arriving
from Host H1 to Router R1 must be forwarded to the next router on a path to H2.
• Routing: The network layer must determine the route or path taken by packets
as they flow from a sender to a receiver. The algorithms that calculate these paths
are referred to as routing algorithms. A routing algorithm would determine, for
example, the path along which packets flow from H1 to H2.
1. IP Protocol: The Internet Protocol (IP) is the method or protocol by which data
is sent from one computer to another on the Internet.
Internetworking:
Repeaters:
Repeaters are the devices that amplify and regenerate the signals to ensure
that the data is not lost during the transmission. A repeater receives a signal and
before it becomes too weak or corrupted, regenerates the original bit pattern.
Repeater is not an amplifier because an amplifier simply amplifies the entire
signal along with noise. Repeater regenerates the original signals and removes the
noise. A repeater operates at physical layer of OSI model.
Types:
Passive Hub
o A passive hub simply combines the signals of the network
segments.
o There is no signal processing or regeneration.
Active Hub:
o They are like passive hub but they have electronic components
for regeneration and amplification of signals.
o Active hubs have their own power supply and are expensive
than passive hub.
Intelligent Hub:
o It work like active hubs and include remote management
capabilities.
Bridges:
A device used to connect similar LANs is a bridge. A router can also do that
but it is a more general- purpose device, capable of interconnecting a variety of
LANs and WANs. The bridge is designed to use between local area networks that
use identical protocols for the physical and link layers. Because the devices all use
the same protocols, the amount of processing required at the bridge is minimal.
By use of a bridge between two (or more) LANs, it appears to all stations on
the two or more LANs that there is a single LAN on which each station has a
unique address.
Transparent Bridge:
Routing Bridge:
In routing bridge, a sending station defines the bridge that
must be visited by the frame. The addresses of these bridges
are included in the frame. Hence a frame contains not only the
source and destination addresses but also the bridge address.
Thus we see that, in the general case, the bridge must be equipped with a
routing capability. When a bridge receives a frame, it must decide whether or not
to forward it. If the bridge is attached to two or more networks, then it must
decide whether or not to forward the frame and, if so, on which LAN the frame
should be transmitted.
Gateway:
The gateway is implemented at the edge of a network and manages all data
that is directed internally or externally from that network. When one network
wants to communicate with another, the data packet is passed to the gateway
and then routed to the destination through the most efficient path.
To transfer data to the particular host, the sending host must need
an address specified to that host called as IP address. Each IP address is 32 bits
long (equivalently, 4 bytes), and there are thus a total of 232 possible IP
addresses.
1. Unicast:
In this mode, data is sent only to one destined host. The Destination
Address field contains 32- bit IP address of the destination host. In short it is ONE-
TO –ONE transmission.
2. Broadcast:
3. Multicast:
The first octet referred here is the left most of all. The octets numbered as
follows depicting dotted decimal notation of IP Address.
Class A Address (N.H.H.H): The first bit of the first octet is always set to 0 (Zero).
Thus the first octet ranges from 1-127, i.e
00000001 – 01111111
1 – 127
Class A addresses only include IP starting from 1.x.x.x to 126.x.x.x only. The IP
range 127.x.x.x is reserved for loopback IP addresses.
The default subnet mask for class A IP address is 255.0.0.0 which implies that class
A addressing can have 126 networks (2^7-2) and 16777214 (2^24-2).
An ip address which belongs to class B has the first two bits in the first octet set to
10, i.e.
10000000 – 10111111
128 – 191
Class B IP addresses range from 128.x.x.x to 191.255.x.x. The default subnet mask
for class B is 255.255.x.x.
Class B has 16354 (2^14) Network addresses and 65534(2^16-2) Host addresses.
The first octet of class C IP address has its first 3 bits set to 110, that is
11000000 – 11011111
192 – 223
Class C gives 2^21 network addresses and 254 (2^8-2) host addresses.
Very first four bits of the first octet in class D ip addresses are set to 1110, giving a
range of 11100000 – 11101111
224 – 239
Class E Address:
Classless Addressing:
CIDR Block-
CIDR Notation-
a.b.c.d / n
• Remaining bits are used for the identification of hosts in the network.
Example-
182.0.1.2 / 22 11111111.1111111.11111100.00000000
It suggests-
• Remaining 4 bits are used for the identification of hosts in the network.
Problem:
Solution-
It suggests-
• Remaining 5 bits are used for the identification of hosts in the network.
• 00010100.00001010.00011110.00100011 / 27
192.168.1.1/
Problem-02:
Solution-
It suggests-
• Remaining 12 bits are used for the identification of hosts in the network.
• 01100100.00000001.00000010.00100011 / 20
So,
Subnetting:
• The process of dividing a single network into multiple sub networks is called
as subnetting.
Advantages-
A subnet mask is like an IP address, but for only internal usage within a network.
Routers use subnet masks to route data packets to the right place.
Example:
Consider-
• For creating four subnets and to represent their subnet IDs, we require 2
bits.
• After borrowing two bits, Host ID part remains with only 6 bits.
• 200.1.2.00000000 = 200.1.2.0
• 200.1.2.01000000 = 200.1.2.64
• 200.1.2.10000000 = 200.1.2.128
• 200.1.2.11000000 = 200.1.2.192
Solution:
Now,
where n = no. of host bits that are shifted from the host bit to
the network bits.
No. of subnets = 4
2n = 4
11111111.11111111.11111111.11000000
= 255.255.255.192
For subnet 1,
For subnet 2,
For subnet 3,
For subnet 4,
Solution:
For HR department:
i.e. 2n ≥ 17
i.e. 2n ≥ 32
i.e. 2n ≥ 26
For ATMs:
i.e. 2n ≥ 13
Supernetting:
Supernetting is the process of combining two or more small networks into a larger
network. In subnetting, network address bits are increased. On the other hand, in
supernetting, host address bits are increased. Supernetting is generally done to
reduce the size of the routing table. If there are too many small networks, the size
the routing table increases and this cause more processing delay.
• Version number (4-bit): These 4 bits specify the IP protocol version of the
datagram. By looking at the version number, the router can determine how to
interpret the remainder of the IP datagram.
• Header length (4-bit). Because an IPv4 datagram can contain a variable number
of options (which are included in the IPv4 datagram header), these 4 bits are
needed to determine where in the IP datagram the data actually begins.
• Type of service (8-bit). The type of service (TOS) bits was included in the IPv4
header to specify datagram priority and request a route for low latency, high
throughput or highly-reliable service.
• Datagram length (16-bit). This is the total length of the IP datagram (header
plus data), measured in bytes. It is 16 bit long.
• Header checksum (16-bit). The header checksum aids a router in detecting bit
errors in a received IP datagram.
• Data (Payload): The data field of the IP datagram contains the transport-layer
segment (TCP or UDP) to be delivered to the destination. However, the data field
can carry other types of data, such as ICMP messages.
IP Datagram Fragmentation:
– DF flag: Do not Fragment flag if set (1), then the network is not
allowed to fragment the datagram.
Example:
Consider-
Solution:
Here, Host A is sending MTU of 520 i.e. 500 byte of actual data and 20 byte
of IP header.
NOW,
– DF bit is set to 0
Router concludes-
– DF bit is set to 0.
Router knows-
– So, maximum total length of any fragment can be only 200 bytes.
– So, maximum amount of data that can be sent in any fragment = 180
bytes.
Rules:
• MF bit = 1
• MF bit = 1
• MF bit = 0
Routing:
• Distance vector routing algorithm and link-state routing algorithm are the
popular routing algorithms.
Types of Routing:
To forward incoming data packets, a router learns all available routes in the
network and stores them in a table known as the routing table.
There are two types of routes: static route and dynamic route. A router can learn
these routes through two types of routing: static routing and dynamic routing.
Routing Algorithm:
• The main function of the network layer is routing packets from the source
machine to the destination machine.
• The routing algorithm is responsible for deciding which output line an incoming
packet should be transmitted on.
This is the simple routing technique that computes the optimal path from the
source to the destination from a complete picture of the network. There could be
multiple paths from the source to destination and routers may not have all the
details of the network. So a distributed routing algorithm needs to these paths
and pick the shortest path among them.
The idea is to build a graph of the network, with each node of the graph
representing a router and each edge of the graph representing a communication
line, or link. To choose a route between a given pair of routers, the algorithm just
finds the shortest path between them on the graph.
There are multiple ways of measuring the cost of a link. In general case, the cost is
computed as hop count, function of distance, bandwidth, average traffic, delay
etc. Once the criteria for measuring the cost is finalized, Dijkstra’s algorithm is
Example:
Step 2: choose a starting vertex and assign infinity path values to all other devices
Step 6: After each iteration, we pick the unvisited vertex with the least path
length. So we choose 5 before 7
Flooding:
The distance vector routing algorithm is sometimes called by other names, most
commonly the distributed Bellman-Ford routing algorithm, after the researchers
who developed it. It was the original ARPANET routing algorithm and was also
used in the Internet under the name RIP.
In distance vector routing, each router maintains a routing table indexed by, and
containing one entry for each router in the network. This entry has two parts:
distance (cost) to reach the destination node and next hope (preferred node to
use to reach that destination).
As like shortest path algorithm, distance can be measured as the no. of hops, or
other metrics like propagation delay, bandwidth etc.
Example:
Consider,
Step 1: Each router prepares its routing table using its local knowledge.
At Router A:
A 0 A
B 2 B
C ∞ –
D 1 D
A 2 A
B 0 B
C 3 C
D 7 D
At Router C-
A ∞ –
B 3 B
C 0 C
D 11 D
At Router D-
A 1 A
B 7 B
C 11 C
D 0 D
For Router A:
Router A receives distance vector from its neighbors B and D.
Router A prepares a new routing table
A 5 B
B 3 B
C 0 C
D 10 B
A 1 A
B 3 A
C 10 B
D 0 D
Each router exchanges its distance vector obtained in Step-02 with its
neighboring routers.
After exchanging the distance vectors, each router prepares a new routing
table.
At Router A-
A 0 A
B 2 B
C 5 B
D 1 D
At Router B-
Cost of reaching destination A from router B = min { 2+0 , 3+5 , 3+1 } = 2 via
A.
Cost of reaching destination C from router B = min { 2+5 , 3+0 , 3+10 } = 3
via C.
Cost of reaching destination D from router B = min { 2+1 , 3+10 , 3+0 } = 3
via A.
A 2 A
B 0 B
C 3 C
D 3 A
At Router C-
A 5 B
B 3 B
C 0 C
D 6 B
At Router D-
A 1 A
B 3 A
C 6 A
D 0 D
Routing Table:
- Routing table is a set of rules in a table format which is used to determine where
data packets traveling over an IP network will be directed.
- It contains all the information necessary to forward a packet along the best path
toward its destination.
a) Destination IP address
e) Routes
- Dynamic routing tables allow devices to respond to device failures and network
congestion.
Adaptive Routing:
Non-Adaptive Routing:
RIP is a protocol that defines a way for routers, which connect networks
using IP, to share information about how to route traffic among networks.
Each router maintains a routing table which consists of a list of all
destinations it knows how to reach and the distance to that destination.
It uses distance vector algorithm to decide the route of packet to its
destination.
It uses hop count as a metric to find best path to the destination.
o RIP has maximum hop count of 15.
o A route with a hop count greater than 15 is considered unreachable.
OSPF messages:
Hello message: These are keep alive messages used for neighbor discovery. These
are exchanged in every 10 seconds. If a hello message is not sent within four time
of hello interval by the neighbor, router will terminate adjacency with the
neighbor.
Database Description: With the help of this message, the router announces what
updates it has.
Link State update: when a router receives LSR, it responds with LSU message
containing the details requested.
The main Problem associated with ICMP is that, these messages can be
used in DDOS attack. A bot host can send continuous ICMP eco messages
(ICMP flood) to the target host resulting denial of a service.
Also to avoid ICMP flood, most firewall don’t accept these messages and
drop them out. This causes poor performance but makes network secure
from ICMP flood.
When a packet traverse outside the local (inside) network, then NAT converts
that local (private) IP address to a global (public) IP address. When a packet enters
the local network, the global (public) IP address is converted to local (private) IP
address.
The router will have a NAT table with the help of which it will translate the Private
IP addresses of the organization to the public IP addresses provided by the
internet and vice-versa.
In ARP, 32-bit IP address is mapped into 48-bit MAC address to find the physical
address of another host or router in its network. For this, the sending host needs
to send an ARP request message. The ARP request contains:
The intended recipient send back an ARP reply message packet containing the
MAC address of the recipient.
Each host and router maintains an ARP table that contains information about IP
addresses of different host their corresponding MAC addresses and TTL.
If a host does not find the MAC address of the intended recipient in its ARP
table, it broadcasts the ARP request packet. In response, it receives ARP response
with the MAC address of the recipient.
In RARP, IP address is fetched through server. Through RARP, 48-bit MAC address
is mapped into 32-bit IP-address. To find the IP address of host/router on a
network it sends an RARP request message to the RARP server.