You are on page 1of 208

Agnel Charities

Fr. C. Rodrigues Institute of Technology, Vashi, Navi-Mumbai


Department of Computer Engineering

Computer Network

9/25/2022 MRS. RAKHI KALANTRI 1


Chapter - 4

Network Layer

9/25/2022 MRS. RAKHI KALANTRI 2


Roadmap

❖ 4.1 Network Layer design issues, Communication Primitives: Unicast,


1.1

Multicast, Broadcast. IPv4 Addressing (classfull and classless),


Subnetting, Supernetting design problems ,IPv4 Protocol, Network
Address Translation (NAT), IPv6

❖ 4.2 Routing algorithms : Shortest Path (Dijkastra‘s), Link state routing,


Distance Vector Routing

2.1

2.2

2.3

9/25/2022 MRS. RAKHI KALANTRI 3


Roadmap
1.1

❖ 4.3 Protocols - ARP,RARP, ICMP, IGMP

❖ 4.4 Congestion control algorithms: Open loop congestion control,


Closed loop congestion control, QoS parameters, Token & Leaky
bucket algorithms
2.1

2.2

2.3

9/25/2022 MRS. RAKHI KALANTRI 4


Network Layer
➢ The network layer is concerned with getting packets from the source all the way to the destination
with minimal cost.
➢ Getting to the destination may require making many hops at intermediate routers along the way
Unlike the DLL which has the more modest goal of just moving frames from one end of a wire to
the other.
➢ Network Layer is the lowest layer that deals with end-to-end transmission.
➢ To achieve its goals, the network layer must know about the topology of the network (i.e., the set
of all routers and links) and choose appropriate paths through it, even for large networks.
➢ It must also take care when choosing routes to avoid overloading some of the communication lines
and routers while leaving others idle.

9/25/2022 MRS. RAKHI KALANTRI 5


Network Layer Design Issues
➢ Store-and-Forward Packet Switching

➢ Services Provided to the Transport Layer

➢ Implementation of Connectionless Service

➢ Implementation of Connection-Oriented Service

➢ Comparison of Virtual-Circuit and Datagram Networks

9/25/2022 MRS. RAKHI KALANTRI 6


Store-and-Forward Switching
➢ The node which has a packet to send, delivers it to the nearest router.

➢ The packet is stored in the router until it has fully arrived and its checksum is verified for error
detection.

➢ Once, this is done, the packet is forwarded to the next router.

➢ Since, each router needs to store the entire packet before it can forward it to the next hop, the
mechanism is called store − and − forward switching.

Home PC
Plugged into
a DSL
modem Office Ethernet

9/25/2022 MRS. RAKHI KALANTRI 7


Services Provided to the Transport Layer
➢ What kind of services the network layer provides to the transport layer.

❖ The services need to be carefully designed with the following goals in mind:
➢ The services should be independent of the router technology.
➢ The transport layer should be shielded from the number, type, andtopology of the routers present.
➢ The network addresses made available to the transport layer should use a uniform numbering plan,
even across LANs and WANs.

➢ Given these goals, the designers of the network layer have a lot of freedom in writing detailed
specifications of the services to be offered to the transport layer.

❖ There are some arguments:


➢ Internet community argue that the routers job is moving packets around and nothing else
(Connectionless).
➢ The telephone companies argues that the network should provide a reliable, connection-oriented
service

9/25/2022 MRS. RAKHI KALANTRI 8


Services Provided to the Transport Layer
➢ The Connectionless network is inherently unreliable, no matter how it is designed. Therefore, the hosts
should do error control (i.e., error detection and correction) and flow control themselves.

➢ The network service should be connectionless, with primitives SEND PACKET and RECEIVE
PACKET.

➢ In particular, no packet ordering and flow control should be done, because the hosts are going to do
that.

➢ This reasoning is an example of the end-to-end argument.

➢ Furthermore, each packet must carry the full destination address, because each packet sent is carried
independently of its predecessors, if any.

➢ In the network that provide a reliable, connection-oriented service, quality of service is the dominant
factor, and without connections in the network, quality of service is very difficult to achieve, especially
for real- time traffic such as voice and video.

9/25/2022 MRS. RAKHI KALANTRI 9


Implementation of Connectionless Service
➢ If connectionless service is offered, packets are injected into the network individually and routed
independently.

➢ No advance setup is needed. In this context, the packets are frequently called datagrams (in
analogy with telegrams) and the network is called a datagram network.

➢ Suppose that the process P1 has a long message for P2. It hands the message to the transport layer,
with instructions to deliver it to process P2 on host H2.

➢ The transport layer code runs on H1, typically within the operating system. It prepends a
transport header to the front of the message and hands the result to the network layer.

9/25/2022 MRS. RAKHI KALANTRI 10


Implementation of Connectionless Service
➢ IP (Internet Protocol) is the dominant example of a connectionless network service. Each packet
carries a destination IP address that routers use to individually forward each packet.The addresses are
32 bits in IPv4 packets and 128 bits in IPv6 packets

9/25/2022 MRS. RAKHI KALANTRI 11


Implementation of Connection-oriented Service
➢ If connection-oriented service is used, a path from the source router all the way to the destination
router must be established before any data packets can be sent.

➢ This connection is called a VC (virtual circuit), in analogy with the physical circuits set up by the
telephone system, and the network is called a virtual- circuit network. Some times it is called label
switching.

➢ Working of VCN: The virtual circuits avoid to choose a new route for every packet sent. Instead,
when a connection is established, a route from the source to the destination machine is chosen as
part of the connection setup and stored in tables inside the routers.
➢ That route is used for all traffic flowing over the connection, exactly the same way that the telephone
system works.
➢ When the connection is released, the virtual circuit is also terminated.
➢ With connection-oriented service, each packet carries an identifier telling which virtual circuit it
belongs to.

9/25/2022 MRS. RAKHI KALANTRI 12


Implementation of Connection-oriented Service
➢ Host H1 has established connection 1 with host H2.This connection is remembered as the first
entry in each of the routing tables.The first line of A’s table says that if a packet bearing connection
identifier 1 comes in from H1, it is to be sent to router C and given connection identifier 1.

9/25/2022 MRS. RAKHI KALANTRI 13


Comparison of datagram and virtual-circuit networks
Issue Datagram network Virtual-circuit network
Circuit setup Not needed Required
Addressing Each packet contains the full Each packet contains a shortVC
source and destination address number
State Routers do not hold state EachVC requires router table
information information about connections space per connection
Routing Each packet is routed Route chosen whenVC is set up;
independently all packets follow it
Effect of None, except for packets lost AllVCs that passed through the
router failures during the crash failed router are terminated
Quality of Difficult Easy if enough resources can be
service allocated in advance for eachVC
Congestion Difficult Easy if enough resources can be
control allocated in advance for eachVC

9/25/2022 MRS. RAKHI KALANTRI 14


Communication Primitives
❖ Unicast: In this case information is transferred between one sender and one receiver.

❖ Broadcast: In this case one sender, can transfer the information to all connected receivers.

❖ Multicast: There may be one or more senders, and the information is distributed to a set of receivers.

9/25/2022 MRS. RAKHI KALANTRI 15


IPv4 Addressing
➢ An IPv4 address is a 32-bit address that uniquely and universally defines the connection of a device to
the Internet.

➢ IPv4 addresses are unique. i.e., each address defines one, and only one, connection to the Internet.

➢ Two devices on the Internet can never have the same address at the same time.

➢ Logical Address: Using some strategies, an address may be assigned to a device for a time period
and then taken away and assigned to another device.

❖ There are two types of addressing: Classful and Classless

9/25/2022 MRS. RAKHI KALANTRI 16


Address Space
➢ A protocol such as IPv4 that defines addresses has an address space.

➢ An address space is the total number of addresses used by the protocol.

➢ If a protocol uses N bits to define an address, the address space is 2 N because each bit can have two
different values (0 or 1) and N bits can have 2 N values.

➢ IPv4 uses 32-bit addresses, which means that the address space is 232 or 4,294,967,296 (more than 4
billion).

➢ This means that, theoretically, if there were no restrictions, more than 4 billion devices could be
connected to the Internet.

9/25/2022 MRS. RAKHI KALANTRI 17


Notations
➢ There are two prevalent notations to show an IPv4 address: binary notation and dotted decimal notation.
❖ Binary Notation
➢ In binary notation the IP,v4 address is displayed as 32 bits. Each octet is often referred to as a byte. So it
is 4-byte address. The following is an example of an IPv4 address in binary notation:
01110101 10010101 00011101 00000010
❖ Dotted-Decimal Notation
➢ To make the IPv4 address more compact and easier to read, Internet addresses are usually written in
decimal form with a decimal point (dot) separating the bytes.
❖ The following is the dotted-decimal notation of the above address:
117.149.29.2

9/25/2022 MRS. RAKHI KALANTRI 18


Example
➢ Change the following IP addresses from binary notation to dotted-decimal notation.
a. 10000001 00001011 00001011 11101111
b. 11111001 10011011 11111011 00001111

➢ We replace each group of 8 bits with its equivalent decimal number and add dots for
separation:
a. 129.11.11.239
b. 249.155.251.15

9/25/2022 MRS. RAKHI KALANTRI 19


Classful Addressing
➢ In classful addressing, the address space is divided into five classes: A, B, C, D, E.
➢ A new architecture, called classless addressing was introduced in the mid-1990s.

9/25/2022 MRS. RAKHI KALANTRI 20


Classful Addressing

➢ How to identify which class the IP address belongs to

⦁ 128 64 32 16 16

9/25/2022 MRS. RAKHI KALANTRI 21


Examples
❖ Find the class of each address.

a. 00000001 00001011 00001011 11101111

b. 11000001 10000011 00011011 11111111

c. 14.23.120.8

d. 252.5.15.111

❖ Solution

a. The first bit is 0.This is a class A address.

b. The first 2 bits are 1; the third bit is 0.This is a class C address.

c. The first byte is 14; the class is A.

d. The first byte is 252; the class is E.

9/25/2022 MRS. RAKHI KALANTRI 22


Netid and Hostid
➢ IP address in classes A, B, and C is divided into netid and hostid

➢ Only classes A, B, and C addresses are subdivided.


❖ Exercise: How many different “Netid”s and “Host”s in each of the classes A, B, C?

Netid’s Hostid’s
• 2^(8-1) = 128 • 2^24 = 16,777,216
• 2^(16-2) = 16,384 • 2^16 = 65,536
• 2^(24-3) = 2,097,152 • 2^8 = 256

9/25/2022 MRS. RAKHI KALANTRI 23


Classes and Blocks
➢ One problem with classful addressing is that each class is divided into a fixed number of blocks
with each block having a fixed size.

2 24 =
27 =
2 14 = 2 16 =
28 =
2 21 =

2 32 =
2 32 =

➢ In classful addressing, a large part of the available addresses were wasted.

9/25/2022 MRS. RAKHI KALANTRI 24


Netid and Hostid
➢ In classful addressing, an IP address in class A, B, or C is divided into netid and hostid.
➢ These parts are of varying lengths, depending on the class of the address. The netid is in pink
color, the hostid is in black.

➢ Note that the concept does not apply to classes D and E.


➢ In class A, one byte defines the netid and three bytes define the hostid. In class B, two bytes
define the netid and two bytes define the hostid. In class C, three bytes define the netid and
one byte defines the hostid.

9/25/2022 MRS. RAKHI KALANTRI 25


Mask
➢ The mask can help us to find the netid and the hostid.
➢ A mask is a 32-bit number in which the n leftmost bits are 1s and the 32 - n rightmost bits are
0s.
➢ For example, the mask for a class A address has eight 1s, which means the first 8 bits of any
address in class A define the netid; the next 24 bits define the hostid.
➢ In classful addressing the length of the netid and hostid (in bits) is predetermined and is called
the default mask. The default masks for classes A, B, and C are shown Slash notation or
Classless Interdomain Routing (CIDR) notation.

9/25/2022 MRS. RAKHI KALANTRI 26


