0% found this document useful (0 votes)
83 views171 pages

Unit-3 Network Layer

Computer Network Layers

Uploaded by

Sadaf Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
83 views171 pages

Unit-3 Network Layer

Computer Network Layers

Uploaded by

Sadaf Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 171

Computer Networks

— Unit - 3 —
— Network Layer —

 Text Book
Behrouz .A. Forouzan, “Data communication and
Networking”, Tata McGrawHill, 2004

11/21/24 Unit-3 : Network Layer 1


Network Layer

11/21/24 Unit-3 : Network Layer 2


Position of network layer

11/21/24 Unit-3 : Network Layer 3


Network layer duties

11/21/24 Unit-3 : Network Layer 4


11/21/24 Unit-3 : Network Layer 5
PACKETIZING
• ENCAPSULATING THE MESSAGE (PAYLOAD)
AT THE SOURCE HOST AND DECAPSULATING
THE MESSAGE AT THE DESTINATION.
• DATA MAY BE LARGE. FRAMENTATION. ?
– DIVIDED INTO FRAGMENTS AND THEN
TRANSMITTED. EACH FRAGMENT NEED S A
HEADER.

11/21/24 Unit-3 : Network Layer 6


ROUTING
• DATA CAN TAKE ANY ROUTE TO
REACH THE DESTINATION.
– BEST ROUTE HAS TO BE CHOSEN. –
NETWORK LAYER PROTOCOL.
– ROUTING TABLE – INFO ABOUT THE
NEIGHBOURHOOD.

11/21/24 Unit-3 : Network Layer 7


FORWARDING
• ACTION TAKEN BY THE ROUTER
WHEN A DATA PACKET ARRIVES.
• UNICAST – IF PACKET HAS TO BE
TRANSMITTED TO ONE NETWORK.
• MULTICAST – MULTIPLE NETWORKS.

11/21/24 Unit-3 : Network Layer 8


11/21/24 Unit-3 : Network Layer 9
ERROR CONTROL
• CHECKSUM FIELD IS ADDED IN THE
DATAGRAM.
• IF ANY MANIPULATIONS ARE DONE TO
THE HEADER THEN IT CAN CONTROL.
• NOT TO THE WHOLE DATAGRAM.
• INTERNET IS ICMP.

11/21/24 Unit-3 : Network Layer 10


FLOW CONTROL
• IF THE SOURCE HOST IS FAST AS
COMPARED TO THE RECEIVER, THEN
A BUFFER CAN BE IMPLEMNTED AT
THE DESTINATION. TO AVOID LOSING
DATA, AVOID THE TASK OF
RETRANSMISSIONS.

11/21/24 Unit-3 : Network Layer 11


CONGESTION CONTROL
• MORE FLOW OF DATAGRAMS IN THE
NETWORK.
• THIS RESULTS IN LOSING PACKETS.
• WHEN ROUTERS ARE NOT CAPABLE
THEN THEY DROP THE PACKETS.

11/21/24 Unit-3 : Network Layer 12


QoS- QUALITY OF SERVICE
• MULTIMEDIA APPLICATIONS ARE
SUPPORTED.

SECURITY
– CONNECTIONLESS VIRTUALLY
CHANGE TO CONNECTION ORIENTED.
– THIS VIRTUAL LAYER IS IPSec.

11/21/24 Unit-3 : Network Layer 13


Figure 19.7 Switching

11/21/24 Unit-3 : Network Layer 14


PACKET SWITCHING
• A router - is a switch that creates a
connection between an input port and an
output port.
• Data communication switching techniques
are divided into two broad categories,
circuit switching and packet switching but
in the network layer – packet switching is
used.

11/21/24 Unit-3 : Network Layer 15


• The NL receives packet from the upper layer (TL).
• The source divides the entire datagram/message into
manageable packets, the message sends the packets
one by one; the destination of the message receives the
packets one by one.
• The destination waits for all packets belonging to the
same message to arrive before delivering the message to
the upper layer.
• The connecting devices in a packet-switched network still
need to decide how to route the packets to the final
destination.
• Packet-switched network can use two different
approaches to route the packets:
• the datagram approach and
• the virtual circuit approach.
11/21/24 Unit-3 : Network Layer
Datagram Approach: Connectionless Service
• In a connectionless service the network-layer
protocol treats each packet independently, with
each packet having no relationship to any other
packet.
• In this approach, the packets in a message may
or may not travel the same path to their
destination.
• The idea was that the network layer is only
responsible for delivery of packets from the
source to the destination.

11/21/24 Unit-3 : Network Layer 17


Figure 19.8 Datagram approach

11/21/24 Unit-3 : Network Layer 18


