Computer Networks Notes
Computer Networks Notes
Datagram Network
In a connectionless communication systems, datagram refers to the smallest unit via which data
is transmitted. Datagrams are data packets which contain adequate header information so that
they can be individually routed by all intermediate network switching devices to the destination.
These networks are called datagram networks since communication occurs via datagrams.
They exist in packet switching networks.
Drawback –
The problem with the choke packet technique is that the action to be taken by the source host
on receiving a choke packet is voluntary and not compulsory.
Routing is the process of establishing the routes that data packets must follow to reach the
destination. In this process, a routing table is created which contains information regarding
routes that data packets follow. Various routing algorithms are used for the purpose of
deciding which route an incoming data packet needs to be transmitted on to reach the
destination efficiently.
Classification of Routing Algorithms
The routing algorithms can be classified as follows:
1. Adaptive Algorithms
2. Non-Adaptive Algorithms
3. Hybrid Algorithms
The routing protocol could be a routing formula that gives the most straightforward path from the
supply to the destination. The simplest path is the path that has the least-cost path from the
source to the destination
1. Adaptive Algorithms
These are the algorithms that change their routing decisions whenever network topology or
traffic load changes. The changes in routing decisions are reflected in the topology as well as
the traffic of the network. Also known as dynamic routing, these make use of dynamic
information such as current topology, load, delay, etc. to select routes. Optimization
parameters are distance, number of hops, and estimated transit time.
Further, these are classified as follows:
Isolated: In this method each, node makes its routing decisions using the information it
has without seeking information from other nodes. The sending nodes don’t have
information about the status of a particular link. The disadvantage is that packets may be
sent through a congested network which may result in delay. Examples: Hot potato
routing, and backward learning.
Centralized: In this method, a centralized node has entire information about the network
and makes all the routing decisions. The advantage of this is only one node is required to
keep the information of the entire network and the disadvantage is that if the central node
goes down the entire network is done. The link state algorithm is referred to as a
centralized algorithm since it is aware of the cost of each link in the network.
Distributed: In this method, the node receives information from its neighbors and then
takes the decision about routing the packets. A disadvantage is that the packet may be
delayed if there is a change in between intervals in which it receives information and
sends packets. It is also known as a decentralized algorithm as it computes the least-cost
path between source and destination.
2. Non-Adaptive Algorithms
These are the algorithms that do not change their routing decisions once they have been
selected. This is also known as static routing as a route to be taken is computed in advance
and downloaded to routers when a router is booted.
Further, these are classified as follows:
Flooding: This adapts the technique in which every incoming packet is sent on every
outgoing line except from which it arrived. One problem with this is that packets may go in
a loop and as a result of which a node may receive duplicate packets. These problems
can be overcome with the help of sequence numbers, hop count, and spanning trees.
Random walk: In this method, packets are sent host by host or node by node to one of its
neighbors randomly. This is a highly robust method that is usually implemented by sending
packets onto the link which is least queued.
3. Hybrid Algorithms
As the name suggests, these algorithms are a combination of both adaptive and non-adaptive
algorithms. In this approach, the network is divided into several regions, and each region uses
adifferentalgorithm.
Further, these are classified as follows:
Link-state: In this method, each router creates a detailed and complete map of the network
which is then shared with all other routers. This allows for more accurate and efficient
routing decisions to be made.
Distance vector: In this method, each router maintains a table that contains information
about the distance and direction to every other node in the network. This table is then
shared with other routers in the network. The disadvantage of this method is that it may
lead to routing loops.
Bellman Ford’s Algorithm works when Dijkstra’s Algorithm may or may not work when
there is negative weight edge, it also there is negative weight edge. But will definitely
detects the negative weight cycle. not work when there is a negative weight cycle.
The result contains the vertices which The result contains the vertices containing whole
contains the information about the other information about the network, not only the
vertices they are connected to. vertices they are connected to.
It is more time consuming than Dijkstra’s It is less time consuming. The time complexity is
algorithm. Its time complexity is O(VE). O(E logV).
Bellman Ford’s Algorithm have more Dijkstra’s Algorithm have less overheads than
overheads than Dijkstra’s Algorithm. Bellman Ford’s Algorithm.
Bellman Ford’s Algorithm have less Dijkstra’s Algorithm have more scalability than
scalability than Dijkstra’s Algorithm. Bellman Ford’s Algorithm.
TCP (Transmission Control Protocol) is one of the main protocols of the Internet protocol
suite. It lies between the Application and Network Layers which are used in providing reliable
delivery services. It is a connection-oriented protocol for communications that helps in the
exchange of messages between different devices over a network. The Internet Protocol (IP),
which establishes the technique for sending data packets between computers, works with
TCP.
Features of TCP
TCP keeps track of the segments being transmitted or received by assigning numbers to
every single one of them.
Flow control limits the rate at which a sender transfers data. This is done to ensure reliable
delivery.
TCP implements an error control mechanism for reliable data transfer.
TCP takes into account the level of congestion in the network.
Advantages of TCP
User Datagram Protocol (UDP) is a Transport Layer protocol. UDP is a part of the Internet
Protocol suite, referred to as the UDP/IP suite. Unlike TCP, it is an unreliable and
connectionless protocol. So, there is no need to establish a connection before data transfer.
The UDP helps to establish low-latency and loss-tolerating connections establish over the
network. The UDP enables process-to-process communication.
Features of UDP
Used for simple request-response communication when the size of data is less and hence
there is lesser concern about flow and error control.
It is a suitable protocol for multicasting as UDP supports packet switching.
UDP is used for some routing update protocols like RIP(Routing Information Protocol) .
Normally used for real-time applications which can not tolerate uneven delays between
sections of a received message.
Advantages of UDP
We can not have any way to acknowledge the successful transfer of data.
UDP cannot have the mechanism to track the sequence of data.
UDP is connectionless, and due to this, it is unreliable to transfer data.
In case of a Collision, UDP packets are dropped by Routers in comparison to TCP.
UDP can drop packets in case of detection of errors.
There is no retransmission of
Retransmission of lost packets is possible in
Retransmission lost packets in the User
TCP, but not in UDP.
Datagram Protocol (UDP).
TCP has a (20-60) bytes variable length UDP has an 8 bytes fixed-length
Header Length
header. header.
Handshaking Uses handshakes such as SYN, ACK, SYN- It’s a connectionless protocol i.e.
Techniques ACK No handshake
Techniques that can be used to improve the quality of service as follows scheduling,
traffic shaping, admission control and resource reservation.
• Scheduling :
Packets from different flows arrive at a switch or router for processing. A good scheduling
technique treats the different flows in a fair and appropriate manner. Several scheduling
techniques are designed to improve the quality of service. Three of them here: FIFO queuing,
priority queuing, and weighted fair queuing.
1) FIFO Queuing: In first-in, first-out (FIFO) queuing, packets wait in a buffer (queue) until the
node (router or switch) is ready to process them. If the average arrival rate is higher than the
average processing rate, the queue will fill up and new packets will be discarded. Figure1 shows
a conceptual view of a FIFO queue.
2) Priority Queuing: In priority queuing, packets are first assigned to a priority class. Each
priority class has its own queue. The packets in the highest-priority queue are processed first.
Packets in the lowest-priority queue are processed last. Note that the system does not stop
serving a queue until it is empty. A priority queue can provide better QoS than the FIFO queue
because higher priority traffic, such as multimedia, can reach the destination with less delay.
3) Weighted Fair Queuing: A better scheduling method is weighted fair queuing. In this
technique, the packets are still assigned to different classes and admitted to different queues.
The queues, however, are weighted based on the priority of the queues; higher priority means a
higher weight. The system processes packets in each queue in a round-robin fashion with the
number of packets selected from each queue based on the corresponding weight.
• Traffic Shaping : Traffic shaping is a mechanism to control the amount and the rate of the
traffic sent to the network. Two techniques can shape traffic: leaky bucket and token bucket.
1) Leaky Bucket: A technique called leaky bucket can smooth out bursty traffic. Bursty chunks
are stored in the bucket and sent out at an average rate.
. A FIFO queue holds the packets. If the traffic consists of fixed-size packets, the process
removes a fixed number of packets from the queue at each tick of the clock. If the traffic
consists of variable-length packets, the fixed output rate must be based on the number of bytes
or bits.
The following is an algorithm for variable-length packets:
1. Initialize a counter to n at the tick of the clock.
2. If n is greater than the size of the packet, send the packet and decrement the counter by
the packet size. Repeat this step until n is smaller than the packet size.
3. Reset the counter and go to step 1.
2) Token Bucket: The token bucket algorithm allows idle hosts to accumulate credit for the
future in the form of tokens. For each tick of the clock, the system sends n tokens to the bucket.
The system removes one token for every cell (or byte) of data sent. For example, if n is 100 and
the host is idle for 100 ticks, the bucket collects 10,000 tokens. Now the host can consume all
these tokens in one tick with 10,000 cells, or the host takes 1,000 ticks with 10 cells per tick. In
other words, the host can send bursty data as long as the bucket is not empty.
• Resource Reservation :
A flow of data needs resources such as a buffer, bandwidth, CPU time, and so on. The quality
of service is improved if these resources are reserved beforehand.
• Admission Control :
Admission control refers to the mechanism used by a router, or a switch, to accept or reject a
flow based on predefined parameters called flow specifications. Before a router accepts a flow
for processing, it checks the flow specifications to see if its capacity (in terms of bandwidth,
buffer size, CPU speed, etc.) and its previous commitments to other flows can handle the new
flow.
An application layer is an abstraction layer that specifies the shared communications protocols
and interface methods that host in network use. It is the layer closest to the end user, implying
that both the application layer and the end user can interact with the software application
directly.
One of the most popular application layer protocols for network services is electronic mail (e-
mail). The TCP/IP protocol that supports electronic mail on the Internet is called Simple Mail
Transfer Protocol (SMTP).
SMTP transfers messages from senders’ mail servers to the recipients’ mail servers using TCP
connections. In SMTP, users are based on e-mail addresses. SMTP provides services for mail
exchange between users on the same or different computers.
SMTP has two sides: a client-side, which executes on a sender’s mail server, and a
server-side, which executes on the recipient’s mail server.
Both the client and server sides of SMTP run on every mail server.
When a mail server sends mail (to other mail servers), it acts as an SMTP client.
When a mail server receives mail (from other mail servers), it acts as an SMTP server.
2.Terminal Network(TELNET)
TELNET is an application layer protocol in which a client-server application allows a user to log
onto a remote machine and lets the user access any application program on a remote
computer. TELNET uses the NVT (Network Virtual Terminal) system to encode characters on
the local system.
On the server (remote) machine, NVT decodes the characters to a form acceptable to the
remote machine. TELNET is a protocol that provides a general, bi-directional, eight-bit byte-
oriented communications facility. Many application protocols are built upon the TELNET
protocol. Telnet services are used on PORT 23.
Data Connection uses PORT 20, and control connection uses PORT 21. FTP is built on a client-
server architecture and uses separate control and data connections between the client and the
server. One connection is used for data transfer, the other for control information (commands
and responses). The FTP is data reliably and efficiently.
Content-Transfer-Encoding: The header alerts the receiving user agent that the
message body has been ASCII encoded and the type of encoding used.
Content-Type: The header informs the receiving mail agent about the type of data in the
message.
When a user connects to the mail server to retrieve his mail, the messages are downloaded
from the mail server to the user’s hard disk.
The HTTP protocol transfers data in plain text, hypertext, audio, video, etc. HTTP utilizes TCP
connections to send client requests and server replies. It is a synchronous protocol that works
by making both persistent and non-persistent connections.
DNS in the Internet: DNS is a protocol that can be used on different platforms.
Generic Domain: The generic domain defines registered hosts according to their generic
behavior. Each node in the tree defines a domain which is an index to the domain name
space database
Country Domain: The country domain section follows the same format as the generic
domain but uses 2 characters of country abbreviations (e.g., the US for the United
States) instead of 3 characters.
Inverse Domain: The inverse domain maps an address to a name.