Mask
➢ Lining up the IP address and the subnet mask together, the network, and host portions of the
address can be separated:
11000000.10101000.01111011.10000100 - IP address (192.168.123.132)
11111111.11111111.11111111.00000000 - Subnet mask (255.255.255.0)
➢ The first 24 bits are identified as the network address.The last 8 bits are identified as the
host address.
11000000.10101000.01111011.00000000 - Network address (192.168.123.0)
00000000.00000000.00000000.10000100 - Host address (000.000.000.132)
➢ In this example using a 255.255.255.0 subnet mask, the network ID is 192.168.123.0,
and the host address is 0.0.0.132.
➢ When a packet arrives on the 192.168.123.0 subnet (from the local subnet or a remote network),
and it has a destination address of 192.168.123.132, your computer will receive it from the
network and process it.

9/25/2022 MRS. RAKHI KALANTRI 27


Subnetting
➢ Subnetting is the practice of dividing a network into two or smaller networks.

➢ It increases routing efficiency, which helps to enhance the security of the network and
reduces the size of the broadcast domain.

➢ It also helps to reduce the size of the routing tables, which is stored in routers.This
method also helps to extend the existing IP address base & restructures the IP address.

➢ If an organization was granted a large block in class A or B, it could divide the addresses into
several contiguous groups and assign each group to smaller networks (called subnets).

➢ Subnetting increases the number of 1s in the mask.

➢ IP Subnetting designates high-order bits from the host as part of the network prefix.This
method divides a network into smaller subnets.

9/25/2022 MRS. RAKHI KALANTRI 28


Class A Subnets
➢ In Class A, only the first octet is used as Network identifier and rest of three octets are used to
be assigned to Hosts (i.e.224 = 16777214 Hosts per Network).
➢ To make more subnet in Class A, bits from Host part are borrowed and the subnet mask is changed
accordingly.
➢ For example, if one MSB is borrowed from host bits of second octet and added to Network
address, it creates two Subnets (21=2) with (223-2) 8388606 Hosts per Subnet.

11111111 00000000 00000000 00000000 11111111 10000000 00000000 00000000

➢ In network, the very first and last IP address is used for Network Number and network
Broadcast IP address respectively.
➢ In subnetting also, the very first and last IP address of every subnet is used for Subnet Number
and Subnet Broadcast IP address respectively.

9/25/2022 MRS. RAKHI KALANTRI 29


Supernetting
➢ The size of a class C block with a maximum number of 256 addresses did not satisfy the
needs of most organizations.
➢ They might be needed more addresses. One solution was supernetting.
➢ In supernetting, an organization can combine several class C blocks to create a larger range of
addresses.
➢ Several networks are combined to create a supernetwork or a supernet.
➢ An organization can apply for more blocks of class C instead of just one block.
➢ For example, an organization that needs 1000 addresses can be granted four contiguous class C
blocks.
➢ The organization can then use these addresses to create one supernet.
➢ Supernetting decreases the number of 1s in the mask.

1215111111 11111111 11111111 00000000 11111111 11111111 11111110 00000000

9/25/2022 MRS. RAKHI KALANTRI 30


Address Depletion
➢ The flaws in classful addressing scheme combined with the fast growth of the Internet led to
the near depletion/exhaustion of the available addresses.

➢ Yet the number of devices on the Internet is much less than the 232 address space.
➢ We have run out of class A and B addresses, and a class C block is too small for most midsize
organizations.
➢ One solution that has alleviated the problem is the idea of classless addressing.

Classful addressing, which is almost obsolete (outdated),


is replaced with classless addressing.

9/25/2022 MRS. RAKHI KALANTRI 31


Classless Addressing
➢ To overcome address depletion and give more organizations access to the Internet, classless
addressing was designed and implemented.

➢ There are no classes here, but the addresses are still granted in blocks.

❖ Address Blocks

➢ When an entity (network), small or large, needs to be connected to the Internet, it is granted a
block (range) of addresses.

➢ The size of the block (the number of addresses) varies based on the nature and size of the entity.
For example,
➢ Households may be given only two addresses;
➢ Large organizations may be given thousands of addresses.
➢ The ISP, may be given hundreds or thousands of addresses based on the number of customers it
may serve.
9/25/2022 MRS. RAKHI KALANTRI 32
Classless Addressing: Restrictions
➢ To simplify the handling of addresses, the Internet authorities impose three restrictions
on classless address blocks:
1. The addresses in a block must be contiguous, one after another.
2. The number of addresses in a block must be a power of 2 (1, 2, 4, 8, ... ).
3. The first address must be evenly divisible by the number of addresses.

9/25/2022 MRS. RAKHI KALANTRI 33


Classless Addressing: Restrictions

11001101 00010000 00100101 00100000

231 + 230 + 227 + 226 + 224 + 220 + 213 + 210 + 28 + 25

= 3,440,387,360

9/25/2022 MRS. RAKHI KALANTRI 34


Mask
➢ A better way to define a block of addresses is to select any address in the block and the
mask.
➢ A mask is a 32-bit number in which the n leftmost bits are 1s and the 32 - n rightmost bits
are 0s.
➢ In classless addressing the mask for a block can take any value from 0 to 32.
➢ It is very convenient to give just the value of n preceded by a slash (CIDR: Classless
Interdomain Routing notation).

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


x.y.z.t / n
in which x.y.z.t defines one of the addresses and the /n defines the mask.

➢ Example: 205.16.37.39/28

9/25/2022 MRS. RAKHI KALANTRI 35


Mask
➢ The address and the /n notation completely define the whole block (the first address, the last
address, and the number of addresses).
❖ First Address: The first address in the block can be found by setting the (32 - n) rightmost bits in
the binary notation of the address to 0s.
❖ Example: A block of addresses is granted to a small organization with IP address:205.16.37.39/28.
What is the first address in the block?
❖ Solution: The binary representation of the given address is
11001101 00010000 00100101 00100111 or 205.16.37.39
If we set (32 - 28) = 4 rightmost bits to 0, we get
11001101 00010000 00100101 00100000 or 205.16.37.32
This is the first address of the block.

9/25/2022 MRS. RAKHI KALANTRI 36


Mask
❖ Last Address: The last address in the block can be found by setting the (32- n) rightmost bits
in the binary notation of the address to 1s.
❖ Example: Same example; IP address: 205.16.37.39/28. What is the last address in the
block?
❖ Solution: 11001101 00010000 00100101 00100111 or 205.16.37.39

If we set (32 - 28) = 4 rightmost bits to 1, we get the last address of the block
11001101 00010000 00100101 00011111 or 205.16.37.47

❖ Number of Addresses: The number of addresses in the block is the difference between the
last and first address. It can easily be found using the formula 232 - n. For the above example it is
232-28 = 24 = 16

➢ There are 16 addresses in the block (from 205.16.37.32 to 205.16.37.47)

9/25/2022 MRS. RAKHI KALANTRI 37


Another way to find first, last and number of
addresses in the block
➢ By representing the mask as a 32-bit binary number.
The number of addresses can be found by complementing the mask ,
interpreting it as a decimal number , and adding 1 to it
Mask complement: 000000000 00000000 00000000 00001111
Number of addresses :15 +1=16
➢ The first address can be found by ANDing the given addresses with the mask

205.16.37.32
➢ The last address can be found by ORing the given addresses with the complement
of the mask.

205.16.37.47
9/25/2022 MRS. RAKHI KALANTRI 38
Network Addresses
➢ When an organization is given a block of addresses, the organization is free to allocate the
addresses to the devices that need to be connected to the Internet.

➢ The first address in a block is normally not assigned to any device; it is used as the network
address that represents the organization to the rest of the world.

➢ Mostly it is used by routers to direct the message sent to the organization from the outside
world.The organization network is connected to the Internet via a router.

9/25/2022 MRS. RAKHI KALANTRI 39


Hierarchy
➢ Like our telephone network, IP addresses also have levels of Hierarchy.

➢ The total length of all phone numbers is constant at 10 digits.

➢ 022-27771000 (area code, operator code, exchange office code and phone number)

➢ An IP address can define only two levels of hierarchy when not subnetted.

❖ Each address in the block can be considered as a two-level hierarchical structure:

• The leftmost n bits (prefix) define the network;

• The rightmost 32 - n bits (suffix) define the host.

➢ The prefix is common to all addresses in the network; the suffix changes from one device to
another.

9/25/2022 MRS. RAKHI KALANTRI 40


Two-Level Hierarchy: No Subnetting
➢ An IP address defines only two levels of hierarchy when not subnetted.
➢ Each address in the block can be considered as a two-level hierarchical structure:
the leftmost n bits (prefix) define the network; the rightmost 32 − n bits define the
host.

9/25/2022 MRS. RAKHI KALANTRI 41


Three-Levels of Hierarchy: Subnetting
➢ An organization that is granted a large block of addresses may want to create clusters of
networks (called subnets) and divide the addresses between the different subnets.

➢ The rest of the world still sees the organization as one entity; however, internally there are
several subnets.

➢ All messages are sent to the router address that connects the organization to the rest of the
Internet; the router routes the message to the appropriate subnets.

➢ The organization needs to create small subblocks of addresses, each assigned to


specific subnets.

➢ The organization has its own mask; each subnet must also have its own.

9/25/2022 MRS. RAKHI KALANTRI 42


Three-Levels of Hierarchy: Subnetting

9/25/2022 MRS. RAKHI KALANTRI 43


Three-Levels Subnetting Example
➢ Suppose an organization is given the block 17.12.40.0/26,which contains 64 addresses.The organization
has three offices and needs to divide the addresses into three subblocks of 32, 16, and 16 addresses.

❖ We can find the new masks by using the following rules:

1. Suppose the mask for the first subnet is n1,then 232- n1 must be 32,which means that n1 =27.

2. Suppose the mask for the second subnet is n2,then 232- n2 must be 16,which means that n2 = 28.

3. Suppose the mask for the third subnet is n3,then 232- n3 must be 16,which means that n3 =28.

➢ This means that we have the masks 27,28,28 with the organization mask being 26.

➢ Figure shows one configuration for the above scenario.

9/25/2022 MRS. RAKHI KALANTRI 44


Three-Levels of Hierarchy: Subnetting
➢ Configuration and addresses in a subnetted network

9/25/2022 MRS. RAKHI KALANTRI 45


➢ Let us check to see if we can find the subnet addresses from one of the addresses in the subnet.

➢ In subnet 1, the address 17.12.14.29/27 can give us the subnet address if we use the mask /27 because
➢ Host: 00010001 00001100 00001110 00011101
➢ Mask: 11111111 11111111 11111111 11100000 (/27)
➢ Subnet: 00010001 00001100 00001110 00000000 ....(17.12.14.0)

➢ In subnet 2, the address 17.12.14.45/28 can give us the subnet address if we use the mask /28 because
➢ Host:00010001 00001100 00001110 00101101
➢ Mask: 11111111 11111111 11111111 11110000 /28
➢ Subnet:00010001 00001100 00001110 00100000 ....(17.12.14.32)

➢ In subnet 3, the address 17.12.14.50/28 can give us the subnet address if we use the mask /28 because
➢ Host: 00010001 00001100 00001110 00110010
➢ Mask: 11111111 11111111 11111111 11110000 /28
➢ Subnet:00010001 00001100 00001110 00110000 ....(17.12.14.48)

9/25/2022 MRS. RAKHI KALANTRI 46


➢ Note that applying the mask of the network,/26,to any of the addresses gives us the network
address 17.12.14.0/26. (address:17.12.14.45)

• Host: 00010001 00001100 00001110 00101101


• Mask: 11111111 11111111 11111111 11000000 (/26)
• Net: 00010001 00001100 00001110 00000000 .... (17.12.14.0)

➢ We can say that through subnetting ,we have three levels of hierarchy.

➢ Note that in our example,the subnet prefix length can differ for the subnets as shown in Figure.

9/25/2022 MRS. RAKHI KALANTRI 47


❖ Given the class C network 192.168.10.0/25 and answer the following:
1) Number of subnets ?
2) Number of hosts per subnet ?
3) Block size of each subnet ?
4) Calculate the IP address of the first host, the last host and the broadcast address of each subnet.

