Sei sulla pagina 1di 26

What is Network Layer?

The network layer is concerned with getting packets from the source all the way to
the destination. The packets may require to make many hops at the intermediate
routers while reaching the destination. This is the lowest layer that deals with end
to end transmission. In order to achieve its goals, the network layer must know
about the topology of the communication network. It must also take care to choose
routes to avoid overloading of some of the communication lines while leaving
others idle. The network layer-transport layer interface frequently is the interface
between the carrier and the customer, that is the boundary of the subnet. The
functions of this layer include :

1. Routing - The process of transferring packets received from the Data Link
Layer of the source network to the Data Link Layer of the correct
destination network is called routing. Involves decision making at each
intermediate node on where to send the packet next so that it eventually
reaches its destination. The node which makes this choice is called a router.
For routing we require some mode of addressing which is recognized by the
Network Layer. This addressing is different from the MAC layer addressing.
2. Inter-networking - The network layer is the same across all physical
networks (such as Token-Ring and Ethernet). Thus, if two physically
different networks have to communicate, the packets that arrive at the Data
Link Layer of the node which connects these two physically different
networks, would be stripped of their headers and passed to the Network
Layer. The network layer would then pass this data to the Data Link Layer
of the other physical network..
3. Congestion Control - If the incoming rate of the packets arriving at any
router is more than the outgoing rate, then congestion is said to occur.
Congestion may be caused by many factors. If suddenly, packets begin
arriving on many input lines and all need the same output line, then a queue
will build up. If there is insufficient memory to hold all of them, packets
will be lost. But even if routers have an infinite amount of memory,
congestion gets worse, because by the time packets reach to the front of the
queue, they have already timed out (repeatedly), and duplicates have been
sent. All these packets are dutifully forwarded to the next router, increasing
the load all the way to the destination. Another reason for congestion are
slow processors. If the router's CPUs are slow at performing the
bookkeeping tasks required of them, queues can build up, even though there
is excess line capacity. Similarly, low-bandwidth lines can also cause
congestion.

We will now look at these function one by one.

Addressing Scheme
IP addresses are of 4 bytes and consist of :
i) The network address, followed by
ii) The host address
The first part identifies a network on which the host resides and the second part
identifies the particular host on the given network. Some nodes which have more
than one interface to a network must be assigned separate internet addresses for
each interface. This multi-layer addressing makes it easier to find and deliver data
to the destination. A fixed size for each of these would lead to wastage or under-
usage that is either there will be too many network addresses and few hosts in each
(which causes problems for routers who route based on the network address) or
there will be very few network addresses and lots of hosts (which will be a waste
for small network requirements). Thus, we do away with any notion of fixed sizes
for the network and host addresses.
We classify networks as follows:

1. Large Networks : 8-bit network address and 24-bit host address. There are
approximately 16 million hosts per network and a maximum of 126 ( 2^7 - 2
) Class A networks can be defined. The calculation requires that 2 be
subtracted because 0.0.0.0 is reserved for use as the default route and
127.0.0.0 be reserved for the loop back function. Moreover each Class A
network can support a maximum of 16,777,214 (2^24 - 2) hosts per
network. The host calculation requires that 2 be subtracted because all 0's
are reserved to identify the network itself and all 1s are reserved for
broadcast addresses. The reserved numbers may not be assigned to
individual hosts.
2. Medium Networks : 16-bit network address and 16-bit host address. There
are approximately 65000 hosts per network and a maximum of 16,384
(2^14) Class B networks can be defined with up to (2^16-2) hosts per
network.
3. Small networks : 24-bit network address and 8-bit host address. There are
approximately 250 hosts per network.

Switching in Computer Networks-


 

The process of moving the data packets towards their destination by forwarding them from one
port to the other port is called as switching.

 
Switching Techniques-
 
Various switching techniques are-
1. Circuit Switching
2. Message Switching
3. Packet Switching
 

Circuit Switching-
1. Establishing a circuit
2. Transferring the data
3. Disconnecting the circuit
 

1. Establishing A Circuit-
 
In this phase,

 A circuit is established between the two ends.


 Circuit provides a dedicated path for data to travel from one to the other end.
 Resources are reserved at intermediate switches which are used during the
transmission.
 The intermediate switches are connected by the physical links.
2. Transferring The Data-
 
After the circuit is established,

 The entire data travels over the dedicated path from one end to the other end.
 

3. Disconnecting The Circuit-


 
After the data transfer is completed,

 The circuit is torn down i.e. disconnected.


 

Total Time-
 