11/21/24 Unit-3 : Network Layer 19
• Each packet is routed based on the information
contained in its header: source and destination
addresses.
• The router in this case routes the packet based
only on the destination address.
• The source address may be used to send an
error message to the source if the packet is
discarded.
• In the datagram approach, the forwarding
decision is based on the destination address
of the packet.
11/21/24 Unit-3 : Network Layer 20
Virtual-Circuit Approach:
Connection-Oriented Service
• There is a relationship between all packets
belonging to a message.
• A virtual connection should be set up to define the
path for the datagrams. After connection setup,
the datagrams can all follow the same path.
• The packet contain,
– the source and destination addresses.
– flow label
– a virtual circuit identifier that defines the virtual path the
packet should follow.

11/21/24 Unit-3 : Network Layer 21


11/21/24 Unit-3 : Network Layer 22
11/21/24 Unit-3 : Network Layer 23
Note:

Switching at the network layer in the


Internet is done using the datagram
approach to packet switching.

11/21/24 Unit-3 : Network Layer 24


Note:

Communication at the network layer


in the Internet is connectionless.

11/21/24 Unit-3 : Network Layer 25


• Virtual Circuit approach – 3 phases:
– Set up – V C gets created.
– Data transfer – Packets are transmitted via a
single route – for a single message.
– Tear down – The connection is destroyed.
(Table entries are deleted)

11/21/24 Unit-3 : Network Layer 26


SET UP PHASE
• A router creates an entry for a virtual
circuit.
• If source A needs to create a virtual circuit
to destination B. Two auxiliary packets
need to be exchanged between the sender
and the receiver: the request packet and
the acknowledgment packet.

11/21/24 Unit-3 : Network Layer 27


Request packet : A request packet is sent from the source
to the destination. This auxiliary packet carries the source
and destination addresses.

11/21/24 Unit-3 : Network Layer 28


• Source A sends a request packet to router R1.
• Router R1 receives the request packet. It knows that a
packet going from A to B goes out through port 3.
– The router creates an entry in its table for this virtual
circuit. The router assigns the incoming port (1) and
chooses an available incoming label (14) and the outgoing
port (3). The router then forwards the packet through port
3 to router R3.
• Router R3 receives the setup request packet. The same
events happen here as at router R1; incoming port (1),
incoming label (66), and outgoing port (3).
• At router 4, incoming port (1), incoming label (22), and
outgoing port (4).
• Destination B receives the setup packet, and if it is ready to
receive packets from A, it assigns a label to the incoming
packets that come from A, in this case 77 29
Acknowledgment Packet

11/21/24 Unit-3 : Network Layer 30


11/21/24 Unit-3 : Network Layer 31
Data Transfer Phase

11/21/24 Unit-3 : Network Layer 32


Tear down phase
• A special packet called a teardown packet
is sent from source to destination.
• Destination B responds with a confirmation
packet.
• All routers delete the corresponding
entries from their tables

11/21/24 Unit-3 : Network Layer 33


Network-Layer Performance - Can be measured
in terms of Delay, Throughput, and Packet loss.

• Delay
– Transmission Delay
• Delaytr = (Packet length) / (Transmission rate)
– Propagation Delay
• depends on the propagation delay of each network
(LAN or WAN). The propagation delay depends on
the propagation speed of the media, which is 3 × 108
meters/second in a vacuum and much less in a
wired medium.
• Delaypg = (Distance) / (Propagation speed).
11/21/24 Unit-3 : Network Layer 34
in a Fast Ethernet LAN (see Chapter 5) with the transmission rate of
100 million bits per second and a packet of 10,000 bits, it takes
(10,000)/(100,000,000) or 100 microseconds for all bits of the packet
to be put on the line

11/21/24 Unit-3 : Network Layer 35


– Processing Delay:
• Is the time required for a router or a destination host to
receive a packet from its input port, remove the header,
perform an error detection procedure, and deliver the
packet to the output port (in the case of a router) or deliver
the packet to the upper-layer protocol (in the case of the
destination host).
• Delaypr = Time required to process a packet in a router or a
destination host.

11/21/24 Unit-3 : Network Layer 36


– Queuing delay:
• Routers have input and output ports – each port has
a queue to store packets.
• The queuing delay for a packet in a router is
measured as the time a packet waits in the input
queue and output queue of a router.
– Delayqu = The time a packet waits in input and output
queues in a router.

Total delay = (n + 1) (Delaytr + Delaypg + Delaypr)


+ (n) (Delayqu)
n – number of routers
11/21/24 Unit-3 : Network Layer 37
Throughput
• Throughput at any point in a network is defined
as the number of bits passing through the point in
a second, which is actually the transmission rate
of data at that point.
• Throughput = minimum {TR1, TR2, . . . TRn}.

11/21/24 Unit-3 : Network Layer 38


11/21/24 Unit-3 : Network Layer 39
Packet Loss
•When a router receives a packet while processing
another packet, the received packet needs to be
stored in the input buffer waiting for its turn. A
router, however, has an input buffer with a limited
size.
•A time may come when the buffer is full and the
next packet needs to be dropped.
•The effect of packet loss on the Internet network
layer is that the packet needs to be resent, which in
turn may create overflow and cause more packet
loss.
11/21/24 Unit-3 : Network Layer 40
NETWORK LAYER
CONGESTION