Solution : Subnetting Class C - 192.168.10.0/25

1) Number of subnets (for /25 mask) = 2 N


N = 1, 226-25 = 2 1 = 2
So number of subnets (for /25 mask) = 2

2) Number of hosts per subnet = (2 H) - 2


H is 7, 232 – 25 -2 so 2 7 - 2
Hosts per subnet = 128 - 2 = 126.

3) Block size of each subnet = 256 - 128 = 128

9/25/2022 MRS. RAKHI KALANTRI 48


• For /25 mask, we will get 2 subnets, each with 126 hosts.

1st Subnet = 192.168.10.0/25


2nd Subnet = 192.168.10.128/25

• For 1st Subnet, 1st valid IP is 192.168.10.1/25, last valid IP is 192.168.10.126/25, and broadcast
address is 192.168.10.127/25

• For 2nd Subnet, 1st valid IP is 192.168.10.129/25, last valid IP is 192.168.10.254/25, and
broadcast address is 192.168.10.255/25
4) IP address of the first host, the last host and the broadcast address of each subnet are as follows:

Subnet First host Last host Broadcast address


1st Subnet 192.168.10.1 192.168.10.126 192.168.10.127
2nd Subnet 192.168.10.129 192.168.10.254 192.168.10.255

9/25/2022 MRS. RAKHI KALANTRI 49


❖ Given the class C network 192.168.10.0. Use the subnet mask 255.255.255.192 to create subnets and
answer the following:
1) Number of subnets ?
2) Number of hosts per subnet ?
3) Block size of each subnet ?
4) Calculate the IP address of the first host, the last host and the broadcast address of
each subnet.
Solution : Given the Class C network 192.168.10.0
Default Subnet mask for Class C network is /24
Given Subnet mask 255.255.255.192 is /

1) The number of subnets created are 226-24 = 22 = 4 subnets


2) Number of hosts per subnet are 232 – 26 -2 = 26 = 62 hosts
3) Block size of each subnet = 256 - 192 = 64

9/25/2022 MRS. RAKHI KALANTRI 50


❖ For /26 mask, we will get 4 subnets, each with 62 hosts, each subnet has block size of 64.
• 1st Subnet = 192.168.10.0/26
• 2nd Subnet=192.168.10.64/26
• 3rd Subnet = 192.168.10.128/26
• 4th Subnet=192.168.10.192/26

4) IP address of the first host, the last host and the broadcast address of each subnet are as follows:

Subnet First host Last host Broadcast address


1st Subnet 192.168.10.1 192.168.10.62 192.168.10.63
2nd Subnet 192.168.10.65 192.168.10.126 192.168.10.127
3rd Subnet 192.168.10.129 192.168.10.190 192.168.10.191
4th Subnet 192.168.10.193 192.168.10.254 192.168.10.255

9/25/2022 MRS. RAKHI KALANTRI 51


Example 1
➢ An organization is granted the block 211.17.180.0/24.The administrator wants to create 32
subnets.
a. Find the subnet mask.
b. Find the number of addresses in each subnet.
c. Find the first and last addresses in subnet 1.
d. Find the first and last addresses in subnet 32.

9/25/2022 MRS. RAKHI KALANTRI 52


211.17.180.0/24
a. Possible subnets:32;
Log 2 32 = 5 or 25 = 32; Extra 1s = 5; Mask: /29 (24 + 5)

b. 232−29 = 23 = 8 Addresses per subnet.

c. Subnet 1: The first address is the beginning address of the block or 211.17.180.0. To find the last address,we
need to write 7 (one less than the number of addresses in each subnet) in base 256 (0.0.0.7) and add it to the first
address (in base 256).
a. First address in subnet 1:211 .17 .180 .0
b. Number of addresses:0 .0 .0 .7
c. Last address in subnet 1:211 .17 .180 .7

d. Subnet 32:To find the first address in subnet 32,we need to add 248 (31 × 8) in base 256 (0.0.0.248) to the
first address in subnet 1.We have 211.17.180.0 +0.0.0.248 or 211.17.180.248. Now we can calculate the last
address in subnet 32 as we did for the first address.
a. First address in subnet 32:211 .17 .180 .248
b. Number of addresses:0 .0 .0 .7
c. Last address in subnet 32:211 .17 .180 .255
9/25/2022 MRS. RAKHI KALANTRI 53
More Levels of Hierarchy
➢ The structure of classless addressing does not restrict the number of hierarchical levels.

➢ An organization can divide the granted block of addresses into subblocks. Each subblock can in turn
be divided into smaller subblocks and so on.

➢ One example of this is the ISPs structure.

➢ A national ISP can divide a granted large block into smaller blocks and assign each of them to a
regional ISP.

➢ A regional ISP can divide the block received from the national ISP into smaller blocks and
assign each one to a local ISP.

➢ A local ISP can divide the block received from the regional ISP into smaller blocks and assign each
one to a different organization.

➢ Finally, an organization can divide the received block and make several subnets out of it.

9/25/2022 MRS. RAKHI KALANTRI 54


Address Allocation
➢ How are the blocks allocated?

➢ The ultimate responsibility of address allocation is given to a global authority called the Internet
Corporation for Assigned Names and Addresses (ICANN).

➢ However, ICANN does not normally allocate addresses to individual organizations.

➢ It assigns a large block of addresses to an ISP.

➢ Each ISP, in turn, divides its assigned block into smaller subblocks and grants the subblocks to its
customers.

➢ In other words, an ISP receives one large block to be distributed to its Internet users.This is called address
aggregation: many blocks of addresses are aggregated in one block and granted to one ISP.

9/25/2022 MRS. RAKHI KALANTRI 55


Example 1
➢ An ISP is granted a block of addresses starting with 190.100.0.0/16 (65,536 addresses).The ISP needs to
distribute these addresses to three groups of customers as follows:
a. The first group has 64 customers; each needs 256 addresses.
b. The second group has 128 customers; each needs 128 addresses.
c. The third group has 128 customers; each needs 64 addresses.

➢ Design the subblocks and find out how many addresses are still available after these allocations.

9/25/2022 MRS. RAKHI KALANTRI 56


❖ Group 1
➢ For this group, each customer needs 256 addresses. This means that 8 (log2 256) bits are needed to
define each host.The prefix length is then 32 −8 = 24.The addresses are

• 1st Customer: 190.100.0.0/24 190.100.1.255/24


• 2nd Customer: 190.100.1.0/24 190.100.1.255/24

⦁ 64th Customer: 190.100.63.0/24 190.100.63.255/24

⦁ Total = 64 X 256 =16,384

9/25/2022 MRS. RAKHI KALANTRI 57


❖ Group 2
➢ For this group, each customer needs 128 addresses. This means that 7 (log2 128) bits are needed to
define each host.The prefix length is then 32 −7 = 25.The addresses are

❖ Group 3
⦁ For this group, each customer needs 64 addresses.This means that 6 (log2 64) bits are needed to each
host.The prefix length is then 32 − 6 = 26.The addresses are

⦁ Number of granted addresses to the ISP: 65,536


⦁ Number of allocated addresses by the ISP: 40,960
⦁ Number of available addresses: 24,576
9/25/2022 MRS. RAKHI KALANTRI 58
An example of address allocation and distribution by an ISP

9/25/2022 MRS. RAKHI KALANTRI 59


Network Address Translation (NAT)
➢ To access the Internet, one public IP address is needed, but we can use a private IP address in our private
network.

➢ The idea of NAT is to allow multiple devices to access the Internet through a single public address.

➢ To achieve this,the translation of a private IP address to a public IP address is required.

➢ Network Address Translation (NAT) is a process in which one or more local IP address is translated
into one or more Global IP address and vice versa in order to provide Internet access to the local hosts.

➢ Also, it does the translation of port numbers i.e. masks the port number of the host with another port
number, in the packet that will be routed to the destination.

➢ It then makes the corresponding entries of IP address and port number in the NAT table. NAT generally
operates on a router or firewall.

9/25/2022 MRS. RAKHI KALANTRI 60


Private IP Addresses

➢ Every class of IP,(A, B & C) has some addresses reserved as Private IP addresses.
➢ These IPs can be used within a network,campus,company and are private to it.
➢ These addresses cannot be routed on the Internet,so packets containing these private addresses are dropped
by the Routers.

= 224

= 220

= 216

➢ In order to communicate with the outside world, these IP addresses must have to be translated to some
public IP addresses using NAT (Network address translation) process, or Web Proxy server can be used.

9/25/2022 MRS. RAKHI KALANTRI 61


NAT
➢ Any organization can use an address out of this set without permission from the Internet authorities.
➢ Everyone knows that these reserved addresses are for private networks.
➢ They are unique inside the organization,but they are not unique globally.
➢ No router will forward a packet that has one of these addresses as the destination address.
➢ The site must have only one single connection to the global Internet through a router that runs the NAT
software.
➢ Figure shows a simple implementation of N AT.

9/25/2022 MRS. RAKHI KALANTRI 62


Address Translation
➢ All the outgoing packets go through the NAT router, which replaces the source address in the packet
with the global NAT address.

➢ All incoming packets also pass through the NAT router, which replaces the destination address in the
packet (the NAT router global address) with the appropriate private address.

➢ Figure shows an example of address translation.

9/25/2022 MRS. RAKHI KALANTRI 63


Translation Table
➢ Translating the source addresses for outgoing packets is straightforward.

➢ But how does the NAT router know the destination address for a packet coming from the Internet?

➢ There may be tens or hundreds of private IP addresses,each belonging to one specific host.

➢ The problem is solved if the NAT router has a translation table.


➢ Using One IPAddress
➢ Using a Pool of IPAddresses
➢ Using Both IPAddresses and Port Numbers

9/25/2022 MRS. RAKHI KALANTRI 64


9/25/2022 MRS. RAKHI KALANTRI 65
IPv4 Protocol: Packet Structure
➢ Internet Protocol being a layer-3 protocol (OSI) takes data Segments from layer-4 (Transport) and
divides it into packets.

➢ IP packet encapsulates data unit received from above layer and add to its own header information.

➢ The encapsulated data is referred to as IP Payload.

➢ IP header contains all the necessary information to deliver the packet at the other end.

9/25/2022 MRS. RAKHI KALANTRI 66


IPv4 Protocol: Header

9/25/2022 MRS. RAKHI KALANTRI 67


IPv4 Protocol: Header
➢ Version: It is a 4 bit field that indicates the IP version used. It is 4.

➢ Header length: It is a 4 bit field that contains the length of the IP header. It helps in knowing from where
the actual data begins. [20 bytes, 60 bytes].The value lies in the range [5, 15]

➢ Type of service: is a 8 bit field that is used for Quality of Service (QoS). It provides 3 bits to signal
priority and 3 bits to signal whether a host cared more about delay, throughput, or reliability. 2 bits are
used to carry explicit congestion notification information.

➢ Total length: It is a 16 bit field that contains the total length of the datagram (in bytes).Total length = Header
length + Payload length. Maximum total length of datagram = Maximum value of 16 bit word = 65535
bytes.

➢ Identification field: It is needed to allow the destination host to determine which packet a newly arrived
fragment belongs to.All the fragments of a packet contain the same Identification value.

9/25/2022 MRS. RAKHI KALANTRI 68


IPv4 Protocol: Header
➢ Flags : As required by the network resources, if IP Packet is too large to handle, these ‘flags’tells if they
can be fragmented or not. In this 3-bit flag, the MSB is always set to ‘0’.

➢ Fragment Offset : This offset tells the exact position of the fragment in the original IP Packet.

➢ Time to Live : To avoid looping in the network, every packet is sent with some TTL value set, which tells
the network how many routers (hops) this packet can cross. At each hop, its value is decremented by one
and when the value reaches zero, the packet is discarded.

➢ Protocol : Tells the Network layer at the destination host, to which Protocol this packet belongs to, i.e.
the next level Protocol. For example protocol number of ICMP is 1,TCP is 6 and UDP is 17.

