Computer Network
Computer Network
Chapter 1
1.1 INTRODUCTION
“Hello world”, which is data here, needs to be transmitted from the Sender
to Receiver, this transmission of data involves some set of protocols (will be
discussed in the next chapters) and this flow of data in a system is called
“Data Communication System”.
Data:
It is a huge subject in itself, but we limit it to the context/information which
needs to be transmitted from sender to receiver (in the above diagram “Hello
World” is a data).
Medium:
Data passes through a medium which can be wireless or wired (Twisted pair,
Coaxial cable or Optical fiber etc.)
Receiver:
One who receives data.
Protocol:
Computer Network Basics
Analog signal:
Data is represented in continuous waveforms.
Digital signal:
Data is represented in discrete form (0’s or 1’s/High or low).
Note:
Signals always varies with respect to time or frequency.
1
(time = ).
frequency
2) Medium:
Transmission medium is a channel through which data can be sent or received.
Computer Network Basics
Coaxial cable:
It has a copper wire as a core, surrounded by insulating materials, which further
surrounded by the braided outer conductor, which is further surrounded by a
plastic sheath. Computer Network Basics
Fiber Optics:
It sends information using lights instead of electrons. Light travels from the
core, a layer which surrounds the core is called cladding.
Fiber optics consist of the light source, transmission medium and detector.
Light pulse indicates 1 and absence of pulse indicates 0, the medium is thin,
fiberglass and detector generate electrical pulses when light falls on it.
Till now we have seen wired medium, now let us see wireless transmission
medium:
Waves which can be used for transmitting information are radio, micro, infrared
and some portion of visible light as they can be modulated and amplified
easily. UV, X and gamma rays do not propagate through the buildings; hence
not used for transmission frequently.
Note:
Data flow can be categorized in simplex mode, half duplex mode and full
Computer Network Basics
duplex mode.
Simplex mode: Only one of the two devices can send the data, hence the
entire channel is used for transmission, example: radio station.
Chapter 1
Half-Duplex mode: Any of the two devices can send or receive the data but
not at the same time; here entire channel is used for transmission or receiving
of data, example: Walkie Talkies.
Full-Duplex mode: Both devices can send and receive data simultaneously,
hence the entire is used for two purposes simultaneously which increases
the efficiency of the channel, for example: Telephone networks.
Topology:
Many links from topology, basically it is a representation of the physical and
logical structure.
Computer Network Basics
Bus topology:
All the nodes are connected to a shared cable.
There will be no central node.
One long cable act as a back-bone of this network.
For n devices, only 1 link is required.
Advantage:
Installation is easy, used for small networks, fewer cables are required.
Disadvantage:
Can be used with limited nodes; cable length is also limited.
Ring Topology:
Each device has a point to point connection only with two devices that are
on either side of a device.
If any device fails, the entire network gets down.
Each device in a ring has a repeater.
Message travel in a single direction.
If n nodes are present, then n physical links.
Advantages:
Using token, each device gets a fair chance to send a message.
Easy to install, good for long-distance.
Disadvantage:
If nodes get moved, it affects the performance.
If a node gets down, entire network gets down.
Computer Network Basics
Advantage:
If one node gets down, still message can flow through other paths.
Fault detection is easy because of the dedicated link.
Disadvantage:
Installation is not easy.
Expensive as more number of cables is used.
There is a possibility of a redundant path.
Tree Topology:
Collection of star topology in hierarchical level.
More devices can be added now as the network can grow by connecting
one central hub to another hub.
Advantage:
Easy to expand, Isolation of different network is possible.
Disadvantage:
If the central hub is down, the entire network goes down.
Cost is high because more number of cables will be required.
Computer Network Basics
10
Chapter 1
1.2 NETWORK TYPES
OSI Model:
International Organization of Standardization (ISO): proposed an open
systems interconnection (OSI) model, which allows two systems to
communicate irrespective of their architecture.
The aim of the OSI model: To represent how to provide communication
between the dissimilar systems without making any changes to the logic of
the underlying software and hardware.
OSI model is a 7 layered architecture.
Protocol Layering:
A list of protocols used by the system in which one protocol is used in each
layer is called protocol layering or protocol stack.
Each layer’s boundaries are decided in such a way that there should be a
minimum flow of information between each layer.
Note:
Computer Network Basics
OSI model has been widely used but the protocols “used in OSI” have been
forgotten.
12
Chapter 1
Fig. 1.14 The OSI Model
Before discussing each layer we must keep in mind that portion of the packet
at stage x-1 contains the whole packet of stage x. Stage x – 1 thinks that the
packet which is coming from stage x is one unit. One can say it follows the
encapsulation technique.
Physical layer:
It deals with the interface between the devices and the transmission
medium.
Computer Network Basics
13
Chapter 1
It deals with the transmission of raw bit through transmitting media the
Rack Your Brain
Data Link Layer:
It makes a frame move from one node to the next node.
It makes data from the physical layer error-free and sends to the network
layer.
It deals with framing (the process of division of data unit from network
layer into manageable streams called frames).
It deals with physical addressing (adding a physical address i.e. MAC
address, so that frame could reach the destination network)
If rates are mismatched between nodes, then the data link layer provides a
flow control mechanism.
Data link layer also see whom to give access if two or more device is
Computer Network Basics
14
Chapter 1
Network layer:
It deals with the delivery of packets from source host to destination host.
Logical addressing: Data link layer solves address issues locally, but the
network layer provides a logical address (IP address) in order to reach from
Source to destination when the packet reaches the destination network.
Network layer do routing: Several networks is interconnected with each
other through the router, and it is the responsibility of the network layer to
route the packet to the destination.
Transport layer:
It is the responsibility of the transport layer to deliver the message from the
source process to the destination process.
It does segmentation (splitting message from application layer into
segments) and reassembly (intact the message correctly on receiving the
destination).
It deals with port addresses in order to reach the service of the process
called port addressing.
Transport layer also determines service provided to the session layer, it
may be connection-oriented or connectionless services.
Flow control: At transport layer, flow control is done from end to end.
Error correction: It is usually done by retransmission if any error occurs.
Session layer:
It is the responsibility of a session layer to establish a session (dialog control
and synchronization) between sender and the receiver.
15
Chapter 1
Dialog control: Between a link, it keeps an eye whose turn is now on the
link for sending the data.
Synchronization: It adds a checkpoint if the sender is sending a huge file,
eg: Sending a file of 1GB, it will add a checkpoint after 100KB so that if any
file gets lost, it will be easily recovered.
Presentation layer:
It deals with compression, translation and encryption.
Translation: It deals with the conversion of bits before sending a message.
Encryption: it deals with an encoded messages before sending; encryption
is done for security reason.
Compression: While sending a multimedia file, it compresses the file for
smooth transmission.
Application layer:
It deals with a variety of protocols which is useful for common clients.
The protocols are HTTP, FTP, DNS, SMTP. (We will discuss this in application
layer chapter.)
TCP/IP Model:
Protocols which are associated with the OSI model are not used in today’s
world, although the OSI model is still in use as it works as a framework for
other models because of its generalized structure.
If not OSI protocol, then whose protocols are we using now?
TCP/IP model
Below is a diagram of the TCP/IP model, which is similar to the OSI model.
Have a look at the difference between the two.
Computer Network Basics
Have you noticed presentation, session and physical layer are absent in
TCP/IP?
16
Chapter 1
Key similarities between OSI and TCP model:
For communication process both are using layered architecture and each
layer is specific to its task in both models.
Both models follow the encapsulation, hiding the implementation details
at each layer.
Both follow the stack independent protocol technique.
Both model has implemented end to end communication upto the transport
layer.
17
Chapter 1
Let us see How these layer work in short (We will go deep of each layer
later but let’s have a taste)
Transport layer receives the message and adds Ht (Transport layer header).
The transport layer segment then passes to the network layer, and the
network layer adds a network layer header to it.
Note
a) You may ask where this header gets acknowledged?
At the received side of the transport layer.
b) Is there any name given to this message at the transport layer?
Yes, we called it as segment.
Network layers send this datagram to the data link layer, which adds a data
link layer header. Do you think there is any name at the data link layer also!!
Frame
Computer Network Basics
18
Chapter 1
At every layer, packet is having two fields:
1) Header field
2) Payload field
From the link layer, it goes to the switch or bridges, which sees till the physical
address (MAC) of the packet and forwards it to the destination node.
Let us say the packet is in a different network; now packet has to pass with
the router, which can see till the IP address of the packet and map to its
destination address.
Finally, packet reaches its destination host, where each layer by seeing
their header and acknowledges the packet.
PRACTICE ǪUESTIONS
Sol:
Computer Network Basics
19
Chapter 1
Ǫ3
Sol: In message streams, packets have separate boundaries, but in byte streams,
packets is considered as a single unit.
Ǫ5 Follow up with the question in d, what if services at layer k has changed, will
Sol: We might need to modify services at upper layer because each layer is giving
services to the upper layer.
Ǫuestion
Computer Network Basics
Sol: b)
Chapter 1
Chapter summary:
The seven-layer OSI model provides guidelines for the development of universally
compatible networking protocols:
Network support layers : Physical, Data Link and Network Layer.
User support layers : Session, Presentation and Application layer.
Physical layer : Delivery of bit streams over physical layer.
Data Link layer : Node to node delivery of data.
Network layer : Source to destination delivery.
Transport layer : Process to process delivery.
Application layer : Enables user to access network.
TCP/IP is a four- layer hierarchical protocol suite.
Level of address used in TCP/IP.
Data link layer uses physical address use in LAN or WAN.
IP address uses logical address used to identify host.
Port address identify a process on a host.
For N devices:
1 link is required for bus topology.
N link is required for ring topology.
N link is required for star topology.
N(N-1)/2 link is required in mesh topology.
Twisted air cable, coaxial cable, and optical fiber are the most popular types of
guided media.
Unguided media transport electromagnetic waves without the use of a physical
conductor.
21
Physical Layer
Chapter 2
2.1 INTRODUCTION
Physical layer:
It deals with electrical, mechanical, and functional characteristics.
Note:
Physical connectivity must be there between one hop to other hop (that
connectivity may be wired or wireless).
It is responsible for the transmission of binary data through a medium.
Transmission can be analog (continuous waveform signals) or digital (discrete
binary signals).
Physical Layer
Baseband transmission:
Typically it is used in local area network (LAN)
It uses a digital signal over a single wire.
In a baseband transmission, the entire bandwidth of the channel is used
by digital signals.
Broadband Transmission:
Typically, it is used in Wide Area Network (WAN).
It uses analog signals over multiple transmission frequencies.
In broadband transmission, multiplexing is used using Frequency Division
Technique (FDM).
Bandwidth:
We can say maximum transmission capacity.
It is a difference between highest and lowest frequencies contained in the
composite signal.
Latency:
It is the delay, how much time it takes to travel a message from source to
destination. When the first bit is sent out from the source to the destination.
Propagation delay: It is the time duration for 1 bit to travel the link
Tp = distance between sender and receiver/velocity of the signal on the link.
Transmission delay: It is the time taken to push the entire packet bits onto
the wire.
Tt = Frame size or packet size/Bandwidth
Ǫueuing delay: It is the time taken for a packet to stay in the buffer.
Processing delay: Routers or switches take some time to process the packet
header, which is called Processing delay.
Transmission of signal:
How information can be represented in digital signal:
1 → Positive voltage
0 → Zero voltage
The diagram below has 2 signal levels; it may have 3 or more levels, depending
upon the amount of data.
Physical Layer
Please note here for sending information at one bit per level, we need two
levels.
Encoding/Decoding techniques:
format.
Decoding: Process of converting from specified format into actual format
(It is the reverse of encoding)
Terms used in encoding:
Unipolar: If all the signal elements have the same sign (like all are positive
or all are negative), then the signal is unipolar.
Polar: If the signal elements have one positive and another negative sign,
then the signal is Polar.
Physical Layer
Physical Layer
Chapter 2
Noise:
When a signal travels, there is a high chance that unwanted signals get attached
to the original signal, which creates bad results and is often termed noise.
There are several types of noise: Thermal, crosstalk and impulse.
Thermal noise:
It gets created by the random motion of electrons in a wire.
Cross talk:
It is an effect of radiation which is induced on other signals because of close
proximity.
Impulse:
It is spike noise which comes for a short duration due to some instant action
like lightning.
Note:
High SNR means the signal is less affected by noise, and low SNR
means signal is highly affected by noise:
SNR (in db) = 10log10SNR
PRACTICE ǪUESTIONS
If the television channels have a Bandwidth 4MHz. If 8 level digital signals are
used. How many bits per second can be sent ? Assume the channel is noiseless.
Physical Layer
Chapter 2
Ǫ2
Ǫ3
Sol:
Switching:
Why do we need switching?
When we have many devices, we can connect using point to point (as we
have seen in mesh topology) or multipoint connections (as we have seen in
star topology). But can we extend these methods when we have a very large
network!! BIG NO
Switching helps here; there are 3 types of switching see figure below:
Physical Layer
Note:
Resource:
Physical Layer
31
Chapter 2
Note:
The message is divided into packets which are fixed or variable
sized networks.
There is no need to establish a dedicated path in advance but it
can be allocated on demand.
The allocation of resources is done on FCFS basis.
Packet contains the user data and controlled information.
Datagram network:
In this, each packet has no relation to the other packet.
Note:
Packet in this network are called datagram.
Packets from the single message travel along the same path.
Resource reservations can be made during the setup phase or on-demand
during the transfer phase.
Each packet contains a Virtual Circuit Identifier (VCI).
Again, in a virtual circuit, there are also 3 phases required to transfer the
data.
layer.
Chapter 2
PRACTICE ǪUESTIONS
Sol: Two set up phase + 1 tear down phase, i.e 3 *(tp + tr)
Sol:
Circuit Switched
Network
Datagram Network
Virtual Circut
Physical Layer
Chapter 2
Ǫ3
Sol:
Ǫuestion
Sol: (GATE-
Physical Layer
Physical Layer Chapter 2
Data Link Layer
Chapter 3
3.1 DATA LINK LAYER
It has two major functions:
Data link control
Medium access control
Byte stuffing:
Add 1 extra byte whenever there is a flag or ESCAPE character in the text.
Special byte is added to the data section of the frame when the same
pattern as that of flag is present inside the frame.
Now frame has an extra byte called as ESCAPE(ESC).
This adding of an extra byte is called Byte stuffing.
But the problem comes when the escape pattern appears in the middle of
the data. The solution is add extra ESCAPE.
See figure below!!
When there is ESC pattern in an original frame add another escape byte:
Byte stuffing has one disadvantage, we have to use 1 byte always. So, there
is always a limitation of using 8 bit.
We can overcome this situation using bit stuffing.
Bit stuffing:
In this, whenever flag pattern appears in the data section of the frame,
to prevent it from looking like a pattern of the flag we add an extra bit to
Data Link Layer
If we have taken 10000001 as Flag, so after bit stuffing, data will be 100000101.
01111110,
1
Note:
Real flag is not stuffed by the sender; hence no need to destuffing for
real flag at the end of the receiver.
2) Error control:
It manages both error connection and error detection.
Basically, it deals with the retransmission of data, and this retransmission is
based on Automatic Repeat Request (ARǪ).
There are basically two types of error: Single bit error and Burst error.
Single bit error: Single bit get changes when data reaches to receiver,
11101010 11111010
Burst error: When 2 or more bits gets changes,
11101010 11111011
Error detecting codes:
In error detection, we can only know the packet is corrupted. Redundant bits
are added to detect error, and when the error is detected, retransmission is
used to recover from error.
In error detection, we can also know the bit which has been corrupted.
Redundant bits are added in such a way, that it will detect and correct the
errors.
Chapter 3
Concept Building Exercise
Error detection:
Parity checking
Cyclic redundancy check
Checksum
Simple parity check codes:
It can detect an odd number of errors.
In this k bits, data is changed into n bit code words.
n = k + 1 (extra 1 bit is called parity bit)
In the case of even parity, if the number of 1’s are even then, we add an extra
bit by adding 0 else, if the number of 1’s is odd, then we add an extra bit of 1
to make the Code bit an even number of 1.
1
d(1100, 1111)
Sol: 2, 2
41
Chapter 3
dmin. = 2d + 1
Let’s see below diagram and understand how simple parity bits are used in
error detection,
Note:
A simple parity check code can detect odd number of errors only.
CRC codes can detect the single bit errors, double errors, odd number
of errors and burst error.
Fast when implemented in hardware compared to software.
The divisor in cyclic codes are normally called generators.
Checksum:
Data Link Layer
Checksum bits are usually placed at the end of the message with a
complement to the sum function.
It is used on the internet but not on the data link layer.
What we are using at the data link layer then!! CRC.
Chapter 3
Ǫuestions:
1) In CRC, what do you think is the relationship between the size of the
divisor or remainder?
Remainder is always one bit smaller than the divisor.
2) CRC generator is x3 + x + 1, data bit are 1101, What will be the CRC which
needs to be appended at the databit?
CRC generator x3 + x + 1 = 1011, we will append 3 bit 0 to the data bit.
After doing the modulo operation, we got CRC as 010, and Codebit will
become 1101001.
3) What is the checksum value which needs to be send for the following
two data items:
0x4589 and 0xBA76?
Data Link Layer
Chapter 3
Checksum bit which needs to be sent is 0000
Ǫuestion
Error correcting:
For error detecting and correcting we will use hamming codes.
Let us first understand relationship between data bits and redundant bits
in hamming code.
Let us take ‘d’ as data bits and ‘t’ as a redundant bits.
Total number of bits that has to be transmitted = d + t.
Think how many states can the redundant bit discover?
Its d + t + 1
Note:
Above condition derives a relationship,
2t d + t + 1
Message: 1011
Here d = 4, now we need to add parity bits for each combination in the powers
of 2 as shown below:
Data Link Layer
Your ultimate goal should be to make an even number of 1’s for particular
parity, in this case, by checking position 3,5,7 we got a number of 1’s as odd,
therefore we have to put t1 = 1 in 1st position in order to make even parity.
Same we will do for t2 and t3,
Ǫuestion
a) 01011011010 b) 01011011011
c) 01011011101 d) 01011011100
Data Link Layer
Sol: c) (GATE-2017)
Chapter 3
Ǫuestion
01111110. 01111100101,
a) 0111110100 b) 0111110101
c) d)
Sol: b) (GATE-2014)
Propagation delay:
(tp) Time taken by 1 bit to travel from sender to receiver.
tp = d/v (d= distance between sender to receiver and v is transmission speed).
Ǫueuing delay:
(tq)Before processing of the frame it has to wait inside the buffer, that waiting
time is called queuing delay.
Processing delay:
(tpr) It is the time taken by a node or processor to process the frame. Basically
it depends on the speed of the processor.
Flow control:
It deals with how much data the sender can transmit so that the receiver
should not overflow.
Data Link Layer
Data link layer uses error control, framing and flow control to send data from
one node to another node.
Chapter 3
Note:
What do you understand about the events happening in the above point?
It means the sender does not know when the packet will come from the network
layer; it has to constantly check, and the receiver does not know when the
packet will come from the physical layer; it also has to constantly check.
There should be some mechanism so that sender should slow down its
speed.
Can you guess what that mechanism is?
Sending ACK or acknowledgment from the receiver to sender.
Chapter 3
How stop and wait works:
1) Sender sends a data packet and waits for acknowledgement from the
receiver.
2) Receiver receives the data packet and sends the acknowledgement to
the sender.
3) After having the acknowledgment from the receiver, the sender sends
the next packet.
Working:
In order to prevent this situation, after sending the data packet, the sender
starts the time out timer, to make sure the packet is transmitted in a
specified amount of time.
Note:
Stop and wait ARǪ = Stop and wait + Time out timer
51
Chapter 3
If the timer goes timeout and sender does not receive any acknowledgement
from the receiver, then the sender will retransmit the packet, but packet
will be duplicated.
How to prevent duplicate packet problem in stop and wait?
Add sequence number in data packet, see, figure below.
Note:
Stop and wait, ARǪ = Stop and wait + Time out timer + Sequence Number
in data packet.
Data Link Layer
Note:
Stop and wait ARǪ = Stop and wait + Time out timer + Sequence Number
in data packet + Sequence number in Ack Packet.
Let us understand the difference between “Stop and wait” and “Stop and
wait ARǪ.”
PRACTICE ǪUESTIONS
Sol:
Ǫ2
Sol:
Data Link Layer
1 500
500 = = 1000
1 − 0.5 0.5
1000 packet needs to be transmitted.
Chapter 3
Ǫuestion
a) 160
(GATE-2015)
Go Back N ARǪ:
What is N here ! Sender window size is N
Points:
The size of the sender window must be less than 2m (where m is the size
of sequence number fields in bits), and the size of receiver window is
always 1.
Each time the receiver receives a new frame, it starts a new acknowledgement
timer, and if the timer expires, the receiver sends the cumulative
acknowledgement for all the frames which are unacknowledged at that
moment and sometimes, it uses an independent frame if the receiver
wants to acknowledge only one frame.
It silently discards the frames if frames are corrupted.
Sender window:
It is the sequence number of the data frames which can be in transmitted.
The maximum size of the window is 2 m – 1.
The sender window will slide according to one or more valid
acknowledgement comes.
Note:
Maximum sequence number >= Sender window Size + Receiver
window size
Maximum sequence number >= N + 1
Ǫ3
Ǫ5
Data Link Layer
Chapter 3
Sol: If N = 4, means window size is 4, if any packet gets lost we need to retransmit
the entire window,
When the acknowledgement of the 5th packet does not reach the sender side, and there
is a timeout timer at the sender side, it will retransmit the entire window.
Note:
The 5th packet contains Sequence numbers from 5,6,7,8. It needs to
retransmit.
Now below diagram shows the scenario for remaining packet.
Efficiency in Go Back N:
Efficiency = Useful time / Total time
Useful time = Sender Window Size * Transmission time (tt)
Total time = tt + tp + tp => tt + 2tp
Efficiency = N * tt / (tt + 2tp)
Data Link Layer
= N/(1 + 2a)
Chapter 3
Ǫuestion
successfully.
At the receiver side, it starts the acknowledgement timer, and when it
expires, the receiver will send the cumulative acknowledgement for the
packet it receives in the meantime.
61
Chapter 3
Points:
The size of sender window is equal to receiver window size.
Available Sequence number = Sender window Size + Receiver window size.
2n = 2n-1 + 2n-1 where n bits are used for sequence number
As soon as the receiver receives the frames, it sends the acknowledgement,
and uses the independent acknowledgement.
In Go back, N, out of order packets are not accepted, which means the sender
has to send the entire window, which
leads to consumption of bandwidth and
more traffic. In noisy channels, there
are more chances of corrupted packets, Rack Your Brain
then we can use a mechanism called
Selective Repeat ARǪ. Do you think Go back N is preferred in
a noisy link !!
In Selective repeat ARǪ, only the
damaged the frame needs to be sent; it
makes efficient use of bandwidth in the noisy channel.
Note:
Receiver has to do more work in selective repeat, Think why !!
Receiver does not accept the corrupted frame and also does not discard
the frame silently, but it will use negative acknowledgement.
Due to the use of negative acknowledgement, the sender need not to wait
for timeout timer completion.
Receiver accepts out of order packets.
Efficiency in SR protocol: N/(1+2a).
Data Link Layer
Chapter 3
Ǫ6
is used _____ ?
16 + 16 = 32
In the below diagram, when all the acknowledgements are lost, the sender will send the
frame again after the time out timer of that frame, and the receiver will accept the same
frame, but in another window, this is an error.
Sequence numbers
2 N+1 2×N
required
In data link control, we have seen that if there is a dedicated link between
sender and receiver how the protocol works, but the case will change if we
do not have a dedicated link.
Pure Aloha:
It will allow the station to send whenever it has data.
After sending the data, it waits for acknowledgement from the receiver.
If it receives the acknowledgement, then the transmission is successful.
If it doesn’t receive the acknowledgement, then the transmission is
unsuccessful; after the timeout timer expires, it will resend the data.
Note:
Vulnerable time: This is the time when collision is possible.
Ǫ7
shared channel having, bandwidth of 100 kbps. Calculate the throughput if
250 frames/second is produced by the system(all station together)?
Slotted Aloha:
In slotted Aloha, data can be transmitted by any station at any given time
slot, but the only condition is that a station has to begin its transmission at
the start(beginning) of the time slot. A station has to wait until the starting
of the next time slot in case it misses the starting of a given slot.
In this, no station sends the data in the middle.
1-persistent method:
If the station finds the line idle, it sends its frame immediately,
If the channel is not idle, the station will continuously sense the channel.
Non persistent method:
If the station finds the channel idle, it sends its frame immediately.
Data Link Layer
Stations will wait for a random amount of time if they find the channel is busy,
and when the channel is idle, it will send the frame again.
Chapter 3
P persistent method:
In this method the station sends its frame with probability p, and it will not
transmit with probability q = 1 - p. The station waits for the beginning of the
next time slot and checks the line again. Now if the line is idle, it sends the
frame with probability p and defers with probability q.
Carrier sense multiple access with collision detection:
Carrier sense multiple access with collision detection (CSMA/CD) elongate
the CSMA to handle the collision.
Note:
Each station can sense the carrier only at its point of contact with the
carrier.
Tt 2Tp
Chapter 3
Rack your Brain
Efficiency:
Useful time = Transmission delay of data packet = Tt
Total time = Time during collisions + Propagation delay of data packet + Tt
= c x 2 x Tp + Tp + Tt (where c = Number of contention slots).
Efficiency = useful time / total time
Tt /(c x 2 x Tp + Tp + Tt)
Analysis using probability gives the Average number of collisions before a
successful transmission = e
Which leads to c = e
Now Efficiency = Tt /(e x 2 x Tp + Tp + Tt )
Note:
What is the average number of collisions before successful transmission?
71
Chapter 3
Points:
It is used in Wired LAN (802.3)
Probability of successful transmission = nC1 x p x (1-p)n-1
Note:
If collision is happening for nth time then station will choose a random
number k from ( 0,2n - 1 )
Possibilities:
A B (Description)
1 1
Chapter 3
Note:
In this algorithm, Backoff time increases exponentially
And collision probability decreases exponentially
It shows a capture effect (if the host wins the collisions for one time, it is
going to win more numbers of times).
Ǫ
8
is increased to 100 Mbps by keeping the propagation delay constant?
Note:
If bandwidth increases, frame size can also increase.
Ǫuestion
1
1
Sol: (GATE-
Data Link Layer
Chapter 3
Polling:
There is a Centralized controller which polls ‘stations’, and gives them an
opportunity to send one packet.
All the data which needs to exchange must go through the controller.
Disadvantage in polling:
There is a high overhead of polling messages.
Stations have to depend on controller.
Data Link Layer
Reservation:
Station that wants to send data needs to make a reservation.
Time is divided into intervals.
In each interval, a reservation frame precedes the data frames sent in that
interval.
In the above figure there are 3 slots made if 3 stations want to send data.
In the first interval, only station 1, and station 3 made a reservation and in
the second interval.
Only station 1 made a reservation.
Token passing:
Stations are connected in the form of ring.
Access is granted through the token.
when the station receives the token, it can send a frame (if it has frame)
before it passes the token to the next station; if the station does not have
a frame simply, it will pass the token to the next station.
Channelization protocol:
Channelization is a multiple-access method in which the available
bandwidth of a link is shared in time, frequency, or through code between
different stations.
Disadvantage:
If the station does not want to send the
frame, then also time slot has given, which
eventually leads to bad efficiency.
Rack Your Brain
Frequency division multiple access:
In FDMA, the available bandwidth of the
common channel is divided into bands that
are separated by guard bands.
Each station has an assigned separate channel.
Data Link Layer
Preamble:
a) It contains 7 bytes.
b) It has 0 and 1 in alternate position.
c) It is actually added at the physical layer.
d) It enables frame to synchronize between sender and receiver.
SFD:
It contains 1 byte: 10101011.
SFD tells the station that this is the last chance for synchronization. The last 2
bits are 11 and alerts the receiver that the next field is the destination address.
Note:
The maximum value that can be accommodated in this field = 216 – 1 = 65535
bytes, but the maximum amount of data that can be sent in an Ethernet
frame is 1500 bytes.
Note:
Minimum frame length = 64 bytes
Maximum frame length = 1518 bytes
Data: This field contains actual data also called payload field.
Minimum bytes in data field = 46 bytes.
Maximum bytes in data field = 1500 bytes. Rack Your Brain
Note:
The least significant bit of the first byte defines the type of address. If the bit
is 0, the address is unicast; otherwise, it is multicast.
Data Link Layer
Chapter 3
Source address is always unicast.
Destination address can be unicast, multicast or broadcast
The broadcast destination address is a special case of the multicast address
in which all bits are 1.
Connecting devices:
Operate at physical layer: Active Hub or repeater
Operate at physical and data link layer:
bridges or 2 layer switches
Operate at physical, data link layer and
etwork layer: Routers or 3 layer switches
Operate at all five layer: Gateways
Repeater:
It receives the signal at physical layer
and before the signal becomes too weak
it regenerates the original bit pattern
A repeater regenerates the signal. It
does not amplify signal.
Data Link Layer
A repeater connects two segments of LAN.
A repeater forwards every frame, it has no filtering capability (Collision
domain remain).
Bridges:
It works at the physical layer and data link layer.
At the physical layer, it regenerates the signal.
Chapter 3
At the data link layer, it can check the MAC address contained in the frame.
It has filtering capability (because it can check the destination MAC address
and decide whether the frame has to forward or drop).
Router:
Three layer switch:
A three-layer switch is a router, which is faster and more sophisticated.
The switching fabric in a three-layer switch allows faster table lookup and
forwarding.
It can separate broadcast domain.
Gateway:
A gateway is normally a computer that operates in all five layers of the
Internet or seven layers of OSI model.
Gateways can provide security.
It is used to filter unwanted application-layer messages.
1
Data Link Layer
Chapter 3
Ǫuestion
Sol: (GATE-
Chapter summary:
Chapter 4
4.1 NETWORK LAYER
Across multiple links, the network layer is responsible for source to
destination delivery. Is the data link layer not enough? No, as it works on
the same links.
Logical addressing:
Now for implementation, logical address is IP addresses having 32 bit
number which is globally unique, and physical address are MAC address
having 48 bit which is also globally unique.
Notation:
Binary notation – 10000001.10000011.10000
010.00000010 Rack Your Brain
Dotted decimal notation – 129 . 131 . 130 . 2
Classful addressing:
In classful addressing, the address space is
0001.00000011.00001011.10101101
divided into five classes: A, B, C, D and E.
a) How each class is distributed when it is
represented in Binary?
When the address is given in binary
notation, the first few bits can signify
class? 00000001.00000011.00001011.10
Note:
Net ID: Network IDs are IP addresses of the network and are used to
identify the network.
Host ID: Host IDs are the IP address of the host and is used to identify the
host within the network.
In Class A, 1 byte denotes Net ID and remaining 3 bytes are Host IDs.
In Class B, 2 bytes denote Net ID and remaining 2 bytes are Host IDs.
In Class C, 3 bytes denote Net ID and remaining 1 bytes are Host IDs.
In Class D, there is no Net ID and Host ID.
In Class E, there is no Net ID and Host ID.
Let’s take a look at individual class.
Class A:
Class C:
Class D:
1110
Class E:
1111
Mask:
It is a 32 bit number made of contiguous 1 followed by contiguous 0. It will
help to find the Net ID and Host ID.
Let’s say the mask for a class A address has eight 1’s, which means the
first 8 bits of any address in class A define the Net ID, and the next 24 bits
define the Host ID.
Network Layer
Class D 228
Class E 228
Note:
Blank spaces are not defined.
1
1
Network Layer
91
Chapter 4
a) 191.2.255.255 b) 127.0.0.1
Ans. d)
Sol: a) 191.2.255.255 is DBA
Note:
In classful addressing, class A, B and C are used for reserved addresses, class D is used for
multicast, and class E is used for future purpose addresses.
Classless addressing:
Classless addressing is used now, and
classful has become obsolete.
In classless addressing, ISP (Internet service provider) grants IP
addresses based on requirement on the number of customers needed.
It is an improved version of classful addressing and is also known as
CIDR (classless interdomain routing).
Network Layer
Chapter 4
How ISP grants IP addresses?
There are 3 rules for CIDR block creation:
Rule 1: All the IP addresses must be contiguous in a block.
Rule 2: A block must be in power of 2 ( 1,2,4,8….).
Rule 3: The first address is evenly divisible with number of address.
PRACTICE ǪUESTIONS
Block of 4 addresses can be assigned to an organisation having an IP
Sol: p.q.r.s/t
t is used as identifier for network Rack Your Brain
bits.
32-t bits used as identifier for Host Ǫ) What is the block address of
bits. 2.2.3.4/5?
Ǫ3
Sol: 188.67.00000100.0 / 24
188.67.4.0 Number of hosts possible in one network is 28
Rule 1: Is the given block contiguous ! Yes.
Rule 2: Is the size of the block is in power of 2 !! yes.
Total number of host possible is 28 + 28 + 28 + 28 = 210
Which is in the power of 10
Rule 3: The address of the first
block is evenly divisible by the size
Rack Your Brain
of the block !!!
188 .67.00000100.0 when divided by
210 last 10 significant bits are 0.
Hence yes given block can follow
CIDR aggregation.
Network Layer
Chapter 4
Note:
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.
Subnetting:
An organisation that is generated a large
block of address may need to break into
small networks (Subnets) On a higher level
i.e. from outside the organisation, it works
as a signal network, but internally, it may
have many networks.
All the subnet have same mask Each subnet have different mask
Case 1:
2.0.0.0
2.64.0.0
Network Layer
2.128.0.0
Chapter 4
Case 2:
2.0.0.0
2.128.0.0
2.192.0.0
Ǫuestion
Sol: b) (GATE-2020)
Sol:
Network Layer
Chapter 4
Ǫ6 How many possible Host addresses does the Unacademy block have?
Sol: 16 bits are available for address; therefore, 216 addresses are possible but first
and the last IP should not be assigned to any host therefore 2 16 - 2 Hosts can be
configured.
Since the NEET team wants 212 and the GATE team wants 212.
combinedly need 213 address. i.e 8192 address.
Total Available address are 216
S0, Available can satisfy the Needs of two teams.
given,
180.200.0.0/16
make, two subnets by borrowing a single bit from HID part 16 bits.
180.200.0/1 0000000.00000000
Suppose NEET team
180.200.00000000.00000000/17 ® start
180.200.01111111.11111111/17 ® end
it has 32 teams each with 128 address requirements.
for 32 teams take 5 bits.
180.200.0xxxxx00.00000000/22
180.200.00000000.00000000/22 -starts
180.200.01111100.00000000/22 -End
suppose GATE team.
180.200.10000000.00000000/17 -- start
180.200.11111111.11111111/17 --end
it has 64 teams with each 64-address requirement.
for 64 teams take 6 bits.
180.200.1xxxxxx0.00000000/23 Rack Your Brain
180.200.10000000.00000000/23 –starts
Network Layer
180.200.11111110.00000000/23 --ends
Chapter 4
How to find the number of subnets if subnet mask 255.255.0.0 belongs to class B.
Network Layer
Chapter 4
How to find the number of subnets if subnet mask 255.255.0.0 belongs to
class C.
Supernetting:
Combination of multiple networks into one single network by following
some rules is Supernetting.
Rules for Supernetting:
Rule 1: All the IP addresses must be contiguous in a block.
Rule 2: A block must be in power of 2 (1,2,4,8….)
Rule 3: The first address is evenly divisible with number of address.
200.100.10.0
200.100.12.0
200.100.15.0
200.100.17.0
200.100.10.0
200.100.11.0
200.100.12.0
200.100.13.0
Network Layer
101
Chapter 4
How does a host get to know that a particular IP coming from the internet
is it’s or not?
Answer: It is the NAT table. A NAT table is responsible for mapping each
private IP to its corresponding public IP.
Range Total
102
Chapter 4
Step 1: Client send an IP packet to access point:
Step 2: Now the modem or access point sends the IP packet with a different
IP address to the server. In addition to this, it records the mapping of the
incoming and outgoing packet
Step 3: Now, when the web server responds it responds with the same
public IP address.
103
Chapter 4
Ǫ.10 How will NAT use this mapping when the packet has source IP 192.168.22.1 returns
NAT Table:
Source IP 200.200.1.1
Destination IP 192.168.22.1
Points:
1) It is 128 bit long, hence a larger address
space (IPV4 is 32 bit long).
2) IPv6 can be written in hexadecimal and
binary notation.
Network Layer
Chapter 4
a) In Binary we denote IPv6 something like this
Now if write IPv6 in binary every time, it would be long, hence we can use
hexadecimal notation also.
b) In hexagonal notation, IPv6 looks like:
1) Abbreviations in IPv6:
The need for abbreviations in IPv6 is that if we write in hexadecimals, then
also there are some zeros which can be shortened. Hence we come up with
rules which can reduce the size of hexadecimal notation illustrated below.
the trailing zeros like 4120 cannot be Expand: 13:: 123: FFFF: ABCD: 1AC0
written as 412.
105
Chapter 4
e) With a larger number of IP addresses, end to end connectivity can be easily done.
f) No broadcasting in IPv6, though multicast is there to communicate multiple host.
g) IPv6 has different types of addressing modes UNICAST, MULTICAST and ANYCAST.
UNICAST:
It is based on one source and one destination.
In unicasting, the router forwards the received packet through only one of its interfaces.
Forwarding a packet is done only one of its interfaces.
Its a type of one one communication.
MULTICAST:
Network Layer
106
Chapter 4
Concept Building Exercise:
Sol: NO,
1
1
Note:
1) In order to find the Subnet ID or number of Subnet, We have to know
class ID or NID.
2) Even without knowing the class of network, we can find HID.
107
Network Layer
Chapter 4
Sol: It should be 32 - 15 = 17
NID = 17 bits
10.1.5.1/30
10.1.5.2/30
10.1.5.3/30
Note:
In above solution only 2 IP can be used as
Host ID.
Network Layer
108
Chapter 4
Special IP address chart and their meaning:
Valid IP Address
0’S Network IP
Note:
Internet uses datagram approach in Rack Your Brain
packet switching.
IP model.
Look where IPv4 is placed at TCP/IP suite.
109
Chapter 4
IPv4 has no error control and no flow control, IP relies on TCP in order to
take care of error and flow control.
110
Chapter 4
Binary 0100 can be written in this field.
Header length:
It has 4 bit.
It defines length of IP header.
Note:
What is the minimum and maximum length
of the IP header? Grey Matter Alert!
Minimum length = 20 Bytes, How? number
of essential rows * size of each rows i.e 5 We have minimum and maximum
* 4 bytes. length as 20 and 60 bytes
Maximum length = 60 bytes, How? respectively.
Maximum size of options are 40 bytes But at header length we have only
20 + 40 = 60 bytes. 4 bits i.e using 4 bits maximum we
can go upto 15 bytes.
Example: If IPv4 has a binary pattern starting
It leads to the concept of scaling
with 0100010.. What does this mean?
factor in this case it is 4 bytes.
This means packet has version 4 and header
Header length = Header length field
length is 2 * 4 = 8 bytes.
value * 4 bytes. If header length
Example: If IPv4 has a binary pattern starting field contains decimal value 6
with 01001111.. What does this mean? (represented as 0110), then-Header
This means packet has version 4 and header length = 6 x 4 = 24 bytes.
length is 15 * 4 = 60 bytes.
Service: It has 8 bit fields.
20 + 0 = 20 bytes
Maximum total length = > with 16 bits we can go upto (2 16 - 1) bytes = 65535
bytes.
Flags:
There are 3 bits, one bit uses do not fragment bit; one bit uses more
fragment bits, and one bit is reserved.
Do not fragment bit: The value of this field can be 0 (do fragment if required)
or 1 (do not fragment).
Network Layer
Note:
total length field = 16 bits = > 65535 Bytes.
Fragment offset = > 13 bits which will give 213 - 1 bytes = 8191 Bytes.
Scaling is done because fragment offset cannot represent sequence of
bytes greater than 8191.
Scaling factor in fragment offset = 216 / 213 = 23
Fragment offset field value = fragment offset/8
Protocol values
Value Protocol
1 ICMP
2 IGMP
6 TCP
17 UDP
89 OSPF
These numbers will eventually decide the router when the traffic becomes
heavy which packet to discard.
The sequence of discarding the packet at routers is ICMP > IGMP > UDP
>TCP
Source IP address:
It is a 32 bit fields.
It is having IPv4 address of the source.
Note:
IPv4 address must not change until packet reaches destination.
Destination IP address:
Network Layer
It is a 32 bit fields.
It is having IPv4 address of the destination.
114
Chapter 4
Note:
IPv4 address must not change until packet reaches source.
Record route:
When this option is set in the options field, the IP address of the router gets
recorded in the options field.
Source routing: This field is used in order to check if the path is working
or not.
It may
Example: A packet has arrived with an M bit value of 0. Is this the first
fragment, the last fragment, or a middle fragment? Give your view about
fragmented packets?
0 0 Invalid
0 !0 Last packet
1 0 First packet
1 !0 Intermediate packet
Ǫuestion
Sol:
Fragmentation:
When the datagram is divided inorder to pass through other networks, this
is called fragmentation.
Let us see the below scenario,
Network Layer
116
Chapter 4
How we can limit fragmentation at the sender side!!
When TL segments the data in such way, that size of data can easily be
taken by the network layer as well as in the data link layer.
Sender and router, but keep in mind sender can limit the fragmentation by
proper implementation.
Note:
MTU (Maximum Transmission Unit) is the maximum length that
can be encapsulated in a frame.
There are two networks, A and B. Network A has MTU 1020 Bytes and
Network B has MTU 500 Bytes.
Host P wants to send the message to Host Ǫ.
See the figure below,
Network Layer
117
Chapter 4
Step 1:
When Router receives the datagram packet having a Total size = 1020B, and
if the DF flag is 0, now it can do fragmentation.
Step 2:
It will check if the network B MTU can accommodate the packet or not!
If not, then it will start fragmentation according to the MTU size of network
B.
Step 3:
Here, MTU network B is 500 Bytes.
Out of 500 Bytes 20 Bytes will be the header, and 480 Bytes will be payload.
Maximum amount of data that can be sent at each fragment = 480.
Note:
Payload at each fragment must be multiple of 8 except the last fragment
i.e. last packet may or may not have a multiple of 8 data byte.
118
Chapter 4
Header checksum will be calculated again.
MF bit = 1
Receiver will take all the three segments and reassembly algorithms applied
119
Network Layer
Chapter 4
Note:
We have taken 176 byte in I.a,I.b, II.a and II.b because datagram
byte must be divisible by 8.
Reassembly algorithm:
Receiver applies the following steps:
I) Identifies whether datagram fragmented or not using MF bits and
fragments offset bits.
Network Layer
120
Chapter 4
III) Fragment with offset field 0 is first fragment.
IV) identifies subsequent fragments using total length, header length and
fragment offset.
V) Repeats step IV until MF = 0
IPv6 header:
Ǫ7
Ǫ8
In binary 1100
Ǫ9
Sol:
Ǫ10
122
Chapter 4
Let’s see 1st fragment:
Length field has 1500 bytes which include 20 bytes of header and 1480
bytes of payload.
MF field is 1 because more fragments are followed.
Identification number will be the same for all the fragments.
Offset field store scaled value, here it is 0 as before this fragment no
data bytes are there.
123
Chapter 4
1500 bytes (i.e. MTU = 1500 bytes). Size of the UDP header is 8 bytes,