11/21/24 Unit-3 : Network Layer 41


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 can be
divided into two broad categories: open-
loop congestion control (prevention) and
closed-loop congestion control (removal).

11/21/24 Unit-3 : Network Layer 42


OPEN LOOP CONGESTION CONTROL
• Policies are applied to prevent congestion before
it happens.
– Retransmission Policy -The retransmission policy and the
retransmission timers must be designed to optimize efficiency and
at the same time prevent congestion
– Window policy – Selective repeat is better than Go back N.
– Acknowledgment Policy – Receiver need not
acknowledge every packet.
– Discarding policy – Discarding less sensitive
packets.
– Admission Policy - first check the resource
requirement of a flow before admitting it to the network
11/21/24 Unit-3 : Network Layer 43
CLOSED LOOP CONGESTION CONTROL

11/21/24 Unit-3 : Network Layer 44


• Implicit signalling – no communication
between the congested node or nodes and
the source.
– The delay in receiving an acknowledgment is
interpreted as congestion in the network; the
source should slow down.
• Explicit signalling – node that experiences
congestion can explicitly send a signal to
the source or destination.
– The signal is included in the packets that carry
data.
11/21/24 Unit-3 : Network Layer 45
STRUCTURE OF A ROUTER

11/21/24 Unit-3 : Network Layer 46


11/21/24 Unit-3 : Network Layer 47
• ROUTING PROCESSOR- NL functions
are performed.
– The destination address of a packet will be
known.
– Which is the next node for transmission; next
hop.
– Table look up.

11/21/24 Unit-3 : Network Layer 48


SWITCHING FABRIC
• How the packets move from input queue
to the output queue.

11/21/24 Unit-3 : Network Layer 49


11/21/24 Unit-3 : Network Layer 50
1st stage – routes based on the highest order bit.
2nd stage – based on second highest order bit.
3rd – based third highest order.
110 – 6 010 – 2 001-1

11/21/24 Unit-3 : Network Layer 51


11/21/24 Unit-3 : Network Layer 52
NETWORK LAYER PROTOCOLS
• The network layer in version 4 can be thought of
as one main protocol and three auxiliary
protocols.
– Internet Protocol version 4 (IPv4) - is responsible for
packetizing, forwarding, and delivery of a packet at
the network layer.
– ICMPv4 - helps IPv4 to handle some errors that may
occur in the network-layer delivery.
– IGMP - help IPv4 in multicasting.
– ARP used to glue the network and data-link layers in
mapping network-layer addresses to link-layer
addresses
11/21/24 Unit-3 : Network Layer 53
IPV4
• IPv4 is an unreliable and connectionless datagram
protocol - a best-effort delivery
service.
• IPv4 must be paired with a reliable transport-layer
protocol such as TCP.

11/21/24 Unit-3 : Network Layer 54


IPv4 Datagram Format

11/21/24 Unit-3 : Network Layer 55


• Packets used by the IP are called
datagrams.
• A datagram is a variable-length packet
consisting of two parts: header and payload
(data).
• The header is 20 to 60 bytes in length and
contains information essential to routing
and delivery.

11/21/24 Unit-3 : Network Layer 56


• Version Number: IPV4 – 4 bits – 0100.
• HLEN: 4 bits - defines the total length of the
datagram header in 4-byte words.
– The total length is divided by 4 and the value is
inserted in the field.
– The receiver needs to multiply the value of this
field by 4 to find the total length.
• Service Type: IETF – DiffServ
• Total Length: This 16-bit field defines the
total length (header plus data) of the IP
datagram in bytes. A 16-bit number can
define a total length of up to 65,535
• Identification, Flags, and Fragmentation
Offset:
– Identification: Unique Packet Id for identifying
the group of fragments of a single IP datagram
(16 bits).
– Flags: 3 flags of 1 bit each : reserved bit (must be
zero), do not fragment flag, more fragments flag
(same order).
– Fragment Offset: Represents the number of
Data Bytes ahead of the particular fragment in the
particular Datagram. Specified in terms of number
of 8 bytes, which has the maximum value of
65,528 bytes.
• Time-to-live (TTL):control the maximum
number of hops (routers) visited by the
datagram.
– When a source host sends the datagram, it
stores a number in this field. This value is
approximately two times the maximum number
of routes between any two hosts.
– Each router that processes the datagram
decrements this number by one.
– If this value, after being decremented, is zero,
the router discards the datagram.

11/21/24 Unit-3 : Network Layer 59


• Protocol: In TCP/IP, the data section of a
packet, called the payload, carries the whole
packet from another protocol.

11/21/24 Unit-3 : Network Layer 60