9/25/2022 MRS. RAKHI KALANTRI 69


IPv4 Protocol: Header

➢ Header Checksum : This field is used to keep checksum value of entire header which is then used
to check if the packet is received error-free.

➢ SourceAddress : 32-bit address of the Sender (or source) of the packet.

➢ DestinationAddress : 32-bit address of the Receiver (or destination) of the packet.

➢ Options : This is optional field, which is used if the value of IHL is greater than 5.These options may
contain values for options such as Security, Record Route,Time Stamp, etc.

9/25/2022 MRS. RAKHI KALANTRI 70


IPv6
➢ Despite all short-term solutions, address depletion is still a long-term problem for the Internet.This
and other problems in the IP protocol itself have been the motivation for IPv6.
➢ An IPv6 address is 128 bits long.

9/25/2022 MRS. RAKHI KALANTRI 71


IPv6 address in binary and hexadecimal colon notation

⦁ Abbreviated IPv6 addresses

9/25/2022 MRS. RAKHI KALANTRI 72


Example

⦁ Expand the address 0:15::1:12:1213 to its original.

0:15:0:0:0:1:12:1213

9/25/2022 MRS. RAKHI KALANTRI 73


Features of IPv6
➢ Larger address space: 128 bits and 32 bits in IPv4.

➢ Multicasting: is part of the base specification in IPv6. In IPv4 this is an optional.

➢ Stateless address autoconfiguration (SLAAC): IPv6 hosts configure themselves automatically.


Every interface has a self-generated link-local address and, when connected to a network, conflict
resolution is performed and routers provide network prefixes via router advertisements.

➢ Ipsec: a mandatory part of all IPv6 protocol implementations.

➢ Extension headers: The IPv6 packet header has a minimum size of 40 octets (320 bits).

9/25/2022 MRS. RAKHI KALANTRI 74


Features of IPv6
➢ No more N AT (NetworkAddressTranslation)

➢ Auto-configuration

➢ No more private address collisions

➢ Better multicast routing

➢ Simpler header format

➢ Simplified,more efficient routing

➢ True quality of service (QoS), also called "flow labeling"

➢ Built-in authentication and privacy support

➢ Flexible options and extensions

9/25/2022 MRS. RAKHI KALANTRI 75


Comparison of IPv4 and IPv6
Ipv4 Ipv6
Address length IPv4 is a 32-bit address. IPv6 is a 128-bit address.
Fields IPv4 is a numeric address that consists of 4 fields IPv6 is an alphanumeric address that consists of 8
which are separated by dot (.). fields, which are separated by colon.
Classes IPv4 has 5 different classes of IP address that IPv6 does not contain classes of IP addresses.
includes Class A, Class B, Class C,
Class D, and Class E.
Number of IP IPv4 has a limited number of IP IPv6 has a large number of IP addresses.
address addresses.
VLSM It supports VLSM (Virtual Length Subnet Mask). It does not support VLSM.
Here,VLSM means that Ipv4 converts IP addresses
into a subnet of different sizes.
Address It supports manual and DHCP It supports manual, DHCP, auto- configuration, and
configuration configuration. renumbering.
Address space It generates 4 billion unique addresses It generates 340 undecillion unique addresses. (3.4
x 1038 )
End-to-end In IPv4, end-to-end connection integrity is In the case of IPv6, end-to-end connection integrity
connection unachievable. is achievable.
integrity
Security In IPv4, security depends on the application. This In IPv6, IPSEC is developed for security
features IP address is not developed in keeping the security purposes.
feature in mind.

9/25/2022 MRS. RAKHI KALANTRI 76


Comparison of IPv4 and IPv6
IPV4 IPV6
Address In IPv4, the IP address is represented in decimal. In IPv6, the representation of the IP address in
representation hexadecimal.
Fragmentation Fragmentation is done by the senders and the Fragmentation is done by the senders only.
forwarding
routers.
Packet flow It does not provide any mechanism for packet It uses flow label field in the header for the
identification flow identification. packet flow identification.
Checksum field The checksum field is available in IPv4. The checksum field is not available in IPv6.

Transmission IPv4 is broadcasting. On the other hand, IPv6 is multicasting, which


scheme provides efficient network operations.
Encryption and It does not provide encryption and It provides encryption and authentication.
Authentication authentication.
Number of It consists of 4 octets. It consists of 8 fields, and each field contains 2
octets octets.Therefore, the total number of octets in
IPv6 is 16.

9/25/2022 MRS. RAKHI KALANTRI 77


Popular (Unicast) Routing Protocols

9/25/2022 MRS. RAKHI KALANTRI 78


Routing algorithms
➢ A routing algorithm is a procedure that lays down the route or path to transfer data packets from
source to the destination.

➢ They help in directing Internet traffic efficiently.

➢ After a data packet leaves its source, it can choose among the many different paths to each its
destination.

➢ Routing algorithm mathematically computes the best path, i.e. “least – cost path” that the packet can
be routed through.

9/25/2022 MRS. RAKHI KALANTRI 79


Types of Routing algorithms
❖ Static or Non-adaptive Routing:
➢ Construct a static routing table to determine the path through which packets are to be sent.The static routing
table is constructed based upon the routing information stored in the routers when the network is booted up.
➢ Shortest path routing (Dijkstra’s Algorithm)
➢ Simple and easy to understand.
➢ Metric for a shortest path: distance, bandwidth, average traffic, communication cost, mean queue length,
measured delay,….
❖ Dynamic or Adaptive Routing:
➢ Makes routing decisions dynamically depending on the network conditions. It constructs the routing table
depending upon the network traffic and topology. They try to compute the optimized route depending upon the
hop count, transit time and distance.
➢ DistanceVector Routing.

9/25/2022 MRS. RAKHI KALANTRI 80


Dijkstra’s Algorithm

➢ An algorithm that is used for finding the shortest distance, or path, from starting node
to target node in a weighted graph is known as Dijkstra’s Algorithm.

➢ Dijkstra's algorithm makes use of weights of the edges for finding the path that
minimizes the total distance (weight) among the source node and all other nodes.

9/25/2022 MRS. RAKHI KALANTRI 81


Dijkstra’s Algorithm
1. Mark the source node with a current distance of 0 and the rest nodes with infinity.

2. Now, fix the source node as the current node.

3. For the current node, analyse all of its unvisited neighbors and measure their distances by adding the current
distance of its own to the weight of the edge that connects to its neighbor node.

4. Compare the recently measured distance with the current distance assigned to the neighbouring node
and make it as the new current distance of the neighboring node.

5. After that,consider all of the unvisited neighbours of the current node, mark the current node as visited.

6. If the destination node has been marked visited then stop,an algorithm has ended.

7. Else, choose the unvisited node that is marked with the least distance, fix it as the new current node, and
repeat the process again from step 3.

9/25/2022 MRS. RAKHI KALANTRI 82


Dijkstra’s Algorithm

9/25/2022 MRS. RAKHI KALANTRI 83


Example of Dijkstra Algorithm

9/25/2022 MRS. RAKHI KALANTRI 84


Routing Table
• Each node uses the shortest path tree protocol to construct its routing table.
• The routing table shows the cost of reaching each node from the root.

9/25/2022 MRS. RAKHI KALANTRI 85


Dijkstra’s Algorithm

9/25/2022 MRS. RAKHI KALANTRI 86


Dijkstra’s Algorithm

9/25/2022 MRS. RAKHI KALANTRI 87


Dijkstra’s Algorithm

9/25/2022 MRS. RAKHI KALANTRI 88


(∞, - )
(∞, - )

(∞, - ) (∞, - )
(0) (∞, - )

(∞, - ) (∞, - )

9/25/2022 MRS. RAKHI KALANTRI 89


Distance Vector Routing
➢ Operates by having each router maintain a table (i.e., a vector) giving the best known distance to each
destination and which link to use to get there.

➢ These tables are updated by exchanging information with the neighbors.

➢ So every router knows the best link to reach each destination.

➢ Also called distributed Bellman-Ford routing algorithm.

➢ It was the original ARPANET routing algorithm and was also used in the Internet under the
name RIP.

➢ Each node shares its routing table with its immediate neighbors periodically when there is a change .

9/25/2022 MRS. RAKHI KALANTRI 90


Distance Vector Routing
❖ Information kept by DV router :
➢ Each router has an ID
➢ Link cost associated with each link connected to a router (static or dynamic).
➢ Intermediate hops

❖ Distance Vector Table Initialization :


➢ Distance to itself = 0
➢ Distance to ALL other routers = infinity number.

❖ Distance Vector Algorithm :


➢ A router transmits its distance vector to each of its neighbors in a routing packet.
➢ Each router receives and saves the most recently received distance vector from each of its neighbors.
➢ A router recalculates its distance vector when:
• It receives a distance vector from a neighbor containing different information than before.
• It discovers that a link to a neighbor has gone down. (or any change occurred)

9/25/2022 MRS. RAKHI KALANTRI 91


Distance Vector Routing
➢ Initially each node can know only the distance between itself and its immediate neighbors, those directly
connected to it.

➢ For this each node can send a message to the immediate neighbors and find the distance between itself and
these neighbors.

➢ Figure shows the initial tables for each node.The distance for any entry that is not a neighbor is marked
as infinite (unreachable).

9/25/2022 MRS. RAKHI KALANTRI 92


Distance Vector Routing
➢ The table for node A shows how we can reach any node from this node. For example, the least cost to
reach node E is 6.The route passes through C.

9/25/2022 MRS. RAKHI KALANTRI 93


Distance Vector Routing
➢ The whole idea of distance vector routing is the sharing of information between neighbors.

➢ Although node A does not know about node E, node C does. So if node C shares its routing table
withA, nodeA can also know how to reach node E.

➢ Node C does not know how to reach node D,but nodeA does.

➢ If nodeA shares its routing table with node C, node C also knows how to reach node D.

➢ In other words, nodes A and C, as immediate neighbors, can improve their routing tables if they help
each other.

➢ There is only one problem.How much of the table must be shared with each neighbor?

9/25/2022 MRS. RAKHI KALANTRI 94


Updating
➢ When a node receives a two-column table from a neighbor, it needs to update its routing table.
Updating takes in three steps:

1. The receiving node needs to add the cost between itself and the sending node to each value in the
second column. Example, if node C claims that its distance to E is x, and the distance between A
and C is y,then the distance betweenAand E,via C ,is (x + y).

2. The receiving node needs to add the name of the sending node to each row as the third column if
the receiving node uses information from any row.The sending node is the next node in the route.

3. The receiving node needs to compare each row of its old table with the corresponding row of the
modified version of the received table.
a. If the next-node entry is different,the receiving node chooses the row with the smaller cost.
b. If the next-node entry is the same, the receiving node chooses the new row.

9/25/2022 MRS. RAKHI KALANTRI 95


Updating
⦁ Figure shows how nodeA updates its routing table after receiving the partial table from node C .

Note that the old routing table is not used in the calculation.

9/25/2022 MRS. RAKHI KALANTRI 96


Distance Vector Routing
➢ In this example,delay is used as a metric.
➢ Suppose that Jhas measured or estimated its delay to its neighbors, A, I,H, and K, as 8,10,12,and 6 msec ,
respectively.

• JtoA → Min(8+0,10+24, 12+20,6+21) = 8 (A)


• Jto B → Min(8+12,10+36, 12+31,6+28)
= 20 that is throughA
• Jto G → Min(8+18,10+31,
12+6,6+31)
• = 18 that is through H

9/25/2022 MRS. RAKHI KALANTRI 97


Two-Node Loop Instability or Count to Infinity

⦁ Instability is the major problem, which means


that a network using this protocol can
become unstable.

9/25/2022 MRS. RAKHI KALANTRI 98


Three-Node Instability
➢ If the instability is between three nodes, stability cannot be guaranteed.

9/25/2022 MRS. RAKHI KALANTRI 99


Distance Vector Routing
❖ Advantages

⦁ It is simpler to configure and maintain than link state routing.

❖ Disadvantages of

➢ It is slower to converge.

➢ It is at risk from the count-to-infinity problem.