Total time taken to transmit a message in circuit switched network


= Connection set up time + Transmission delay + Propagation delay + Tear down time

 
where-

 Transmission delay = Message size / Bandwidth


 Propagation delay = (Number of hops on way x Distance between 2 hops) /
Propagation speed
 
Advantages-
 
Circuit switching has the following advantages-

 A well defined and dedicated path exists for the data to travel.
 There is no header overhead.
 There is no waiting time at any switch and the data is transmitted without any
delay.
 Data always reaches the other end in order.
 No re ordering is required.
 

Disadvantages-
 
Circuit switching has the following disadvantages-

 The channel is blocked for two ends only.


 It is inefficient in terms of utilization of system resources.
 The time required for establishing the circuit between the two ends is too long.
 Dedicated channels require more bandwidth.
 It is more expensive than other switching techniques.
 Routing decisions can not be changed once the circuit is established.
 

Important Notes-
 

 Circuit switching is implemented at physical layer.


 Circuit switching is now outdated.
 

PRACTICE PROBLEM BASED ON CIRCUIT SWITCHING TECHNIQUE-


 

Problem-
 
Consider all links in the network use TDM with 24 slots and have a data rate of 1.536
Mbps. Assume that host A takes 500 msec to establish an end to end circuit with host B
before begin to transmit the file. If the file is 512 kilobytes, then how much time will it
take to send the file from host A to host B?
 

Solution-
 
Given-

 Total bandwidth = 1.536 Mbps


 Bandwidth is shared among 24 slots
 Connection set up time = 500 msec
 File size = 512 KB
 

Calculating Bandwidth Per User-


 
Total bandwidth = Number of users x Bandwidth per user
So, Bandwidth per user
= Total bandwidth / Number of users
= 1.536 Mbps / 24
= 0.064 Mbps
= 64 Kbps
 

Calculating Transmission Delay-


 
Transmission delay (Tt)
= File size / Bandwidth
= 512 KB / 64 Kbps
=  (512 x 210 x 8 bits) / (64 x 103 bits per sec)
= 65.536 sec
= 65536 msec
 

Calculating Time Required To Send File-


 
Time taken to send a file in circuit switched network
= Connection set up time + Transmission delay
= 500 msec + 65536 msec
= 66036 sec
=66.036 msec

Message Switching-
 
In message switching,

 There exists no dedicated path to transfer data.


 The entire message is treated as a single data unit.
 The message is then forwarded from hop to hop.
 Store and Forward is an important characteristic of message switching.
 The message carries a header that contains the full information about the
destination.
 When any intermediate switch receives the message, it stores the entire
message.
 The message is stored until sufficient resources become available to transfer it to
the next switch.
 When resources become available, the switch forwards the message to the next
switch.
 

Advantages-
 

Point-01:
 

 It improves the channel efficiency over Circuit Switched Network.


 In circuit switched network, the channel is blocked for two ends only.
 But here, more devices can share the channel.
 

Point-02:
 

 It is helpful in reducing traffic congestion.


 The message may be temporarily stored in the route and then forwarded
whenever required.
 

Point-03:
 

 It is helpful in setting the message priorities due to store and forward technique.
 

Disadvantages-
 

Point-01:
 

 It requires enough storage at every switch to accommodate the entire message


during the transmission.
 

Point-02:
 

 It is extremely slow due to store and forward technique.


 Also, the message has to wait until sufficient resources become available to
transfer it to the next switch.
 

Message switching is replaced by Packet switching.

 
To gain better understanding about Message Switching,

Packet Switching-
 
In packet switching,

 The entire message to be sent is divided into multiple smaller size packets.
 This process of dividing a single message into smaller size packets is called
as packetization.
 These smaller packets are sent after the other.
 It gives the advantage of pipelining and reduces the total time taken to transmit
the message.
 

Optimal Packet Size-


 
If the packet size is not chosen wisely, then-

 It may result in adverse effects.


 It might increase the time taken to transmit the message.
So, it is very important to choose the packet size wisely.
 

Example-
 
Consider-

 There is a network having bandwidth of 1 MBps.


 A message of size 1000 bytes has to be sent.
 Packet switching technique is used.
 Each packet contains a header of 100 bytes.
 

 
Out of the following, in how many packets the message must be divided so that total
time taken is minimum-
1. 1 packet
2. 5 packets
3. 10 packets
4. 20 packets
 

NOTE
 While calculating the total time, we often ignore the propagation delay.
 The reason is in packet switching, transmission delay dominates over propagation delay.
 This is because each packet is transmitted over the link at each hop.

 