• Header Checksum:
– IP is not a reliable protocol.
– Error checking of the payload is done by the
protocol that owns the payload.
• Source and Destination Addresses: 32 bit
addresses.
• Options: used for Network testing and
Debugging.
• Payload: packet coming from other protocols
that use the service of IP.

11/21/24 Unit-3 : Network Layer 61


Question ????
•An IPv4 packet has arrived with the first 8
bits as shown: 01000010. Analyze the
scenario. 2 -> 2*4=8 BYTES.
•MINI- 20 BYTES . Header corrupted. Discard
datagram.
•In an IPv4 packet, the value of HLEN is 1000
in binary. How many bytes of options are
being carried by this packet?
– 1000 – 8 - 8*4 = 32.
– Minimum 20 BYTES – 32-20=12BYTES -
OPTIONS
11/21/24 Unit-3 : Network Layer 62
FRAGMENTATION
• Each router decapsulates the IP datagram from
the frame it receives, processes it, and then
encapsulates it in another frame.
• The format and size of the frame received
depend on the protocol used by the physical
network through which the frame just travelled.
• The format and size of the frame sent depend on
the protocol used by the physical network
through which the frame is going to travel.
• If a router connects a LAN to a WAN, it receives
a frame in the LAN format and sends a frame in
the WAN format
11/21/24 Unit-3 : Network Layer 63
Maximum Transfer Unit (MTU)
• Link Layer has its own frame format.
• Each format has the maximum size of the payload that
can be encapsulated.
• When a datagram is encapsulated in a frame, the total
size of the datagram must be less than this maximum
size.

11/21/24 Unit-3 : Network Layer 64


• MTU differs from one physical network
protocol to another.
• IP protocol independent of the physical
network - maximum length of the IP
datagram equal to 65,535 bytes.
• For other physical networks, Divide the
datagram to make it possible for it to pass
through these networks. This is called
Fragmentation.
• Each fragment has its own header with
most of the fields repeated.
11/21/24 Unit-3 : Network Layer 65
Fields Related to Fragmentation
• 16-bit identification field - IP protocol uses
a counter to label the datagrams. The
counter is initialized to a positive number.
• When the IP protocol sends a datagram, it
copies the current value of the counter to
the identification field and increments the
counter by one.
• The identification number helps the
destination in reassembling the datagram
11/21/24 Unit-3 : Network Layer 66
• 3-bit flags field:
– leftmost bit is reserved.
– D bit is called the do not fragment bit (1-> no
fragmenting, 0-> fragmenting is allowed).
• If datagram cannot pass through the Physical network
then discard it.
– M bit is called the more fragment bit (1->more
fragments are present, 0-> last fragment).
– 13-bit fragmentation offset field: shows the
relative position of this fragment with respect to
the whole datagram

11/21/24 Unit-3 : Network Layer 67


Fragment offset field
• 20 Bytes header.
• 65535 bytes in total.
• Datagram / frame can be 65535-20 =65515,
which is represented using 2 to the power 16.

• Offset field is 13 bits. Hence scaling down 


216/213

• 8 bits-. So all fragments must have size in


multiples of 8, except the last frame.

11/21/24 Unit-3 : Network Layer 68


11/21/24 Unit-3 : Network Layer 69
a. The first fragment has an offset field value of zero.
b. Divide the length of the first fragment by 8. The second
fragment has an offset value equal to that result.
c. Divide the total length of the first and second fragment
by 8. The third fragment has an offset value equal to that
result.
d. Continue the process. The last fragment has its M bit
set to 0.

11/21/24 Unit-3 : Network Layer 70


• This-host address: 0.0.0.0/32- It is used whenever a
host needs to send an IP datagram but it does not know its
own address to use as the source address.
• Limited-broadcast address : 255.255.255.255/32-
data sent to all devices
• Loopback address: 127.0.0.0/8 - A packet with one
of the addresses in this block as the destination
address never leaves the host
• Private addresses: Four blocks are assigned as
private addresses: 10.0.0.0/8, 172.16.0.0/12,
192.168.0.0/16, and 169.254.0.0/16.
• Multicast addresses: 224.0.0.0/4 is reserved for
multicast addresses
11/21/24 Unit-3 : Network Layer 71
19.2 Addressing
Internet Address
Classful Addressing
Subnetting
Supernetting
Classless Addressing
Dynamic Address Configuration
Network Address Translation
11/21/24 Unit-3 : Network Layer 72
Note:

An IP address is a 32-bit address.

The IP address is the address of the connection, not


the host or the router, because if the device is
moved to another network, the IP address may be
changed

11/21/24 Unit-3 : Network Layer 73


Note:

The IP addresses are unique


and universal.

11/21/24 Unit-3 : Network Layer 74


Address Space
•A protocol like 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 b bits to define an address, the
address space is 2b.

•IPV4 – b=32 - 4,294,967,296