➢ It creates more traffic since updates take place on a periodic basis and if there are changes in the
network topology,so bandwidth-wasting broadcasts occur.

➢ For larger networks, distance vector routing results in larger routing tables since each router must know
about allother routers.This can also lead to congestion onWAN links.

9/25/2022 MRS. RAKHI KALANTRI 100


Link State Routing
➢ Link state routing is a technique in which each router shares the knowledge of its neighborhood
with every other router in the internetwork.

➢ The three keys to understand the Link State Routing algorithm:


➢ Knowledge about the neighborhood: Instead of sending its routing table, a router sends the
information about its neighborhood only. A router broadcast its identities and cost of the directly
attached links to other routers.
➢ Flooding: Each router sends the information to every other router on the internetwork except its
neighbors.This process is known as Flooding. Every router that receives the packet sends the copies to
all its neighbors. Finally,each and every router receives a copy of the same information.
➢ Information sharing: A router sends the information to every other router only when the change
occurs in the information.

9/25/2022 MRS. RAKHI KALANTRI 101


Link State Routing
➢ The idea behind link state routing is fairly simple and can be stated as five parts. Each router must do
the following things to make it work:

1. Discover its neighbors and learn their network addresses.

2. Set the distance or cost metric to each of its neighbors.

3. Construct a packet telling all it has just learned.

4. Send this packet to and receive packets from all other routers.

5. Compute the shortest path to every other router.

➢ In effect, the complete topology is distributed to every router. Then Dijkstra’s algorithm can be run at
each router to find the shortest path to every other router.

9/25/2022 MRS. RAKHI KALANTRI 102


Link State Routing
❖ Learning about the Neighbors :

➢ When a router is booted,its first task is to learn who are its neighbors.

➢ It accomplishes this goal by sending a special HELLO packet on each point-to- point line.

➢ The router on the other end is expected to send back a reply giving its name.

➢ These names must be globally unique.

9/25/2022 MRS. RAKHI KALANTRI 103


Link State Routing
❖ Setting Link Costs

➢ The link state routing algorithm requires each link to have a distance or cost metric for finding shortest
paths.

➢ The cost to reach neighbors can be set automatically,or configured by the network operator.

➢ If the network is geographically spread out, the delay of the links may be factored into the cost so that
paths over shorter links are better choices.

➢ The most direct way to determine this delay is to send over the line a special ECHO packet that the
other side is required to send back immediately.

➢ By measuring the round-trip time and dividing it by two, the sending router can get a reasonable estimate of
the delay.

9/25/2022 MRS. RAKHI KALANTRI 104


Link State Routing
❖ Building Link State Packets

➢ Each router needs to build a packet containing all the data.

➢ The packet starts with the identity of the sender, followed by a sequence number, age of the packet, a list of
neighbors and the cost to each neighbor.

➢ Example:

9/25/2022 MRS. RAKHI KALANTRI 105


Link State Routing

➢ Building the link state packets is easy.The hard part is determining when to build them.

➢ One possibility is to build them periodically,that is,at regular intervals.

➢ Another possibility is to build them when some significant event occurs, such as a line or
neighbor going down or coming back up again or changing its properties appreciably.

9/25/2022 MRS. RAKHI KALANTRI 106


Link State Routing
❖ Distributing the Link State Packets
➢ It is the trickiest part of the algorithm. All of the routers must get all of the link state packets quickly and reliably.
➢ If different routers are using different versions of the topology,the routes they compute can have inconsistencies
such as loops,unreachable machines…
❖ Use flooding to distribute the link state packets to all routers.
➢ To keep the flood in check,each packet contains a sequence number that is incremented for each new packet
sent.
➢ Routers keep track of all the (source router,sequence) pairs they see.
➢ When a new link state packet comes in, it is checked against the list of packets already seen.
⦁ If it is new,it is forwarded on all lines except the one it arrived on.
⦁ If it is a duplicate,it is discarded.
⦁ If a packet with a sequence number lower than the highest one seen so far ever arrives, it is rejected as being
outdated.
9/25/2022 MRS. RAKHI KALANTRI 107
Link State Routing
➢ This algorithm has a few problems,but they are manageable.

➢ First, if the sequence numbers wrap around, confusion will reign.The solution here is to use a
32-bit sequence number. With one link state packet per second, it would take 137 years to wrap
around, so this possibility can be ignored.

➢ Second, if a router ever crashes, it will lose track of its sequence number. If it starts again at 0, the next
packet it sends will be rejected as a duplicate.

➢ Third, if a sequence number is ever corrupted and 65,540 is received instead of 4 (a 1-bit error),
packets 5 through 65,540 will be rejected as obsolete, since the current sequence number will be
thought to be 65,540.

➢ 0000000000000100 4 100000000000100 65536 + 4

9/25/2022 MRS. RAKHI KALANTRI 108


Link State Routing

➢ The solution to all these problems is to include the age of each packet after the sequence number
and decrement it once per second.

➢ When the age hits zero,the information from that router is discarded.

➢ Normally, a new packet comes in, say, every 10 sec, so router information only times out when a
router is down (or six consecutive packets have been lost,an unlikely event).

➢ The Age field is also decremented by each router during the initial flooding process, to make sure
no packet can get lost and live for an indefinite period of time (a packet whose age is zero is
discarded).

9/25/2022 MRS. RAKHI KALANTRI 109


Link State Routing
➢ Some refinements to this algorithm make it more robust.

➢ When a link state packet comes in to a router for flooding,it is not queued for transmission immediately.

➢ Instead,it is put in a holding area to wait a short while in case more links are coming up or going down.

➢ If another link state packet from the same source comes in before the first packet is transmitted, their
sequence numbers are compared.

➢ If they are equal,the duplicate is discarded.

➢ If they are different,the older one is thrown out.

➢ To guard against errors on the links,all link state packets are acknowledged.

9/25/2022 MRS. RAKHI KALANTRI 110


Fig. (b) the packet buffer for router B in Fig.(a).

9/25/2022 MRS. RAKHI KALANTRI 111


Link State Routing
❖ Computing the New Routes

➢ Once a router has accumulated a full set of link state packets, it can construct the entire network
graph because every link is represented.

➢ Every link is,in fact,represented twice,once for each direction.

➢ The different directions may even have different costs.

➢ The shortest-path computations may then find different paths from router A to B than from router B
toA.

➢ Now Dijkstra’s algorithm can be run locally to construct the shortest paths to all possible
destinations.

➢ The results of this algorithm tell the router which link to use to reach each destination.This
information is installed in the routing tables,and normal operation is resumed.

9/25/2022 MRS. RAKHI KALANTRI 112


Link state routing concept

9/25/2022 MRS. RAKHI KALANTRI 113


Link state knowledge

9/25/2022 MRS. RAKHI KALANTRI 114


9/25/2022 MRS. RAKHI KALANTRI 115
Comparison between Link state & DVR

9/25/2022 MRS. RAKHI KALANTRI 116


Comparison between Link state & DVR

9/25/2022 MRS. RAKHI KALANTRI 117


Address Mapping
➢ An internet is a combination of physical networks connected by internetworking devices such as
routers.
➢ A packet starting from a source host may pass through several different physical networks before
reaching the destination host.
➢ The hosts and routers are recognized at the network level by their logical (IP) addresses.
➢ Packets pass through physical networks to reach these hosts and routers.
➢ At the physical level,the hosts and routers are recognized by their physical addresses.
➢ A physical address is a local address under the control of a local network.
➢ It must be unique locally,but is not necessarily unique universally.
➢ It is called a physical address because it is usually (but not always) implemented in hardware. (48-bit
MAC address in the Ethernet – NIC).

9/25/2022 MRS. RAKHI KALANTRI 118


Address Mapping
➢ The physical address and the logical address are two different identifiers.

➢ We need both because a packet at a network layer (such as IP) may pass through physical networks
(such as Ethernet and LocalTalk (Apple)).

➢ That means the delivery of a packet to a host or a router requires two levels of addressing:logical
and physical.

➢ It is required to map a logical address to its corresponding physical address and vice versa.

➢ This can be done by using either static or dynamic mapping.

9/25/2022 MRS. RAKHI KALANTRI 119


Static Mapping
➢ Each machine on the network stores a table that associates a logical address with a physical address.
➢ Each machine that knows,for example,the IP address of another machine but not its physical
address can look it up in the table.
➢ This has some limitations because physical addresses may change in the following ways:
1. A machine could change its NIC, resulting in a new physical address.
2. In some LANs, such as Local Talk,the physical address changes every time the computer is
turned on.
3. A mobile computer can move from one physical network to another,resulting in a change in its
physical address.
➢ To implement these changes, a static mapping table must be updated periodically. This overhead could
affect network performance.

9/25/2022 MRS. RAKHI KALANTRI 120


Dynamic Address Mapping
➢ In Dynamic mapping each time a machine knows one of the two addresses (logical or physical), it can use
a protocol to find the other one.

➢ We need protocols to create a mapping between physical and logical addresses.

➢ IP packets use logical (host-to-host) addresses. These packets need to be encapsulated in a frame,
which needs physical addresses (node-to-node).

➢ TheAddress Resolution Protocol (ARP), is designed for this purpose.

➢ We sometimes need reverse mapping-mapping a physical address to a logical address.

➢ For example, when booting a diskless network or leasing an IP address to a host.Three protocols are
designed for this purpose: RARP, BOOTp, and DHCP (Dynamic Host Configuration Protocol).
9/25/2022 MRS. RAKHI KALANTRI 121
Address Resolution Protocol
➢ Anytime a host or a router has an IP datagram to send to another host or router,it has the logical
(IP) address of the receiver.

➢ The logical (IP) address is obtained from the DNS ifthe sender is the host or it is found in a
routing table if the sender is a router.

➢ But the IP datagram must be encapsulated in a frame to be able to pass through the physical
network.

➢ This means that the sender needs the physical address of the receiver.

➢ The host or the router sends anARP query packet.

➢ The packet includes the physical and IP addresses of the sender and the IP address of the receiver.

➢ Because the sender does not know the physical address of the receiver,the query is broadcast over
the network.

9/25/2022 MRS. RAKHI KALANTRI 122


ARP Operation

9/25/2022 MRS. RAKHI KALANTRI 123


ARP packet

9/25/2022 MRS. RAKHI KALANTRI 124


Encapsulation of ARP Packet

➢ An ARP packet is encapsulated directly into a data link frame (Ethernet frame).Where the type field
indicates that the data carried by the frame are an ARP packet.

9/25/2022 MRS. RAKHI KALANTRI 125


Operation: Steps involved in an ARP process
1. The sender knows the IP address of the target.
2. IP asks ARP to create an ARP request message, filling in the sender physical address, the sender IP
address, and the target IP address.The target physical address field is filled with 0s.
3. The message is passed to the data link layer where it is encapsulated in a frame by using the physical
address of the sender as the source address and the physical broadcast address as the destination
address.
4. Every host or router receives the frame. All machines except the one targeted drop the packet.The target
machine recognizes its IP address.
5. The target machine replies with an ARP reply message that contains its physical address.The message is
unicast.
6. The sender receives the reply message.It now knows the physical address of the target machine.
7. The IP datagram, which carries data for the target machine, is now encapsulated in a frame and is unicast
to the destination.
9/25/2022 MRS. RAKHI KALANTRI 126
➢ There are four cases in which a host or router needs to useARP

9/25/2022 MRS. RAKHI KALANTRI 127


Example:
➢ A host with IP address 130.23.43.20 and physical address B2:34:55:10:22:10 has a packet to send to another
host with IP address 130.23.43.25 and physical address A4:6E:F4:59:83:AB.The two hosts are on the same
Ethernet network.Show theARP request and reply packets encapsulated in Ethernet frames.

9/25/2022 MRS. RAKHI KALANTRI 128


Proxy ARP
➢ ProxyARP is used to create a sub netting effect. WhereARP acts on behalf of a set of hosts.

➢ Whenever a router running a proxy ARP receives an ARP request looking for the IP address of one of
these hosts,the router sends anARP reply announcing its own hardware (physical) address.

