Computer Networks
Computer Networks
Hub
A hub joins multiple devices on the same LAN, broadcasting messages to all
ports without examining frames
Switch
A network switch forwards data to its
proper destination, examining a packets
MAC address info to determining the
intended device.
Router
The router is a physical or virtual internetworking
device that is designed to receive, analyze, and
forward data packets between computer networks. A
router examines a destination IP address of a given
data packet, and it uses the headers and forwarding
tables to decide the best way to transfer the
packets.
Bridge
Bridges are used to connect two subnetworks that use interchangeable
protocols. It combines two LANs to form an extended LAN. The main
difference between the bridge and repeater is that the bridge has a
penetrating efficiency.
Gateway
A gateway connects discrete networks and translates packet data so it can
travel between the systems. This network device allows to broaden network.
handles traffic issues efficiently. but it never filters data, it is costly and
difficult to manage.
Modem
Modem is a device that enables a computer to send or receive data over
telephone or cable lines. The data stored on the computer is digital whereas a
telephone line or cable wire can transmit only analog data.
Repeater
Repeaters are network devices operating at physical layer of the OSI model
that amplify or regenerate an incoming signal before retransmitting it. They
are incorporated in networks to expand its coverage area. They are also
known as signal boosters.
Access Point
device that sends and receives data wirelessly over radio frequencies
It's an easy installation, allows data transmission even user is moving
simple to extends to places where wires and cables are not
accessible.but it's range of network devices is limited which causes
issues for many users installing this network device is difficult.
Transmission Modes
The way in which data is transmitted from one device to another is known as
transmission mode.
simplex mode
half duplex mode
full duplex mode
Simplex mode
The communication is unidirectional i.e. data flows in one direction. since it is
unidirectional it has no intercommunication between devices.Example:
Keyboard and traditional monitors. The keyboard can only introduce input,
the monitor can only give the output
Half duplex mode
In half-duplex mode, each station can both transmit and receive, but not at
the same time. When one device is sending, the other can only receive, and
vice versa. The half-duplex mode is used in cases where there is no need for
communication in both directions at the same time. The entire capacity of the
channel can be utilized for each direction.
Example: Walkie-talkie in which message is sent one at a time and messages
are sent in both directions.
Full duplex
In full-duplex mode, both stations can transmit and receive simultaneously. In
full_duplex mode, signals going in one direction share the capacity of the link with
signals going in another direction.Full-duplex mode is used when communication in
both directions is required all the time. The capacity of the channel, however, must
be divided between the two directions. Example: Telephone Network in which
there is communication between two persons by a telephone line, through which
both can talk and listen at the same time.
(Open Systems Interconnect)
OSI Reference Model
OSI or Open System Interconnection model was developed by International
Standards Organization (ISO). It gives a layered networking framework that
conceptualizes how communications should be done between heterogeneous
systems. It has seven interconnected layers. The seven layers of the OSI
Model are a physical layer, data link layer, network layer, transport layer,
session layer, presentation layer, and application layer
7 Layers of OSI Model
Physical layer: The physical layer is the lowest layer of the OSI model. It
is responsible for the electrical and physical aspects of data
transmission. This includes the physical medium, such as copper wire or
fiber optic cable, and the connectors and hardware used to connect
devices to the network.
Data link layer: The data link layer is responsible for error detection and
correction for data transmitted over the physical layer. It also defines
how data is to be framed into packets for transmission. The data link layer
uses a variety of techniques to detect and correct errors, such as
checksums and cyclic redundancy checks (CRCs).
Network layer: The network layer is responsible for routing data between
devices on different networks. It also provides addressing and routing
information for data packets. The network layer uses a variety of routing
protocols to determine the best path for data to travel.
Transport layer: The transport layer provides a reliable connection
between two applications. It ensures that data is delivered in the correct
order and that any errors are corrected. The transport layer uses a variety
of mechanisms to ensure reliability, such as sequence numbers,
acknowledgments, and retransmissions.
Session layer: The session layer manages the communication between two
applications. It establishes and maintains a connection between the two
applications, and it ensures that data is exchanged in a coordinated
manner. The session layer uses a variety of mechanisms to manage
communication, such as synchronization points and checkpoints.
Presentation layer: The presentation layer translates data between
different formats. For example, it can convert text from one character
encoding to another. The presentation layer also provides encryption and
compression services.
It stands for Open System Interconnection. It stands for Transmission Control Protocol.
OSI model has been developed by ISO (International It was developed by ARPANET (Advanced Research
Standard Organization). Project Agency Network).
This model is based on a vertical approach. This model is based on a horizontal approach.
Protocols in the OSI model are hidden and can be easily replaced
In this model, the protocol cannot be easily replaced.
when the technology changes.
The usage of this model is very low. This model is highly used.
It provides standardization to the devices like router, motherboard, It does not provide the standardization to the devices. It provides a
switches, and other hardware devices. connection between various computers.
Switching
Switching as applied to networking and IT, is the practice of directing a signal
or data element toward a particular hardware destination
Packet Switching
In packet based networks, the message gets broken into small data
packets.
These packets are sent out from the computer and they travel around the
network seeking out the most efficient route to travel as circuits become
available.
This does not necessarily mean that they seek out the shortest route.
Each packet may go a different route from others.
Circuit Switching
There are three phases in circuit switching:
Establish
Transfer
Disconnect
The telephone message is sent all together; it is not broken up
The message arrives in the same order that it was originally sent.
In modern circuit-switching networks, electronic signals pass through
several switches before a connection is established.
During a call no other network traffic can use those switchess.
The resources remain dedicated to the circuit during the entire data
transfer and the entire message follows the same path.
Circuit switching can be analog or digital.
Advantages
Circuit is dedicated to the call - no interference no sharing.
Guaranteed the full bandwidth for the duration of the call
Guaranteed quality of service
Disadvantages
Inefficient - the equipment may be unused for a lot of the call; if no data is
being sent, the dedicated line still remains open.
It takes a relatively long time to set up the circuit.
During a crisis or disaster, the network may become unstable or
unavailable.
It was primarily developed for voice traffic rather than data traffic.
Data Link Layer
The data link layer is responsible for error detection and correction
for data transmitted over the physical layer. It also defines how data
is to be framed into packets for transmission. The data link layer
uses a variety of techniques to detect and correct errors, such as
checksums and cyclic redundancy checks (CRCs).
Data Link Layer Design Issues
Services provide to the Network layer
Framing
Error Control
Flow Control
Functions of the Data Link Layer
Provide service interface to the network layer.
Framing provides a way for a sender to transmit a set of bits that are
meaningful to the reciever.
Dealing with transmission errors.
Regulating data flow.
Slow recievers not swamped by fast senders.
Services provided to network layer
Actual Communication :
In this communication, physical
medium is present through which
Data Link Layer simply transmits
data frames.
Virtual Communication :
In this communication, no physical
medium is present for Data Link
Layer to transmit data. It can be
only be visualized and imagined
that two Data Link Layers are
communicating with each other
with the help of or using data link
protocol.
Types of Services provided by Data Link Layer :
1. Unacknowledged Connectionless Service
Loses are taken care at higher layers.
used on a reliable medium like coax cables or optical fibers where the
error rate is low.
appropriate for voice, where delay is worse than bad data.
the data link layer of the sending machine sends independent frames to
the data link layer of the receiving machine.
The receiving machine does not acknowledge receiving the frame.
No logical connection is set up between the host machines. Error and
data loss is not handled in this service.
This is applicable in Ethernet services and voice communications.
2. Acknowledged Connectionless Service
useful on unreliable medium like wireless.
Acknowledgements add delays.
adding ACK (Aknowledgement) in Data Link Layer rather than on Network
Layer is just an optimization and not a requirement.
Leaving it to the network layer is inefficient as a large message has to be
resent in that case in contrast to small frames here.
On reliable channels, like fiber, the overhead associated with the ACK is
not justified.
no logical connection is set up between the host machines, but each
frame sent by the source machine is acknowledged by the destination
machine on receiving.
If the source does not receive the acknowledgment within a stipulated
time, then it resends the frame. This is used in Wifi (IEEE 802.11) services.
3. Acknowledged Connection Oriented Service
Most reliable
Guaranteed service-
Each frame sent is received.
Each frame is received exactly once.
Frames are received in order.
This is the best service that the data link layer can offer to the network
layer.
A logical connection is set up between the two machines and the data is
transmitted along this logical path.
The frames are numbered, that keeps track of loss of frames and also
ensures that frames are received in correct order.
Framing
In the physical layer, data transmission involves synchronised
transmission of bits from the source to the destination. The data link layer
packs these bits into frames.
Data-link layer takes the packets from the Network Layer and
encapsulates them into frames. If the frame size becomes too large, then
the packet may be divided into small sized frames. Smaller sized frames
makes flow control and error control more efficient.
Then, it sends each frame bit-by-bit on the hardware. At receiver’s end,
data link layer picks up signals from hardware and assembles them into
frames.
Framing is a function of Data Link Layer. It provides a way for a sender
to transmit a set of bits that are meaningful to the receiver.
Types of Framing
Character Count
Flag Bytes with byte stuffing
Flag Bytes with bit stuffing
Physical layer validation
Character Count
(a) without errors and (b) with errors.
Problems with framing with CC
What if the count is unclear.
Even with the checksum the receiver knows that the frame is bad and
there is no way to tell whether the next frame starts.
asking for retransmission doesn't help either because start of the
retransmission frame is unknown.
No longer used.
Framing with byte stuffing
Problem- fixed character size:
assumes character size to be 8
bits: can't handle heterogeneous
environment.
The data become so bulky.
Framing with bit stuffing
Bit stuffing
(a) The original data.
(b) The data as they appear on the line.
(c) The data as they are stored in receiver’s memory after destuffing.
Physical Layer Encoding Violations
The final framing method is physical layer coding violations and is applicable
to networks in which the encoding on the physical medium contains some
redundancy. In such cases normally, a 1 bit is a high-low pair and a 0 bit is a
low-high pair. The combinations of low-low and high-high which are not used
for data may be used for marking frame boundaries.
Error Control
Positive and Negative Acknowledgement -To make sure all frames are
eventually delivered to the network layer at the destination and in the
proper order the receiver send back a special control frames bearing
positive or negative acknowledgements about the incoming frames.
If the sender receives a positive acknowledgement about a frame, a frame
has arrived safely.
A negative acknowledgement means that something has gone wrong, and
the frame must be transmitted again.
If there is hardware trouble, positive or negative acknowledgement will
not reach the sender and it has to hang forever.
In this case, timers are used.
Timers : what happens when a frame completely vanishes : receiver
neither sends a +ack nor –ack … then timer comes to help.
It may result in a frame being sent more than once and received more
than once :
solution : assign sequence numbers to frames
Error detection and correction
Data can be corrupted during its transmission. For reliable communication,
errors must be detected and corrected. Error detection and correction are
implemented either at the data link layer or the transport layer of the OSI
model
On a reliable medium : ED is sufficient where the error rate is low and asking
for retransmission after ED would work efficiently
In contrast, on an unreliable medium : Retransmission after ED may result in
another error and still another and so on. Hence EC is desirable.
Error Detecting code
1. Parity
value of parity bit is such that character has even (even parity) or odd (odd
parity) number of ones.
even number of bit errors goes undetected.
simple parity
Longitudinal Redundancy
Check/Vertical redundancy check (LRC/VRC)
Even Parity of 1's LRC/VRC
Error Detection
Error detection using CRC [cyclic redundancy check] bits.
It is also known as polynomial codes.
polynomial codes are based upon creating bit strings as representation of
polynomials with coefficients of 0 and 1 only.
to be XOR again
to be XOR again
receiver side
C1 = (3,5,7,9,11,13,15,17,19,21) 1 excluded
C2 = (3,6,7,10,11,14,15,18,19) 2 excluded
C3 = (5,6,7,12,13,14,15,20,21) 4 excluded
C4 = (9,10,11,12,13,14,15) 8 excluded
C5 = (17,18,19,20,21) 16 excluded
C1 = 10101011111
C2 = 1010101011
C3 = 0011001010
C4 = 00110011
C5 = 101011
since C1 and C2's values have changed at
the receiver side it detects that there is
some error and C1 = 2^0 = 1 and C3=2^2 = 4
then add them up than we get 5.
thus altered bit is the 5th bit.
A bit stream of 16 bits data is to be transmitted
across the network. The receiver needs to detect
and correct error in the received data if any. Give
the code word obtained by the sender for
transmission. Assume that 5th bit is altered
during the transmission and how does the
receiver detect and correct that one bit error?
Data: 1100110011001100
FLOW CONTROL
Flow control is a technique that allows two stations working at different
speeds to communicate with each other. It is a set of measures taken to
regulate the amount of data that a sender sends so that a fast sender does
not overwhelm a slow receiver. In data link layer, flow control restricts the
number of frames the sender can send before it waits for an acknowledgment
from the receiver.
Stop and Wait Protocol
It is the simplest flow control method. In
this, the sender will transmit one frame at a
time to the receiver. The sender will stop
and wait for the acknowledgement from the
receiver.
performs better for LAN's than WAN's
because:
efficiency = 1/distance between sender
and receiver
Only problem is that there is a high
probability of occurrence of deadlock. due
to loss in data packet/ loss in feedback.
Sliding window protocol for noisy channel
Explanation
•In this example, the sending window sends data to the receiving window. The
receiving window sends the acknowledgment after receiving the data and
then the sending window sends another data frame.
•However, this time, along with the received acknowledgment, the receiving
window also sends another message saying that the available memory is full.
•The sending window pauses the transmission of data until it gets the
acknowledgment of the receiving window that space has been released and it
can continue the transmission process.
we are creating connection between sender and receiver.
there are 2 buffers created.
for sender - sending window
for receiver - receiving window
when sender sends data packet receiver sends back the remaining
receiving buffer space.
windowing - A flow control method for transfering data over a network.
window size - number of data packets that can be sent without waiting for
ACK.
Sliding Window -
each time frame is sent - window shrink
each time ACK received - window grows
Stop and Wait ARQ
working is same as that of stop and wait protocol and includes additional
components .
timeout timer.
sequence number of data packets
sequence number of feedback
available sequence numbers >= sender window size +receiver window
size.
EXPLANATION.
sender keeps a copy of last frame until it receives ACK.
for identification both data frames and ACKs are numbered alternatively 0
and 1.
sender has control variable (S) that holds number of recently sent frame
(0 or 1).
receiver has control variable (R) that holds number of next frame
expected (0 or 1).
sender starts a timer when it sends a frame and if the ACK is not received
within the time period sender assumes frame was lost and resent it.
receiver sends only positive ACK if the frame is intact.
ACK number always defines the number of next expected frame.
Piggybacking
•A method to combine a data
frame with ACK.
•Station A and B both have data
to send.
•Instead of sending separately,
station A sends a data frame
that includes an ACK.
•Station B does the same thing.
•Piggybacking saves bandwidth.
Problem with 1 bit sliding windows
Bandwidth utilization is poor (waiting for ACK, time out period .. etc.
wasting bandwidth for a valid period of time).
Solution - Pipelining
If the sender could send more frames without waiting for ACK for the first
one, the channel could have been utilized more efficiently. This technique
is called pipelining.
What to do if errors occur during pipelining
Go back n, or
Selective Repeat
Go Back n
Go Back N ARQ which stands for Go Back N Automatic Repeat Request
(ARQ) is a data link layer protocol that is used for data flow control
purposes. It is a sliding window protocol in which multiple frames are sent
from sender to receiver at once. The number of frames that are sent at
one depends upon the size of the window that is taken.
What to do when a frame in the middle of a long stream is bad? Large # of
succeeding frames may come to receiver before sender is told of error.
On discovering error, a solution is go back n. Here receiver discards all
subsequent frames (upto n) & sends no ack for the discarded frames.
Therefore the receiver DLL refuses all frames but the next one it must give
to the NL.
Eventually sender will retransmit all frames including lost/damaged one.
Advantages of Go Back n
CLASS A
CLASS B Used in Lan and
WAN
CLASS C
Broadcast Address
IP addresses with all bits as ones in host portion
left most bit will be altered into a bit value 1 and added to 192.168.1.
then it will become
the 1 you have moved is 2^7th bit so
25 bits 7 bits 2^7 = 128 this value is called block
192.168.1.1 0000000 size
formation of subnets
192.168.1.0+
128
192.168.1.128+ valid
128
192.168.1.256 invalid
then we get the customized subnet ID's
1st network id - 192.168.1.0 - 192.168.1.127
2nd network id - 192.168.1.128 - 192.168.1.255
2 left most bits will be altered into a bit value 1 and added to 192.168.1.
then it will become
formation of subnets
26 bits 6 bits
192.168.1.0+ valid
192.168.1.11 000000
64
192.168.1.64+ valid
the 1 you have moved is 2^7th and 64
2^6th bit so 2^7 = 128 and 2^6 = 64 192.168.1.128+ valid
then the block size will be 128+64 = 64
192 192.168.1.192+ valid
64
192.168.1.256 invalid
then we get the customized subnet ID's
1st network id - 192.168.1.0 - 192.168.1.63
2nd network id - 192.168.1.64 - 192.168.1.127
3rd network id - 192.168.1.128 - 192.168.1.191
4th network id - 192.168.1.192 - 192.168.1.255
default subnet ID for class C - 255.255.255.0
customized subnet id for class C - 255.255.255.192
When the host has to send a packet , In this, the bucket holds tokens
packet is thrown in bucket. generated at regular intervals of time.
Step 2: In this step server responds to the client request with SYN-ACK signal
set. ACK helps you to signify the response of segment that is received and
SYN signifies what sequence number it should able to start with the
segments.
Step 3: In this final step, the client acknowledges the response of the Server,
and they both create a stable connection will begin the actual data transfer
process.
Case 1
Case 2
What is Protocol?
A network protocol is an established set of rules that determine how data
is transmitted between different devices in the same network.
We have seen that the client and server carry on a machine-to-machine
conversation
A network protocol is the set of rules governing a conversation between a
client and a server
There are many protocols, HTTP is just one
HTTP vs HTML
The Web client and the Web server are application programs
Application layer programs do useful work like retrieving Web
pages, sending and receiving email or transferring files
Lower layers take care of the communication details
The client and server send messages and data without
knowing anything about the communication network
Many application layer protocols are used on the
Internet, HTTP is only one
SMTP - POP3 - IMAP
SMTP (Simple Mail Transfer Protocol) is a TCP/IP protocol used in sending
and receiving email. SMTP is used most commonly by email clients,
including Gmail, Outlook, Apple Mail and Yahoo Mail. SMTP can send and
receive email, but email clients typically use a program with SMTP for
sending email.
POP3 (Post Office Protocol)
POP3 is an older protocol that was originally designed to be used on
only one computer. Unlike modern protocols that use two-way
synchronization, POP3 only supports one-way email synchronization,
only allowing users to download emails from a server to a client.
IMAP stands for Internet Message Access Protocol. It is an application
layer protocol which is used to receive the emails from the mail server. It
is the most commonly used protocols like POP3 for retrieving the emails.
The basic difference between SMTP and POP3 is that SMTP is a message
transfer agent used to send the message and POP3 is a message access agent
used to receive the message.
The SMTP is a protocol that defines the working of Message Transfer Agent. It
is used to send the mail from the sender’s computer to the receiver’s mail
server. POP is a pull protocol that is required to pull mail from receiver’s mail
server to receiver’s computer. It also let user organize the mails.
sender side
SMTP protocol is used in the scenario where both the sender and receiver of
mail must be connected to their mail server by WAN or LAN. SMTP protocol is
used two times, first between sender and its mail server and second between
client’s mail server and receivers mail server. SMTP is not used between
receiver’s mail server and receiver; the POP protocol accomplishes this task.
receiver side
To access mail from the mail box present at the mail server the client MAA at
recipient computer establishes the connection with the mail server using TCP
port 110. For establishing connection client MAA at recipient’s computer
sends username and password to the mailbox. Then the user is authenticated
to retrieve mail messages one by one.
SMTP vs POP3
BASIS FOR COMPARISON SMTP POP3
Full form Simple Mail Transfer Protocol. Post Office Protocol version 3.
It transfers the
It allows to retrieve and organize
mail from senders computer to
work mails from mailbox on receiver mail
the mail box present on receiver's
server to receiver's computer.
mail server.
DNS
What is DNS?
DNS stands for Domain Name System (DNS) services. When we access a
website, we are using this service to locate the server where the domain's
website is located. When browsing the web, we usually type in a domain name
like www.google.com into our browser. This is better than trying to remember
an IP address linked to a Google server.
Behind the scenes, a conversion happens using this service which converts
www.google.com to 172.217.12.46. The IP address designates the location of a
server on the Internet. This conversion process is called a query. This is an
integral part of how devices connect with each other to communicate over
the internet. To understand the query process, let’s review how this query
works.
Iterative DNS Lookup