11/21/24 Unit-3 : Network Layer 75


Figure 19.9 Dotted-decimal notation

Notation

11/21/24 Unit-3 : Network Layer 76


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

Solution
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

11/21/24 Unit-3 : Network Layer 77


Example 2
Change the following IP addresses from dotted-decimal notation to
binary notation.
a. 111.56.45.78
b. 75.45.34.78

Solution
We replace each decimal number with its binary equivalent
(see Appendix B):

a. 01101111 00111000 00101101 01001110


b. 01001011 00101101 00100010 01001110

11/21/24 Unit-3 : Network Layer 78


Note:

In classful addressing, the address


space is divided into five classes: A, B,
C, D, and E.

• ADDRESSING – TWO PARTS –


• PREFIX (NETWORK )AND
• SUFFIX (NODE)
11/21/24 Unit-3 : Network Layer 79
Figure 19.10 Finding the class in binary notation

11/21/24 Unit-3 : Network Layer 80


11/21/24 Unit-3 : Network Layer 81
Figure 19.11 Finding the address class

11/21/24 Unit-3 : Network Layer 82


Example 3
Find the class of each address:
a. 00000001 00001011 00001011 11101111
b. 11110011
1111 10011011 11111011 00001111

Solution
See the procedure in Figure 19.11.

a. The first bit is 0; this is a class A address.


b. The first 4 bits are 1s; this is a class E address.

11/21/24 Unit-3 : Network Layer 83


Figure 19.12 Finding the class in decimal notation

11/21/24 Unit-3 : Network Layer 84


Example 4
Find the class of each address:
a. 227.12.14.87
b. 252.5.15.111
c. 134.11.78.56

Solution
a. The first byte is 227 (between 224 and 239); the class is D.
b. The first byte is 252 (between 240 and 255); the class is E.
c. The first byte is 134 (between 128 and 191); the class is B.

11/21/24 Unit-3 : Network Layer 85


Figure 19.13 Netid and hostid

11/21/24 Unit-3 : Network Layer 86


Figure 19.14 Blocks in class A

11/21/24 Unit-3 : Network Layer 87


SUBNET AND SUPERNET
• CLASS A- PREFIX – 8BITS.
• 24 BITS FOR DEVICES.
• IF WE DIVIDE THIS CLASS A INTO 4 SUB-
NETWORKS.
• 10 SUB NETWORKS – 4 BITS – 1010
• 01100111 _ _ _ _
• 8- 3 BITS 000 001 010 011 100 101 110 111
• 0110000 00 4
11/21/24 Unit-3 : Network Layer 88
Note:

Millions of class A addresses are


wasted.

ADDRESS DEPLETION – THOUGH


THERE ARE ENOUGH UNIQUE
ADDRESSES IT, MANY WERE
UNUSED.
11/21/24 Unit-3 : Network Layer 89
Figure 19.15 Blocks in class B

11/21/24 Unit-3 : Network Layer 90


Note:

Many class B addresses are wasted.

11/21/24 Unit-3 : Network Layer 91


Note:

The number of addresses in class C is


smaller than the needs of most
organizations.

11/21/24 Unit-3 : Network Layer 92


Figure 19.16 Blocks in class C

11/21/24 Unit-3 : Network Layer 93


Note:

In classful addressing, the network


address is the one that is assigned to
the organization.

11/21/24 Unit-3 : Network Layer 94


Example 5
Given the address 23.56.7.91, find the network address.

Solution
The class is A. Only the first byte defines the netid. We can find the
network address by replacing the hostid bytes (56.7.91) with 0s. Therefore,
the network address is 23.0.0.0.

11/21/24 Unit-3 : Network Layer 95


Example 6
Given the address 132.6.17.85, find the network address.

Solution

11/21/24 Unit-3 : Network Layer 96


Example 7
Given the network address 17.0.0.0, find the class.

Solution
The class is A because the netid is only 1 byte.

11/21/24 Unit-3 : Network Layer 97


Note:

A network address is different from a


netid. A network address has both
netid and hostid,
with 0s for the hostid.

11/21/24 Unit-3 : Network Layer 98


Note:

IP addresses are designed with two


levels of hierarchy.

11/21/24 Unit-3 : Network Layer 99


Figure 19.19 A network with two levels of hierarchy

11/21/24 Unit-3 : Network Layer 100


Figure 19.20 A network with three levels of hierarchy (subnetted)

11/21/24 Unit-3 : Network Layer 101


In classless addressing, variable-length blocks are used
that belong to no classes.
PREFIX –BLOCK-NETWORK ADDRESS
SUFFIX- NODE
2 ^0, 2^1, ……2^32
RESTRICTION – THE ADDRESSES IN A BLOCK MUST
BE IN POWER OF 2.
PREFIX IS SMALL – LARGE NETWORK
PREFIX –LARGE-SMALLER NETWORK
SIZE OF NETWORK IS INVERSELY PROPORTIONAL
TO THE PREFIX LENGTH.