Let us analyze each case one by one.
 

Case-01: Sending Message in 1 Packet-


 
In this case, the entire message is sent in a single packet.
 

Size Of Packet-
 
Packet size
= 1000 bytes of data + 100 bytes of header
= 1100 bytes
 

Transmission Delay-
 
Transmission delay
= Packet size / Bandwidth
= 1100 bytes / 1 MBps
=  1100 x 10-6 sec
= 1100 μsec
= 1.1 msec
 

Total Time Taken-


 
Total time taken to send the complete message from sender to receiver
= 3 x Transmission delay
= 3 x 1.1 msec
= 3.3 msec
 

Case-02: Sending Message in 5 Packets-


 
In this case,

 The entire message is divided into total 5 packets.


 These packets are then sent one after the other.
 

Data Sent in One Packet-


 
Data sent in one packet
= Total data to be sent / Number of packets
= 1000 bytes / 5
= 200 bytes
 

Size Of One Packet-


 
Packet size
= 200 bytes of data + 100 bytes of header
= 300 bytes
 

Transmission Delay-
 
Transmission delay
= Packet size / Bandwidth
= 300 bytes / 1 MBps
=  300 x 10-6 sec
= 300 μsec
= 0.3 msec
 

Time Taken By First Packet-


 
Time taken by the first packet to reach from sender to receiver
= 3 x Transmission delay
= 3 x 0.3 msec
= 0.9 msec
 

Time Taken By Remaining Packets-


 
Time taken by the remaining packets to reach from sender to receiver
= Number of remaining packets x Transmission delay
= 4 x 0.3 msec
= 1.2 msec
 

Total Time Taken-


 
Total time taken to send the complete message from sender to receiver
= 0.9 msec + 1.2 msec
= 2.1 msec
 

Case-03: Sending Data in 10 packets-


 
In this case,

 The entire message is divided into total 10 packets.


 These packets are then sent one after the other.
 

Data Sent in One Packet-


 
Data sent in one packet
= Total data to be sent / Number of packets
= 1000 bytes / 10
= 100 bytes
 

Size Of One Packet-


 
Packet size
= 100 bytes of data + 100 bytes of header
= 200 bytes
 

Transmission Delay-
 
Transmission delay
= Packet size / Bandwidth
= 200 bytes / 1 MBps
=  200 x 10-6 sec
= 200 μsec
= 0.2 msec
 

Time Taken By First Packet-


 
Time taken by the first packet to reach from sender to receiver
= 3 x Transmission delay
= 3 x 0.2 msec
= 0.6 msec
 

Time Taken By Remaining Packets-


 
Time taken by the remaining packets to reach from sender to receiver
= Number of remaining packets x Transmission delay
= 9 x 0.2 msec
= 1.8 msec
 

Total Time Taken-


 
Total time taken to send the complete message from sender to receiver
= 0.6 msec + 1.8 msec
= 2.4 msec
 

Case-04: Sending Data in 20 Packets-


 
In this case,

 The entire message is divided into total 5 packets.


 These packets are then sent one after the other.
 

Data Sent in One Packet-


 
Data sent in one packet
= Total data to be sent / Number of packets
= 1000 bytes / 20
= 50 bytes
 

Size Of One Packet-


 
Packet size
= 50 bytes of data + 100 bytes of header
= 150 bytes
 

Transmission Delay-
 
Transmission delay
= Packet size / Bandwidth
= 150 bytes / 1 MBps
=  150 x 10-6 sec
= 150 μsec
= 0.15 msec
 

Time Taken By First Packet-


 
Time taken by the first packet to reach from sender to receiver
= 3 x Transmission delay
= 3 x 0.15 msec
= 0.45 msec
 

Time Taken By Remaining Packets-


 
Time taken by the remaining packets to reach from sender to receiver
= Number of remaining packets x Transmission delay
= 19 x 0.15 msec
= 2.85 msec
 

Total Time Taken-


 
Total time taken to send the complete message from sender to receiver
= 0.45 msec + 2.85 msec
= 3.3 msec
 

Observations-
 

 When data is sent in 1 packet, total time taken = 3.3 msec


 When data is sent in 5 packets, total time taken = 2.1 msec
 When data is sent in 10 packets, total time taken = 2.4 msec
 When data is sent in 20 packets, total time taken = 3.3 msec
 

Conclusion-
 
We conclude-

 Total time decreases when packet size is reduced but only up to a certain limit.
 If the packet size is reduced beyond a certain limit, then total time starts
increasing.
 