9/25/2022 MRS. RAKHI KALANTRI 129


Reverse Address Resolution Protocol(RARP)
➢ There are occasions in which a host knows its physical address, but needs to know its logical address.This
may happen in two cases:

1. A diskless station is just booted.The station can find its physical address by checking its interface, but it
does not know its IP address.

2. An organization does not have enough IP addresses to assign to each station; it needs to assign IP
addresses on demand.The station can send its physical address and ask for a short time lease.

➢ ReverseAddress Resolution Protocol (RARP) is used for this purpose.

➢ The requesting machine must be running a RARP client program; the responding machine must be
running a RARP server program.

9/25/2022 MRS. RAKHI KALANTRI 130


RARP

➢ There is a serious problem with RARP:


• Broadcasting is done at the data link layer. The physical broadcast address,all 1s in the case of Ethernet,does
not pass the boundaries of a network.
• This means that if an administrator has several networks or several subnets,it needs to assign a RARP
server for each network or subnet.
9/25/2022 MRS. RAKHI KALANTRI 131
Syllabus for AT –II and IA-II
• IPv4 and IPv6 Protocol.

• Routing algorithms : Shortest Path (Dijkastra‘s), Link state routing, Distance Vector
Routing.

• Protocols - ARP,RARP.

• Congestion control algorithms: Open loop congestion control, Closed loop congestion
control, QoS parameters, Token & Leaky bucket algorithms.

• The Transport Service: Transport service primitives, Berkeley Sockets, Connection


management (Handshake), UDP, TCP.

• Application Layer: DNS: Name Space, Resource Record and Types of Name Server.
HTTP, SMTP, Telnet, FTP, DHCP
9/25/2022 MRS. RAKHI KALANTRI 132
Application Layer Questions
1. What is domain name space and how it is organized? “Hierarchy help in better
organization of domain names”. Justify the statement by giving example.

2. Show the sequence of characters exchanged between the TELNET client and the server to
switch from the default mode to the character mode and from the character mode to the
default mode.

3. Draw and brief the structure of HTTP request and response.

4. User aaa@xxx.com sends a message to user bbb@yyy.com. The latter replies. Show all
SMTP commands and responses.

5. Show how a file transfer process is carried out in FTP.

6. Brief the purpose, working and benefits of DHCP.


9/25/2022 MRS. RAKHI KALANTRI 133
Roadmap
1.1

❖ 4.4 Congestion control algorithms: Open loop congestion control,


Closed loop congestion control, QoS parameters, Token & Leaky
bucket algorithms
2.1

2.2

2.3

9/25/2022 MRS. RAKHI KALANTRI 134


Congestion Control Overview
➢ Too many packets present in the network causes packet delay and loss
that degrades performance. This situation is called congestion.

➢ When number of packets sent is within subnet carrying capacity, all are
delivered. As traffic increases, packet loss happens.At very high traffic,
performance collapses.
➢ Both transport and network layers share responsibility of handling congestion.
➢ Network layer is directly affected.
➢ Network congestion control should Protect the network from congestion
collapse but run the network as close to limits as possible.
➢ Higher utilization makes economic sense.

➢ Goodput: rate at which useful


packets are delivered by the
network.

9/25/2022 MRS. RAKHI KALANTRI 135


How Congestions Happens
➢ Incoming packets from multiple inputs need to go to same output line; queue builds up.
➢ If insufficient memory, packets lost
➢ Adding memory helps to some point
➢ Even with ∞ memory, congestion gets worse
⦁ delayed packets timeout, retransmitted
⦁ duplicates increase load

➢ Congestion collapse: load exceeds capacity


➢ Slow processors
⦁ CPU slow in doing bookkeeping tasks
⦁ queues build up

➢ Low bandwidth lines


⦁ can’t forward packets same as arriving speeds

➢ Mismatch between system parts


⦁ upgrading some parts only shifts bottleneck

9/25/2022 MRS. RAKHI KALANTRI 136


Congestion Control
➢ Congestion control refers to techniques and mechanisms that can either prevent congestion, before it
happens, or remove congestion, after it has happened.

➢ Congestion control mechanisms are divided into two broad categories: open-loop congestion
control (prevention) and closed-loop congestion control (removal).

➢ Open-Loop Congestion Control: policies are applied to prevent congestion before it happens. In
these mechanisms, congestion control is handled by either the source or the destination (Examples:
retransmission policy, Acknowledgment policy ect.)

➢ Closed-Loop Congestion Control: mechanisms try to alleviate congestion after it happens.


Several mechanisms have been used by different protocols.

9/25/2022 MRS. RAKHI KALANTRI 137


Congestion Control VS Flow Control
➢ Congestion control try to make sure subnet can carry offered traffic, a global issue involving all the hosts
and routers. It can be open-loop based or involving feedback.
➢ Flow control is related to point-to-point traffic between given sender and receiver, it always involves direct
feedback from receiver to sender. Ensure fast sender not overwhelm slow receiver.
❖ Flow control
• Fiber optic network with 1000 Gbps
• Super Computer try to transfer file to a PC @ 1Gbps
• No congestion, flow control needed to slow SC
❖ Congestion control
• Network with 1 Mbps lines, 1000 computers
• Half of them trying to transfer @ 100 kbps
• No overpowering problem, but total traffic exceed network capacity

9/25/2022 MRS. RAKHI KALANTRI 138


Congestion Control VS Flow Control
BASIS FOR
FLOW CONTROL CONGESTION CONTROL
COMPARISON

Basic It controls the traffic from a particular It controls the traffic entering the network.
sender to a receiver.
Purpose It prevents the receiver from being It prevents the network from getting congested.
overwhelmed by the data.
Responsibility Flow control is the responsibility handled Congestion Control is the responsibility handled
by data link layer and the transport layer. by network layer and transport layer.
Responsible The sender is responsible for transmitting The transport layer is responsible transmitting
extra traffic at receivers side. extra traffic into the network.

Preventive The sender transmits the data slowly to the Transport layer transmits the data into the
measures receiver. network slowly.
Methods Feedback-based flow control and Rate- Provisioning, traffic-aware routing and
based flow control admission control

9/25/2022 MRS. RAKHI KALANTRI 139


Approaches to congestion control
➢ The presence of congestion means that the load is (temporarily) greater than the resources (in a part of the
network) can handle.Two solutions come to mind: increase the resources or decrease the load.
➢ Approaches to congestion control range from slower preventive techniques to faster reactive techniques.

➢ These solutions are usually applied on different time scales to either prevent congestion or react to
it once it has occurred.

9/25/2022 MRS. RAKHI KALANTRI 140


Network Provisioning

➢ Build network well matched to traffic

➢ Turn on spare resources as needed

➢ Upgrade heavily utilized routers and links

➢ Scale of months: long term trends of traffic

9/25/2022 MRS. RAKHI KALANTRI 141


Traffic‐Aware Routing
➢ Compute routes: take traffic into account
➢ Shift traffic away from congestion hotspots
➢ Used in early Internet
➢ Serious issue: Can cause routing oscillations
➢ If load is ignored and only bandwidth and propagation delay are considered, this problem does not occur
➢ Adding weight only slows down oscillations
❖ Solutions?
➢ Multipath routing
➢ Shift traffic slowly enough that it can converge
➢ In internet routing protocol, route are not adjusted depends on
load, adjustments are made outside the routing protocol by
slowly changing its inputs.This is called traffic engineering.

9/25/2022 MRS. RAKHI KALANTRI 142


Admission Control
➢ Once there’s congestion, no more VCs setup
➢ In telephone: no dial tone
➢ In data networks: traffic is variable (bursts)
➢ Reserve resources: wasteful
➢ Use statistics of previous behavior
➢ Trade performance for acceptable risk
➢ Combined with traffic‐aware routing
➢ Redraw network without congested links

9/25/2022 MRS. RAKHI KALANTRI 143


Traffic Throttling
Slow down when congestion is approaching.
❖ Approaches to throttling traffic: must solve 2 problems

1. Routers must determine when congestion is approaching


⦁ Monitor resource usage
⦁ Utilization of output links: Average utilization: not account for bursts
⦁ Buffering of queued packets inside router
⦁ Number packets lost for lack of buffer space: Packet loss: too late

⦁ Queue delay directly captures congestion

To maintain good estimate of queue length: dnew = α * dold+ (1 −α) s


⦁ s : sample of instantaneous queue length

⦁ α < 1 : how fast router forgets recent history


⦁ EWMA: Exponentially Weighted Moving Average
⦁ smooth fluctuations and equivalent to low‐pass filter

⦁ When d > threshold : report congestion

2. Routers must deliver timely feedback to senders: different mechanisms


9/25/2022 MRS. RAKHI KALANTRI 144
Traffic Throttling
❖ Choke Packets
• Most direct way,tell sender directly.
• The router selects a congested packet and send choke packet back to source host.
• Original packet is tagged,so will not generate another choke packet,then forwarded as usual.
❖ Explicit Congestion Notification

❖ Hop‐by‐hop backpressure
⦁ Affect every hop it passes through
⦁ Provide quick relief at the point of congestion

9/25/2022 MRS. RAKHI KALANTRI 145


a) A choke packet that affects
only the source

b) A choke packet that affects


each hop it passes through

9/25/2022 MRS. RAKHI KALANTRI 146


Load Shedding
➢ When other methods fail: Throw excess packets away
➢ Term taken from electricity
⦁ Blacking certain areas to save entire grid
⦁ On hot summer days with high demand
➢ Choosing packets to discard
⦁ Random, may cause retransmissions
⦁ Priority‐based, required coop from senders
➢ Random Early Detection (RED)
⦁ Drop packets before situation become hopeless
⦁ Routers maintain average queue length
⦁ If exceeds threshold, line said to be congested
⦁ Router can’t tell which source most trouble
⦁ Pick packet randomly from congested queue: sender notice the packet drop when not received
acknowledgement

9/25/2022 MRS. RAKHI KALANTRI 147


Quality of Service
❖ Four issues must be addressed to ensure quality of service:

1. What applications need from the network.

2. How to regulate the traffic that enters the network.

3. How to reserve resources at routers to guarantee performance.

4. Whether the network can safely accept more traffic.

➢ No single technique deals efficiently with all these issues. Instead, a variety of techniques have been
developed for use at the network (and transport) layer.

➢ Practical quality-of-service solutions combine multiple techniques.

9/25/2022 MRS. RAKHI KALANTRI 148


Application Requirement
➢ A stream of packets from a source to a destination is called a flow.
➢ The needs of each flow can be characterized by four primary parameters: bandwidth, delay,jitter,and
loss.
➢ Together, these determine the QoS (Quality of Service) the flow requires.

Jitter is defined as a variation in the delay of received packets.

9/25/2022 MRS. RAKHI KALANTRI 149


QoS

To accommodate a variety of applications, networks may support different categories of QoS. They
support:

1. Constant bit rate (e.g., telephony).

2. Real-time variable bit rate (e.g., compressed videoconferencing).

3. Non-real-time variable bit rate (e.g., watching a movie on demand).

4. Available bit rate (e.g., file transfer).

9/25/2022 MRS. RAKHI KALANTRI 150


Leaky Bucket
➢ Traffic Shaping : is a mechanism to control the traffic in a network. Before the
Network layer can guarantee Quality of Service, it needs to ensure there is
traffic.Traffic shaping reduces congestion and regulates the rate of data
transmission.
➢ Leaky Bucket technique can be used to shape the traffic.
➢ Suppose we have a bucket in which we are pouring water in a random order
but we have to get water in a fixed rate , for this we will make a hole at the
bottom of the bucket. It will ensure that water coming out is in a some fixed
rate and also if bucket will full we will stop pouring in it.
➢ The input rate can vary, but the output rate remains constant. Similarly, in
networking, a technique called leaky bucket can smooth out bursty traffic.
Bursty chunks are stored in the bucket and sent out at an average rate.

9/25/2022 MRS. RAKHI KALANTRI 151