11/21/24 Unit-3 : Network Layer 102


CLASSLESS
• HOW TO IDENTIFY THE PREFIX
(NETWORK ADDRESS)??
– Slash notation -CIDR – CLASSLESS
INTERDOMAIN ROUTING
– 18.12.14.2/4
– 00010010.00001100.00001110.00000010 /4

11/21/24 Unit-3 : Network Layer 103


Extracting Information from an Address
• Three pieces of information need to be
known about the block to which the
address belongs:
– the number of addresses,
– the first address
– the last address
SOLUTIONS – NETWORK
LAYER QUIZ – 25/11/2020
• Determine if a datagram with the following
information is a first fragment, a middle
fragment, a last fragment, or the only
fragment (no fragmentation):
• a. M-bit is set to 1 and the value of the
offset field is zero.
• b. M-bit is set to 1 and the value of the
offset field is nonzero.(1 point)
11/21/24 Unit-3 : Network Layer 105
11/21/24 Unit-3 : Network Layer 106
160
5 – 5*4 = 20
160-20=140 BYTES

11/21/24 Unit-3 : Network Layer 107


14.12.72.8 /24
00001110.00001100.01001000.00001000
1st 00001110.00001100.01001000. 00000000
last : 00001110.00001100.01001000.11111111

11/21/24 Unit-3 : Network Layer 108