From the given choices,

 Sending the message in 5 packets would be most efficient.


 In other words, packet size = 300 bytes would be the best choice.
 

Types of Packet Switching-


 
Packet switching may be carried out in the following 2 ways-
 

 
1. Virtual Circuit Switching
2. Datagram Switching
 

Virtual Circuit Switching-


 
Virtual circuit switching operates in the following three phases-
1. Establishing a circuit
2. Transferring the data
3. Disconnecting the circuit
 

1. Establishing A Circuit-
 
In this phase,

 A logical connection is established between the two ends.


 It provides a dedicated path for data to travel from one to the other end.
 Resources are reserved at intermediate switches which are used during the
transmission.
 

2. Transferring The Data-


 
After the connection is established,
 The entire data travels over the dedicated path from one end to the other end.
 

3. Disconnecting The Circuit-


 
After the data transfer is completed,

 The connection is disconnected.


 

Datagram Switching-
 
In datagram switching,

 There exists no dedicated path for data to travel.


 The header of each packet contains the destination address.
 When any intermediate switch receives the packet, it examines its destination
address.
 It then consults the routing table.
 Routing table finds the corresponding port through which the packet should be
forwarded.
 

Virtual Circuit Switching Vs Datagram Switching-


 
The following table shows a comparison between virtual circuit switching and datagram
switching-
 

Virtual Circuit Switching Datagram Switching

The first packet during its transmission-


1) Informs the intermediate switches that
more packets are following. The first packet does not perform any such
task during its transmission.
2) Reserve resources (CPU, bandwidth and
buffer) for the following packets at all the
switches on the way.

The packets are never discarded at


The packets may be discarded at intermediate
intermediate switches and immediately
switches if sufficient resources are not
forwarded since resources are reserved for
available to process the packets.
them.

It is a connection oriented service since


It is a connection less service since no
resources are reserved for the packets at
resources are reserved for the packets.
intermediate switches.

All the packets follow the same dedicated


All the packets take path independently.
path.

Data appears in order at the destination Data may appear out of order at the
since all the packets take the same destination since the packets take path
dedicated path. independently.

It is highly reliable since no packets are It is not reliable since packets may be
discarded. discarded.
It is costly. It is cost effective.

Only first packet requires a global header


which identifies the path from one end to
other end. All the packets require a global header which
contains full information about the destination.
All the following packets require a local
header which identifies the path from hop to
hop.

ATM (Asynchronous Transfer Mode) uses


IP Networks use datagram switching.
virtual circuit switching.

Virtual circuit switching is normally Datagram switching is normally implemented


implemented at data link layer. at network layer.

PRACTICE PROBLEM BASED ON PACKET SWITCHING TECHNIQUE-


 

Problem-
 
In a packet switching network, packets are routed from source to destination along a
single path having two intermediate nodes. If the message size is 24 bytes and each
packet contains a header of 3 bytes, then the optimum packet size is-
1. 4 bytes
2. 6 bytes
3. 7 bytes
4. 9 bytes
 

Solution-
 

 
Let bandwidth of the network = X Bps and 1 / X = a
 

Option-A: Packet Size = 4 Bytes


 
In this case,

 The entire message is divided into packets of size 4 bytes.


 These packets are then sent one after the other.
 

Data Sent in One Packet- 


 
Data size
= Packet size – Header size
= 4 bytes – 3 bytes
= 1 byte
Thus, only 1 byte of data can be sent in each packet.
 

Number Of Packets-
 
Number of packets required
= Total data to be sent / Data contained in one packet
= 24 bytes / 1 byte
= 24 packets
 

Transmission Delay-
 
Transmission delay
= Packet size / Bandwidth
= 4 bytes / X Bps
=  4a sec
 

Time Taken By First Packet-


 
Time taken by the first packet to reach from sender to receiver
= 3 x Transmission delay
= 3 x 4a sec
= 12a sec
 

Time Taken By Remaining Packets-


 
Time taken by the remaining packets to reach from sender to receiver
= Number of remaining packets x Transmission delay
= 23 x 4a sec
= 92a sec
 

Total Time Taken-


 
Total time taken to send the complete message from sender to receiver
= 12a sec + 92a sec
= 104a sec
 

Option-B: Packet Size = 6 bytes


 
In this case,

 The entire message is divided into packets of size 6 bytes.


 These packets are then sent one after the other.
 

Data Sent in One Packet-


 
Data size
= Packet size – Header size
= 6 bytes – 3 bytes
= 3 bytes
Thus, only 3 bytes of data can be sent in each packet.
 