Leaky Bucket Algorithm Example
❖ Example : Consider a frame relay network having a capacity of 1Mb and data is input at the rate of 25mbps.
Calculate

1. What is the time needed to fill the bucket.


2. If the output rate is 2 mbps , the time needed to empty the bucket.

Ans.:
Here , C is Capacity of bucket = 1mb
Data input rate = 25 mbps
output rate = 2mbps.

T = C/input rate = 1/25 = 40 msec


T = C/output rate = ½ = 500 msec

9/25/2022 MRS. RAKHI KALANTRI 152


Leaky Bucket
➢ Each network interface contains a leaky bucket and the following steps are involved in leaky bucket
algorithm:
1. When host wants to send packet, packet is thrown into the bucket.
2. The bucket leaks at a constant rate, meaning the network interface transmits packets at a constant
rate.
3. Bursty traffic is converted to a uniform traffic by the leaky bucket.
4. In practice the bucket is a finite queue (FIFO) that outputs at a finite rate.

136
9/25/2022 MRS. RAKHI KALANTRI 153
Token Bucket
➢ The leaky bucket algorithm enforces output pattern at the average rate, no matter how bursty the traffic is.

➢ So in order to deal with the bursty traffic we need a flexible algorithm so that the data is not lost. One such
algorithm is token bucket algorithm.

➢ It is an algorithm used in packet-switched computer networks to ensure that data transmission in the
form of packets does not cross its bandwidth.

❖ Steps of this algorithm can be described as follows:

⦁ In regular intervals tokens are thrown into the bucket.

⦁ The bucket has a maximum capacity.

⦁ If there is a ready packet, a token is removed from the bucket, and the packet is sent.

⦁ If there is no token in the bucket, the packet cannot be sent.

9/25/2022 MRS. RAKHI KALANTRI 154


Token Bucket
➢ In figure (a) we see a bucket holding three tokens, with five packets waiting to be transmitted.
For a packet to be transmitted, it must capture and destroy one token.
➢ In figure (b) We see that three of the five packets have gotten through, but the other two are stuck
waiting for more tokens to be generated.

9/25/2022 MRS. RAKHI KALANTRI 155


Algorithm :
Token Bucket Algorithm
Step – 1 : A token is added at every ∆t time.

Step – 2 : The bucket can hold at most b-tokens. If a token arrive when bucket is full it is discarded.

Step - 3 : When a packet of m bytes arrived m tokens are removed from the bucket and the packet is sent
to the network.

Step – 4 : If less than n tokens are available no tokens are removed from the buckets and the packet is
considered to be non conformant.The non conformant packet may be enqueued for subsequent
transmission when sufficient token have been accumulated in the bucket.

➢ If C is the maximum capacity of bucket and ρ is the arrival rate and M is the maximum output rate
then Burst Length S can be calculated as

C + ρS = MS
9/25/2022 MRS. RAKHI KALANTRI 156
Token Bucket
➢ To understand the algorithm, we can assume a bucket that is getting filled with tokens.The bucket is of
limited size, and the tokens represent packets of predetermined size.
➢ Whenever a packet wants to enter the bucket, the bucket checks its size and compares it with the defined
limit of the bucket, if it does not go above the limit, it is allowed or else it is dropped.
❖ For better understanding it can be divided into the following steps:
⦁ Every 1/r second a token is added to the bucket.
⦁ The capacity of the bucket is to hold b tokens.
⦁ When it has reached capacity and a token arrives, it is dropped or discarded.
⦁ Assuming a packet of n bytes comes, and there are already n tokens in the bucket, those tokens are
removed and the packet is sent to the network. Or if there is lesser than n tokens, then no tokens are
removed and the packet is said to be non-conformant.

9/25/2022 MRS. RAKHI KALANTRI 157


Token Bucket Algorithm Example
Example :Consider a frame relay network having a capacity of 1Mb of data is arriving at the rate of 25mbps for
40msec.The Token arrival rate is 2mbps and the capacity of bucket is 500 kb with maximum output rate 25mbps. Calculate
1.The Burst Length.
2.Total output time.
Ans.
➢ If C is the maximum capacity of bucket and ρ is the arrival rate and M is the maximum output rate then Burst Length
S can be calculated as C + ρS = MS

Here, C is Capacity of bucket = 500kb


M= 25 mbps
ρ = 2mbps.

1. S = 500/((25-2)*1000) = 21.73msec ~ = 22msec

2. For 22msec the output rate is 25mbps after that the output rate becomes 2mbps i.e. token arrival rate.Therefore, for
another 500 kb the time taken will be: 500/(2000) = 250 msec
Therefore, total output time = 22 +250 = 272 msec.

9/25/2022 MRS. RAKHI KALANTRI 158


Leaky bucket v/s Token bucket

9/25/2022 MRS. RAKHI KALANTRI 159


Leaky bucket v/s Token bucket
Leaky Bucket Token Bucket

When the host has to send a packet, packet is In this leaky bucket holds tokens generated at
thrown in bucket. regular intervals of time.

Bucket leaks at constant rate Bucket has maximum capacity.

If there is a ready packet , a token is removed from


Bursty traffic is converted into uniform Bucket and packet is send.
traffic by leaky bucket.

In practice bucket is a finite queue outputs at If there is a no token in bucket, packet can not be
finite rate send.

9/25/2022 MRS. RAKHI KALANTRI 160


Leaky bucket v/s Token bucket

❖ Some advantage of token Bucket over leaky bucket

⦁ If bucket is full in token Bucket , tokens are discard not packets.While in leaky bucket, packets are
discarded.

⦁ Token Bucket can send Large bursts at a faster rate while leaky bucket always sends packets at
constant rate.

9/25/2022 MRS. RAKHI KALANTRI 161


Internet Control Message Protocol
➢ IP provides unreliable,connectionless datagram delivery
• Efficient use of network resources
• Best effort service to send from source to destination

➢ IPhas two deficiencies: lack of error control and lack of assistance mechanisms
➢ No error control :
• What if router must discard datagram because it cannot find route to final destination or because the
time-to-live field has a zero value?
• What if final destination must discard all fragments because some don’t arrive within a predetermined
time limit?
• These are examples of situations where an error has occurred and IP Protocol has no built-in
mechanism to notify the original host.

➢ No method to obtain node information:Is router or host alive?


9/25/2022 MRS. RAKHI KALANTRI 162
Internet Control Message Protocol
➢ The IP protocol has no error-reporting or error-correcting mechanism.

➢ It also lacks a mechanism for host and management queries.

➢ The Internet Control Message Protocol (ICMP)has been designed to compensate for the above
two deficiencies.

➢ It is a companion to the IP protocol.

9/25/2022 MRS. RAKHI KALANTRI 163


Types of Messages
❖ Two broad categories:
⦁ Error-reporting messages and
⦁ Query messages.

➢ The error-reporting messages report problems that a router or a host (destination) may encounter
when it processes an IP packet.

➢ The query messages, which occur in pairs,help a host or a network manager get specific information
from a router or another host.
• For example,nodes can discover their neighbors.
• Hosts can discover and learn about routers on their network, and
• Routers can help a node redirect its messages.

9/25/2022 MRS. RAKHI KALANTRI 164


General format of ICMP messages

➢ If there is no additional data, there are 4 bytes set to


zero.
➢ Each ICMP messages is at least 8 bytes long.

➢ The message has an 8-byte header and a variable-size data section.


➢ The general format of the header is different for each message type but, the first 4 bytes are common to all.
• ICMPtype, defines the type of the message.
• The code field is a subtype that specifies the reason for the particular message type.
• The checksum field similar to IPheader checksum and it is calculated over entire ICMPmessage.
• The rest of the header is specific for each message type.
➢ The data section
⦁ In error messages carries information for finding the original packet that had the error.
⦁ In query messages carries extra information based on the type of the query.

9/25/2022 MRS. RAKHI KALANTRI 165


Example of checksum calculation

9/25/2022 MRS. RAKHI KALANTRI 166


Encapsulation of ICMP packet
➢ ICMP messages are not passed directly to the DLL as would be expected.

➢ Instead, the messages are first encapsulated inside IP datagrams before going to the lower layer .

➢ The value of the protocol field in the IP datagram is 1 to indicate that the IP data is an ICMP message .

9/25/2022 MRS. RAKHI KALANTRI 167


Error Reporting Messages

➢ ICMP error messages report errors conditions.Typically sent when a datagram is discarded.

➢ Error messages are always sent to the original source because the only information available in the
datagram about the route is the source and destination IP addresses.

➢ ICMP uses the source IP address to send the error message to the source (originator) of the datagram .

9/25/2022 MRS. RAKHI KALANTRI 168


Error Reporting Messages

❖ Important points about ICMP error messages:


➢ No ICMP error message will be generated:
⦁ In response to a datagram carrying an ICMP error message.
⦁ For a fragmented datagram that is not the first fragment.
⦁ For a datagram having a multicast address.
⦁ For a datagram having a special address such as 127.0.0.0 or 0.0.0.0.

9/25/2022 MRS. RAKHI KALANTRI 169


Error Reporting Messages
Message type Description Generated by
Destination Packet could not be delivered either a router or the destination
unreachable host
Source quench Choke packet:designed to a router or host discards a datagram due
add a kind of flow control to the IP. to congestion, it sends a source-quench
message to the sender of
the datagram

Time exceeded Time to live field hit 0 the router

Parameter Invalid header field: an ambiguous or a router or the destination host


problem missing value in any field of the
datagram

Redirect Teach a router about geography A router to a host on the same local
network

9/25/2022 MRS. RAKHI KALANTRI 170


Redirection concept

9/25/2022 MRS. RAKHI KALANTRI 171


Query messages
➢ ICMP can diagnose some network problems.This is accomplished through the four query
messages.
➢ In this type of ICMP message, a node sends a message that is answered in a specific format by
the destination node.
➢ A query message is encapsulated in an IP packet, which in tum is encapsulated in a
data link layer frame.

9/25/2022 MRS. RAKHI KALANTRI 172


Query messages

Message type Description


Echo request and reply Check if a machine is alive
Timestamp request and reply Same as Echo, but with timestamp

Address-Mask Request and Reply Find a mask value if IP is known

Router solicitation /advertisement Find a nearby router

9/25/2022 MRS. RAKHI KALANTRI 173


Echo request and reply
➢ Used by network managers and users for diagnosing network problems.
➢ Tests if IP stack functioning on destination and routers in between Tests for the “reachability” of a
host
➢ Used to implement the PING command
➢ An echo-request message can be sent by a host or router.
➢ An echo-reply message is sent by the host or router which receives an echo-request message
➢ Echo-request and echo-reply messages can be used by network managers to check the operation
of the IP protocol.

• Optional Data must be returned exactly as sent


• Identifier and Sequence # not formally
defined
• Identifier often Process ID of sender
• Sequence # keeps track of particular request/reply

9/25/2022 MRS. RAKHI KALANTRI 174


Timestamp request and reply
➢ Used by two machines to determine the roundtrip time for an IP datagram to travel between
them . Also used to synchronize the clocks in two machines.
➢ Format contains three timestamps, each 32-bits.
➢ Represents time (in milliseconds) from midnight in Universal Time.

9/25/2022 MRS. RAKHI KALANTRI 175


Timestamp request and reply
❖ Timestamp-request

➢ Original Timestamp receives UT shown by clock at departure time

➢ Receive/Transmit timestamps initialized to 0s


❖ Timestamp-reply

➢ Original Timestamp receives value copied from request

➢ Receive timestamp contains UT time dest received packet

➢ Transmit timestamps contains UT time packet sent

Sending time = value of receive timestamp − value of original timestamp

Receiving time = time the packet returned − value of transmit timestamp

Round-Trip Time = Sending time + Receiving time

9/25/2022 MRS. RAKHI KALANTRI 176


Mask request and reply message format
➢ Used by Host to obtain its IP address mask

➢ Host sends request to router if it knows IP of router

➢ If not, host broadcasts request and then router replies

➢ Diskless workstations use RARP to first get IP

➢ Then use ICMP Mask-request to get address mask

9/25/2022 MRS. RAKHI KALANTRI 177