ADDRESS MASK
• ADDRESS MASK IS: LEFTMOST ‘n’ BITS ARE 1S AND
32-n BITS ARE ALL 0S. (14.12.72.8 /24)
• 11111111 11111111 11111111 00000000.
– The number of addresses in the block N = NOT
(Mask) + 1.
• 00000000 00000000 00000000 11111111
1
• 00000000 00000000 00000001 00000000
– The first address in the block = (Any address in the
block) AND (Mask).
– The last address in the block = (Any address in the
block) OR [(NOT (Mask)].

11/21/24 Unit-3 : Network Layer 109


• 167.199.170.82 / 27 Last Address:
• Address mask?? 11111111 11111111 10100111 11000111 10101010
11111111 11100000 01010010
Number of addresses: OR
NOT(MASK) +1 NOT (11111111 11111111 11111111
00000000 00000000 00000000 00011111 11100000)
THAT IS : 00000000 000000000
1 00000000 00011111
00000000 00000000 00000000 00100000 10100111 11000111 10101010 01010010
2^5 = 32 ADDRESSES. Last address: 167.199.170.95

First Address:
10100111 11000111 10101010
01010010
AND
11111111 11111111 11111111
11100000
10100111 11000111 10101010
01000000
first address:167.199.170.64

11/21/24 Unit-3 : Network Layer 110


• 167.199.170.82 / 27
10100111 11000111 10101010 01000000

82 -> 90
167.199.170.90 /27 (even when other address
from the block is considered, we still get the
same first address.)
10100111 11000111 10101010 01011010
11111111 11111111 11111111 11100000
10100111 11000111 10101010 01000000
167.199.170.64

11/21/24 Unit-3 : Network Layer 111


14.12.72.8 /24
• Number of addresses: 256
• First address: 14.12.72.0
• Last address: 14.12.72.255

11/21/24 Unit-3 : Network Layer 112


Figure 19.21 Addresses in a network with and without subnetting

11/21/24 Unit-3 : Network Layer 113


The address 230.8.24.56 can belong to many blocks.

Prefix length:16 → Block: 230.8.0.0 to 230.8.255.255


Prefix length:20 → Block: 230.8.16.0 to 230.8.31.255
Prefix length:26 → Block: 230.8.24.0 to 230.8.24.63
Prefix length:27 → Block: 230.8.24.32 to 230.8.24.63
Prefix length:29 → Block: 230.8.24.56 to 230.8.24.63
Prefix length:31 → Block: 230.8.24.56 to 230.8.24.57

11/21/24 Unit-3 : Network Layer 114


11/21/24 Unit-3 : Network Layer 115
• Let us assume that an internet is made of m networks
and a router with m interfaces.
• When a packet arrives at the router from any source
host, the router needs to know to which network the
packet should be sent: from which interface the packet
should be sent out.
• When the packet arrives at the network, it reaches its
destination host using another strategy.
• The router consults its forwarding table to find the
corresponding interface from which the packet should be
sent out.
• The network address is actually the identifier of the
network; each network is identified by its network
address.
DESIGNING SUBNETS
• Assume the total number of addresses granted to
the organization is N, the prefix length is n, the
assigned number of addresses to each sub-
network is Nsub, and the prefix length for each sub-
network is nsub.
• The number of addresses in each sub-network
should be a power of 2.
• The prefix length for each sub-network should be
found using the following formula:
• The starting address in each sub-network should
be divisible by the number of addresses in that
sub-network. (first assign addresses to larger sub-
networks).
An organization is granted a block of addresses with the
beginning address 14.24.74.0/24. The
organization needs to have 3 subblocks of addresses to
use in its three subnets: one subblock of 10
addresses, one subblock of 60 addresses, and one
subblock of 120 addresses. Design the subblocks.
• Main network – prefix – ‘n’ = 24
• 14.24.74.0
– 3 sub networks????
• Total addresses in each sub-network must be
known.
• Prefix for each sub-network. nsub=32-log2 Nsub.

11/21/24 Unit-3 : Network Layer 118


11/21/24 Unit-3 : Network Layer 119
Address Aggregation
• One of the advantages of the CIDR strategy is
address aggregation. (sometimes called address
summarization or route summarization).
• When blocks of addresses are combined
• to create a larger block, routing can be done
based on the prefix of the larger block.
• ICANN - (Internet Corporation for Assigned
Names and Numbers)assigns a large block of
addresses to an ISP.

11/21/24 Unit-3 : Network Layer 120


11/21/24 Unit-3 : Network Layer 121
Special Addresses
• This-host address:
• Limited-broadcast address:
• Loopback address:
• Private addresses:
• Multicast addresses:

11/21/24 Unit-3 : Network Layer 122


Forwarding of IP Packets
• Forwarding means to place the packet in its
route to its destination.
• In Internet (combinations of networks),
forwarding means to deliver the packet to the
next hop.
• When IP is used as a connectionless protocol,
forwarding is based on the destination address of
the IP datagram.
• When the IP is used as a connection-oriented
protocol, forwarding is based on the label
attached to an IP datagram.
In each row, the n leftmost bits of the destination address (prefix)
are kept and the rest of the bits (suffix) are set to 0s. If the resulting
address (which we call the network address), matches with the
address in the first column, the information in the next two columns
is extracted; otherwise the search continues.

11/21/24 Unit-3 : Network Layer 124


180.70.65.192/26

11/21/24 Unit-3 : Network Layer 125


Show the forwarding process if a packet arrives at R1 in Figure
with the destination address 180.70.65.140

• The first mask (/26) is applied to the destination address. The result is
180.70.65.128, which does not match the corresponding network
address.
• The second mask (/25) is applied to the destination address. The result
is 180.70.65.128, which matches the corresponding network address.
The next-hop address and the interface number m0 are extracted for
forwarding the packet
• 180.70.65.140
• Apply the first row’s mask that is 26.
– 10110100 01000110 01000001 10000000
– The network address does not match the first row’s network
address.
– Not sent to interface m2

• 180.70.65.140 / 25
– 10110100 01000110 01000001 10000000
– The network address of 2nd row matches the
destination’s network address.
– Sent to interface m0.

11/21/24 Unit-3 : Network Layer 127


An ISP is granted the block 80.70.56.0/21. The ISP
needs to allocate addresses for two organizations
each with 500 addresses, two organizations each with
250 addresses, and three organizations each with 50
addresses.
a.Find the number and range of addresses in the ISP
block.
b.Find the range of addresses for each organization
and the range of unallocated addresses.
c. Show the outline of
11/21/24 the
Unit-3 address
: Network Layer distribution and 128
the
forwarding table.
ADDRESS AGGREGATION

11/21/24 Unit-3 : Network Layer 129


11/21/24 Unit-3 : Network Layer 130
11/21/24 Unit-3 : Network Layer 131
140.24.7.200
R2 FORWARDING TABLE
•140.24.7.192 / 26
•140.24.7.0 / 24
•140.24.7. 11000000
140.24.7.0
140.24.7. 11001000

11/21/24 Unit-3 : Network Layer 132


FORWARDING OF IP PACKETS BASED ON
LABEL

• In a connection-oriented network (virtual-


circuit approach), a switch forwards a
packet based on the label attached to the
packet.

11/21/24 Unit-3 : Network Layer 133


11/21/24 Unit-3 : Network Layer 134
Multi-Protocol Label Switching (MPLS)
• IETF approved this standard.
• MPLS routers, can behave like a router and
a switch.
• When behaving like a router, MPLS can
forward the packet based on the
destination address; when behaving like a
switch, it can forward a packet based on
the label.
• The MPLS header is actually a stack of
sub-headers that is used for multilevel
hierarchical switching.
11/21/24 Unit-3 : Network Layer 136
• Label: This 20-bit field defines the label that
is used to index the forwarding table in the
router.
• Exp: This 3-bit field is reserved for
experimental purposes.
• S: The one-bit stack field defines the
situation of the sub-header in the stack.
When the bit is 1, it means that the header
is the last one in the stack.
• TTL: This 8-bit field is similar to the TTL
field in the IP datagram
Table 19.1 Default masks
In Dotted-
Class In Binary Using Slash
Decimal

A 11111111 00000000 00000000 00000000 255.0.0.0 /8

B 11111111 11111111 00000000 00000000 255.255.0.0 /16

C 11111111 111111111 11111111 00000000 255.255.255.0 /24

11/21/24 Unit-3 : Network Layer 138


Note:

The network address can be found


by applying the default mask to any
address in the block (including itself).
It retains the netid of the block and
sets the hostid to 0s.

11/21/24 Unit-3 : Network Layer 139


Example 8
A router outside the organization receives a packet with destination
address 190.240.7.91. Show how it finds the network address to
route the packet.

Solution
The router follows three steps:
1. The router looks at the first byte of the address to find the
class. It is class B.
2. The default mask for class B is 255.255.0.0. The router ANDs
this mask with the address to get 190.240.0.0.
3. The router looks in its routing table to find out how to route the
packet to this destination. Later, we will see what happens if
this destination does notUnit-3
11/21/24 exist.: Network Layer 140
Figure 19.23 Subnet mask

11/21/24 Unit-3 : Network Layer 141


Example 9
A router inside the organization receives the same packet with
destination address 190.240.33.91. Show how it finds the
subnetwork address to route the packet.

Solution
The router follows three steps:
1. The router must know the mask. We assume it is /19, as shown in
Figure 19.23.
2. The router applies the mask to the address, 190.240.33.91. The subnet
address is 190.240.32.0.
3. The router looks in its routing table to find how to route the packet to
this destination. Later, we will see what happens if this destination does
not exist.

11/21/24 Unit-3 : Network Layer 142


Table 19.2 Default masks

Range Total

10.0.0.0 to 10.255.255.255 224

172.16.0.0 to 172.31.255.255 220

192.168.0.0 to 192.168.255.255 216

11/21/24 Unit-3 : Network Layer 143


Figure 19.27 Translation

11/21/24 Unit-3 : Network Layer 144


Routing Algorithms

1.Distance Vector Routing


2.Link State Routing

11/21/24 Unit-3 : Network Layer 145


Figure 21-18
The Concept of Distance
Vector Routing

11/21/24 Unit-3 : Network Layer 146


Figure 21-19

Distance Vector Routing Table

11/21/24 Unit-3 : Network Layer 147


Figure 21-20

Routing Table Distribution

11/21/24 Unit-3 : Network Layer 148


Figure 21-21

Updating Routing Table for Router A

11/21/24 Unit-3 : Network Layer 149


Figure 21-22
Final Routing Tables

11/21/24 Unit-3 : Network Layer 150


Figure 21-23
Example 21.1

11/21/24 Unit-3 : Network Layer 151


Figure 21-24
Concept of Link State Routing

11/21/24 Unit-3 : Network Layer 152


Figure 21-25
Cost in Link State Routing

11/21/24 Unit-3 : Network Layer 153


Figure 21-26

Link State Packet

11/21/24 Unit-3 : Network Layer 154


Figure 21-27
Flooding of A’s LSP

11/21/24 Unit-3 : Network Layer 155


Figure 21-28
Link State Database

11/21/24 Unit-3 : Network Layer 156


Figure 21-29

Costs in the Dijkstra Algorithm

11/21/24 Unit-3 : Network Layer 157


Figure 21-30, Part I

Shortest Path Calculation, Part I

11/21/24 Unit-3 : Network Layer 158


Figure 21-30, Part II

Shortest Path Calculation, Part II

11/21/24 Unit-3 : Network Layer 159


Figure 21-30, Part III

Shortest Path Calculation, Part III

11/21/24 Unit-3 : Network Layer 160


Figure 21-30, Part IV

Shortest Path Calculation, Part IV

11/21/24 Unit-3 : Network Layer 161


Figure 21-30, Part V

Shortest Path Calculation, Part V

11/21/24 Unit-3 : Network Layer 162


Figure 21-30, Part VI

Shortest Path Calculation, Part VI

11/21/24 Unit-3 : Network Layer 163


Figure 21-31, Part VII

Shortest Path Calculation, Part VII

11/21/24 Unit-3 : Network Layer 164


Figure 21-31, Part I

Shortest Path Calculation, Part VIII

11/21/24 Unit-3 : Network Layer 165


Figure 21-31, Part II

Shortest Path Calculation, Part IX

11/21/24 Unit-3 : Network Layer 166


Figure 21-31, Part III

Shortest Path Calculation, Part X

11/21/24 Unit-3 : Network Layer 167


Figure 21-31, Part IV
Shortest Path Calculation, Part XI

11/21/24 Unit-3 : Network Layer 168


Figure 21-31, Part V

Shortest Path Calculation, Part XII

11/21/24 Unit-3 : Network Layer 169


Figure 21-31, Part VI

Shortest Path Calculation, Part XIII

11/21/24 Unit-3 : Network Layer 170


Figure 21-32
Routing Table for Router A

11/21/24 Unit-3 : Network Layer 171

You might also like