Number Of Packets-
 
Number of packets required
= Total data to be sent / Data contained in one packet
= 24 bytes / 3 bytes
= 8 packets
 

Transmission Delay-
 
Transmission delay
= Packet size / Bandwidth
= 6 bytes / X Bps
=  6a sec
 

Time Taken By First Packet-


 
Time taken by the first packet to reach from sender to receiver
= 3 x Transmission delay
= 3 x 6a sec
= 18a sec
 

Time Taken By Remaining Packets-


 
Time taken by the remaining packets to reach from sender to receiver
= Number of remaining packets x Transmission delay
= 7 x 6a sec
= 42a sec
 

Total Time Taken-


 
Total time taken to send the complete message from sender to receiver
= 18a sec + 42a sec
= 60a sec
 

Option-C: Packet Size = 7 bytes


 
In this case,

 The entire message is divided into packets of size 7 bytes.


 These packets are then sent one after the other.
 

Data Sent in One Packet-


 
Data size
= Packet size – Header size
= 7 bytes – 3 bytes
= 4 bytes
Thus, only 4 bytes of data can be sent in each packet.
 

Number Of Packets-
 
Number of packets required
= Total data to be sent / Data contained in one packet
= 24 bytes / 4 bytes
= 6 packets
 

Transmission Delay-
 
Transmission delay
= Packet size / Bandwidth
= 7 bytes / X Bps
=  7a sec
 

Time Taken By First Packet-


 
Time taken by the first packet to reach from sender to receiver
= 3 x Transmission delay
= 3 x 7a sec
= 21a sec
 

Time Taken By Remaining Packets-


 
Time taken by the remaining packets to reach from sender to receiver
= Number of remaining packets x Transmission delay
= 5 x 7a sec
= 35a sec
 

Total Time Taken-


 
Total time taken to send the complete message from sender to receiver
= 21a sec + 35a sec
= 56a sec
 

Option-D: Packet size = 9 Bytes


 
In this case,

 The entire message is divided into packets of size 9 bytes.


 These packets are then sent one after the other.
 

Data Sent in One Packet-


 
Data size
= Packet size – Header size
= 9 bytes – 3 bytes
= 6 bytes
Thus, only 6 bytes of data can be sent in each packet.
 

Number Of Packets-
 
Number of packets required
= Total data to be sent / Data contained in one packet
= 24 bytes / 6 bytes
= 4 packets
 

Transmission Delay-
 
Transmission delay
= Packet size / Bandwidth
= 9 bytes / X Bps
=  9a sec
 

Time Taken By First Packet-


 
Time taken by the first packet to reach from sender to receiver
= 3 x Transmission delay
= 3 x 9a sec
= 27a sec
 

Time Taken By Remaining Packets-


 
Time taken by the remaining packets to reach from sender to receiver
= Number of remaining packets x Transmission delay
= 3 x 9a sec
= 27a sec
 

Total Time Taken-


 
Total time taken to send the complete message from sender to receiver
= 27a sec + 27a sec
= 54a sec
 

Observations-
 
From here,

 Total time taken when packet size is 4 bytes = 104a sec


 Total time taken when packet size is 6 bytes = 60a sec
 Total time taken when packet size is 7 bytes = 56a sec
 Total time taken when packet size is 9 bytes = 54a sec
 

Result-
 
Time taken is minimum when packet size is 9 bytes.
Thus, Option (D) is correct.

Difference Between Circuit Switching And Packet Switching-


 
The following table compares circuit switching and packet switching techniques-
 

Packet Switching
Circuit Switching
Virtual Circuit Switching Datagram Switching

Connection oriented service Connection oriented service Connection less service

Packets may be delivered out


Ensures in order delivery Ensures in order delivery
of order

No reordering is required No reordering is required Reordering is required

A dedicated path exists for A dedicated path exists for No dedicated path exists for
data transfer data transfer data transfer

All the packets take the same All the packets take the same All the packets may not take
path path the same path

Resources are allocated Resources are allocated on No resources are allocated


before data transfer demand using 1st packet

Stream oriented Packet oriented Packet oriented

Fixed bandwidth Dynamic Bandwidth Dynamic bandwidth

Reliable Reliable Unreliable

No header overheads Only label overheads Higher overheads

Implemented at data link


Implemented at physical layer Implemented at network layer
layer

Provides better efficiency


Inefficient in terms of Provides better efficiency
than message switched
resource utilization than circuit switched systems
systems

Example- Telephone systems Examples- X.25, Frame relay Example- Internet

Potrebbero piacerti anche