Router solicitation message format
➢ Hosts need to know addresses of routers .

➢ Request broadcast by host to obtain the operating routers .

➢ Routers reply with all routers they are aware of including themselves (Sometimes reply
without request) .

9/25/2022 MRS. RAKHI KALANTRI 178


Router advertisement message format
➢ Preference level is used to select default router

➢ If preference level is 0 then it is default. If level is 0x80000000 never selected as default

9/25/2022 MRS. RAKHI KALANTRI 179


0 :Net Unreachable
1: Host Unreachable
2: Protocol Unreachable
3: Port Unreachable
4: Frag Needed but “Don't Frag” was Set
5: Source Route Failed
6: Dest. Net Unknown
7: Dest. Host Unknown
8: Source Host Isolated
9: Communication with Dest Net is Admin Prohibited
10: Communication with Dest Host is Admin Prohibited
11: Dest Net Unreachable for Type of Service
12: Dest Host Unreachable for Type of Service
13: Communication Administratively Prohibited
14: Host Precedence Violation
15: Precedence cutoff in effect
9/25/2022 MRS. RAKHI KALANTRI 180
Source-quench format

9/25/2022 MRS. RAKHI KALANTRI 181


Time-exceeded message format

➢ Code 0:Time to live


➢ Code 1:Fragmentation

9/25/2022 MRS. RAKHI KALANTRI 182


Parameter-problem message format

➢ Code 0: Parameter field points to problem byte


➢ Code 1: Parameter field unused

9/25/2022 MRS. RAKHI KALANTRI 183


Redirection message format

➢ Code 0: Network specific

➢ Code 1: Host specific

➢ Code 2: Network specific (specified service)

➢ Code 3: Host specific (specified service)

9/25/2022 MRS. RAKHI KALANTRI 184


Internet Group Management Protocol
❖ Multicasting

⦁ Processes may have to send the same message to a large numbers of receivers simultaneously.
This is called multicasting, which is aone-to-many communication.

❖ Examples:
• D istance learning and Video-on-demand
• Informing multiple stockbrokers about changes to a stock price
• Travel agents can be informed of a plane cancellation

➢ IGMP is one of the necessary but not sufficient protocol for multicasting

9/25/2022 MRS. RAKHI KALANTRI 185


IGMP: Group Management
➢ For multicasting in the Internet we need routers that are able to route multicast packets.

➢ Routing tables must be updated using a multicasting routing protocol.

➢ IGMP is not a multicasting routing protocol.

➢ It is a protocol that manages group membership.

➢ Group membership: hosts and routers and the groups they are “interested” in (subscribe to).

➢ In any network, there are one or more multicast routers that distribute multicast packets to hosts or other
routers.

➢ The IGMP protocol gives the information about the membership status of hosts (routers) connected to the
network to multicast routers.

9/25/2022 MRS. RAKHI KALANTRI 186


IGMP: Group Management

➢ Amulticast router may receive thousands of multicast packets every day for different groups.

➢ If a router has no knowledge about the membership status of the hosts, it must broadcast all these packets.

➢ This creates a lot of traffic and consumes bandwidth.

➢ Abetter solution is to keep a list of groups in the network for which there is at least one loyal member.

➢ IGMP helps the multicast router create and update this list.

IGMP is a group management protocol.It helps a multicast router create


and update a list of loyal members related to each router interface.

9/25/2022 MRS. RAKHI KALANTRI 187


IGMP Message Types

9/25/2022 MRS. RAKHI KALANTRI 188


IGMP Message Types
➢ There are several types of IGMP messages:
❖ Query:
➢ General membership queries: Sent by multicast routers to determine which multicast addresses are of
interest to systems attached to the network(s) they serve to refresh the group membership state for all
systems on its network.
❖ Special Query:
➢ Group-specific membership queries: Used for determining the reception state for a particular multicast
address.
➢ Group-and-source-specific queries: Allow the router to determine if any systems desire reception of
messages sent to a multicast group from a source address specified in a list of unicast addresses.
➢ Membership reports: Sent by multicast receivers in response to a member- ship query or asynchronously
when first registering for a multicast group.
➢ Leave group messages: Sent by multicast receivers when specified multicast transmissions are
no longer needed at the receiver.
➢ IGMP messages are carried in bare IP packets with IP protocol number 2.
9/25/2022 MRS. RAKHI KALANTRI 189
IGMP Message Format

➢ Type: This 8-bit field defines the type of message

Type Value
General or special query Ox11 or 00010001
Membership report Ox16 or 00010110
Leave report Ox17 or 00010111

➢ Maximum Response Time: This 8-bit field defines the amount of time in which a query must be answered.
The value is nonzero in the query message; it is set to zero in the other two message types.
➢ Checksum: The checksum is calculated over the 8-byte message.
➢ Group address: The value of this field is 0 for a general query message.
The value defines the groupid (multicast address of the group) in the special query, and other two messages.

MRS. RAKHI KALANTRI

9/25/2022 190
IGMP Operation
➢ IGMP operates locally, i.e., within a network
➢ For each group there is only one router connected to the network that has the duty of distributing the multicast
packets destined for that group
➢ A host or multicast router can have membership in a group.
➢ A host has “membership” if one of its processes receives multicast packets from some group
➢ A router has “membership” means that there is a network attached to some other interface that receives
multicast packets for the group

• R is distributing router
• R1 & R2 are multicast routers
• Possibly receive packets from R
• Forward to other networks but not on this network

9/25/2022 MRS. RAKHI KALANTRI 191


Joining a Group
➢ A host or router can join a group
❖ Host Joining a group:
➢ The host receives requests from processes to join a group.
➢ If no previous request from another process, a membership report message is sent.
➢ Otherwise, no membership report need be sent as the host already receives multicast packets for this
group.
❖ Router Joining a group:
➢ A router also maintains a list of groupids that show membership for the networks connected to each
interface.
➢ If a multicasting router receives a membership report from a device attached to an interface for a network
where there was not already interest, the router will issue a membership report message to a device on the
network that supplies the multicast packets for this group.
➢ Router acts like host but group list is much broader (accumulation of all loyal members that are
connected to its interfaces).
9/25/2022 MRS. RAKHI KALANTRI 192
Membership report

➢ The protocol requires that the membership report be sent twice, one after the other within a few moments.

➢ In this way, if the first one is lost or damaged, the second one replaces it.

9/25/2022 MRS. RAKHI KALANTRI 193


Leaving a Group
➢ When a host sees that no process is interested in a specific group, it sends a leave report.

➢ Similarly, when a router sees that none of the networks connected to its interfaces is interested in a
specific group, it sends a leave report about that group.

➢ When a multicast router receives a leave report, it cannot immediately purge that group from its list
because the report comes from just one host / router; there may be other hosts or routers that are still
interested in that group.

➢ To make sure, the router sends a special query message and inserts the groupid, or multicast
address, related to the group.

➢ The router allows a specified time for any host or router to respond.

➢ If, during this time, no interest (membership report) is received, the router assumes that there are no
loyal members in the network and purges the group from its list.

9/25/2022 MRS. RAKHI KALANTRI 194


Leave report

104
9/25/2022 MRS. RAKHI KALANTRI 195
Monitoring Membership
➢ A host or router can join a group by sending a membership report message and leave a group by sending a
leave report message.

➢ However, sending these two types of reports is not enough.

➢ Consider the situation in which there is only one host interested in a group, but the host is shut down
or removed from the system.

➢ The multicast router will never receive a leave report. How is this handled?

➢ The multicast router is responsible for monitoring all the hosts or routers in a LAN to see if they want to
continue their membership in a group.

➢ The router periodically (by default, every 125 s) sends a general query message.

➢ In this message, the group address field is set to 0.0.0.0.This means the query for membership
continuation is for all groups in which a host is involved, not just one.

9/25/2022 MRS. RAKHI KALANTRI 196


A general query message

106
9/25/2022 MRS. RAKHI KALANTRI 197
A general query message
➢ The router expects an answer for each group in its group list; even new groups may respond.

➢ The query message has a maximum response time of 10 s (the value of the field is actually 100, but this is
in tenths of a second).

➢ When a host or router receives the general query message, it responds with a membership report if it is
interested in a group.

➢ However, if there is a common interest (two hosts, for example, are interested in the same group), only
one response is sent for that group to prevent unnecessary traffic. This is called a delayed response.

➢ Note that the query message must be sent by only one router (normally called the query router), also to
prevent unnecessary traffic.

9/25/2022 MRS. RAKHI KALANTRI 198


Example of delayed response
➢ Imagine there are three hosts in a network, as shown in Figure. A query message was received at time
0; the random delay time (in tenths of seconds) for each group is shown next to the group address.
Show the sequence of report messages.

9/25/2022 MRS. RAKHI KALANTRI 199


Example of delayed response
Solution: The events occur in this sequence:
⦁ Time 12: The timer for 228.42.0.0 in host A expires, and a membership report is sent, which is received by
the router and every host including host B which cancels its timer for 228.42.0.0.

109
9/25/2022 MRS. RAKHI KALANTRI 200
Example of delayed response
➢ Time 30: The timer for 225.14.0.0 in host A expires, and a membership report is sent, which is received by
the router and every host including host C which cancels its timer for 225.14.0.0.

110
9/25/2022 MRS. RAKHI KALANTRI 201
Example of delayed response
➢ Time 50: The timer for 238.71.0.0 in host B expires, and a membership report is sent, which is
received by the router and every host.

111
9/25/2022 MRS. RAKHI KALANTRI 202
Example of delayed response
⦁ Time 70: The timer for 230.43.0.0 in host C expires, and a membership report is sent,
which is received by the router and every host including host A which cancels its timer for
230.43.0.0.

⦁ Note that if each host had sent a report for every group in its list, there would have been seven reports;
with this strategy only four reports are sent.

9/25/2022 MRS. RAKHI KALANTRI 203


Query Router

➢ Query messages may create a lot of responses.

➢ To prevent unnecessary traffic, IGMP designates one router as the query router for each network.

➢ Only this designated router sends the query message, and the other routers are passive (they receive
responses and update their lists).

113
9/25/2022 MRS. RAKHI KALANTRI 204
Encapsulation at Network Layer

➢ The value of the protocol field is 2 for the IGMP protocol.


➢ The IP packet that carries an IGMP packet has a value of 1 in its TTL field.
➢ This is required because the domain of IGMP is the LAN. No IGMP message must travel beyond
the LAN.

9/25/2022 MRS. RAKHI KALANTRI 205


Encapsulation at Data Link Layer
➢ The ARP protocol cannot find the corresponding MAC (physical) address to forward the packet at the
data link layer.

➢ Most LANs support physical multicast addressing.

➢ Ethernet is one of them. An Ethernet physical address (MAC address) is six bytes (48 bits) long.

➢ If the first 25 bits in an Ethernet address are 000000100000000010111100, this identifies a physical
multicast address for the TCP/IP protocol.

➢ The remaining 23 bits can be used to define a group.

➢ To convert an IP multicast address into an Ethernet address, the multicast router extracts the least
significant 23 bits of a class D IP address and inserts them into a multicast Ethernet physical
address.

9/25/2022 MRS. RAKHI KALANTRI 206


Encapsulation at Data Link Layer
➢ Mapping class D to Ethernet physical address

➢ An Ethernet multicast physical address is in the range 01:00:5E:00:00:00 to 01:00:5E:7F:FF:FF.

9/25/2022 MRS. RAKHI KALANTRI 207


Example 1

➢ Change the multicast IP address 230.43.14.7 to an Ethernet multicast physical address.

➢ Solution: We can do this in two steps:

➢ We write the rightmost 23 bits of the IP address in hexadecimal.This can be done by changing the
rightmost 3 bytes to hexadecimal and then subtracting 8 from the leftmost digit if it is greater than or equal
to 8. In our example, the result is 2B:0E:07.

➢ We add the result of part a to the starting Ethernet multicast address, which is 01:00:5E:00:00:00.The
result is

9/25/2022 MRS. RAKHI KALANTRI 208

You might also like