0% found this document useful (0 votes)
14 views246 pages

CN Notes

The document outlines the first module of a Computer Networks course, covering key concepts in data communications and networking. It details components of data communication, types of networks, network criteria, and various topologies, including Local Area Networks (LAN) and Wide Area Networks (WAN). Additionally, it discusses data flow modes, protocol layering, and switching methods, providing a comprehensive overview of the foundational elements of computer networking.

Uploaded by

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

CN Notes

The document outlines the first module of a Computer Networks course, covering key concepts in data communications and networking. It details components of data communication, types of networks, network criteria, and various topologies, including Local Area Networks (LAN) and Wide Area Networks (WAN). Additionally, it discusses data flow modes, protocol layering, and switching methods, providing a comprehensive overview of the foundational elements of computer networking.

Uploaded by

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

COMPUTER NETWORKS– V SEM CSE VTU

CONTENTS: MODULE -1

1. DATA COMMUNICATIONS
1.1. Components
1.2. Data Representation
1.3. Data Flow
2. NETWORKS
2.1. Network Criteria
2.2. Physical Structures
3. NETWORK TYPES
3.1. Local Area Network
3.2. Wide Area Network
3.3. Switching
3.4. The Internet
3.5. Accessing the Internet
4. PROTOCOL LAYERING
4.1. Scenarios
4.2. Principles of Protocol Layering
4.3. Logical Connections
5. TCP/IP PROTOCOL SUITE
5.1. Layered Architecture
5.2. Layers in the TCP/IP Protocol Suite
5.3. Description of Each Layer
5.4. Encapsulation and Decapsulation
5.5. Addressing
5.6. Multiplexing and Demultiplexing
6. TRANSMISSION MEDIA
6.1. GUIDED MEDIA
6.2. Twisted-Pair Cable
6.3. Coaxial Cable
6.4. Fiber-Optic Cable
7. UNGUIDED MEDIA: WIRELESS
7.1. Radio Waves
7.2. Microwaves
7.3. Infrared
8. PACKET SWITCHING
8.1. Datagram Networks
8.2. Virtual-Circuit Networks
MODULE-1: Data Communications & Networks

1. DATA COMMUNICATIONS
Data communication is the process of transferring data from one point to another using a
communication system. It involves several essential components and mechanisms to ensure the
accurate and timely delivery of data.

1.1. Components
A data communication system includes the following components:

Figure 1.1: A data communications system has five components

1. Message: The data or information being communicated (e.g., text, images, audio).

2. Sender: The device that sends the message, such as a computer or smartphone.
3. Receiver: The device that receives the message, like another computer or a printer.

4. Transmission Medium: The physical path through which the data is transmitted, like
cables or radio waves.

5. Protocol: A set of rules that governs the communication between devices to ensure proper
data exchange.
The performance of a data communication system relies on four key characteristics: delivery,
accuracy, timeliness, and jitter.
1. Delivery: The system must ensure that data reaches the correct destination. Only the
intended recipient—whether a device or a user—should receive the data.

2. Accuracy: Data must be transmitted without errors. If data is altered during transmission
and not corrected, it becomes unusable.

3. Timeliness: Data must be delivered promptly. Delayed data, especially in applications like
video and audio, lose their value. For real-time transmission, data must be delivered in the
same sequence and without significant delays.

Dr. Devaraju B M Dept of CSE, RNSIT 1


4. Jitter: Jitter refers to the inconsistency in packet arrival times. Inconsistent delays, such as
video packets arriving at varying intervals, can degrade the quality of the audio or video.
For instance, if video packets are sent every 30 ms, but some arrive after 40 ms, the video
quality will be affected.

1.2. Data Representation


Data can be represented in various forms to suit the type of communication. Common types of
data representation include:
• Text: Represented as a sequence of bits using encoding systems like ASCII or Unicode.

• Numbers: Represented directly in binary form, which allows for efficient computation and
transmission.
• Images: Represented as a matrix of pixels, where each pixel is assigned a bit pattern based
on the image's color or intensity. Color images often use RGB (Red, Green, Blue) or YCM
(Yellow, Cyan, Magenta) encoding.

• Audio: Audio data is captured as a continuous signal, which can be sampled and digitized
for transmission.

• Video: A sequence of images or frames is used to convey motion, with each frame
represented as individual bit patterns.

1.3. Data Flow


Data flow refers to the manner in which data is transmitted between two devices. It can happen
in three modes:

1. Simplex: Data flows in one direction only, like a keyboard sending data to a computer
(one-way communication).
2. Half-Duplex: Both devices can send and receive data, but not at the same time. For
example, a walkie-talkie allows communication in both directions, but one at a time.
3. Full-Duplex: Both devices can transmit and receive data simultaneously, like in a phone
conversation where both parties can speak and listen at the same time.

Dr. Devaraju B M Dept of CSE, RNSIT 2


Figure 1.2: Data flow (simplex, half-duplex, and full-duplex)

2. NETWORKS
A network refers to the interconnection of a set of devices capable of communication. These
devices can include hosts such as computers, smartphones, and security systems, as well as
connecting devices like routers, switches, and modems. Networks are connected through
transmission media, either wired (like cables) or wireless (like air).

2.1. Network Criteria


Networks must meet several essential criteria to be effective, namely:

1. Performance: This is evaluated by:

o Transit time: Time for a message to travel between two devices.

o Response time: Time between sending a request and receiving a response. Factors
influencing performance include the number of users, the transmission medium,
hardware capabilities, and software efficiency. Key metrics include:

o Throughput: Amount of data transmitted successfully.

o Delay: Time taken for data to reach its destination. Optimizing both often leads to
trade-offs.

2. Reliability: This includes:

o Accuracy in data delivery.

o Frequency and recovery time from network failures.


o The network’s ability to function during a catastrophe.
3. Security: It encompasses protecting data from unauthorized access, damage, or corruption
and establishing recovery procedures for security breaches.

Dr. Devaraju B M Dept of CSE, RNSIT 3


2.2. Physical Structures
Networks can be categorized by their connection types and topologies:

1. Type of Connection:

o Point-to-Point: A direct link between two devices, providing the full capacity of
the link for communication (e.g., remote control to TV).

o Multipoint (Multidrop): Multiple devices share a single link, either spatially


(simultaneous use) or temporally (taking turns).

Figure 1.3: Types of connections: point-to-point and multipoint

2. Physical Topology: Refers to how devices are physically arranged in a network. Four main
topologies include:

o Mesh Topology:

▪ Every device is connected to every other device, requiring n(n−1)/2 links


for n devices.

▪ Node 1 must be connected to n – 1 nodes, node 2 must be connected to n –


1 nodes, and finally node n must be connected to n – 1 nodes. We need n (n
– 1) physical links. However, if each physical link allows communication
in both directions (duplex mode), we can divide the number of links by 2.
In other words, we can say that in a mesh topology, we need n (n – 1) / 2
duplex-mode links.

▪ Advantages: Dedicated links, fault isolation, robust, secure.

▪ Disadvantages: Expensive, complex installation, excessive cabling.

▪ Example: Telephone networks between regional offices.

Dr. Devaraju B M Dept of CSE, RNSIT 4


Figure 1.4 A fully connected mesh topology (five devices)

o Star Topology:
▪ Each device is connected to a central hub, which manages communication.

▪ Advantages: Easy installation and fault isolation; if a link fails, only that
device is affected.

▪ Disadvantages: Entire system fails if the hub goes down.

▪ Common in local area networks (LANs).

Figure 1.5: A star topology connecting four stations

o Bus Topology:

▪ All devices are connected to a single backbone cable.

▪ Advantages: Easy installation, less cabling than mesh.

▪ Disadvantages: Difficult to add devices, faults in the backbone disrupt the


entire network.

▪ Example: Early Ethernet LANs.

Dr. Devaraju B M Dept of CSE, RNSIT 5


Figure 1.6: A bus topology connecting three stations

o Ring Topology:

▪ Devices are connected in a loop, with signals traveling in one direction


through repeaters.

▪ Advantages: Easy to install, simple fault detection.

▪ Disadvantages: A break in the ring can disable the entire network, though
dual rings or switches can mitigate this.

▪ Example: IBM’s Token Ring LANs.

Figure 1.7: A ring topology connecting six stations

3. NETWORK TYPES
Which is used to connect networks to form an internetwork (a network of networks).

3.1. Local Area Network (LAN)


A LAN is a network that connects computers and devices within a small geographical area, such
as a home, office, or campus.

Characteristics:

• Covers a limited area.


• High data transfer rates (up to 10 Gbps).
• Typically owned and managed by a single organization.

Dr. Devaraju B M Dept of CSE, RNSIT 6


Examples: Ethernet networks, Wi-Fi networks in homes and small offices.

Figure 1.8: An isolated LAN in the past and today


LAN Setup:
• Common Cable Connection: In the past, all hosts within a Local Area Network (LAN)
were connected via a single common cable.
o Packet Transmission: When one host sent a packet to another, it was broadcast to
all hosts on the network.
o Packet Filtering: The intended recipient would accept the packet, while all other
hosts would drop it.
o Drawback: This method created significant network congestion, as every packet
was visible to all hosts, even when they weren't the intended recipient.
Modern LAN Setup:
• Switch-Based LAN: Today, most LANs use smart switches to handle packet delivery.
o Address Recognition: A switch is intelligent enough to recognize the destination
address of each packet.
o Selective Packet Forwarding: Instead of broadcasting packets to all hosts, the
switch sends the packet directly to the destination host.
o Benefits:
▪ Reduced Traffic: Since packets are only sent to the intended recipient,
overall network traffic is significantly reduced.
▪ Simultaneous Communication: More than one pair of hosts can
communicate simultaneously as long as they have different source and
destination addresses. This improves network efficiency.
LAN Capacity:
• Flexibility: The term "LAN" does not specify any constraints on the number of hosts. A
LAN can accommodate a wide range of host numbers, depending on the network’s size
and structure.

Dr. Devaraju B M Dept of CSE, RNSIT 7


3.2. Wide Area Network (WAN)
A WAN covers a large geographical area, such as a city, country, or even globally. It connects
multiple LANs.
Characteristics:

• Slower data transfer rates than LANs.


• Often managed by multiple entities (e.g., ISPs, governments).
• Utilizes routers and public or private communication links.

Examples: The Internet itself is a WAN, Private networks connecting different company
branches.

A point-to-point WAN:

Figure 1.9: A point-to-point WAN

A Point-to-Point WAN is a network that connects two communication devices directly via
transmission media, such as cables or wireless links. This type of network allows data transmission
between just two endpoints, ensuring a dedicated and private communication link. Used by
businesses to link branch offices or remote locations.

Transmission Media:

• Cable: Examples include fiber optic, coaxial, or twisted-pair cables.


• Air: Wireless links like microwave or satellite connections.

Advantages:

• Dedicated Line: Since only two devices share the link, there is minimal congestion and
consistent bandwidth.
• Security: Limited exposure to external devices reduces the risk of unauthorized access.

A switched WAN:

A switched Wide Area Network (WAN) is a network infrastructure with multiple endpoints that
are interconnected. Unlike traditional point-to-point WANs, which only connect two endpoints, a
switched WAN allows for dynamic routing between several nodes through switches.

Dr. Devaraju B M Dept of CSE, RNSIT 8


Role in Global Communication: Switched WANs are fundamental in the backbone of modern
global communication systems, facilitating data transfer across vast geographical areas.

• A switched WAN is scalable and can connect many endpoints.


• The switches in the network are responsible for choosing the best path for data to travel.
• It is commonly used in large-scale, high-traffic networks like the internet.

Figure 1.10: A switched WAN

Internetwork
In modern networks, it's uncommon to find a LAN (Local Area Network) or WAN (Wide Area
Network) operating independently. Instead, they are often connected. When two or more networks
connect, they form an internetwork, or internet.
For example, imagine a company with offices on the east and west coasts. Each office has a LAN
where employees can communicate within the office. To allow communication between employees
at both locations, the company leases a dedicated WAN connection from a service provider. This
WAN links the two LANs, creating an internetwork, or a private internet. Now, employees from
both offices can communicate with each other

Figure 1.11: An internetwork made of two LANs and one point-to-point WAN

A heterogeneous network
A heterogeneous network is a system that connects various types of devices and network
architectures. The term "heterogeneous" signifies diversity in the types of networks, which may

Dr. Devaraju B M Dept of CSE, RNSIT 9


include different hardware, operating systems, and communication protocols. When combining
WANs and LANs into a heterogeneous network, the WANs provide the backbone for long-distance
communication, while the LANs allow for local connectivity.

Figure 1.12: A heterogeneous network made of four WANs and three LANs

3.3. Switching
Switching is the process of forwarding data packets in a network from a source to a destination
through intermediate devices called switches.
Types of Switching:

1. Circuit Switching:

In a circuit-switched network, a fixed connection (circuit) is always available between two devices,
like telephones, and it can be activated or deactivated by the network switch.

Figure 1.13: A circuit-switched network

Dr. Devaraju B M Dept of CSE, RNSIT 10


Example Figure 1.13

• The network consists of four telephones on each side, connected to a switch.


• When a call is made, the switch connects a phone on one side to a phone on the other side.
• A thick line connects the two switches, with enough capacity to support four simultaneous
voice calls. This line’s capacity is shared by all phone pairs.

Two Scenarios:

1. All phones are in use: Four people on one side are talking to four people on the other side,
using the full capacity of the line.
2. One phone in use: Only one pair of phones is talking, using only one-quarter of the line’s
capacity.

Disadvantages: A circuit-switched network is only efficient when operating at full capacity. If


fewer devices are active, the unused capacity leads to inefficiency. The thick line needs four times
the capacity of a single voice line to prevent call failures when all phones are in use simultaneously.

2. Packet Switching:

In a computer network, communication between devices is carried out in blocks of data called
packets, rather than as continuous streams, as seen in phone calls. These packets are independent
units, which makes it possible for network switches to store and forward them later if needed.

Example Figure 1.14

A packet-switched network where two sets of four computers are connected across two sites. In
this setup, a router queues the packets and sends them when the network is ready.

Figure 1.14: A packet-switched network

Consider a scenario where the thick line (the main connection) has twice the capacity of the smaller
data lines that connect computers to routers. If only two computers (one from each site) are
communicating, the packets move without delay. However, if the thick line is busy and more
packets arrive, they are queued and sent in order of arrival.

Dr. Devaraju B M Dept of CSE, RNSIT 11


Disadvantages: This demonstrates the efficiency of packet-switched networks over circuit-
switched networks. However, packet-switching can introduce delays when network traffic is
heavy.

3. Message Switching:
o Entire messages are stored and forwarded from one switch to another (obsolete in
modern networks).

3.4. The Internet


The Internet is a global system of interconnected computer networks that use the TCP/IP
protocol to link billions of devices worldwide.
Characteristics:

• Decentralized: No central controlling entity.


• Based on TCP/IP for communication.
• Enables various services such as web browsing, email, file sharing, etc.

Components:

• Clients: Devices that request services from servers.


• Servers: Systems that provide resources and services to clients.
• Routers and switches: Devices that direct data traffic across the network.
• ISPs (Internet Service Providers): Organizations that provide access to the Internet.

Figure 1.15: The Internet today

Dr. Devaraju B M Dept of CSE, RNSIT 12


3.5. Accessing the Internet

Methods of Access:

1. Dial-up:
o Connects to the Internet using a telephone line.
o Low-speed, outdated method (up to 56 kbps).
2. DSL (Digital Subscriber Line):
o Uses telephone lines but allows simultaneous voice and data transmission.
o Faster than dial-up (up to 100 Mbps).
3. Cable:
o Uses cable television lines to provide high-speed Internet (up to 1 Gbps).
4. Fiber Optic:
o Uses light to transmit data through optical fibers.
o Extremely high-speed (up to 10 Gbps and beyond).
5. Satellite:
o Provides Internet access via satellite communication, useful in remote areas.
o Slower than fiber or cable but offers wide coverage.
6. Mobile Broadband:
o Wireless Internet access through cellular networks (3G, 4G, 5G).
o Widely accessible but may have data limits.
7. Wi-Fi Access:

• Wireless local area networking technology that allows devices to access the
Internet within the range of a wireless router.
• Common in homes, offices, and public places.

4. PROTOCOL LAYERING
Protocol layering is a design principle in computer networks where communication tasks are
broken down into multiple layers. Each layer performs a specific function, and the layers work
together to enable communication between devices over a network.

4.1. Scenarios
First Scenario: Simple Communication in One Layer

Figure 1.16: A single-layer protocol

Dr. Devaraju B M Dept of CSE, RNSIT 13


In the first scenario, communication is straightforward and occurs in a single layer. Imagine Maria
and Ann, who are neighbors and share many common interests. Their interaction happens face-to-
face, in the same language, as depicted in Figure 1.16. Despite its simplicity, certain rules govern
their communication.
Second Scenario: A three-layer protocol

In this scenario, Ann is offered a promotion requiring her to relocate far from her friend Maria.
Despite the distance, they wish to continue their communication to collaborate on an innovative
project for their future retirement business. To maintain the confidentiality of their exchange, they
decide to use a secure encryption/decryption technique. This technique ensures that their letters
remain unreadable to unauthorized individuals.

Figure 1.17 A three-layer protocol

The communication between Ann and Maria can be visualized as taking place in three distinct
layers:

1. Third Layer (Plaintext Creation): Maria speaks to the third-layer machine, which listens
and generates the plaintext (the original letter). This plaintext is then handed over to the
second-layer machine.
2. Second Layer (Encryption/Decryption): The second-layer machine encrypts the
plaintext, creating ciphertext (the encrypted letter). This ciphertext is then passed to the
first-layer machine.

3. First Layer (Mailing): The first-layer machine puts the ciphertext in an envelope, adds
the sender's and receiver's addresses, and mails it.

Dr. Devaraju B M Dept of CSE, RNSIT 14


Protocol layering is useful in various scenarios, such as:

• Data transmission over the internet where multiple types of data (emails, videos, web
pages) are transmitted using different protocols at each layer.

• Device communication between a computer and a printer, where layered protocols


manage data transfer and error detection.

• Telecommunication systems, where layered protocols ensure voice signals are transmitted
efficiently and correctly.

• Multimedia streaming, where protocols manage data buffering, synchronization, and


error correction to deliver seamless audio and video streams.

Advantages of Protocol Layering:


1. Modularity: Each layer is independent, allowing for changes in one layer without affecting
others. For example, if Ann and Maria decide that the encryption needs to be upgraded,
they can replace only the second-layer machine without altering the other layers.

2. Service Separation: Protocol layering separates the services from their implementation.
Maria could perform the tasks of the first layer herself if needed, as long as she provides
the required services.
3. Intermediate Systems: In more complex networks, intermediate systems only need to
handle specific layers, making the overall system less complex and less expensive.

Disadvantages of Protocol Layering:


1. Complexity in Layer Integration: While modularity offers flexibility, it can add
complexity. A single machine performing all tasks could simplify the setup, but if there are
issues, the entire system might need to be replaced rather than just one layer.

4.2. Principles of Protocol Layering

First Principle: Bidirectional Communication

To achieve bidirectional communication in protocol layering, each layer must be designed to


handle two complementary tasks, one for each direction of communication. For example:

Third Layer: Responsible for listening in one direction and transmitting in the other.
Second Layer: Handles encryption in one direction and decryption in the other.
First Layer: Manages sending and receiving mail.

Dr. Devaraju B M Dept of CSE, RNSIT 15


Each layer must be capable of performing its specific function for both incoming and outgoing
data.

Second Principle: Identical Objects

In protocol layering, the objects processed by each layer at both communicating sites must be
identical. For instance:

Layer 3: The object should be a plaintext letter at both sites.


Layer 2: The object should be a ciphertext letter at both sites.
Layer 1: The object should be a piece of mail at both sites.

Consistency in the objects at each layer ensures proper communication and processing across
different layers.

4.3. Logical Connections

Figure 1.18: Logical connection between peer layers

This means there is communication from one layer to the next. Imagine that Maria and Ann view
each layer as having a logical (or imaginary) connection that allows them to transmit objects
created at that layer. Understanding these logical connections will enhance your comprehension of
layering in data communication and networking.
In a layered model, logical connections refer to virtual connections established between the same
layers in different devices. For example:
• The application layers of two computers communicate as though they are directly
connected, even though physical transmission occurs across multiple lower layers.

• Logical connections provide the abstraction necessary to hide the complexities of the
underlying transmission methods, giving the appearance that communication occurs at a
single layer.

Dr. Devaraju B M Dept of CSE, RNSIT 16


Logical connections ensure that communication protocols at each layer, such as TCP (Transport
Layer) or HTTP (Application Layer), interact correctly without the user needing to understand the
intricacies of network transmission.

5. TCP/IP PROTOCOL SUITE


TCP/IP is the protocol suite widely used for communication on the Internet today. It is a collection
of protocols organized into different layers, where each layer handles specific tasks, making it
easier to manage complex communication processes. TCP/IP is a hierarchical protocol, meaning
that each higher-level protocol depends on the services provided by one or more lower-level
protocols. This layered structure ensures efficient and organized communication across networks.
However, today, it is more commonly represented as a five-layer model. These layers work
together to ensure smooth data transmission over the network.

5.1. Layered Architecture

To understand how the layers in the TCP/IP protocol suite work during communication between
two hosts, let's consider a small network composed of three local area networks (LANs), each
connected by a link-layer switch. These LANs are also interconnected through a router. Figure
1.20 illustrates this setup.

Figure 1.19: Layers in the TCP/IP protocol suite

In this scenario, imagine that Host A (the source) communicates with Host B (the destination).
The communication process involves five devices:

1. Source Host (Computer A)


2. Link-layer switch in LAN 1
3. Router
4. Link-layer switch in LAN 2
5. Destination Host (Computer B)

Dr. Devaraju B M Dept of CSE, RNSIT 17


Figure 1.20: Communication through an internet

Each of these devices operates at different layers of the TCP/IP protocol stack, depending on its
role in the network:

1. Hosts (Source and Destination)

Both Host A and Host B are involved in all five layers of the TCP/IP model:

• Application Layer: The source host (Host A) creates a message at the application layer
and sends it down through the stack.
• Transport Layer: The message is passed to the transport layer, which ensures reliable
delivery.
• Network Layer: At the network layer, the message is encapsulated into packets for
transmission across the network.
• Data Link Layer: The packets are then prepared for transmission over the physical
network in the data-link layer.
• Physical Layer: Finally, the message is sent through the physical medium (wires, cables,
etc.) to reach the destination host.

At the destination, Host B receives the message at the physical layer and passes it up through the
layers until it reaches the application layer for processing.

2. Router

A router plays a different role and operates at three layers of the TCP/IP model:

Dr. Devaraju B M Dept of CSE, RNSIT 18


• Network Layer: The router’s primary function is routing packets across networks. It
forwards packets based on their destination IP address.
• Data Link Layer & Physical Layer: A router is connected to multiple links, and each link
may use a different data-link and physical-layer protocol. For instance, if a packet arrives
from LAN 1 (Link 1) using one set of protocols, the router must handle it and forward it to
LAN 2 (Link 2) using another set of protocols.

Importantly, the router does not deal with the transport or application layers, as its role is solely to
move packets between networks.

3. Link-Layer Switch

A link-layer switch operates only at the data-link and physical layers:

• Data Link Layer: The switch processes the data frames and ensures they are forwarded to
the correct device within the same LAN.
• Physical Layer: The switch forwards the data through the physical medium.

Unlike routers, link-layer switches do not need to handle different sets of protocols for different
links. They operate within a single LAN, using a single protocol set for the data-link and physical
layers.

5.2. Layers in the TCP/IP Protocol Suite

TCP/IP protocol suite functions and responsibilities of each layer.

Understanding the Logical Connections Between Layers

To grasp the role of each layer, it's helpful to visualize the logical connections between them.
Figure 1.21 in the book illustrates these connections in a simple internet model.

• End-to-End vs. Hop-to-Hop Duties:


o The application, transport, and network layers are responsible for end-to-end
communication, meaning they manage data from one end device to the other
across the network.
o The data-link and physical layers, on the other hand, handle communication on
a hop-to-hop basis, where each "hop" refers to a host or router.

This distinction is key: the top three layers operate across the entire internet, while the lower two
layers manage communication on individual network segments or "links."

Data Units and Layer Responsibilities

Another important way to understand these connections is by considering the data units created
at each layer.

Dr. Devaraju B M Dept of CSE, RNSIT 19


• In the top three layers, the data units (referred to as packets) are not modified by routers
or link-layer switches.
• In the bottom two layers, however, the packet created by the host can be modified by
routers but not by link-layer switches.

Figure 1.21: Logical connections between layers of the TCP/IP protocol suite

Figure 1.22 shows a second principle of protocol layering: identical objects exist below each
layer for connected devices.

• At the network layer, even though there's a logical connection between two hosts, a
router might fragment packets into smaller units.
• The link between two hops does not alter these packets.

This layering approach allows for a structured, predictable method of managing data as it moves
across the network.

Figure 1.22: Identical objects in the TCP/IP protocol suite

Dr. Devaraju B M Dept of CSE, RNSIT 20


5.3. Description of Each Layer

Physical Layer:

Role of the Physical Layer:

• The physical layer focuses on transmitting the bits from the data-link layer as electrical or
optical signals over a physical medium (such as cables or wireless channels).
• It converts bits from the data-link layer into signals that can travel through the medium
connecting the devices.

Transmission Media:

• The physical connection between two devices is made through a transmission medium,
which can be either cables (like twisted-pair, fiber-optic cables) or air (wireless
communication).
• The transmission medium does not directly carry bits; instead, it transmits signals
(electrical or optical) that represent the bits.

Logical Communication:

• Despite being the lowest layer, the physical layer enables logical communication between
devices by ensuring that signals are accurately transmitted and interpreted.
• From a logical perspective, the unit of data at this layer is the bit, even though the actual
signals sent over the medium are different in nature.

Signal Transformation:

• The physical layer converts bits into appropriate forms of signals (either electrical or
optical) depending on the medium used.
• Protocols at this layer define how these bits are transformed into signals to be carried over
the medium.

Data-link Layer:

In an internet, multiple links (LANs and WANs) are connected by routers. There are often multiple
paths that a datagram can take from the host to its destination. Routers are responsible for
determining the most efficient route. Once the next link is chosen by a router, the data-link layer
manages the process of transmitting the datagram across that link.

These links can vary widely and include:

• Wired LANs with link-layer switches


• Wireless LANs
• Wired WANs
• Wireless WANs

Dr. Devaraju B M Dept of CSE, RNSIT 21


Each type of link may use different protocols, but the data-link layer has the essential role of
ensuring that the packet is successfully transmitted across any type of link.

The TCP/IP model does not mandate a specific protocol for the data-link layer. Instead, it
accommodates a wide range of both standard and proprietary protocols. Any protocol that can
encapsulate a datagram and move it across a link is considered acceptable.

At the data-link layer, the datagram is encapsulated into a packet, referred to as a frame.

• Some link-layer protocols offer both error detection and correction, ensuring that
transmitted data is free from errors.

Network Layer:

The network layer is crucial for establishing communication between the source and destination
computers. It manages host-to-host communication across multiple devices (routers) in the path.
Each router ensures that packets are directed along the most efficient route. The main role of the
network layer is to enable communication between hosts and determine the best path for data
transmission.

Internet Protocol (IP)

The primary protocol of the network layer is the Internet Protocol (IP), which defines the
structure and format of data packets, known as datagrams at this level. IP also determines the
addressing system, ensuring each packet is sent from its source to its destination. The forwarding
of packets from router to router is a fundamental part of IP's function.

• Connectionless Protocol: IP is connectionless, meaning it does not manage flow control,


error control, or congestion control. These features are handled by the transport layer if
needed by an application.
• Routing Protocols: While IP is responsible for actual routing, protocols like unicast (one-
to-one) and multicast (one-to-many) create forwarding tables to assist routers with routing
decisions.

Auxiliary Protocols Supporting IP

Several additional protocols work alongside IP to assist in the routing and delivery process:

• ICMP (Internet Control Message Protocol): Helps IP report issues encountered during
packet routing.
• IGMP (Internet Group Management Protocol): Supports IP with multicast
communication.
• DHCP (Dynamic Host Configuration Protocol): Assigns network-layer addresses to
hosts.
• ARP (Address Resolution Protocol): Converts a network-layer address into a link-layer
address for communication with a specific host or router.

Dr. Devaraju B M Dept of CSE, RNSIT 22


These protocols ensure efficient routing and network management, enabling seamless host-to-host
communication in complex networks.

Transport Layer:
The Transport Layer plays a crucial role in ensuring end-to-end communication between hosts
in a network. It handles the transfer of data between the application layer on one device and the
corresponding application layer on another device, making sure that messages are transmitted
reliably and efficiently.

Key Functions:

• Encapsulation and Transmission: The transport layer at the source host takes messages
from the application layer, encapsulates them into transport layer packets (called segments
in TCP or user datagrams in UDP), and transmits them to the destination transport layer.
• End-to-End Communication: Even though the application layer provides an end-to-end
connection, the transport layer separates tasks, handling data transmission independently
from the application. This separation allows flexibility by providing multiple protocols
suited for different needs.

Protocols in the Transport Layer:

1. Transmission Control Protocol (TCP):


o Connection-Oriented: TCP establishes a connection between two hosts before
transferring data. It creates a virtual "pipe" for sending a continuous stream of bytes.
o Flow Control: Ensures that the data sent matches the receiving capability of the
destination, preventing data loss due to overwhelming the receiver.
o Error Control: TCP checks for errors in data transmission and ensures that any
corrupted segments are retransmitted.
o Congestion Control: Helps avoid network congestion by adjusting the
transmission rate based on the current network conditions.
2. User Datagram Protocol (UDP):
o Connectionless: Unlike TCP, UDP does not establish a connection before sending
data. Each user datagram is sent independently, without reference to previous or
subsequent datagrams.
o Simplicity: UDP is lightweight, with minimal overhead. However, it does not
provide flow control, error control, or congestion control.
o Use Case: Best suited for applications that need to send small, independent
messages, where speed is critical and retransmission (as in TCP) would be
inefficient.
3. Stream Control Transmission Protocol (SCTP):
o Designed for Modern Applications: SCTP is tailored for emerging multimedia
applications, offering more advanced features suited to high-demand data
transmissions.

Dr. Devaraju B M Dept of CSE, RNSIT 23


By providing these different protocols, the transport layer allows application programs to choose
the one that best suits their specific requirements, whether they prioritize reliability, simplicity, or
speed.

Application Layer:
The application layer in a network facilitates end-to-end communication between two application
layers. It appears as though a direct bridge exists between them, but in reality, communication
passes through all layers of the networking model.

At this layer, the communication happens between two processes (programs running on separate
machines). One process sends a request, and the other process responds. This process-to-process
communication is the core responsibility of the application layer. While many predefined protocols
exist at this level, users can also create their own custom processes to communicate across hosts.

Key protocols in the application layer include:

• HTTP (Hypertext Transfer Protocol): Used for accessing the World Wide Web
(WWW).
• SMTP (Simple Mail Transfer Protocol): The primary protocol for sending and receiving
email.
• FTP (File Transfer Protocol): Enables the transfer of files between hosts.
• TELNET and SSH (Secure Shell): Facilitate remote access to a site.
• SNMP (Simple Network Management Protocol): Allows administrators to manage
Internet resources both globally and locally.
• DNS (Domain Name System): Helps find the network-layer address (IP address) of a
computer for other protocols.
• IGMP (Internet Group Management Protocol): Collects information on group
membership for multicast communication.

5.4. Encapsulation and Decapsulation


Encapsulation and decapsulation are key concepts in protocol layering within the Internet. These
processes occur at both the source and destination hosts, as well as at intermediary devices like
routers.
I. Encapsulation at the Source Host
At the source host, the encapsulation process involves the following steps:
1. Application Layer: The data generated by the application is called a message. This
message typically doesn't have a header or trailer, but if it does, the whole unit is still
referred to as a message. This message is passed to the transport layer.

2. Transport Layer: The transport layer treats the message as a payload. It adds a transport
layer header, which includes details like the source and destination application program
identifiers and information necessary for tasks such as flow control, error control, or

Dr. Devaraju B M Dept of CSE, RNSIT 24


congestion control. The resulting packet is known as a segment (in TCP) or a user datagram
(in UDP). This transport layer packet is then passed to the network layer.

3. Network Layer: At this layer, the transport layer packet is treated as the payload. A
network layer header is added, which contains the source and destination IP addresses, as
well as additional information for error checking and fragmentation. The final packet is
referred to as a datagram, which is then passed to the data-link layer.

4. Data-Link Layer: The network layer packet is encapsulated in a data-link layer frame. A
header is added here, which includes the addresses of the sending host and the next hop
(e.g., a router). The frame is then passed to the physical layer for transmission over the
network.

Figure 1.23: Encapsulation/Decapsulation

II. Encapsulation and Decapsulation at the Router

Routers perform both encapsulation and decapsulation, as they are connected to multiple network
links. Here's how this works:

1. Decapsulation at Data-Link Layer: When the router receives a frame, the data-link layer
extracts the datagram from the frame and passes it to the network layer.

2. Network Layer Processing: The router's network layer examines the source and
destination addresses within the datagram header. Using its forwarding table, the router
determines the next hop for the datagram. The content of the datagram is not altered unless
it requires fragmentation to pass through the next link. Once processed, the datagram is
passed to the data-link layer of the next link.

3. Encapsulation at Data-Link Layer: The datagram is encapsulated into a new frame


suitable for the next link, and the frame is passed to the physical layer for transmission.

Dr. Devaraju B M Dept of CSE, RNSIT 25


III. Decapsulation at the Destination Host

At the destination host, the reverse process of encapsulation—decapsulation—occurs:

1. Data-Link Layer: The frame is received, and the data-link layer removes its header to
extract the network layer datagram.

2. Network Layer: The network layer removes its header to extract the transport layer
segment or user datagram.

3. Transport Layer: The transport layer removes its header to deliver the original message
to the application layer.

During decapsulation, error checking is performed at each layer to ensure data integrity. The
process continues until the original message reaches the application layer, where it can be used by
the application program.

5.5. Addressing in Network


In the context of the Internet and network protocol layering, addressing is a key concept that
ensures logical communication between pairs of layers. For any communication between two
parties, there must be two essential addresses: a source address and a destination address.
Although it might seem like each layer of the protocol model would require a separate pair of
addresses, in practice only four are needed, as the physical layer does not use addresses. The
physical layer deals with bits, and individual bits do not have addresses.

Addressing at Different Layers

Each layer in the protocol stack uses specific types of addresses, which relate to the type of
communication and the name of the data unit used at that layer. Here's a breakdown:
1. Application Layer:

o At this layer, addresses are typically names, such as a domain name (e.g.,
someorg.com) or an email address (e.g., [email protected]). These names
represent the service or resource being accessed.

o Packet name: Message.

2. Transport Layer:

o Addresses here are called port numbers. Port numbers identify the specific
application-layer programs (e.g., web server-Port 80, email client - Port 25) on the
source and destination devices. Each running program has its own port number,
ensuring that data reaches the correct application.

o Packet name: Segment (for TCP) or User Datagram (for UDP).

Dr. Devaraju B M Dept of CSE, RNSIT 26


Figure 1.24: Addressing in the TCP/IP protocol suite

3. Network Layer:

o The network layer uses global addresses, which are known as IP addresses
(45.113.122.159). These uniquely identify a device's connection to the Internet and
allow data to be routed across networks.

o Packet name: Datagram.

4. Link Layer:

o At this layer, link-layer addresses (also known as MAC addresses 78-45-C4-29-


17-E8) are used. These are local addresses that uniquely identify specific devices
on a network (such as a LAN or WAN), ensuring that data reaches the correct
physical machine.

o Packet name: Frame.

5.6. Multiplexing and Demultiplexing


In the TCP/IP protocol suite, multiplexing and demultiplexing are essential concepts for managing
data flow between different layers of the protocol stack.

Figure 1.25: Multiplexing and demultiplexing

Dr. Devaraju B M Dept of CSE, RNSIT 27


Multiplexing at the Source: Multiplexing occurs when a protocol at a certain layer can handle
multiple types of data from higher layers. For example, at the transport layer, protocols like TCP
and UDP can receive messages from various application-layer protocols (such as FTP, HTTP,
DNS, and SNMP). The transport layer encapsulates these messages into segments and adds a
header field to indicate which application-layer protocol the data belongs to.

Demultiplexing at the Destination: Demultiplexing happens at the destination when a protocol


needs to deliver the data to the appropriate higher-layer protocol. At the transport layer, TCP or
UDP will examine the header to determine which application-layer protocol should receive the
data. Similarly, at the network layer, IP can handle segments from TCP or datagrams from UDP,
and it can also process packets from other protocols like ICMP or IGMP. At the data-link layer, a
frame may carry payloads from various protocols, such as IP or ARP.

Illustration:
• At the Transport Layer: UDP or TCP encapsulates data from application-layer protocols
(e.g., FTP, HTTP, DNS, SNMP).
• At the Network Layer: IP handles segments from TCP, datagrams from UDP, and packets
from other protocols.
• At the Data-Link Layer: Frames may include payloads from IP or other protocols like
ARP.

6. TRANSMISSION MEDIA
Transmission media are essentially the physical substances through which information travels.
They operate at a level below the physical layer of the OSI model, often referred to as "layer zero."
Essentially, transmission media can be considered as a fundamental layer that directly interfaces
with the physical layer.

Figure 1.26: Transmission medium and physical layer

Data Communications Examples:

• Transmission media include free space, metallic cables, or fiber-optic cables.


• The information transmitted is usually in the form of signals generated from data.

Dr. Devaraju B M Dept of CSE, RNSIT 28


➢ Telegraph (19th Century): Invented by Morse, it was an early long-distance
communication technology using metallic wires, but was slow.
➢ Telephone (1869): Allowed voice transmission over long distances via metallic cables,
though communication quality was poor due to inferior wires.
➢ Wireless Communication (1895): Hertz transmitted high-frequency signals, and Marconi
later improved this by sending messages across the Atlantic Ocean.

• Improved Metallic Media: Development of twisted-pair and coaxial cables has enhanced data
transmission.

• Optical Fibers: The advent of fiber-optic cables has significantly increased data
transmission rates.
• Efficient Use of Free Space: Advances in modulation and multiplexing have optimized
the use of free space (air, vacuum, water) for communication.

Electromagnetic Spectrum:

• Signals and Electromagnetic Energy: Computers and telecommunication devices


transmit data as electromagnetic energy, which includes power, radio waves, infrared,
visible light, ultraviolet light, and X-rays.

• Spectrum Usability: Not all parts of the electromagnetic spectrum are suitable for
telecommunications. Only certain portions are used, and the types of media to harness these
are limited.
Categories of Transmission Media:

1. Guided Media: These include twisted-pair cables, coaxial cables, and fiber-optic cables.
2. Unguided Media: This refers to free space, such as air and vacuum.

Figure 1.27: Classes of transmission media

Dr. Devaraju B M Dept of CSE, RNSIT 29


6.1. Guided Media
Guided media are types of communication channels that provide a specific path for signals to travel
from one device to another. These include:

1. Twisted-Pair Cable: This type of cable consists of pairs of insulated copper wires twisted
together. The twisting helps reduce electromagnetic interference and maintains signal
quality.
2. Coaxial Cable: Coaxial cables have a central conductor, an insulating layer, a metallic
shield, and an outer insulating layer. This structure helps to protect the signal from
interference and allows for high-speed data transmission.

3. Fiber-Optic Cable: Unlike twisted-pair and coaxial cables, fiber-optic cables use light
signals to transmit data. They consist of thin strands of glass or plastic that carry light pulses
over long distances with minimal signal loss.

6.2. Twisted-Pair Cable


A twisted pair cable consists of two insulated copper conductors twisted together. Each wire in the
pair serves a different function: one carries the signal to the receiver, and the other acts as a ground
reference. The receiver processes the difference between the two wires to retrieve the signal.

Figure 1.28: Twisted-pair cable

Noise and Interference

Twisted pair cables are designed to minimize the impact of interference (noise) and crosstalk.
When the wires are parallel, noise or crosstalk can affect each wire differently due to their varying
distances from the sources of interference. By twisting the wires, the cable maintains a balance. In
each twist, the relative positions of the wires to the noise source change, helping to ensure that
both wires experience similar levels of interference. This twisting reduces the impact of unwanted
signals, as the receiver calculates the difference between the wires, canceling out most of the noise.

Shielded vs. Unshielded Twisted-Pair Cables


• Unshielded Twisted-Pair (UTP): The most common type used in communications, UTP
cables do not have additional shielding. They are less expensive and less bulky but can be
more susceptible to interference.
• Shielded Twisted-Pair (STP): STP cables have an additional metal foil or braided mesh
covering each pair of conductors. This shielding reduces interference and improves signal

Dr. Devaraju B M Dept of CSE, RNSIT 30


quality but makes the cables bulkier and more costly. STP is primarily used by IBM and is
less common outside of their applications.

Figure 1.29: UTP and STP cables

Categories of UTP Cables

The Electronic Industries Association (EIA) classifies UTP cables into seven categories, with
Category 1 being the lowest quality and Category 7 being the highest. Each category is suitable
for specific applications, and the standards help ensure the cable meets certain performance
criteria.

Connectors

The RJ45 connector is the most common connector for UTP cables. It is a keyed connector,
meaning it can only be inserted in one direction, which ensures a proper connection.
Table 1.1: Categories of unshielded twisted-pair cables

Data
Category Specification Rate Use
(Mbps)
1 Unshielded twisted-pair used in telephone lines 2 Telephone
2 Unshielded twisted-pair originally used in T1 lines 10 T1 Lines
3 Improved Category 2 used in LANs 20 LANs
Token
4 Improved Category 3 used in Token Ring networks 100 Ring
Networks
Cable wire is normally 24 AWG with a jacket and
5 125 LANs
outside sheath
An extension of Category 5 with additional features to
5E 125 LANs
minimize crosstalk and electromagnetic interference
New category with matched components from the same
6 200 LANs
manufacturer; cable tested at a 200-Mbps data rate

Sometimes called SSTP (Shielded Screen Twisted-


7 Pair); each pair is wrapped in helical metallic foil 600 LANs
followed by a metallic foil shield

Dr. Devaraju B M Dept of CSE, RNSIT 31


Figure 1.30: UTP connector

Performance
The performance of twisted-pair cables is often assessed by measuring attenuation (signal loss) in
relation to frequency and distance. Although twisted-pair cables can handle a broad range of
frequencies, attenuation increases significantly at frequencies above 100 kHz. Attenuation is
measured in decibels per kilometer (dB/km), and higher frequencies result in greater signal loss.

Applications

Twisted-pair cables are widely used in various applications:

• Telephone Lines: Used for voice and data transmission in the local loop connecting
subscribers to telephone offices.

• DSL Lines: Provide high-data-rate connections by utilizing the high bandwidth of UTP
cables.

• Local-Area Networks (LANs): Employed in networks such as 10Base-T and 100Base-T


for data transmission.

6.3. Coaxial Cable


Coaxial cable, often referred to as coax, is designed to carry high-frequency signals, unlike twisted-
pair cables. It consists of the following parts:

• Central Core Conductor: A solid or stranded copper wire, responsible for carrying the
signal.
• Insulating Sheath: Surrounds the core conductor, separating it from the outer conductor.
• Outer Conductor: Made of metal foil, braid, or both, which serves two purposes:
o Acts as a shield against external noise.
o Functions as the second conductor to complete the circuit.
• Additional Insulation: Encases the outer conductor for further protection.
• Plastic Cover: Provides external protection for the entire cable.

Dr. Devaraju B M Dept of CSE, RNSIT 32


Figure 1.31 Coaxial cable

This design helps coaxial cables transmit signals with less interference and at higher frequencies
compared to twisted-pair cables.

Coaxial Cable Standards (RG Ratings)

Coaxial cables are classified based on Radio Government (RG) ratings. Each RG number specifies
certain physical characteristics of the cable, such as:

• Wire Gauge: Thickness of the inner conductor.


• Insulation: Thickness and material of the inner insulator.
• Shielding: Design and construction of the outer conductor.
• Outer Casing: Size and type of the protective cover.

These RG-rated cables are suited for different specialized applications, as indicated by their
specifications.

Table 1.2: RG-rated cables are suited for different specialized applications.

Category Use
RG-59 75 Ω Cable TV
RG-58 50 Ω Thin Ethernet
RG-11 50 Ω Thin Ethernet

Coaxial Cable Connectors

To connect coaxial cables to devices, special connectors are required. The most common connector
type is the Bayonet Neill-Concelman (BNC) connector. There are different variations of this
connector:

• BNC Connector: Used to connect the cable to a device (e.g., a TV).


• BNC T Connector: Often used in Ethernet networks to split the signal to multiple devices.
• BNC Terminator: Placed at the end of the cable to prevent signal reflection and ensure
stable transmission.

Dr. Devaraju B M Dept of CSE, RNSIT 33


Figure 1.32: BNC connectors

Performance of Coaxial Cables

Coaxial cables provide higher bandwidth compared to twisted-pair cables, allowing them to carry
more data. However, their attenuation (signal weakening) is greater, meaning the signal degrades
over distance and requires frequent use of repeaters to maintain signal strength.

Applications

• Analog Telephone Networks: Coaxial cables were used to carry large amounts of voice
signals, with one cable supporting up to 10,000 voice channels.
• Digital Telephone Networks: Coaxial cables were capable of transmitting digital data at
speeds up to 600 Mbps.

Today, fiber optic cables have largely replaced coaxial cables in telephone networks due to their
superior performance.

6.4. Fiber-Optic Cable


A fiber-optic cable is a medium made of glass or plastic that transmits signals as light. To
understand how it works, it's important to first grasp the nature of light.

Properties of Light

Dr. Devaraju B M Dept of CSE, RNSIT 34


Figure 1.33: Bending of light ray

• Light travels in a straight line when moving through a uniform material.

• If light passes from one substance into another with a different density, the direction
changes (refraction).

• Critical Angle: The angle of incidence at which light bends along the boundary between
two materials. If the angle is greater than the critical angle, the light reflects instead of
refracting.

Structure of Optical Fibers

Optical fibers guide light through internal reflection. The core (made of glass or plastic) is
surrounded by a cladding with lower density. This ensures that light reflecting off the core-
cladding boundary remains in the core.

Figure 1.34: Optical fiber

Propagation Modes
Optical fibers use two main modes for light propagation:

Figure 1.35: Propagation modes

1. Multimode: Multiple light beams travel through the core along different paths.

o Step-Index Fiber: The core has uniform density, and light changes direction
abruptly at the core-cladding interface.

o Graded-Index Fiber: The core's density gradually decreases from the center,
reducing signal distortion.
2. Single-Mode: Uses step-index fiber but has a smaller core and tightly focused light. The
beams travel nearly parallel, minimizing delay and distortion.

Dr. Devaraju B M Dept of CSE, RNSIT 35


Figure 1.36: Modes

Fiber Sizes
Optical fibers are classified by the ratio of core diameter to cladding diameter (both measured in
micrometers). Single-mode fibers typically have a smaller core diameter compared to multimode
fibers.
Fiber-Optic Cable Composition
A typical fiber-optic cable consists of:
• Outer jacket (PVC or Teflon)
• Kevlar strands for strength
• Plastic coating for cushioning
• Core and cladding for light transmission
Fiber-Optic Connectors
There are three types of connectors:
1. SC (Subscriber Channel): Push/pull locking, used in cable TV.
2. ST (Straight Tip): Bayonet locking, used in networking.
3. MT-RJ: Same size as RJ45, used for data networks.

Dr. Devaraju B M Dept of CSE, RNSIT 36


Figure 1.37: Fiber-optic cable connectors

Performance
Fiber-optic cables experience less signal attenuation than twisted-pair or coaxial cables, requiring
fewer repeaters. They also support higher data transfer rates, especially with wavelength-division
multiplexing (WDM).
Applications
• Backbone Networks: Due to their wide bandwidth, fiber-optic cables are used in backbone
networks, such as SONET.
• Hybrid Networks: Some cable TV companies use a mix of fiber-optic and coaxial cables.
• Local Area Networks (LANs): Fiber-optic cables are used in networks like 100Base-FX
and 1000Base-X.
Advantages of Optical Fiber
1. Higher Bandwidth: Supports higher data rates.
2. Less Signal Attenuation: Can transmit over longer distances without needing repeaters.
3. Immunity to Electromagnetic Interference: Not affected by electromagnetic noise.
4. Resistance to Corrosive Materials: More durable in harsh environments.
5. Lightweight: Lighter than copper cables.
6. Greater Immunity to Tapping: More secure than copper cables.
Disadvantages of Optical Fiber
1. Installation and Maintenance: Requires specialized skills.
2. Unidirectional Light Propagation: Requires two fibers for bidirectional communication.
3. Cost: More expensive than other cables, especially if bandwidth demand is low.
Fiber-optic cables offer numerous benefits, particularly in high-bandwidth and long-distance
applications, but their costs and technical requirements must be carefully considered.

Dr. Devaraju B M Dept of CSE, RNSIT 37


7. UNGUIDED MEDIA: WIRELESS
Unguided media refers to communication channels that use wireless signals to transmit data. These
signals travel through the air without any physical conductor. Common types of wireless
transmission include radio waves, microwaves, and infrared.

Wireless communication involves transmitting electromagnetic waves without using physical


conductors like cables or wires. Instead, signals are broadcast through free space, making them
accessible to any device equipped to receive them.

Electromagnetic Spectrum for Wireless Communication


Wireless communication utilizes a portion of the electromagnetic spectrum, ranging from 3 kHz
to 900 THz, as shown in Figure 1.38. This spectrum includes a variety of frequencies that allow
different methods of signal transmission.

Figure 1.38 Electromagnetic spectrum for wireless communication

Types of Propagation

Unguided signals, such as radio waves, can travel from the source to the destination in three main
ways, illustrated in Figure 1.40:

1. Ground Propagation:

o In this method, low-frequency radio waves travel close to the Earth’s surface,
following the curvature of the planet.

o These signals radiate from the transmitting antenna in all directions, and the
distance they cover depends on the power of the signal—the higher the power, the
farther the signal can travel.
2. Sky Propagation:

o Higher-frequency radio waves are transmitted upward into the ionosphere, where
they are reflected back to Earth.
o This method enables long-distance communication with relatively low power.

Dr. Devaraju B M Dept of CSE, RNSIT 38


3. Line-of-Sight Propagation:

o In this method, very high-frequency signals are transmitted directly between


antennas in a straight line.

o The antennas must be properly aligned and either tall enough or close enough to
avoid being affected by the curvature of the Earth. This method is more complex
because radio waves can’t be perfectly focused.

Figure 1.40: Propagation methods

Frequency Bands

The electromagnetic spectrum for wireless communication is divided into eight different ranges or
"bands." These bands are classified based on frequency and are regulated by government
authorities. The ranges extend from Very Low Frequency (VLF) to Extremely High Frequency
(EHF). Each band has specific propagation characteristics and applications, as summarized in
Table 1.3.
Table 1.3: Frequency Bands for Applications

Band Range Propagation Application


Very Low Frequency
3–30 kHz Ground Long-range radio navigation
(VLF)
Radio beacons, navigational
Low Frequency (LF) 30–300 kHz Ground
locators
300 kHz–3
Middle Frequency (MF) Sky AM radio
MHz
Citizens band (CB),
High Frequency (HF) 3–30 MHz Sky
ship/aircraft communication
Very High Frequency Sky and Line-of-
30–300 MHz VHF TV, FM radio
(VHF) sight
Ultra-High Frequency 300 MHz–3 UHF TV, cellular phones,
Line-of-sight
(UHF) GHz paging, satellite
Super High Frequency
3–30 GHz Line-of-sight Satellite communication
(SHF)
Extremely High Frequency Radar, satellite
30–300 GHz Line-of-sight
(EHF) communication
300 GHz–
Light Wave (Infrared) Line-of-sight Infrared communication
900 THz

Dr. Devaraju B M Dept of CSE, RNSIT 39


This breakdown of the spectrum ensures efficient and organized use of frequencies for various
communication purposes.

7.1. Radio Waves


Frequency Range: Typically, from 3 kHz to 1 GHz.

Characteristics of Radio Waves:

• Omnidirectional Propagation: Radio waves are mostly omnidirectional, meaning they


spread out in all directions from the transmitting antenna. The sending and receiving
antennas don’t need to be aligned for successful communication, as any receiving antenna
in range can pick up the signal. However, this characteristic also leads to a disadvantage:
interference. Multiple antennas transmitting on the same frequency or band can interfere
with one another.
• Long-Distance Travel: Radio waves, especially those that propagate in the sky mode, can
travel long distances, making them ideal for applications like AM radio broadcasting.
• Penetration of Walls: Radio waves, particularly those with low and medium
frequencies, can penetrate walls. This is useful because devices like AM radios can receive
signals indoors. However, it can also be a disadvantage, as signals cannot be restricted to
only the inside or outside of a building, leading to potential signal leakage.

Limitations:

• The radio wave band is relatively narrow, just under 1 GHz. When divided into subbands,
the limited width of these subbands results in low data rates for digital communications.
• Most of the radio wave spectrum is regulated by government authorities, like the FCC in
the United States and Department of Telecommunications (DoT) & Telecom Regulatory
Authority of India (TRAI) in India. Any use of this spectrum requires official permission.
• Licensed Frequency Bands: FM band is licensed between 88-108 MHz for radio
broadcasting and Unlicensed Frequency Bands: Wi-Fi: 2.4 GHz, 5 GHz band.

Omnidirectional Antenna:

Radio waves typically utilize omnidirectional antennas, which transmit signals in all directions.
These antennas come in various types, depending on factors like wavelength, signal strength,
and the intended purpose of transmission.

Applications of Radio Waves:

Thanks to their omnidirectional nature, radio waves are widely used for multicasting, where one
sender transmits to many receivers. Common examples include:

• AM and FM radio
• Television broadcasting

Dr. Devaraju B M Dept of CSE, RNSIT 40


• Maritime radio
• Cordless phones
• Paging systems

Figure 1.41: Omnidirectional antenna

7.2. Microwaves
Frequency Range: From 1 GHz to 300 GHz.
Characteristics: Microwaves require line-of-sight transmission, meaning the transmitter and
receiver must be directly visible to each other. They are less effective in penetrating obstacles like
buildings.

Figure 1.42 Unidirectional antennas

Applications: Satellite communications, radar systems, and microwave ovens. In networking,


microwaves are used for point-to-point communication links and cellular networks.

7.3. Infrared
Frequency Range: From 300 GHz to 400 THz.
Characteristics: Infrared signals are used for short-range communication and do not penetrate
walls, making them suitable for indoor use. They are highly directional and require line-of-sight
transmission.
Applications: Remote controls, short-range data transmission (such as between computers and
peripherals), and infrared sensors for detecting heat in security systems or medical devices.

Dr. Devaraju B M Dept of CSE, RNSIT 41


8. PACKET SWITCHING
In data communication, when a message needs to be sent from one end system to another through
a packet-switched network, it must be divided into smaller units called packets. These packets
can be of either fixed or variable sizes, depending on the network and the protocol being used.

Key Features of Packet Switching:

1. No Resource Allocation:

o Unlike circuit-switched networks, packet switching does not reserve any specific
resources like bandwidth or processing time for the packets.

o Resources are allocated only when needed, and packets are processed on a first-
come, first-served basis.
2. Possible Delays:

o Since there is no dedicated path or reserved resources, packets might experience


delays. For instance, if a switch is busy processing other packets, newly arrived
packets must wait their turn, which can increase transmission time.

Types of Packet-Switched Networks:

1. Datagram Networks: In these networks, each packet is treated independently, and it may
take different routes to reach the destination.

2. Virtual Circuit Networks: These networks establish a pre-determined path before any
data packets are sent, ensuring all packets follow the same route.

Packet switching is an efficient way to transfer data, especially in systems where multiple users
need to share the same network resources.

8.1. Datagram Networks


In a datagram network, each packet is handled independently, even if it's part of a larger
transmission. The network treats each packet as if it stands alone. These individual packets are
known as datagrams.

Key Features of Datagram Networks:

1. Packet Independence: Each packet in a datagram network can take a different path to its
destination, and the network doesn't maintain any connection state between sender and
receiver.

2. Routing: Packet routing is typically done at the network layer, where packets are
forwarded based on their destination address. The devices that manage packet routing are
called routers.

Dr. Devaraju B M Dept of CSE, RNSIT 42


3. No Fixed Path: Since packets may travel along different routes, they might reach their
destination out of order or with varying delays. Some packets could even be dropped if the
network runs out of resources.

4. Connectionless: A datagram network is often referred to as a connectionless network


because it doesn’t require a setup phase (like circuit-switched networks). No information
about the connection is saved, and each packet is routed independently.

How Datagram Networks Work


In Figure 1.43, four packets are sent from station A to station X using the datagram approach. Here,
switches are called routers, and they are depicted with a different symbol. Although these four
packets belong to the same message, they might take different paths to reach their destination due
to varying link capacities and network congestion. This can lead to packets arriving out of order,
with differing delays, or even being lost or dropped due to insufficient resources. Upper-layer
protocols typically handle the reordering and retransmission of lost packets before delivering them
to the application.

Figure 1.43: A datagram network with four switches (routers)

Routing Table

In a datagram network, each switch uses a routing table based on destination addresses to forward
packets. These tables are dynamic and updated regularly.

Figure 1.44: Routing table in a datagram network

Dr. Devaraju B M Dept of CSE, RNSIT 43


The routing table records destination addresses and the corresponding output ports. This differs
from circuit-switched networks, where entries are created during the setup phase and removed
during teardown.

Destination Address

Every packet in a datagram network has a header containing a destination address. Upon receiving
a packet, the switch checks this address and uses the routing table to determine the appropriate
forwarding port. This destination address remains unchanged throughout the packet's journey.
Delay

Despite their efficiency, datagram networks can experience higher delays compared to virtual-
circuit networks. Although there are no setup or teardown phases, each packet may encounter
waiting times at switches. Additionally, since packets from the same message may travel through
different routes, delays are not uniform. Figure 1.45, illustrates the delay for a packet traveling
through two switches, including transmission times (3T), propagation delays (3τ), and waiting
times (w1 + w2). The total delay is given by:

𝑇𝑜𝑡𝑎𝑙 𝑑𝑒𝑙𝑎𝑦 = 3𝑇 + 3𝜏 + 𝑤1 + 𝑤2

• Transmission Time: The time to send a packet from one point to another.

• Propagation Delay: The time it takes for the signal to travel through the medium.
• Waiting Time: Time spent at routers before being forwarded.

Figure 1.45: Delay in a datagram network

Advantages:

• Efficiency: Datagram networks can be more efficient than circuit-switched networks.


Resources like bandwidth are allocated only when packets are being transmitted, allowing
for better utilization of network resources.

Dr. Devaraju B M Dept of CSE, RNSIT 44


8.2. Virtual-Circuit Networks
A virtual-circuit network (VCN) is a hybrid network model that combines features of both
circuit-switched and datagram networks. It provides a balance between connection-oriented and
connectionless transmission methods.

Key Features:

1. Connection Phases:

o A VCN has three distinct phases: setup, data transfer, and teardown.

▪ Setup Phase: A path is established between the sender and receiver before
data transmission.

▪ Data Transfer Phase: Data is sent along the established path in packets.

▪ Teardown Phase: After data transmission, the connection is terminated,


and resources are released.

Figure 1.46: Virtual-circuit network

2. Resource Allocation:
o Resources can either be allocated during the setup phase (as in a circuit-switched
network) or dynamically during data transmission (similar to a datagram network).

3. Packetized Data with Local Addressing:

o Data is divided into packets, each of which carries an address. However, unlike in
a datagram network, the address is not end-to-end but local, meaning it only tells
the next switch where to send the packet.

4. Consistent Path for Packets:

o Once a connection is established, all packets follow the same predetermined path.
This ensures a predictable route for all the packets between the sender and receiver,
akin to a circuit-switched network.

Dr. Devaraju B M Dept of CSE, RNSIT 45


5. Layer of Operation:

o Virtual-circuit networks typically operate at the data-link layer, while circuit-


switched networks operate at the physical layer, and datagram networks at the
network layer.

Addressing in Virtual-Circuit Networks:

1. Global Addressing:

o A global address is used to uniquely identify the source and destination during the
setup phase. This address is typically unique within the network or globally if the
network is part of a larger system.

2. Virtual-Circuit Identifier (VCI):


o During the data transfer phase, a virtual-circuit identifier (VCI) is used instead of
the global address. The VCI is a small number with local scope, meaning it only
identifies the path between two adjacent switches.

o The VCI changes at each switch, as each switch uses its own set of VCIs to manage
the connection. This allows efficient and simple management of packet forwarding.

Figure 1.47: Virtual-circuit identifier

Three Phases in a Virtual-Circuit Network

In a virtual-circuit network, the communication between a source and destination involves three
phases: setup, data transfer, and teardown. These phases ensure that a reliable path is established
and maintained for the communication session.

1. Setup Phase:
o The source and destination use their global addresses to establish a connection.
During this phase, switches along the path create table entries to store information
about the virtual circuit. This phase ensures that each switch is prepared to route
the data properly.

2. Data Transfer Phase:


o After the setup phase, data is transferred between the source and destination. The
switches use the table entries created during the setup phase to route the frames.

Dr. Devaraju B M Dept of CSE, RNSIT 46


The switches maintain information like the incoming and outgoing ports and Virtual
Circuit Identifiers (VCI). Each frame is processed the same way, with the VCIs
changing at each switch to ensure the data follows the correct path. This phase
continues until all frames are transferred.
3. Teardown Phase:

o Once the data transfer is complete, the source and destination send signals to the
switches to remove the corresponding table entries, effectively ending the virtual
circuit.

Figure 1.48: Switch and tables in a virtual-circuit network

Data-Transfer Phase

During data transfer, the key action is switching the frames between the source and destination.
Each switch in the path must have a table with entries corresponding to the virtual circuit. A table
typically consists of four columns: incoming port, incoming VCI, outgoing port, and outgoing
VCI.

• When a frame arrives at a switch, the switch looks for the entry that matches the incoming
port and VCI.

• After identifying the entry, the switch updates the VCI to the new value and forwards the
frame to the next switch via the outgoing port.

For example, if a frame arrives at switch 1 with VCI 14 on port 1, the switch finds this entry in its
table, updates the VCI to 22, and forwards the frame through port 3. This process repeats at each
switch, ensuring the frame reaches its destination.

Dr. Devaraju B M Dept of CSE, RNSIT 47


Setup Phase

In the setup phase, a virtual circuit is established between the source and destination by creating
table entries at each switch. This phase consists of two main steps:

1. Setup Request:

o A setup request frame is sent from the source (A) to the destination (B). As the
frame passes through each switch, the switch creates an entry in its table.

o For example, when the setup frame reaches switch 1, it identifies that the outgoing
port for the connection is port 3 and assigns an incoming VCI (14) for the frame
coming from port 1. At this point, the outgoing VCI remains unknown.

Figure 1.49: Source-to-destination data transfer in a virtual-circuit network

2. Acknowledgment:

o Once the setup request reaches the destination, the destination assigns a VCI (e.g.,
77) for incoming frames from the source. The acknowledgment is sent back to the
source, and each switch updates its table to complete the missing outgoing VCI
information.

Dr. Devaraju B M Dept of CSE, RNSIT 48


Figure 1.50: Setup acknowledgment in a virtual-circuit network

3. Teardown Phase

When the communication is finished, the source and destination send a signal to the switches to
remove the corresponding table entries, thus ending the virtual circuit. This process frees up the
resources for future virtual circuits.

Efficiency in Virtual-Circuit Networks

In a virtual-circuit network, resource allocation can happen either during the setup phase or on
demand during the data-transfer phase. When resources are reserved during the setup phase, each
packet experiences the same delay. However, if resources are allocated on demand, packet delays
may vary.

Even when resource allocation is on demand, a significant advantage of virtual-circuit networks is


that the source can check resource availability before data transfer.

In virtual-circuit switching, all packets from the same source to the same destination follow the
same path. However, with on-demand resource allocation, packets may arrive with different delays
depending on resource availability.
Delay in Virtual-Circuit Networks

In a virtual-circuit network, delays occur during the setup and teardown phases. These are one-
time delays. If resources are allocated during setup, there is no additional waiting time for
individual packets during data transfer.

The total delay in such a network includes:


• Three transmission times (3T): the time taken for the packet to be transmitted across
links.

Dr. Devaraju B M Dept of CSE, RNSIT 49


• Three propagation times (3τ): the time taken for the packet to travel across physical
distances.
• Setup delay: includes transmission and propagation in both directions during the setup
phase.
• Teardown delay: includes transmission and propagation in one direction during the
teardown phase.
For simplicity, processing delays at the switches (routers) are ignored in this calculation.
Thus, the total delay for the packet is:

𝑇𝑜𝑡𝑎𝑙 𝑑𝑒𝑙𝑎𝑦 = 3𝑇 + 3𝜏 + 𝑠𝑒𝑡𝑢𝑝 𝑑𝑒𝑙𝑎𝑦 + 𝑡𝑒𝑎𝑟𝑑𝑜𝑤𝑛 𝑑𝑒𝑙𝑎𝑦

QUESTIONS
1. Data Communications

1. What are the five key components of a data communication system, and what role does
each play in ensuring effective communication?

2. Explain the different forms of data representation used in data communications and provide
examples for each.

3. Describe the three modes of data flow and provide real-world examples where each mode
is used.

2. Networks

1. What are the key criteria used to evaluate the performance, reliability, and security of a
network?

2. Explain the difference between point-to-point and multipoint physical structures in


network connections. Provide advantages and disadvantages of each.
3. Network Types

1. Compare and contrast a Local Area Network (LAN) and a Wide Area Network (WAN) in
terms of characteristics, speed, and geographical coverage.

2. Define packet switching and explain the key differences between circuit switching and
packet switching.

3. Discuss the role of routers and switches in the structure of the Internet. How do they
contribute to efficient data transfer?

4. What are the different ways to access the Internet, and how do factors like speed and
coverage differ between these methods?

Dr. Devaraju B M Dept of CSE, RNSIT 50


4. Protocol Layering

1. Explain the key principles of protocol layering and discuss how these principles ensure
efficient communication between two devices over a network.
2. What are logical connections in the context of protocol layering, and how do they facilitate
communication between peer layers on different devices?
3. Explain the layered architecture of the TCP/IP protocol suite. How does each layer
contribute to overall network communication?
4. Discuss the main functions of the following layers in the TCP/IP protocol suite:
a. Application Layer
b. Transport Layer
c. Network Layer
d. Data Link Layer
e. Physical Layer
5. Describe the process of encapsulation and decapsulation in the TCP/IP protocol suite. Why
are these processes crucial for data communication?
6. Explain the different types of addresses used at each layer of the TCP/IP protocol stack.
Why is addressing critical for network communication?
7. What is multiplexing and demultiplexing in the TCP/IP protocol suite? How do these
processes ensure that data is correctly sent and received by the right application?

5. Transmission Media
1. Define guided media and list and explain three types of guided media used in network
communications.
2. Explain the difference between unshielded twisted-pair (UTP) and shielded twisted-pair (STP)
cables. What are their primary uses?
3. Describe how the twisting of pairs in twisted-pair cables helps to reduce crosstalk.
4. What are the main components of a coaxial cable, and how do they contribute to its
performance?
5. Describe the principle of operation of fiber-optic cables and explain why they provide high-
speed data transmission.
6. Discuss the advantages and disadvantages of fiber-optic cables compared to coaxial and
twisted-pair cables.
7. What are radio waves, and how are they used in wireless communication? Provide an example
of a common application.
8. Explain the concept of frequency allocation in radio wave communication and its importance.
9. Discuss the characteristics of microwave transmission and its typical uses in communication
systems.
10. Describe how infrared communication works and list two common applications where infrared
technology is used.

Dr. Devaraju B M Dept of CSE, RNSIT 51


6. Packet Switching
1. What is a datagram network? Describe its key characteristics and how it handles packet routing
and delivery.
2. Compare and contrast datagram networks with virtual-circuit networks in terms of reliability,
complexity, and overhead.
3. In a datagram network, how does the destination node determine the correct order of packets?
What issues might arise from the unordered delivery of packets?
4. Explain how a datagram network handles packet fragmentation and reassembly. What are the
potential impacts on network performance and reliability?
5. Define a virtual-circuit network and describe the main phases involved in setting up,
maintaining, and tearing down a virtual circuit.
6. Discuss the advantages and disadvantages of virtual-circuit networks compared to datagram
networks. Include aspects such as connection setup, resource allocation, and data transfer
efficiency.
7. How does a virtual-circuit network handle data transfer once the connection is established?
What mechanisms are in place to ensure data integrity and order?
8. Explain the role of signaling in virtual-circuit networks. How does signaling contribute to the
establishment and teardown of virtual circuits?
9. Describe a scenario where virtual-circuit networks would be preferred over datagram
networks. Justify your choice based on factors such as performance requirements and network
management.

Dr. Devaraju B M Dept of CSE, RNSIT 52


COMPUTER NETWORKS– V SEM CSE VTU
MODULE-2: Data Link Layer

1. Error Detection and Correction


1.1. Introduction
1.2. Block Coding
1.3. Cyclic Codes
2. Data link control
2.1. DLC Services
2.2. Data link layer protocols
2.3. High Level Data Link Control
3. Media Access Control
3.1. Random Access
3.2. Controlled Access

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 1


1. Error Detection and Correction
1.1 Introduction
For many applications system must guarantee that the data received are same to the data
transmitted. During transmission data may be corrupted because of many factors. Hence there should be
some mechanism to detect and correct errors.

Types of Errors
There are two types of error: Single bit error and Burst error.

Single-Bit Error

The term single-bit error means that only 1 bit of a given data unit (such as a byte, character, or
packet) is changed from 1 to 0 or from 0 to 1. Single-bit errors are the least likely type of error in
serial data transmission.

Burst Error
The term burst error means that 2 or more bits in the data unit have changed from 1 to 0 or from 0
to 1. In the below figure, 0100010001000011 was sent, but 0101110101100011 was received.

Note that a burst error does not necessarily mean that the errors occur in consecutive bits. The
length of the burst is measured from the first corrupted bit to the last corrupted bit. Some bits in
between may not have been corrupted.

Redundancy

To detect or correct errors some extra bits are sent with data. These redundant bits are added by
the sender and removed by the receiver. Their presence allows the receiver to detect or correct
corrupted bits.

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 2


Detection versus Correction
• The correction of errors is more difficult than the detection.
• In error detection, we are looking only to see if any error has occurred.
• In error correction, we need to know the exact number of bits that are corrupted and more
importantly, their location in the message. The number of the errors and the size of the message
are important factors.
• If we need to correct one single error in an 8-bit data unit, we need to consider eight possible
error locations; if we need to correct two errors in a data unit of the same size, we need to
consider 28 possibilities.

Forward Error Correction versus Retransmission


There are two main methods of error correction.
• Forward error correction is the process in which the receiver tries to guess the message by
using redundant bits. This is possible, if the number of errors is small.
• Correction by retransmission is a technique in which the receiver detects the occurrence of
an error and asks the sender to resend the message. Resending is repeated until a message
arrives that the receiver believes is error-free.

Coding
• Redundancy is achieved through various coding schemes.
• The sender adds redundant bits through a process that creates a relationship between the
redundant bits and the actual data bits.
• The receiver checks the relationships between the two sets of bits to detect or correct the
errors.

• Coding schemes can be divided into two broad categories: block coding and convolution
coding.

Modular Arithmetic
• In modular arithmetic only integers in the range 0 to N-1 is used. This is known as modulo-N
arithmetic. For example, if the modulus is 12, we use only the integers 0 to 11, inclusive.

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 3


Modulo-2 Arithmetic
In this arithmetic, the modulus N is 2. We can use only 0 and 1. Operations in this arithmetic are
very simple. The following shows how we can add or subtract 2 bits.
Adding:
0+0=0 0+1=1 1+0=1 1+1=0
Subtracting:
0-0=0 0-1=1 1-0=1 1-1=0
In this arithmetic we use the XOR (exclusive OR) operation for both addition and subtraction. The
result of an XOR operation is 0 if two bits are the same; the result is I if two bits are different.

1.2 Block Coding


• In block coding message is divided into k bits blocks called datawords. Then r redundant bits
are added to each block to make the length n = k + r. The resulting n-bit blocks are called
codewords.
• With k bits, we can create a combination of 2k datawords; with n bits, we can create a
combination of 2n codewords.
• Since n > k, the number of possible codewords is larger than the number of possible
datawords.
• The block coding process is one-to-one; the same dataword is always encoded as the same
codeword. This means that we have 2n - 2k codewords that are not used. We call these
codewords invalid or illegal.

Error Detection
If the following two conditions are met, the receiver can detect a change in the original
Chethana H R, Asst. Prof Dept. of CSE, RNSIT 4
codeword.
 The receiver has (or can find) a list of valid codewords.
 The original codeword has changed to an invalid one.

Process of error detection in block coding


• The sender creates codewords out of datawords by using a generator that applies the rules
and procedures of encoding.
• Each codeword sent to the receiver may change during transmission.
• If the received codeword is the same as one of the valid codewords, the word is accepted; the
corresponding dataword is extracted for use. If the received codeword is not valid, it is
discarded.
• However, if the codeword is corrupted during transmission but the received word still
matches a valid codeword, the error remains undetected.
• This type of coding can detect only single errors. Two or more errors may remain
undetected.

Example:
Let us assume that k =2 and n =3. Below Table shows the list of datawords and codewords.
Dataword Codeword
00 000
01 011
10 101
11 110

Assume the sender encodes the dataword 01 as 011 and sends it to the receiver. Consider the
following cases:
 The receiver receives 011. It is a valid codeword. The receiver extracts the dataword 01 from
it.
 The codeword is corrupted during transmission, and 111 is received (the leftmost bit is
corrupted).
Chethana H R, Asst. Prof Dept. of CSE, RNSIT 5
This is not a valid codeword and is discarded.
The codeword is corrupted during transmission, and 000 is received (the right two bits are corrupted). This
is a valid codeword. The receiver incorrectly extracts the dataword 00. Two corrupted bits have made the
error undetectable.

Error Correction
In error detection, the receiver needs to know only that the received codeword is invalid; in error correction
the receiver needs to find (or guess) the original codeword sent.

Below Table shows the datawords and codewords.


Dataword Codeword
00 00000
01 01011
10 10101
11 11110
Assume the dataword is 01. The sender consults the table (or uses an algorithm) to create
the codeword 01011.
The codeword is corrupted during transmission, and 01001 is received (error in the second bit
from the right).
1. First, the receiver finds that the received codeword is not in the table. This means an error
has occurred. (Detection must come before correction.)
2. The receiver, assuming that there is only 1 bit corrupted, uses the following strategy to guess
the correct dataword.
3. Comparing the received codeword with the first codeword in the table (01001 versus 00000),
the receiver decides that the first codeword is not the one that was sent because there are two
different bits.
4. By the same reasoning, the original codeword cannot be the third or fourth one in the table.
The original codeword must be the second one in the table because this is the only one that differs from the
received codeword by 1 bit. The receiver replaces 01001 with 01011 and consults the table to find the
dataword 01.
Chethana H R, Asst. Prof Dept. of CSE, RNSIT 6
Hamming Distance
The Hamming distance between two words (of the same size) is the number of differences between the
corresponding bits. Hamming distance between two words x and y is represented as d(x, y).The Hamming
distance can be found by applying the XOR operation on the two words and counting the number of 1s in
the result.
Example:
1. The Hamming distance d(000, 011) is 2 because 000 011 is 011 (two 1s).
2. The Hamming distance d(10101, 11110) is 3 because 10101 11110 is 01011 (three 1s)

Minimum Hamming Distance: The minimum Hamming distance is the smallest Hamming
distance between all possible pairs in a set of words. It is represented as dmin.
Find the minimum Hamming distance of the coding scheme in below table:
Dataword Codeword
00 000
01 011
10 101
11 110
Solution

d(000,011) = 2, d(000,101) = 2, d(000,110) = 2, d(011,101) = 2, d(011,110) = 2,


d(101,110) = 2
The dmin in this case is 2.
Example 2
Find the minimum Hamming distance of the coding scheme in below table:
Dataword Codeword
00 00000
01 01011
10 10101
11 11110

Solution

d(00000,01011) = 3, d(00000,10101) = 3, d(00000,11110) = 4 d(01011,10101)


= 4, d(01011,11110) = 3, d(10101,11110) = 2
The dmin in this case is 3.

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 7


Coding scheme needs to have at least three parameters: the codeword size n, the dataword size k,
and the minimum Hamming distance dmin. A coding scheme C is written as C(n, k) with a separate
expression for dmin.
Ex: C(5, 2) with dmin = 3.

Hamming Distance and Error


• When a codeword is corrupted during transmission, the Hamming distance between the
sent and received codewords is the number of bits affected by the error.
• The Hamming distance between the received codeword and the sent codeword is the
number of bits that are corrupted during transmission.
• For example, if the codeword 00000 is sent and 01101 is received, 3 bits are in error and
the Hamming distance between the two is d(00000, 01101) =3.

Minimum Distance for Error Detection


• If S errors occur during transmission, the Hamming distance between the sent codeword and
received codeword is S.
• To guarantee the detection of up to S errors in all cases, the minimum Hamming distance in a
block code must be dmin =S + 1.
• Let us assume that the sent codeword x is at the center of a circle with radius S. All other
received codewords that are created by 1 to S errors are points inside the circle or on the
perimeter of the circle. All other valid codewords must be outside the circle.

Minimum Distance for Error Correction


• When a received codeword is not a valid codeword, the receiver needs to decide which valid
codeword was actually sent. The decision is based on the concept of territory, an exclusive area
surrounding the codeword. Each valid codeword has its own territory.
• We use a geometric approach to define each territory. We assume that each valid codeword
has a circular territory with a radius of t and that the valid codeword is at the center.
• For example, suppose a codeword x is corrupted by t bits or less. Then this corrupted codeword
is located either inside or on the perimeter of this circle. If the receiver receives a codeword
that belongs to this territory, it decides that the original codeword is the one at the center.
• To guarantee correction of up to t errors in all cases, the minimum Hamming distance in a
block code must be dmin == 2t + 1.
Chethana H R, Asst. Prof Dept. of CSE, RNSIT 8
Linear Block Codes
Linear block code is a code in which the exclusive OR of two valid codewords creates another
valid codeword.
Minimum Distance for Linear Block Codes: The minimum Hamming distance is the number
of 1s in the nonzero valid codeword with the smallest number of 1s.

Some Linear Block Codes


1) Simple Parity-Check Code
• In this code, a k-bit dataword is changed to an n-bit codeword where n = k + 1. The extra
bit, called the parity bit, is selected to make the total number of 1s in the codeword even.
A simple parity-check code is a single-bit error-detecting code in which n =k + 1 with dmin =2.

• The encoder uses a generator that takes a copy of a 4-bit dataword ( a0, a1, a2, and a3)
and generates a parity bit r0.
• The dataword bits and the parity bit create the 5-bit codeword. The parity bit that is added
makes the number of 1s in the codeword even.
Example: Simple parity-check code C(5, 4)

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 9


• This is normally done by adding the 4 bits of the dataword (modulo-2); the result is the parity
bit. In other words,
r0=a3+a2+a1+a0 (modulo – 2)
• If the number of 1s is even, the result is 0; if the number of 1s is odd, the result is 1. In
both cases, the total number of 1s in the codeword is even.
• The sender sends the codeword which may be corrupted during transmission.
• The receiver receives a 5-bit word.
• The checker at the receiver does the same thing as the generator in the sender with one
exception: The addition is done over all 5 bits.
• The result, which is called the syndrome, is just 1 bit. The syndrome is 0 when the number
of 1s in the received codeword is even; otherwise, it is 1.
s0=b3+b2+b1+b0+q0 (modulo – 2)
• The syndrome is passed to the decision logic analyzer.
• If the syndrome is 0, there is no error in the received codeword; the data portion of the
received codeword is accepted as the dataword.
• If the syndrome is 1, the data portion of the received codeword is discarded. The
dataword is not created.

Assume the sender sends the dataword 1011. The codeword created from this dataword is
10111, which is sent to the receiver.
1. No error occurs; the received codeword is 10111. The syndrome is O. The dataword 1011
is created.
2. One single-bit error changes a1 The received codeword is 10011. The syndrome is 1.
No dataword is created.
3. One single-bit error changes r0 The received codeword is 10110. The syndrome is 1. No
dataword is created. Note that although none of the dataword bits are corrupted, no dataword
is created because the code is not sophisticated enough to show the position of the corrupted
bit.
4. An error changes ro and a second error changes a3 The received codeword is 00110. The
syndrome is 0. The dataword 0011 is created at the receiver. Note that here the dataword is
wrongly created due to the syndrome value. The simple parity-check decoder cannot detect an
Chethana H R, Asst. Prof Dept. of CSE, RNSIT 10
even number of errors. The errors cancel each other out and give the syndrome a value of 0.
5. Three bits-a3, a2, and a1 are changed by errors. The received codeword is 01011. The syndrome is
1. The dataword is not created. This shows that the simple parity check, guaranteed to detect one
single error, can also find any odd number of errors.
Limitation: A simple parity-check code can detect an odd number of errors.
a. A better approach is the two-dimensional parity check. In this method, the dataword is
organized in a table.
b. The data to be sent, five 7-bit bytes, are put in separate rows.
c. For each row and each column, 1 parity-check bit is calculated.
d. The whole table is then sent to the receiver, which finds the syndrome for each row and each column.
e. The two-dimensional parity check can detect up to three errors that occur anywhere in the table.
However, errors affecting 4 bits may not be detected.

Hamming Codes
These codes were originally designed with dmin = 3, which means that they can detect up to two
errors or correct one single error.
In hamming code we need to choose an integer m, say m >= 3. The values of n and k are then

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 11


calculated from m as n = 2m – 1 and k = n - m. The number of check bits r =m. Eg: if m = 3, n=7,
k=4
Hamming code C(7, 4) - n=7, k = 4:

Below figure shows the structure of the encoder and decoder:

A copy of a 4-bit dataword is fed into the generator that creates three parity checks.
r0 = a2 + a1 + a0 modulo-2
r1 = a3 + a2 + a1 modulo-2
r2 = a1 + a0 + a3 modulo-2

The checker in the decoder creates a 3-bit syndrome (s2s1s0) in which each bit is the parity check
for 4 out of the 7 bits in the received codeword:
s0 = b2 + b1 + b0 modulo-2
s1 = b3 + b2 + b1 modulo-2
s2 = b1 + b0 + b3 modulo-2
Chethana H R, Asst. Prof Dept. of CSE, RNSIT 12
The 3-bit syndrome creates eight different bit patterns (000 to 111) that can represent eight
different conditions. These conditions define a lack of error or an error in 1 of the 7 bits of the
received codeword.
Syndrome 000 001 010 011 100 101 110 111
Error None q0 q1 b2 q2 b0 b3 b1
For example, if q0 is in error, S0 is the only bit affected; the syndrome, therefore, is 001. If b 2 is in
error, S0 and S1 are the bits affected; the syndrome therefore is 01l. Similarly, if b1 is in error, all
3 syndrome bits are affected and the syndrome is 111.

Example:

1. The dataword 0100 becomes the codeword 0100011. The codeword 0100011 is received.
The syndrome is 000 (no error), the final dataword is 0100.
2. The dataword 0111 becomes the codeword 0111001. The codeword 0011001 is received. The
syndrome is 011. Therefore b2 is in error. After flipping b2 (changing the 1 to 0), the final
dataword is 0111.
3. The dataword 1101 becomes the codeword 1101000. The codeword 0001000 is received (two
errors). The syndrome is 101, which means that b0 is in error. After flipping b0, we get 0000,
the wrong dataword. This shows that our code cannot correct two errors.

Performance
A Hamming code can only correct a single error or detect a double error. However, there is a way to make it
detect a burst error.
The key is to split a burst error between several codewords, one error for each codeword.

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 13


To make the Hamming code respond to a burst error of size N, we need to make N codewords out
of our frame. Then, instead of sending one codeword at a time, we arrange the codewords in a
table and send the bits in the table a column at a time.
In the above Figure, the bits are sent column by column (from the left). In each column, the bits
are sent from the bottom to the top. In this way, a frame is made out of the four codewords and
sent to the receiver. It is shown in the figure that when a burst error of size 4 corrupts the frame,
only 1 bit from each codeword is corrupted. The corrupted bit in each codeword can then easily be
corrected at the receiver.

1.3 Cyclic Codes


Cyclic codes are special linear block codes in which, if a codeword is cyclically shifted
(rotated), the result is another codeword.
For example, if 1011000 is a codeword and we cyclically left-shift, then 0110001 is also a
codeword.
In this case, if we call the bits in the first word a0 to a6 and the bits in the second word b0 to b6,
we can shift the bits by using the following:
b1 = a0 b2 = a1 b3 = a2 b4 = a3 b5 = a4 b6 = a5 b0 = a6

Cyclic Redundancy Check

Below Table shows an example of a CRC code.

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 14


• In the encoder, the dataword has k bits (4 here); the codeword has n bits (7 here). The size of
the dataword is augmented by adding n - k (3 here) 0s to the right-hand side of the word. The
n-bit result is fed into the generator.
• The generator uses a divisor of size n - k + 1 (4 here), predefined and agreed upon. The
generator divides the augmented dataword by the divisor (modulo-2 division).
• The quotient of the division is discarded; the remainder is appended to the dataword to create
the codeword.
• The decoder receives the possibly corrupted codeword. A copy of all n bits is fed to the
checker which is a replica of the generator.
• The remainder produced by the checker is a syndrome of n - k (3 here) bits, which is fed to
the decision logic analyzer.
• The analyzer has a simple function. If the syndrome bits are all as, the 4 leftmost bits of the
codeword are accepted as the dataword (interpreted as no error); otherwise, the 4 bits are
discarded (error).

Encoder
The encoder takes the dataword and augments it with n - k number of 0s. It then divides the
augmented dataword by the divisor.

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 15


Decoder
The codeword can change during transmission. The decoder does the same division process as the
encoder. The remainder of the division is the syndrome. If the syndrome is all 0s, there is no error;
the dataword is separated from the received codeword and accepted. Otherwise, everything is
discarded.
The left side figure shows the value of syndrome when no error has occurred; the syndrome is 0. The
right-hand part of the figure shows the case in which there is one single error. The syndrome is not all 0s

Hardware Implementation
One of the advantages of a cyclic code is that the encoder and decoder can easily and cheaply be
implemented in hardware by using a handful of electronic devices. Also, a hardware
implementation increases the rate of check bit and syndrome bit calculation.
Divisor:
1. The divisor is repeatedly XORed with part of the dividend.
2. The divisor has n - k + 1 bits which either are predefined or are all Os. In other words, the
bits do not change from one dataword to another. In previous example, the divisor bits were
either 1011 or 0000. The choice was based on the leftmost bit of the part of the augmented
data bits that are active in the XOR operation.

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 16


3. A close look shows that only n - k bits of the divisor is needed in the XOR operation. The
leftmost bit is not needed because the result of the operation is always 0, no matter what the
value of this bit. The reason is that the inputs to this XOR operation are either both 0s or
both 1s.

Steps:
1. Assume that the remainder is originally all Os (000 in our example).
2. At each time click (arrival of 1 bit from an augmented dataword), repeat the following
two actions:
a. Use the leftmost bit to make a decision about the divisor (011 or 000).
b. The other 2 bits of the remainder and the next bit from the augmented dataword (total of
3 bits) are XORed with the 3-bit divisor to create the next remainder.

Below Figure shows this simulator, but note that this is not the final design; there will be more
improvements.

At each clock tick, shown as different times, one of the bits from the augmented dataword is used in
the XOR process.
The above design is for demonstration purposes only. It needs simplification to be practical. First, we do not
need to keep the intermediate values of the remainder bits; we need only the final bits. We therefore need
only 3 registers instead of 24. After the XOR operations, we do not need the bit values of the previous
remainder. Also, we do not need 21 XOR devices; two are enough because the output of an XOR operation
in which one of the bits is 0 is simply the value of the other bit. This other bit can be used as the output. With
these two modifications, the design becomes tremendously simpler and less expensive, as shown below

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 17


Chethana H R, Asst. Prof Dept. of CSE, RNSIT 18
General Design

Polynomials
A pattern of 0s and 1s can be represented as a polynomial with coefficients of 0 and 1. The power
of each term shows the position of the bit; the coefficient shows the value of the bit. Figure shows
a binary pattern and its polynomial representation.

Degree of a Polynomial
The degree of a polynomial is the highest power in the polynomial. For example, the degree of the
polynomial x6 + x + 1 is 6. Note that the degree of a polynomial is 1 less that the number of bits in the pattern.
The bit pattern in this case has 7 bits.

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 19


Cyclic Code Analysis
Following notations can be used in the cyclic codes:
Dataword: d(x) Error: e(x) Syndrome: s(x) Generator: g(x) Codeword: c(x)

In a cyclic code,
1. If s(x) != 0, one or more bits is corrupted.
2. If s(x) = 0, either
a. No bit is corrupted. or
b. Some bits are corrupted, but the decoder failed to detect them.
The received codeword is the sum of the sent codeword and the error. Received
codeword =c(x) + e(x)
The receiver divides the received codeword by g (x) to get the syndrome.

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 20


The Right hand side of above equation is called as syndrome. If Syndrome does not have a remainder
(syndrome =0), either e(x) is 0 or e(x) is divisible by g(x). In a cyclic code, those e(x) errors that are
divisible by g(x) are not caught.

Checksum
The checksum is used in the Internet by several protocols. The checksum is based on the concept
of redundancy.
Below Figure shows the process at the sender and at the receiver. The sender initializes the
checksum to 0 and adds all data items and the checksum (the checksum is considered as one data
item and is shown in color). The result is 36. However, 36 cannot be expressed in 4 bits. The extra
two bits are wrapped and added with the sum to create the wrapped sum value 6. In the figure, we
have shown the details in binary. The sum is then complemented, resulting in the checksum value
9 (15 - 6 = 9). The sender now sends six data items to the receiver including the checksum 9. The
receiver follows the same procedure as the sender. It adds all data items (including the checksum);
the result is 45. The sum is wrapped and becomes 15. The wrapped sum is complemented and
becomes 0. Since the value of the checksum is 0, this means that the data is not corrupted. The
receiver drops the checksum and keeps the other data items. If the checksum is not zero, the entire
packet is dropped.

Internet Checksum
Traditionally, the Internet has been using a 16-bit checksum.

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 21


Sender site:
1. The message is divided into 16-bit words.
2. The value of the checksum word is set to 0.
3. All words including the checksum are added using one's complement addition.
4. The sum is complemented and becomes the checksum.
5. The checksum is sent with the data.
Receiver site:
1. The message (including checksum) is divided into 16-bit words.
2. All words are added using one's complement addition.
3. The sum is complemented and becomes the new checksum.
4. If the value of checksum is 0, the message is accepted; otherwise, it is rejected.
Example:

2.1 DLC SERVICES


 The data link control (DLC) deals with procedures for communication between two
adjacent nodes i.e., node-to-node communication.
 Data link control functions include 1) Framing and 2) Flow control and 3) Error control.
Framing
 Data transmission in the physical layer means moving bits in the form of a signal from the
source to the destination.
 The physical layer provides bit synchronization to ensure that the sender and receiver use
the same bit durations and timing.

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 22


 The data link layer, on the other hand, needs to pack bits into frames, so that each frame is
distinguishable from another.
 Framing in the data link layer separates a message from one source to a destination, or
from other messages to other destinations, by adding a sender address and a destination
address.
 The destination address defines where the packet is to go; the sender address helps the
recipient acknowledge the receipt.
 Frames can be of fixed or variable size.
1) Fixed-Size Framing
 In fixed-size framing, there is no need for defining the boundaries of the frames; the
size itself can be used as a delimiter.
2) Variable-Size Framing
 In variable-size framing, we need a way to define the end of the frame and the
beginning of the next.
 Historically, two approaches were used for this purpose: a character-oriented
approach and a bit-oriented approach.

Character-Oriented Protocols
 In a character-oriented protocol, data to be carried are 8-bit characters from a coding
system such as ASCII.
 The header, which normally carries the source and destination addresses and other control
information, and the trailer, which carries error detection or error correction redundant bits,
are also multiples of 8 bits. 
 To separate one frame from the next, an 8-bit (1-byte) flag is added at the beginning and
the end of a frame. The flag, composed of protocol-dependent special characters, signals
the start or end of a frame.

 Flag should be different from the text pattern used in the data section. Otherwise, when the
receiver encounters this pattern in the middle of the data, it thinks that it has reached the
end of the frame. To fix this problem, a byte-stuffing strategy was added to character-
oriented framing.

 Byte stuffing is the process of adding 1 extra byte whenever there is a flag or escape
character in the text.

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 23


 The data section is stuffed with an extra byte. This byte is usually called the escape
character (ESC), which has a predefined bit pattern. Whenever the receiver encounters the
ESC character, it removes it from the data section and treats the next character as data, not
a delimiting flag.
 If even the escape character is also part of the text, an extra escape character is added to
show that the second one is part of the text.

 Character-oriented protocols present another problem in data communications. The


universal coding systems in use today, such as Unicode, have 16-bit and 32-bit characters
that conflict with 8-bit characters.

Bit-Oriented Protocols:
 In a bit-oriented protocol, the data section of a frame is a sequence of bits to be
interpreted by the upper layer as text, graphic, audio, video, and so on.
 In addition to headers a special 8-bit pattern flag 01111110 is used as the delimiter to
define the beginning and the end of the frame.


 If the flag pattern appears in the data, bit stuffing is used to differentiate the flag from
information.
 Bit stuffing is the process of adding one extra 0 whenever five consecutive 1s follow a 0
in the data, so that the receiver does not mistake the pattern 0111110 for a flag.

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 24


 This extra stuffed bit is eventually removed from the data by the receiver.

Flow and Error Control


Flow Control
 Flow control coordinates the amount of data that can be sent before receiving an
acknowledgment.
 Flow control refers to a set of procedures used to restrict the amount of data that the
sender can send before waiting for acknowledgment.
 The flow of data must not be allowed to overwhelm the receiver.
 Any receiving device has a limited speed at which it can process incoming data and a
limited amount of memory in which to store incoming data.
 The receiving device must be able to inform the sending device before those limits are
reached and to request that the transmitting device send fewer frames or stop temporarily.
 Incoming data must be checked and processed before they can be used. The rate of such
processing is often slower than the rate of transmission. For this reason, each receiving
device has a block of memory, called a buffer, reserved for storing incoming data until they
are processed. If the buffer begins to fill up, the receiver must be able to tell the sender to
halt transmission until it is once again able to receive.

Error Control
 Error control is both error detection and error correction.
 It allows the receiver to inform the sender of any frames lost or damaged in transmission
and coordinates the retransmission of those frames by the sender.
 In the data link layer, the term error control refers primarily to methods of error detection
and retransmission.
 Error control in the data link layer is based on automatic repeat request, which is the
retransmission of data.

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 25


2.2 Protocols
The protocols are normally implemented in software by using one of the common programming
languages.

 In a real-life network, the data link protocols are implemented as bidirectional; data flow
in both directions. In these protocols the flow and error control information such as ACKs
and NAKs is included in the data frames in a technique called piggybacking.

Simplest Protocol
 Simplest protocol is one that has no flow or error control.
 It is a unidirectional protocol in which data frames are traveling in only one direction-from
the sender to receiver.

Design
 The data link layer at the sender site gets data from its network layer, makes a frame out
of the data, and sends it.
 The data link layer at the receiver site receives a frame from its physical layer, extracts
data from the frame, and delivers the data to its network layer.
 The data link layers of the sender and receiver provide transmission services for their
network layers.
 The data link layers use the services provided by their physical layers (such as signaling,
multiplexing, and so on) for the physical transmission of bits.
 The sender site cannot send a frame until its network layer has a data packet to send. The
receiver site cannot deliver a data packet to its network layer until a frame arrives.

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 26



Fig: The design of the simplest protocol with no flow or error control

Figure below shows an example of communication using this protocol. It is very simple. The
sender sends a sequence of frames without even thinking about the receiver. To send three frames,
three events occur at the sender site and three events at the receiver site.

Fig: Flow diagram

FSMs
 Each FSM has only one state, the ready state. The sending machine remains in the ready
state until a request comes from the process in the network layer. When this event occurs,
the sending machine encapsulates the message in a frame and sends it to the receiving
machine.
 The receiving machine remains in the ready state until a frame arrives from the sending
machine. When this event occurs, the receiving machine decapsulates the message out of
the frame and delivers it to the process at the network layer.

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 27


Stop-and-Wait Protocol
 If data frames arrive at the receiver site faster than they can be processed, the frames
must be stored until their use.
 Normally, the receiver does not have enough storage space, especially if it is receiving
data from many sources. This may result in either the discarding of frames or denial of
service.
 To prevent the receiver from becoming overwhelmed with frames, we somehow need to
tell the sender to slow down. There must be feedback from the receiver to the sender.
 The protocol is called the Stop-and-Wait Protocol because the sender sends one frame,
stops until it receives confirmation from the receiver, and then sends the next frame.
Design
 At any time, there is either one data frame on the forward channel or one ACK frame on
the reverse channel. We therefore need a half-duplex link.

 The sender sends one frame and waits for feedback from the receiver. When the ACK
arrives, the sender sends the next frame.

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 28


Sender States

 The sender is initially in the ready state, but it can move between the ready and blocking
state.
Ready State.

 When the sender is in this state, it is only waiting for a packet from the network layer. If a
packet comes from the network layer, the sender creates a frame, saves a copy of the
frame, starts the only timer and sends the frame.
 The sender then moves to the blocking state.
Blocking State.

 When the sender is in this state, three events can occur:


a. If a time-out occurs, the sender resends the saved copy of the frame and restarts the
timer.
b. If a corrupted ACK arrives, it is discarded.
c. If an error-free ACK arrives, the sender stops the timer and discards the saved copy of
the frame. It then moves to the ready state.

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 29


Receiver

 The receiver is always in the ready state. Two events may occur:
a. If an error-free frame arrives, the message in the frame is delivered to the network
layer and an ACK is sent.
b. If a corrupted frame arrives, the frame is discarded.
 Figure below shows an example. The first frame is sent and acknowledged. The second
frame is sent, but lost. After time-out, it is resent. The third frame is sent and
acknowledged, but the acknowledgment is lost. The frame is resent. However, there is a
problem with this scheme. The network layer at the receiver site receives two copies of the
third packet, which is not right.

 To correct the problem in the above Example , we need to add sequence numbers to the
data frames and acknowledgment numbers to the ACK frames.
 However, numbering in this case is very simple. Sequence numbers are 0, 1, 0, 1, 0, 1, . .
the acknowledgment numbers can also be 1, 0, 1, 0, 1, 0, … In other words, the sequence
numbers start with 0, the acknowledgment numbers start with 1. An acknowledgment
number always defines the sequence number of the next frame to receive.
 Figure below shows how adding sequence numbers and acknowledgment numbers can
prevent duplicates. The first frame is sent and acknowledged. The second frame is sent, but
lost. After time-out, it is resent. The third frame is sent and acknowledged, but the
acknowledgment is lost. The frame is resent.

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 30


2.3 HDLC
High-level Data Link Control (HDLC) is a bit-oriented protocol for communication over point-
to-point and multipoint links. It implements the ARQ mechanisms.

Configurations and Transfer Modes


HDLC provides two common transfer modes that can be used in different configurations:
1. Normal response mode (NRM)
2. Asynchronous balanced mode (ABM)

Normal Response Mode:


 In normal response mode (NRM), the station configuration is unbalanced. We have one
primary station and multiple secondary stations.
 A primary station can send commands; a secondary station can only respond.
 The NRM is used for both point-to-point and multiple-point links

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 31


Asynchronous Balanced Mode
In asynchronous balanced mode (ABM), the configuration is balanced. The link is point-to-point,
and each station can function as a primary and a secondary.

Frames
 HDLC defines three types of frames:
1. Information frames (I-frames)
2. Supervisory frames (S-frames)
3. Unnumbered frames (U-frames)
 Each type of frame serves as an envelope for the transmission of a different type of message.
 I-frames are used to transport user data and control information relating to user data
(piggybacking).
 S-frames are used only to transport control information.
 U-frames are reserved for system management. Information carried by U-frames is intended
for managing the link itself.
Frame Format

Fields
 Flag field: The flag field of an HDLC frame is an 8-bit sequence with the bit pattern 01111110
that identifies both the beginning and the end of a frame and serves as a synchronization pattern
for the receiver.
 Address field: The second field of an HDLC frame contains the address of the secondary
station. If a primary station created the frame, it contains a to address. If a secondary creates
the frame, it contains a from address. An address field can be 1 byte or several bytes long,

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 32


depending on the needs of the network. One byte can identify up to 128 stations (l bit is used
for another purpose). Larger networks require multiple-byte address fields. If the address field
is only 1 byte, the last bit is always a 1. If the address is more than 1 byte, all bytes but the last
one will end with 0; only the last will end with 1. Ending each intermediate byte with 0
indicates to the receiver that there are more address bytes to come.
 Control field: The control field is a 1- or 2-byte segment of the frame used for flow and error
control. The interpretation of bits in this field depends on the frame type.
 Information field: The information field contains the user's data from the network layer or
management information. Its length can vary from one network to another.
 FCS field: The frame check sequence (FCS) is the HDLC error detection field. It can contain
either a 2- or 4-byte ITU-T CRC.

Control Field
The control field determines the type of frame and defines its functionality.

Control Field for I-Frames


 I-frames are designed to carry user data from the network layer. In addition, they can include
flow and error control information (piggybacking).
 If the first bit of the control field is 0, this means the frame is an I-frame.
 The next 3 bits, called N(S), define the sequence number of the frame. Note that with 3 bits,
we can define a sequence number between 0 and 7; but in the extension format, in which the
control field is 2 bytes, this field is larger.
 The last 3 bits, called N(R), correspond to the acknowledgment number when piggybacking
is used.
 The single bit between N(S) and N(R) is called the P/F bit. The P/F field is a single bit with a
dual purpose. It has meaning only when it is set (bit = 1) and can mean poll or final. It means
poll when the frame is sent by a primary station to a secondary. It means final when the frame
is sent by a secondary to a primary.

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 33


Control Field for S-Frames
 Supervisory frames are used for flow and error control whenever piggybacking is either
impossible or inappropriate.
 S-frames do not have information fields.
 If the first 2 bits of the control field is 10, this means the frame is an S-frame.
 The last 3 bits, called N(R), corresponds to the acknowledgment number (ACK) or negative
acknowledgment number (NAK) depending on the type of S-frame.
 The 2 bits called code is used to define the type of S-frame itself. With 2 bits, we can have
four types of S-frames, as described below:
Receive ready (RR): If the value of the code subfield is 00, it is an RR S-frame. This kind
of frame acknowledges the receipt of a safe and sound frame or group of frames. In this

case, the value N(R) field defines the acknowledgment number.
Receive not ready (RNR): If the value of the code subfield is 10, it is an RNR S-frame.
This kind of frame is an RR frame with additional functions. It acknowledges the receipt
of a frame or group of frames, and it announces that the receiver is busy and cannot receive
more frames. It acts as a kind of congestion control mechanism by asking the sender to

slow down. The value of NCR) is the acknowledgment number.
Reject (REJ): If the value of the code subfield is 01, it is a REJ S-frame. This is a NAK
frame, but not like the one used for Selective Repeat ARQ. It is a NAK that can be used in
Go-Back-N ARQ to improve the efficiency of the process by informing the sender, before
the sender time expires, that the last frame is lost or damaged. The value of N(R) is the

negative acknowledgment number.
Selective reject (SREJ): If the value of the code subfield is 11, it is an SREJ S-frame. This
is a NAK frame used in Selective Repeat ARQ. Note that the HDLC Protocol uses the term
selective reject instead of selective repeat. The value of N(R) is the negative
acknowledgment number.

Control Field for V-Frames


 Unnumbered frames are used to exchange session management and control information
between connected devices. Unlike S-frames, U-frames contain an information field, but one
used for system management information, not user data.
 As with S-frames, however, much of the information carried by U-frames is contained in
codes included in the control field.
 U-frame codes are divided into two sections: a 2-bit prefix before the P/F bit and a 3-bit suffix
after the P/F bit. Together, these two segments (5 bits) can be used to create up to 32 different
types of U-frames. Some of the more common types are shown below.



Chethana H R, Asst. Prof Dept. of CSE, RNSIT 34

Example: Connection/Disconnection

Example: Piggybacking without Error

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 35


Example: Piggybacking with error

Point-To-Point Protocol
 Today, millions of Internet users who need to connect their home computers to the server
of an Internet service provider use PPP. The majority of these users have a traditional
modem; they are connected to the Internet through a telephone line, which provides the
services of the physical layer. But to control and manage the transfer of data, there is a need
for a point-to-point protocol at the data link layer.
 PPP provides several services:
1. PPP defines the format of the frame to be exchanged between devices.
2. PPP defines how two devices can negotiate the establishment of link and the exchange of data.
3. PPP defines how network layer data are encapsulated in the data link frame.
4. PPP defines how two devices can authenticate each other.
5. PPP provides multiple network layer services supporting a variety of network layer protocols.
6. PPP provides connections over multiple links.
7. PPP provides network address configuration. This is particularly useful when a home user
needs a temporary network address to connect to the Internet.

Limitations of PPP:
1. PPP does not provide flow control.

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 36


2. PPP has a very simple mechanism for error control. A CRC field is used to detect errors. If the
frame is corrupted, it is silently discarded; the upper-layer protocol needs to take care of the
problem. Lack of error control and sequence numbering may cause a packet to be received out of
order.
3. PPP does not provide a sophisticated addressing mechanism to handle frames in a multipoint
configuration.
Framing
Frame Format

 Flag: A PPP frame starts and ends with 1-byte flag with the bit pattern 01111110.
 Address: The address field in this protocol is a constant value and set to 11111111
(broadcast address).
 Control: This field is set to the constant value 11000000
 Protocol: The protocol field defines what is being carried in the data field: either user
data or other information.
 Payload field: This field carries either the user data or other information. The data field is
a sequence of bytes with the default of a maximum of 1500 bytes; but this can be changed
during negotiation. Because there is no field defining the size of the data field, padding is
needed if the size is less than the maximum default value or the maximum negotiated value.
 FCS: The frame check sequence (FCS) is simply a 2-byte or 4-byte standard CRC.
 is a byte-oriented protocol using byte stuffing with the escape byte 01111101.

Transition Phases

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 37


 Dead: In the dead phase the link is not being used. There is no active carrier (at the physical
layer) and the line is quiet.
 Establish: When one of the nodes starts the communication, the connection goes into this
phase. In this phase, options are negotiated between the two parties. If the negotiation is
successful, the system goes to the authentication phase (if authentication is required) or directly
to the networking phase.
 Authenticate: The authentication phase is optional; the two nodes may decide, during the
establishment phase, not to skip this phase. However, if they decide to proceed with
authentication, they send several authentication packets. If the result is successful, the
connection goes to the networking phase; otherwise, it goes to the termination phase.

 Network: In the network phase, negotiation for the network layer protocols takes place. PPP
specifies that two nodes establish a network layer agreement before data at the network layer
can be exchanged. The reason is that PPP supports multiple protocols at the network layer. If
a node is running multiple protocols simultaneously at the network layer, the receiving node
needs to know which protocol will receive the data.

 Open: In the open phase, data transfer takes place. When a connection reaches this phase, the
exchange of data packets can be started. The connection remains in this phase until one of the
endpoints wants to terminate the connection.
 Terminate: In the termination phase the connection is terminated. Several packets are
exchanged between the two ends for house cleaning and closing the link.

Multiplexing in PPP
 PPP: A link-layer protocol that uses various protocols to:
1. Establish links
2. Authenticate parties involved
3. Carry network-layer data
 Three key protocols in PPP:
1. Link Control Protocol (LCP)
2. Authentication Protocols (APs)
3. Network Control Protocols (NCPs)
 Allows carrying of data from multiple sources in the data field of PPP packets.

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 38


Figure: Multiplexing in PPP

Link Control Protocol (LCP) - PPP


• Role of LCP:
• Establishes, configures, maintains, and terminates links
• Negotiates options between endpoints
• Agreement on options required before link establishment
• LCP transitions through phases, illustrated by states like:
• Dead
• Establish
• Authenticate
• Network
• Terminate
LCP packet encapsulated in a frame – PPP

• Fields in LCP Packet:


• Code: Packet type identifier (11 types of packets)
• ID: Matches requests with replies
• Length: Total length of the LCP packet
• Information: Contains options, if needed
• LCP Packet Types
• Three categories of LCP packets:
• Link Configuration (e.g., Configure-request, Configure-ack)

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 39


• Link Termination (e.g., Terminate-request, Terminate-ack)
• Link Monitoring/Debugging (e.g., Echo-request, Echo-reply)

Authentication Protocols in PPP


• Essential for user identity verification.
• Validates user identity for resource access.
• PPP Authentication Protocols:
1. Password Authentication Protocol (PAP).
2. Challenge Handshake Authentication Protocol (CHAP).

Password Authentication Protocol (PAP).


• Simple authentication process.
• Involves a two-step process between user and system.
• PAP Authentication Steps:
1. Step 1: User sends an authentication ID (username) and password.
2. Step 2: System verifies credentials and accepts or denies access.
• PAP Packet Types:
1. Authenticate-Request: Sent by user (username and password).
2. Authenticate-Ack: Sent by system to accept access.
3. Authenticate-Nak: Sent by system to deny access.
PAP Packet Structure in PPP Frame
• Protocol Field Value: 0xC023 for PAP packets.
• Packet Types in Detail:
1. Authenticate-Request: User credentials.
2. Authenticate-Ack: Grant access.
3. Authenticate-Nak: Deny access.
• PAP Usage Limitation:
1. Vulnerable due to plaintext password transmission.
Chethana H R, Asst. Prof Dept. of CSE, RNSIT 40
2.Challenge Handshake Authentication Protocol (CHAP)
• Secure, three-way handshake protocol.
• Password is never sent directly.
• CHAP Authentication Steps:
• Step 1: System sends a challenge packet with a unique challenge value.
• Step 2: User applies a function using challenge value + password, sends the result.
• Step 3: System performs the same calculation and verifies the result.

• CHAP Packet Structure in PPP Frame


• Protocol Field Value: 0xC223 for CHAP packets.

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 41


• CHAP Packet Types:
• Challenge: System initiates authentication.
• Response: User’s calculated result.
• Success: System grants access if results match.
• Failure: System denies access if results don’t match.
Comparison: PAP vs. CHAP
• PAP:
• Simple two-step process.
• Username and password sent directly.
• Less secure due to plaintext transmission.
• CHAP:
• Three-way handshake.
• Password is never transmitted.
• More secure due to dynamic challenge values.
• Best Practices:
• Use CHAP for enhanced security in dial-up PPP links.
Network Control Protocols (NCP)
• Purpose: Configure link-layer settings for various network-layer protocols.
• Each network protocol has a specific NCP to handle configuration, e.g., IPCP for IP.
1. Internet Protocol Control Protocol (IPCP)
• Configures links for IP data packets.
• Encapsulated within a PPP frame, contains code, ID, length, and IPCP info.

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 42


Multilink PPP (MLPPP)
• Original PPP Limitation: Single-channel point-to-point.
• Multilink PPP: Uses multiple channels to split a logical PPP frame across physical
frames.
• Protocol Field in MLPPP: Set to 0x003d to indicate fragmentation.
• Additional Complexity: Sequence numbers to indicate fragment order.

Phases of Network Layer Packet Transmission in PPP Connection

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 43


1. PPP Transmission:
Steps for sending data from user site to system site (e.g., sending an email through an ISP).
Unidirectional data flow assumed for simplicity.
2. Link Establishment:
Frames 1 and 2: Establish the link.
3. Authentication Phase:
Frames 3 and 4: Execute authentication with PAP.
4. Network Layer Connection Setup:
Frames 5 and 6: Establish Network Layer connection using IPCP (IP Control Protocol).
5. Data Transfer:
Encapsulation of IP packets within PPP frames.
System can recognize data for IP protocol as IPCP was used to establish the connection.
6. Termination of Connection:
User terminates Data Link Layer connection, which system acknowledges.
Optionally, user/system can terminate IPCP at the Network Layer while keeping the Data Link
Layer active to initiate a new NCP protocol.

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 44


Media Access control

 Data link layer is subdivided into two sublayers: data link control (DLC) and media
access control (MAC).
 The data link control sublayer deals with all issues common to both point-to-point and
broadcast links. The media access control sublayer deals only with issues specific to
broadcast links. In other words, we separate these two types of links at the data-link layer,
as shown in Figure 9.4.

 When nodes or stations are connected and use a common link, called a multipoint or
broadcast link, we need a multiple-access protocol to coordinate access to the link.
Taxonomy of multiple access protocols is given below:

3.1 RANDOM ACCESS or CONTENTION methods

 In random access or contention methods, no station is superior to another station and none
is assigned the control over another.
 A station that has data to send uses a procedure defined by the protocol to make a decision
to send or not to send. This decision depends on the state of the medium (idle or busy).
Main features are:

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 45


1. There is no scheduled time for a station to transmit. Transmission is random among the
stations, hence called random access.
2. No rules specify which station should send next. Stations compete with one another to
access the medium, hence called contention methods.
To avoid access conflict or to resolve it when it happens, each station follows a procedure that
answers the following questions:

 When can the station access the medium?


 What can the station do if the medium is busy?
 How can the station determine the success or failure of the transmission?
 What can the station do if there is an access conflict?

ALOHA
ALOHA, the earliest random access method was developed at the University of Hawaii in early
1970. It was designed for a radio (wireless) LAN, but it can be used on any shared medium.
Pure ALOHA

 The original ALOHA protocol is called pure ALOHA.


 It supports multiple access. The idea is that each station sends a frame whenever it has a
frame to send.
 However, since there is only one channel to share, there is the possibility of collision
between frames from different stations.
 Figure below shows an example of frame collisions in pure ALOHA.

 Here four stations that contend with one another for access to the shared channel.
 Each station sends two frames, total of eight frames on the shared medium. Some of these
frames collide because multiple frames are in contention for the shared channel.
Chethana H R, Asst. Prof Dept. of CSE, RNSIT 46
 Figure above shows that only two frames survive, frame 1.1 from station 1 and frame 3.2
from station 3.
 If one bit of a frame coexists on the channel with one bit from another frame, there is a
collision and both will be destroyed.
 The pure ALOHA protocol relies on acknowledgments from the receiver. When a station
sends a frame, it expects the receiver to send an acknowledgment.
 If the acknowledgment does not arrive after a time-out period, the station assumes that the
frame has been destroyed and resends the frame.
 A collision involves two or more stations. If all these stations try to resend their frames
after the time-out, the frames will collide again.
 Pure ALOHA dictates that when the time-out period passes, each station waits a random
amount of time before resending its frame. This randomness will help avoid more
collisions.
 The time is back-off time TB. Below figure 12.4 shows the procedure for pure ALOHA
based on the above strategy.

 The time-out period is equal to the maximum possible round-trip propagation delay, which
is twice the amount of time required to send a frame between the two most widely separated
stations (2 x Tp).
 The back-off time TB is a random value that normally depends on K (the number of
attempted unsuccessful transmissions).
 Formula for TB depends on the implementation. One common formula is the binary
exponential back-off. In this method, for each retransmission, a multiplier in the range 0 to

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 47


2K - 1 is randomly chosen and multiplied by Tp (maximum propagation time) or Tfr (the
average time required to send out a frame) to find TB.

Example 12.1

The stations on a wireless ALOHA network are a maximum of 600 km apart. If we assume that
signals propagate at 3 × 108 m/s, Then

Tp = (600 × 103) / (3 × 108) = 2 ms.

For K = 2, the range of R is {0, 1, 2, 3}

This means that TB can be 0, 2, 4, or 6 ms, based on the outcome of the random variable R.

Vulnerable time

 It is the Length of time, in which there is a possibility of collision. We assume that the
stations send fixed-length frames with each frame taking Tfr Sec to send. Figure 12.5 shows
the vulnerable time for station A.

 Station A sends a frame at time t. Now imagine station B has already sent a frame between
t - Tfr and t.
 This leads to a collision between the frames from station A and station B. The end of B's
frame collides with the beginning of A's frame.
 Suppose that station C sends a frame between t and t + Tfr . Here, there is a collision
between frames from station A and station C. The beginning of C's frame collides with the
end of A's frame.
 Figure 12.4, shows vulnerable time, during which a collision may occur in pure ALOHA,
is 2 times the frame transmission time.
Pure ALOHA vulnerable time = 2 x Tfr

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 48


Example 12.2

A pure ALOHA network transmits 200-bit frames on a shared channel of 200 kbps. What is the
requirement to make this frame collision-free?
Solution:
 Average frame transmission time Tfr is 200 bits/200 kbps or 1 ms.
 The vulnerable time is 2 × 1 ms = 2 ms.
 This means no station should send later than 1 ms before this station starts transmission
and no station should start sending during the period (1 ms) that this station is sending.
Throughput

 Let G be the average number of frames generated by the system during one frame
transmission time.
 Then average number of successfully transmitted frames for pure ALOHA is S = G
× e−2G.
 The maximum throughput Smax is 0.184 for G = ½.
 In other words, if one-half a frame is generated during one frame transmission time (one
frame during two frame transmission times), then 18.4 percent of these frames reach their
destination successfully.
Example 12.3

A pure ALOHA network transmits 200-bit frames on a shared channel of 200 kbps. What is the
throughput if the system (all stations together) produces
a. 1000 frames per second
b. 500 frames per second
c. 250 frames per second
Solution
The frame transmission time is 200/200 kbps or 1 ms.

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 49


Slotted ALOHA
 Pure ALOHA has a vulnerable time of 2 x Tfr . This is so because there is no rule that
defines when the station can send. A station may send soon after another station has started
or soon before another station has finished. Slotted ALOHA was invented to improve the
efficiency of pure ALOHA.
 In slotted ALOHA, we divide the time into slots of Tfr’s and force the station to send only
at the beginning of the time slot. Figure below shows an example of frame collisions in
slotted ALOHA.

 Because a station is allowed to send only at the beginning of the synchronized time slot, if
a station misses this moment, it must wait until the beginning of the next time slot.
 This means that the station which started at the beginning of this slot has already finished
sending its frame.
 There is still the possibility of collision if two stations try to send at the beginning of the
same time slot.
 The vulnerable time is now reduced to one-half, equal to Tfr. Figure below shows that the
vulnerable time for slotted ALOHA is one-half that of pure ALOHA.
Slotted ALOHA vulnerable time = Tfr

Throughput
 It can be proved that the average number of successful transmissions for slotted
ALOHA is
S = G x e-G.
The maximum throughput Smax is 0.368, when G = 1.

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 50


Example 12.4

A slotted ALOHA network transmits 200-bit frames using a shared channel with a 200-kbps
bandwidth. Find the throughput if the system (all stations together) produces
a. 1000 frames per second
b. 500 frames per second
c. 250 frames per second
Solution

 The frame transmission time is 200/200 kbps or 1 ms.


 a. In this case G is 1. S =G x e-G or S =0.368 (36.8 percent). This means that the
throughput is 1000 x 0.0368 =368 frames. Only 368 out of 1000 frames will probably
survive. Note that this is the maximum throughput case, percentagewise.
 b. Here G is1/2. In this case S =G x e-G or S =0.303 (30.3 percent). This means that the
throughput is 500 x 0.0303 =151. Only 151 frames out of 500 will probably survive.
 c. Now G is1/4. In this case S =G x e-G or S =0.195 (19.5 percent). This means that the
throughput is 250 x 0.195 = 49. Only 49 frames out of 250 will probably survive.

Carrier Sense Multiple Access (CSMA)


 Carrier sense multiple access (CSMA) requires that each station first listen to the medium
before sending. The reason for this is shown in Figure below, a space and time model of
a CSMA network.
 Stations are connected to a shared channel. The possibility of collision still exists because
of propagation delay;

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 51


 When a station sends a frame, it still takes time for the first bit to reach every station and
for every station to sense it. At time t1 station B senses the medium and finds it idle, so it
sends a frame. At time t2 (t2> t1) station C senses the medium and finds it idle because,
at this time, the first bit from station B has not reached station C. Station C also sends a
frame. The two signals collide and both frames are destroyed.

Vulnerable Time

 The vulnerable time for CSMA is the propagation time Tp . This is the time needed
for a signal to propagate from one end of the medium to the other. When a station
sends a frame, and any other station tries to send a frame during this time, a collision
will result.
 Figure below shows the worst case. The leftmost station A sends a frame at time t1
which reaches the rightmost station D at time t1 + Tp.

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 52


Persistence Methods

 What should a station do if the channel is busy? What should a station do if the channel is
idle? Three methods have been devised to answer these questions.
1. I-persistent method 2. nonpersistent method and 3. p-persistent method.
Figure below shows the behavior of three persistence methods when a station finds a channel
busy.

 1-Persistent: In this method, after the station finds the line idle, it sends its frame
immediately. This method has the highest chance of collision because two or more stations
may find the line idle at the same time and send their frames immediately.
 Non-persistent: A station that has a frame to send senses the line. If the line is idle, it
sends immediately. If the line is not idle, it waits a random amount of time and then senses
the line again. The non-persistent approach reduces the chance of collision because it is
unlikely that two or more stations will wait the same amount of time and retry to send
simultaneously. However, this method reduces the efficiency of the network.
 P-Persistent: Used if the channel has time slots with slot duration equal to or greater than
the maximum propagation time. The p-persistent approach combines the advantages of
the other two strategies. It reduces the chance of collision and improves efficiency. In this
method, after the station finds the line idle it follows steps:
1. With probability p, the station sends its frame.
2. With probability q = 1 - p, the station waits for the beginning of the next time slot and
checks the line again.
a. If the line is idle, it goes to step 1.
b. If the line is busy, it acts as though a collision has occurred and uses the back-
off procedure.
 Flow diagram for three persistence methods are given below.

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 53


Carrier Sense Multiple Access with Collision Detection (CSMA/CD)
 Carriers sense multiple access with collision detection (CSMA/CD) augments the
algorithm to handle the collision.
 A station monitors the medium after it sends a frame to see if the transmission was
successful. If so, the station is finished else the frame is sent again.
 Below Figure shows stations A and C are involved in the collision.

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 54


 At time t1, station A has executed its persistence procedure and starts sending the bits of
its frame. At time t2, station C has not yet sensed the first bit sent by A. Station C executes
its persistence procedure and starts sending the bits in its frame, which propagate both
to the left and to the right.
 The collision occurs sometime after time t2 Station C detects a collision at time t3 when it
receives the first bit of A's frame. Station C immediately aborts transmission. Station A
detects collision at time t4 when it receives the first bit of C's frame, it also immediately
aborts transmission.
 Station A transmits for the duration t4 – t1 and C is t3 - t2. At time t4, station A aborts its
transmission and time t3 station C aborts its transmission. Figure below shows complete
graph.

Minimum Frame Size

 For CSMA/CD to work, there should be a restriction on the frame size.


 Before sending the last bit of the frame, the sending station must detect a collision, if any,
and abort the transmission.
 This is so because the station, once the entire frame is sent, does not keep a copy of the
frame and does not monitor the line for collision detection.
 Therefore the frame transmission time Tfr must be at least two times the maximum
propagation time Tp.
Tfr = 2 * Tp

Example 12.5
 A network using CSMA/CD has a bandwidth of 10 Mbps. If the maximum propagation
time (including the delays in the devices and ignoring the time needed to send a jamming
signal, as we see later) is 25.6 μs, what is the minimum size of the frame?
Solution

The minimum frame transmission time is Tfr = 2 × Tp = 51.2 μs. This means, in the worst
case, a station needs to transmit for a period of 51.2 μs to detect the collision.
The minimum size of the frame is 10 Mbps × 51.2 μs = 512 bits or 64 bytes.

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 55


Procedure
 Flow diagram for CSMA/CD is as shown below figure. It is similar to the one for the
ALOHA protocol, but there are differences.

 First difference is the addition of the persistence process. The corresponding box can be
replaced by one of the persistence processes.
 The second difference is the frame transmission. In ALOHA, we first transmit the entire
frame and then wait for an acknowledgment. In CSMA/CD, transmission and collision
detection is a continuous process. We do not send the entire frame and then look for a
collision. The station transmits and receives continuously and simultaneously.
 The third difference is the sending of a short jamming signal that enforces the collision
in case other stations have not yet sensed the collision.
Energy Level

 The level of energy in a channel can have three values: zero, normal, and abnormal.
 At the zero level, the channel is idle.
 At the normal level, a station has successfully captured the channel and is sending its
frame.
 At the abnormal level, there is a collision and the level of the energy is twice the normal
level.
 A station that has a frame to send or is sending a frame needs to monitor the energy level
to determine if the channel is idle, busy, or in collision mode. Figure below shows the
situation.

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 56


Throughput

 The throughput of CSMA/CD is greater than that of pure or slotted ALOHA.


 The maximum throughput occurs at a different value of G and is based on the persistence
method and the value of p in the p-persistent approach.
 For 1-persistent method the maximum throughput is around 50 percent when G =1.
 For non-persistent method, the maximum throughput can go up to 90 percent when G is
between 3 and 8.

Carrier Sense Multiple Access with Collision Avoidance (CSMA/CA)


 Carrier sense multiple access with collision avoidance (CSMA/CA) was invented for
wireless networks.
 Collisions are avoided through the use of CSMA/CA’s three strategies:
1. The interframe space(IFS)
2. Contention window and
3. Acknowledgments

Interframe Space (IFS)

 Collisions are avoided by deferring transmission even if the channel is found idle.
When an idle channel is found, the station does not send immediately. It waits for a period
of time called the interframe space or IFS, because distant station may have already started
transmitting. The distant station's signal has not yet reached this station. The IFS time
allows the front of the transmitted signal by the distant station to reach this station. If after
the IFS time the channel is still idle, the station can send, but it still needs to wait a time

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 57


equal to the contention time. The IFS variable can also be used to prioritize stations or
frame types.
Contention Window
 The contention window is an amount of time divided into slots. A station that is ready
to send chooses a random number of slots as its wait time. The number of slots in the
window changes according to the binary exponential back-off strategy. This means that
it is set to one slot the first time and then doubles each time the station cannot detect an
idle channel after the IFS time. One interesting point about the contention window is that
the station needs to sense the channel after each time slot. However, if the station finds
the channel busy, it does not restart the process. It just stops the timer and restarts it when
the channel is sensed as idle. This gives priority to the station with the longest waiting
time.
Acknowledgment
 With all these precautions, still there may be a collision resulting in destroyed data. In
addition, the data may be corrupted during the transmission. The positive
acknowledgment and the time-out timer can help guarantee that the receiver has
received the frame.

 Figure below shows the flow chart of CSMA/CA.

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 58


Frame Exchange Time Line
 Figure below shows the exchange of data and control frames in time.
1. Before sending a frame, the source station senses the medium by checking the
energy level at the carrier frequency.
a. The channel uses a persistence strategy with backoff until the channel is idle.
b. After the station is found to be idle, the station waits for a period of time called
the DCF interframe space (DIFS); then the station sends a control frame called the
request to send (RTS).

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 59


2. After receiving the RTS and waiting a period of time called the short interframe
space (SIFS), the destination station sends a control frame, called the clear to send (CTS),
to the source station. This control frame indicates that the destination station is ready to
receive data.
3. The source station sends data after waiting an amount of time equal to SIFS.
4. The destination station, after waiting an amount of time equal to SIFS, sends an
acknowledgment to show that the frame has been received. Acknowledgment is needed in
this protocol because the station does not have any means to check for the successful
arrival of its data at the destination. On the other hand, the lack of collision in CSMA/CD
is a kind of indication to the source that data have arrived.

Network Allocation Vector


 How do other stations defer sending their data if one station acquires access? In other
words, how is the collision avoidance aspect of this protocol accomplished? The key is a
feature called NAV.
 When a station sends an RTS frame, it includes the duration of time that it needs to occupy
the channel. The stations that are affected by this transmission create a timer called a
network allocation vector (NAV) that shows how much time must pass before these
stations are allowed to check the channel for idleness.
 Each time a station accesses the system and sends an RTS frame, other stations start their
NAV. In other words, each station, before sensing the physical medium to see if it is idle,
first checks its NAV to see if it has expired. Figure 12.17 shows the idea of NAV.

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 60


Collision During Handshaking

 Collision can happen during the time when RTS or CTS control frames are in transition, often
called the handshaking period. Two or more stations may try to send RTS frames at the same
time. These control frames may collide. However, because there is no mechanism for collision
detection, the sender assumes there has been a collision if it has not received a CTS frame
from the receiver. The backoff strategy is employed, and the sender tries again.

3.2 CONTROLLED ACCESS


In controlled access, the stations consult one another to find which station has the right to send.

1. Reservation
 A station needs to make a reservation before sending data.
 Time is divided into intervals. In each interval, a reservation frame precedes the data
frames sent in that interval. If there are N stations in the system, there are exactly N
reservation mini-slots in the reservation frame, each mini-slot belongs to a station.
 When a station needs to send a data frame, it makes a reservation in its own mini-slot.
Figure 12.18 shows a situation with five stations and a five-mini-slot reservation frame.
In the first interval, only stations 1, 3, and 4 have made reservations. In the second
interval, only station 1 has made a reservation.
Figure 12.18

2. Polling
 Polling works with topologies in which one device is designated as a primary station
and the other devices are secondary stations.
 All data exchanges must be made through the primary device even when the ultimate
destination is a secondary device.
 The primary device controls the link. The secondary devices follow its instructions. It is up
to the primary device to determine which device is allowed to use the channel at a
given time, as shown below figure 12.19.

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 61


Figure 12.19

 If the primary wants to receive data, it asks the secondary’s if they have anything to send,
this is called poll function. If the primary wants to send data, it tells the secondary to get
ready to receive; this is called select function.
Select

 The select function is used whenever the primary device has something to send.
 The primary must alert the secondary to the upcoming transmission and wait for an
acknowledgment of the secondary's ready status. Before sending data, the primary creates
and transmits a select (SEL) frame, one field of which includes the address of the intended
secondary.
Poll

 The poll function is used by the primary device to solicit transmissions from the secondary
devices.
 When the primary is ready to receive data, it must ask (poll) each device in turn if it
has anything to send. When the first secondary is approached, it responds either with a
NAK frame if it has nothing to send. When the response is positive (a data frame), the
primary reads the frame and returns an acknowledgment (ACK frame), verifying its
receipt.

3. Token Passing
 The stations in a network are organized in a logical ring, each station there is a predecessor
and a successor.
 The predecessor is the station which is logically before the station in the ring; the
successor is the station which is after the station in the ring.
 Here special packet called a token circulates through the ring. The possession of the token
gives the station the right to access the channel and send its data. When a station has some
data to send, it waits until it receives the token from its predecessor. It then holds the token
and sends its data. When the station has no more data to send, it releases the token, passing
it to the next logical station in the ring.

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 62


Logical Ring

 In a token-passing network, stations do not have to be physically connected in a ring, the


ring can be a logical one. Figure below show four different physical topologies.

 In the physical ring topology, when a station sends the token to its successor, the token
cannot be seen by other stations; the successor is the next one in line. This means that the
token does not have to have the address of the next successor. The problem with this
topology is that if one of the links-the medium between two adjacent stations fails, the
whole system fails.
 The dual ring topology uses a second ring which operates in the reverse direction
compared with the main ring. The second ring is for emergencies only. If one of the links
in the main ring fails, the system automatically combines the two rings to form a temporary
ring, after the failed link is restored. Each station needs to have two transmitter ports and
two receiver ports. The high-speed Token Ring networks called FDDI (Fiber Distributed
Data Interface) and CDDI (Copper Distributed Data Interface) use this topology.
 In the bus ring topology, also called a token bus, the stations are connected to a single
cable called a bus. They, however, make a logical ring, because each station knows the
address of its successor. When a station has finished sending its data, it releases the token
and inserts the address of its successor in the token. Only the station with the address
matching the destination address of the token gets the token to access the shared media.
The Token Bus LAN, standardized by IEEE, uses this topology.
 In a star ring topology, there is a hub, however, that acts as the connector. The wiring
inside the hub makes the ring; the stations are connected to this ring through the two wire
connections. This topology makes the network less prone to failure because if a link goes
down, it will be bypassed by the hub and the rest of the stations can operate.

Chethana H R, Asst. Prof Dept. of CSE, RNSIT 63


COMPUTER NETWORKS–V SEM CSE VTU

MODULE-3: NETWORK LAYER

1. NETWORK-LAYER

1.1 Network Layer Services

1.2 Packet Switching

1.3 IPv4 Addresses

1.4 IPv4 Datagram

1.5 IPv6 Datagram

2. INTRODUCTION TO ROUTING ALGORITHMS

2.1 Introduction

2.2 Routing Algorithms

2.3 Unicast Routing Protocols:DVR, LSR, PVR

2.4 Unicast Routing Protocols:RIP, OSPF,BGP

2.5 Multicast Routing:MOSPF

Ravi Kumar S G Dept Of CSE, RNSIT 1


1. NETWORK-LAYER

The network layer in the TCP/IP protocol suite plays a crucial role in ensuring host-to-host
delivery of data. It operates between the data-link layer and the transport layer, providing
services to the latter while receiving services from the former. It is responsible for routing and
delivering packets across various networks, encapsulating data into packets, and decapsulating
them at the destination.
1.1 Network Layer Services

The Internet, a combination of LANs and WANs, consists of many networks connected through
routers and switches. The network layer is involved in:

• Source Host (e.g., Alice): It encapsulates the transport layer packet into a datagram and
hands it over to the data-link layer for transmission.

• Destination Host (e.g., Bob): It decapsulates the received datagram to retrieve the packet
and deliver it to the transport layer.

• Routers (R2, R4, R5, R7): They forward the datagrams across multiple networks until
they reach the destination.

Figure 3.1:Communication at the network layer

Ravi Kumar S G Dept Of CSE, RNSIT 2


Functions of the Network Layer

1. Packetizing:

o The network layer encapsulates data from the transport layer into packets
(datagrams) at the source and decapsulates them at the destination.

o The source adds necessary headers, including source and destination addresses, to
the packet.

2. Routing:

o The network layer selects the best route for packets to travel across multiple
networks (LANs, WANs).

o Routers use algorithms to determine the most efficient path from source to
destination.

3. Forwarding:

o Forwarding refers to how routers handle packets upon arrival. Routers look up
the forwarding table or routing table to determine which network interface to send
the packet through.

o The decision is based on packet headers (e.g., destination address, labels).

Figure 3.2: Forwarding process

Additional Services Provided by the Network Layer

• Error Control:

o Although the network layer itself doesn’t handle errors directly, the ICMP
protocol helps detect errors, such as when a packet cannot be delivered.

Ravi Kumar S G Dept Of CSE, RNSIT 3


• Flow Control:

o The network layer helps prevent the receiver from becoming overwhelmed with
data by ensuring the sender doesn't send more data than the receiver can process.

• Congestion Control:

o The network layer helps in managing and avoiding congestion in the network by
controlling the flow of packets, especially in high-traffic conditions.

• Quality of Service (QoS):

o QoS ensures the network layer delivers data with a certain performance level,
managing delays, throughput, and packet loss.

1.2 Packet Switching


➢ Packet switching is a method of data transmission in which information is broken into
small, manageable pieces called packets. Each packet is sent independently through a
network, and they may take different routes to reach the destination. Once all packets
arrive, they are reassembled in the correct order to recreate the original message
➢ .Although in data communication switching techniques are divided into two broad
categories, circuit switching and packet switching, only packet switching is used at the
network layer because the unit of data at this layer is a packet.
➢ Circuit switching is mostly used at the physical layer; the electrical switch mentioned
earlier is a kind of circuit switch.
➢ At the network layer, a message from the upper layer is divided into manageable packets
and each packet is sent through the network.
➢ The source of the message sends the packets one by one; the destination of the message
receives the packets one by one.
➢ The destination waits for all packets belonging to the same message to arrive before
delivering the message to the upper layer

Today, a packet-switched network can use two different approaches to route the packets: the
datagram approachand the virtual circuit approach.

Ravi Kumar S G Dept Of CSE, RNSIT 4


Types of Packet Switching:

• Datagram Packet Switching:


o Each packet is treated independently with no pre-established path.
o Routing decisions are made for each packet at every node.
o Examples: User Datagram Protocol (UDP).

Fig 3.3: A connectionless packet-switched network

• Virtual Circuit Packet Switching:


o A logical path (virtual circuit) is established between sender and receiver before
any packets are sent.
o Packets follow the same route, which helps maintain the order of transmission.
o Examples: Transmission Control Protocol (TCP), Frame Relay.

Fig 3.4 A virtual-circuit packet-switched network

Ravi Kumar S G Dept Of CSE, RNSIT 5


The virtual-circuit approach is a type of connection-oriented service used in data
communication networks. Before transmitting data, a logical connection, known as a virtual
circuit, is established between the sender and receiver. All data packets then follow this
predefined path throughout the communication session.

Fig 3.5: Forwarding process in a router when used in a virtual-circuit network

➢ To create a connection-oriented service, a three-phase process is used: setup, data


transfer, and teardown.
➢ In the setup phase, the source and destination addresses of the sender and receiver are
used to make table entries for the connection-oriented service.
➢ In the teardown phase, the source and destination inform the router to delete the
corresponding entries. Data transfer occurs between these two phases.

1. Setup Phase

• Goal: Establish a virtual circuit between Source A and Destination B using request and
acknowledgment packets.
• Steps in Setup:
o Request Packet:
1. Source A sends a request packet to Router R1.
2. Router R1:

Ravi Kumar S G Dept Of CSE, RNSIT 6


▪ Identifies the outgoing port for packets to B (Port 3).
▪ Assigns:
▪ Incoming Port: 1
▪ Incoming Label: 14
▪ Outgoing Port: 3
▪ Forwards the packet to Router R3.
3. Router R3:
▪ Fills its routing table with:
▪ Incoming Port: 1
▪ Incoming Label: 66
▪ Outgoing Port: 3
▪ Forwards the packet to Router R4.
4. Router R4:
▪ Assigns:
▪ Incoming Port: 1
▪ Incoming Label: 22
▪ Outgoing Port: 4
▪ Sends the request packet to Destination B.
5. Destination B assigns Label 77 to incoming packets from A.

Fig: 3.6: Sending request packet in a virtual-circuit network

o Acknowledgment Packet:
1. Destination B sends an acknowledgment packet back to Router R4:
▪ Router R4 fills the outgoing label as 77.

Ravi Kumar S G Dept Of CSE, RNSIT 7


2. Router R4 sends the acknowledgment to Router R3, which fills its
outgoing label as 22.
3. Router R3 sends an acknowledgment to Router R1, which fills its
outgoing label as 66.
4. Router R1 sends the acknowledgment to Source A, which fills its
outgoing label as 14 for future packets.

Fig: 3.7: Sending acknowledgments in a virtual-circuit network

2. Data Transfer Phase

• Goal: Transfer data between Source A and Destination B once the virtual circuit is
established.
• Steps:
1. Source A labels the packets with Label 14 (from R1).
2. Router R1:
▪ Receives packets with Label 14.
▪ Changes the label to 66 and forwards to Router R3.
3. Router R3:
▪ Receives packets with Label 66.
▪ Changes the label to 22 and forwards to Router R4.
4. Router R4:
▪ Receives packets with Label 22.

Ravi Kumar S G Dept Of CSE, RNSIT 8


▪ Changes the label to 77 and forwards to Destination B.
5. Destination B receives the packets with Label 77 (which it recognizes from
setup).

3. Teardown Phase

• Goal: End the virtual circuit once data transmission is complete.


• Steps:
1. Source A sends a teardown packet to Destination B.
2. Destination B responds with a confirmation packet.
3. Each router along the path (R4, R3, R1) deletes the virtual circuit entries from its
routing table.

1.3 IPv4 Datagram


• Packetizing is the primary service provided by IPv4. It defines the format of a packet
(called a datagram) to encapsulate data from the upper layers.
• An IPv4 datagram is a variable-length packet, with a header (20 to 60 bytes) and payload
(data).

• A datagram consists of two main parts:


o Header (20–60 bytes): Contains control and routing information.
o Payload (data): The actual data being transmitted from the upper layers (e.g.,
TCP/UDP).

Fig 3.8: IPv4 datagram format.

Ravi Kumar S G Dept Of CSE, RNSIT 9


IPv4 Datagram Structure

• Header:
o 20 to 60 bytes in length.
o Contains crucial fields to ensure the proper routing and handling of the packet.
o Shown in 4-byte (32-bit) sections for easy reference.
• Payload:
o Contains the data from the upper-layer protocols, such as TCP, UDP, or other
transport or network protocols.

2. Key Header Fields

1. Version (4 bits):
o Specifies the IP version. For IPv4, the value is always 4.
2. Header Length (HLEN) (4 bits):
o Indicates the length of the header in 4-byte words.
o Helps identify where the header ends and the data (payload) begins.
3. Service Type (8 bits):
o Originally called Type of Service (TOS), now redefined as Differentiated
Services (DiffServ).
o Used for prioritizing different types of network traffic (e.g., voice over IP).
4. Total Length (16 bits):
o Specifies the total length of the datagram, including both header and data, in
bytes.
o Helps receivers distinguish between actual data and any padding that might be
added (e.g., in Ethernet frames).
5. Identification, Flags, and Fragmentation Offset:
o Used for fragmenting datagrams that exceeds the maximum transmission unit
(MTU) of the network.
o Allows reassembly of fragmented packets at the destination.
6. Time-to-Live (TTL) (8 bits):
o Limits the number of hops a datagram can take.
o Each router decrements this value, and if it reaches zero, the datagram is
discarded.
o Prevents datagrams from endlessly circulating due to routing errors.
7. Protocol (8 bits):
o Identifies the protocol of the encapsulated payload (e.g., TCP = 6, UDP = 17).
o Ensures the correct upper-layer protocol receives the data at the destination
(demultiplexing).

Ravi Kumar S G Dept Of CSE, RNSIT 10


8. Header Checksum (16 bits):
o Used to verify the integrity of the header (not the payload).
o Each router recalculates the checksum since fields like TTL change with every
hop.
9. Source and Destination IP Addresses (32 bits each):
o Source IP Address: The IP address of the sender.
o Destination IP Address: The IP address of the receiver.
o These fields remain unchanged as the datagram travels across the network.
10. Options (0–40 bytes):
o Optional field used for network testing, debugging, or special features.
o Adds flexibility, but may require routers to recalculate the checksum if options
are altered.

3. Payload (Data)

• The payload is the data encapsulated in the datagram, which comes from upper-layer
protocols (e.g., TCP, UDP).
• The payload is the primary reason for sending the datagram, with the header providing
the necessary instructions for delivery.

4. Important Concepts

• Multiplexing and Demultiplexing:


o The Protocol field in the IP header functions like port numbers in the transport
layer.
o It ensures data is delivered to the correct upper-layer protocol.
• Fragmentation:
o Large datagrams are fragmented when they exceed the size limit of the network’s
maximum transmission unit (MTU).
o The Identification, Flags, and Fragmentation Offset fields help in reassembling
the fragments at the destination.
• TTL and Loop Prevention:
o The TTL field prevents infinite looping by limiting the number of hops the
packet can traverse.
o If the TTL reaches zero, the datagram is discarded.

• An IPv4 address is a 32-bit identifier used to uniquely define the connection of a device
(host or router) to the Internet.

Ravi Kumar S G Dept Of CSE, RNSIT 11


1.4 IPv4 Addresses
• The address is assigned to the connection (not the device), meaning if a device changes its
network, its IP address may also change.
• IPv4 addresses are both unique and universal, ensuring global consistency and uniqueness
across all devices connected to the Internet
1. 4.1 Address Space

• The address space is the total number of addresses available for use in the IPv4 protocol.
• IPv4 uses 32 bits, so the address space is 2³² (or 4,294,967,296 addresses).
• In theory, this would allow more than 4 billion devices to connect to the Internet, but
practical limitations such as network design reduce the usable address space.

1.4.2. IPv4 Address Notations

IPv4 addresses can be represented in three main formats:

• Binary Notation (Base 2):


o The address is shown as 32 bits, separated into 8-bit octets for readability (e.g.,
11000000 10101000 00000001 00000001).
• Dotted-Decimal Notation (Base 256):
o The address is written in decimal format, with each octet separated by dots (e.g.,
192.168.1.1).
o Each octet is a value between 0 and 255.
• Hexadecimal Notation (Base 16):
o The address is represented as 8 hexadecimal digits (e.g., C0A80101).
o This format is often used in network programming.

1.4.3. Hierarchy in IPv4 Addressing

• IPv4 addresses are hierarchical, divided into two parts:


o Prefix: Defines the network (similar to a postal country or city code).
o Suffix: Defines the specific node (device or connection) on that network (similar
to a house number in postal addressing).
• There are two main types of address hierarchy:
o Classful Addressing: Original fixed-length prefix system (now obsolete).
o Classless Addressing: Modern variable-length prefix system.

Ravi Kumar S G Dept Of CSE, RNSIT 12


4Classful Addressing (Obsolete)

• Classful Addressing divides the IPv4 address space into five classes (A, B, C, D, E),
designed to accommodate different network sizes.

IPv4 Address Classes:

Fig 3.9: classful addressing

1. Class A:
o Prefix length: 8 bits (first bit is always 0, so only 7 bits are available for network
identification).
o Supports up to 128 networks.
o Example range: 1.0.0.0 to 126.0.0.0.
2. Class B:
o Prefix length: 16 bits (first two bits are 10, so 14 bits for network identification).
o Supports up to 16,384 networks.
o Example range: 128.0.0.0 to 191.255.0.0.
3. Class C:
o Prefix length: 24 bits (first three bits are 110, so 21 bits for network
identification).
o Supports up to 2,097,152 networks.
o Example range: 192.0.0.0 to 223.255.255.0.
4. Class D (Multicast):
o First four bits are 1110.
o Reserved for multicast addresses (group communication).
o Range: 224.0.0.0 to 239.255.255.255.

Ravi Kumar S G Dept Of CSE, RNSIT 13


5. Class E (Experimental):
o First four bits are 1111.
o Reserved for experimental purposes.
o Range: 240.0.0.0 to 255.255.255.255.

Address Depletion

Problem: Classful addressing led to rapid depletion of IPv4 addresses due to inefficient
distribution.

• Class A:
o Designed for very large organizations.
o Only 128 networks available, each with 16,777,216 addresses.
o Most organizations didn't need so many addresses, leading to significant waste.
• Class B:
o Designed for midsize organizations.
o Despite more networks available, many addresses remained unused.
• Class C:
o Intended for smaller networks.
o Each network had only 256 addresses, which was often too few for organizations.
• Class E: Reserved and almost never used, leading to wastage of the entire class.

Solutions to Address Depletion

• Subnetting:
o Concept: Divides a large class A or class B network into smaller subnets.
o Method: Increases the prefix length, creating multiple smaller networks from a
single large network.
o Issue: Not widely adopted because large organizations were reluctant to share
unused addresses with smaller ones.
• Supernetting:
o Concept: Combines several smaller class C networks into a larger block.
o Purpose: Designed to create larger address blocks for organizations needing more
than 256 addresses.
o Issue: Made packet routing more complex, limiting its effectiveness.

Advantage of Classful Addressing

• Simplicity: The class of an address is easily identifiable from the address itself.

Ravi Kumar S G Dept Of CSE, RNSIT 14


• Fixed Prefix Length:
o Each address class (A, B, C) has a predefined prefix length.
o No additional information is required to determine the prefix and suffix, making it
easier to understand and manage

1.Introduction to Classless Addressing:

• Classless addressing was introduced to solve the IPv4 address depletion problem.
• It eliminates the rigid class structure (A, B, C) of classful addressing and allows variable-
length blocks of IP addresses.
• Provides more efficient and flexible distribution of IP addresses to organizations and
ISPs.
• Classful addressing wasted many IP addresses due to fixed-size blocks; classless
addressing resolves this by allowing different block sizes.

2. Why Classless Addressing Was Introduced:

• Address Depletion: The Internet’s growth led to a shortage of IPv4 addresses.


• ISPs (Internet Service Providers): ISPs required a flexible address allocation system to
serve individuals, small businesses, and organizations efficiently.
• Efficient Allocation: Classless addressing allowed ISPs to assign blocks of addresses
based on actual needs, rather than forcing organizations to take larger, unused ranges.

3. Variable-Length Blocks:

• In classless addressing, IP addresses are grouped into blocks of varying sizes, which can
be 2, 4, 8, 16, 32, 64 addresses, and so on.
• The block sizes must be a power of 2, such as 21, 22, 23 and so on.

Fig: 3.10: Variable-length blocks in classless addressing

4. Prefix Length and Slash Notation (CIDR):

• The length of the network portion of the IP address is indicated by the prefix length.
• Slash Notation or CIDR (Classless Interdomain Routing) is used to specify the prefix
length, written as /n, where n is the number of bits used for the network part.

Ravi Kumar S G Dept Of CSE, RNSIT 15


o Example: 192.168.1.0/24 means the first 24 bits are for the network and the
remaining 8 bits are for hosts.
• Larger prefix length = smaller network (fewer hosts).
• Smaller prefix length = larger network (more hosts).

Fig: 3.11: Slash notation (CIDR)

5. Block of Addresses:

• A block of addresses is determined by the prefix (network part) and the suffix (host part).
• The size of the block is based on the prefix length.
• The number of addresses in a block is calculated using the formula: N=232-n where n is
the prefix length.

6. How to Extract Information from a Block:

• To extract key information from any given IP address block:


1. Number of addresses: Use N=232−n where n is the prefix length.
2. First address: Set the last (32−n) bits to 0.
3. Last address: Set the last (32 – n) bits to 1.

Fig 3.11: Information extraction in classless addressing

Ravi Kumar S G Dept Of CSE, RNSIT 16


Example : A classless address is given as 167.199.170.82/27. We can find the above three
pieces of information as follows. The number of addresses in the network is 232 − n = 25 = 32
addresses.

Example 18.3
In classless addressing, an address cannot per se define the block the address belongs to. For
example, the address 230.8.24.56 can belong to many blocks. Some of them are shown below
with the value of the prefix associated with that block.

Network Address
The above examples show that, given any address, we can find all information about the block.
The first address, the network address, is particularly important because it is used in routing a
packet to its destination network.

Fig 3.12: Network address

Ravi Kumar S G Dept Of CSE, RNSIT 17


For the moment, let us assume that an internet is made of m networks and a router with m
interfaces. When a packet arrives at the router from any source host, the router needs to know to
which network the packet should be sent: from which interface the packet should be sent out.

7. Advantages of Classless Addressing:

• Efficient use of IP addresses: Avoids the waste of addresses that occurs with classful
addressing.
• Scalability: Allows for more precise address allocation based on actual need, which is
crucial as the number of devices connected to the Internet grows.
• Better management by ISPs: ISPs can assign blocks of different sizes to customers,
ensuring everyone gets only the number of addresses they need.

Classless addressing (CIDR) was a crucial development in managing the limited IPv4 address
space. By allowing variable-length prefixes and more flexible block sizes, it ensures a more
efficient and scalable distribution of IP addresses across the Internet.

8. Block Allocation in Classless Addressing:

• Global Authority (ICANN): The Internet Corporation for Assigned Names and
Numbers (ICANN) is responsible for assigning IP address blocks.
o ICANN does not assign addresses to individual users but allocates large blocks to
ISPs or large organizations.
• Responsibilities of ISPs: ISPs receive large blocks of addresses from ICANN, which
they further subdivide and assign to customers.

Restrictions for Block Allocation:

Two main restrictions ensure the proper functioning of CIDR:

1. Number of Addresses (N):


o The number of requested addresses must be a power of 2.
o This is because N=232−nN = 2^{32 - n}N=232−n, and nnn must be an integer. If
NNN is not a power of 2, nnn will not be a valid integer.
o Example: If 1000 addresses are requested, since 1000 is not a power of 2, the next
power of 2 (1024) addresses will be allocated.
2. First Address Requirement:
o The first address of the block must be divisible by the number of addresses in the
block.

Ravi Kumar S G Dept Of CSE, RNSIT 18


o The first address should be represented as the prefix followed by (32−n) mzeros
in binary.
o The decimal value of the first address must be divisible by the number of
addresses.

Example (Block Allocation):

• An ISP requests 1000 addresses.


• Since 1000 is not a power of 2, 1024 addresses are allocated instead.
• The prefix length n is calculated as n=32−log21024=22 The ISP is assigned the block
18.14.12.0/22. The first address in this block (in decimal) is 302,910,464, which is
divisible by 1024.

1. Overview of Subnetting:

• Subnetting: The process of dividing a larger block of IP addresses (assigned to an


organization or ISP) into smaller blocks called subnetworks (or subnets).
• Multi-level Hierarchy: Subnetting can be performed at multiple levels. For example, a
subnet can be further divided into sub-subnets, sub-sub-subnets, etc.
• Subnetting provides more granular control over IP address allocation and network design,
allowing for efficient use of address space and easier management of smaller networks.

2. Designing Subnets:

To design subnetworks efficiently, the following steps must be followed:

1. Number of Addresses in Subnet:


o The number of addresses in each subnetwork (Nsub) must be a power of 2.
o This ensures that subnetting adheres to the same principles as block allocation,
where the address block size must be a power of 2.
2. Prefix Length for Each Subnetwork:
o The prefix length for each subnetwork (nsub) can be calculated using the
formula: nsub=32−log⁡2(Nsub)nsub = 32 - \log_2 (Nsub)nsub=32−log2(Nsub)
o This formula helps determine how many bits in the IP address are used for the
network part, and how many are left for the hosts.
3. Starting Address of Each Subnet:
o The starting address of each subnet must be divisible by the number of addresses
in the subnet.

Ravi Kumar S G Dept Of CSE, RNSIT 19


o This can be achieved by assigning addresses to larger subnetworks first and
then working down to smaller subnets.

Example:

• Suppose an organization is granted 1024 addresses (/22).


• The organization can divide the range into subnetworks based on the number of required
addresses per subnet.
o For a subnet that needs 256 addresses, the prefix length would be
nsub=32−log2256=24
o The starting address of each subnet must be divisible by the size of the subnet
(256 in this case).

3. Finding Information About Each Subnetwork:

After designing the subnetworks, key information about each subnet (such as the first address
and last address) can be calculated using the same method applied to larger networks. The
process is as follows:

1. First Address:
o The first address of the subnet is found by setting the host bits (the last 32−n sub
bits) to 0.
2. Last Address:
o The last address is found by setting the host bits to 1.

Steps to Find First and Last Address:

• If a subnet has a prefix length of /24, the first address will have the last 8 bits set to 0, and
the last address will have the last 8 bits set to 1.

Key Points to Remember:

• Subnetting allows an organization to efficiently use its allocated IP address block by


dividing it into smaller subnetworks.
• Each subnetwork must contain a power-of-2 number of addresses.
• The prefix length for each subnetwork is calculated based on the number of addresses it
requires.
• Proper design of subnets is crucial for efficient routing and network management.
• Once designed, the first and last address of each subnet can be determined using the
prefix length.

Ravi Kumar S G Dept Of CSE, RNSIT 20


This approach ensures optimal usage of IP addresses, simplifies routing, and improves the
scalability of network infrastructure.

Address Aggregation
One of the advantages of the CIDR strategy is address aggregation (sometimes called address
summarization or route summarization). When blocks of addresses are combined to create a
larger block, routing can be done based on the prefix of the larger block. ICANN assigns a large
block of addresses to an ISP. Each ISP in turn divides its assigned block into smaller sub blocks
and grants the sub locks to its customers.

Example: An organization has been granted a block of 256 addresses, starting at 14.24.74.0/24.
The organization needs to divide this block into three subnets with the following requirements:

1. Subnet 1: 120 addresses


2. Subnet 2: 60 addresses
3. Subnet 3: 10 addresses

The solution involves allocating a number of addresses that are powers of 2, which are larger
than or equal to the required number. The subnets are designed by starting with the largest
requirement and working down to the smallest.

Steps and Subnet Design:

1. Total Addresses:
o The block 14.24.74.0/24 has a total of: 232−24=256 addresses
o First address: 14.24.74.0
o Last address: 14.24.74.255

Subnet A: Largest Subnet (120 addresses)

• Required: 120 addresses, but this is not a power of 2.


• Allocated: 128 addresses (since 128=is the next power of 2).
• Prefix length: n1=32−log2(128)=25
• First address: 14.24.74.0/25
• Last address:
o The block starts at 14.24.74.0, and since there are 128 addresses, the last address
is 14.24.74.127/25.

Subnet B: Second Largest Subnet (60 addresses)

• Required: 60 addresses, but this is not a power of 2.

Ravi Kumar S G Dept Of CSE, RNSIT 21


• Allocated: 64 addresses (since 64=26 is the next power of 2).
• Prefix length: n2=32−log2(64)=26
• First address: The next available address after the first block is 14.24.74.128/26.
• Last address:
o The block starts at 14.24.74.128, and since there are 64 addresses, the last address
is 14.24.74.191/26.

Subnet C: Smallest Subnet (10 addresses)

• Required: 10 addresses, but this is not a power of 2.


• Allocated: 16 addresses (since 16=24 is the next power of 2).
• Prefix length: n3=32−log2(16)=28
• First address: The next available address after the second block is 14.24.74.192/28.
• Last address:
o The block starts at 14.24.74.192, and since there are 16 addresses, the last address
is 14.24.74.207/28.

Remaining Addresses:

• After assigning the three subnets, the total number of allocated addresses is:
128+64+16=208 addresses
• This leaves 48 addresses unused.
• First address of unused range: 14.24.74.208
• Last address of unused range: 14.24.74.255
• Prefix length: To be determined, but the range can be used for future subnets or other
purposes.

Summary of Subblocks:

• Subnet A:
o 120 required, 128 allocated
o First address: 14.24.74.0/25
o Last address: 14.24.74.127/25
• Subnet B:
o 60 required, 64 allocated
o First address: 14.24.74.128/26
o Last address: 14.24.74.191/26
• Subnet C:
o 10 required, 16 allocated
o First address: 14.24.74.192/28
o Last address: 14.24.74.207/28

Ravi Kumar S G Dept Of CSE, RNSIT 22


• Unused Block:
o First address: 14.24.74.208
o Last address: 14.24.74.255
o 48 addresses left for future use.

This method ensures efficient utilization of IP addresses while allowing for potential future
expansions.

Special IPv4 Addresses

IPv4 includes several special-purpose addresses used for specific functions in networking. Here
are five important types:

1. This-host Address (0.0.0.0/32)

• Address: 0.0.0.0/32
• Purpose: Used when a host doesn't know its own IP address and needs to communicate.
• Use Case: A host might use this address as a source address before it knows its IP (e.g.,
during DHCP requests).

2. Limited-broadcast Address (255.255.255.255/32)

• Address: 255.255.255.255/32
• Purpose: Sends a datagram to all devices on the local network.
• Restrictions: Routers block these packets from being forwarded to other networks (they
stay within the local network).
• Use Case: A host can broadcast to all devices within the same local network segment.

3. Loopback Address (127.0.0.0/8)

• Address: 127.0.0.0/8 (commonly, 127.0.0.1)


• Purpose: Used for testing and local communications within the same host. Packets sent
to this address never leave the device.
• Use Case: Software testing (e.g., running a client-server application on the same host
using 127.0.0.1 as the server address).

Ravi Kumar S G Dept Of CSE, RNSIT 23


4. Private Addresses

• Blocks:
o 10.0.0.0/8
o 172.16.0.0/12
o 192.168.0.0/16
o 169.254.0.0/16 (link-local addresses)
• Purpose: Used for internal/private networks. These addresses are not routable on the
public Internet.
• Use Case: Networks within homes, businesses, or organizations. They require Network
Address Translation (NAT) for accessing the Internet.

5. Multicast Addresses (224.0.0.0/4)

• Address Block: 224.0.0.0/4


• Purpose: Used for multicasting, where a datagram is sent to multiple destinations
simultaneously.
• Use Case: Applications like video conferencing, live streaming, or network services that
need to send data to a group of devices.

Summary of Special IPv4 Addresses:


Type Address/Block Purpose

This-host 0.0.0.0/32 Host doesn't know its IP address

Limited- Broadcast to all devices in the


255.255.255.255/32
broadcast local network

Testing local applications


Loopback 127.0.0.0/8
(remains on host)

Private 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, Internal, non-routable IP


Addresses 169.254.0.0/16 addresses

Send data to multiple devices


Multicast 224.0.0.0/4
simultaneously

These addresses serve distinct roles in networking, ensuring proper communication, testing, and
private address use within internal networks.

Ravi Kumar S G Dept Of CSE, RNSIT 24


Dynamic Host Configuration Protocol (DHCP)

1. What is DHCP?
o Definition: DHCP (Dynamic Host Configuration Protocol) automates the process
of assigning IP addresses and other essential network configurations to devices
within a network.
o Purpose: Reduces the need for manual IP address setup by network
administrators.
2. IP Address Allocation Sources
o Large Organizations and ISPs: Receive IP address blocks directly from ICANN
(Internet Corporation for Assigned Names and Numbers).
o Small Organizations: Obtain IP address blocks from their ISP.
3. Manual vs. Automatic Assignment
o Manual Assignment: Admins manually assign each device an IP address, which
can be time-consuming.
o Automatic Assignment with DHCP: DHCP automatically assigns IPs,
improving efficiency and reducing errors.
4. How DHCP Works
o Layer and Model: Operates at the application layer and follows a client-server
model.
o Process: Devices (clients) request IP configuration from a DHCP server, which
assigns an IP and other necessary details.
5. Plug-and-Play Protocol
o DHCP is often called "plug-and-play" because it allows devices to connect to the
network and obtain configuration settings automatically, without user
intervention.
6. Permanent vs. Temporary IP Addressing
o Permanent IP Assignment: For devices like servers and routers needing a stable
IP.
o Temporary IP Assignment: For devices requiring short-term connectivity (e.g.,
laptops in hotels).
o Example of Efficiency: ISPs with limited IPs can use DHCP to support more
devices by reallocating addresses dynamically, such as serving 4,000 households
with 1,000 IPs if only 25% are online simultaneously.
7. Essential Information Provided by DHCP
o IP Address: Unique identifier for the device.
o Network Prefix (Subnet Mask): Defines the device's network range.
o Default Router (Gateway): The IP address of the router to connect to external
networks.
o DNS Server Address: Resolves domain names into IP addresses, allowing easy
access to websites.

Ravi Kumar S G Dept Of CSE, RNSIT 25


8. Uses and Benefits of DHCP
o Applications: Commonly used in all types of networks (home, office, ISP) to
manage IPs and provide necessary network details.
o Simplified Network Management: DHCP reduces setup time, decreases the
chance of configuration errors, and optimizes IP allocation.

DHCP is crucial for modern networks, making IP management simple and efficient. It provides
both permanent and temporary IP assignments along with other essential network information,
ensuring that devices can connect to the network with minimal setup.

DHCP Message Format

DHCP is a client-server protocol in which the client sends a request message and the server
returns a response message

Opcode: Operation code, request (1) or reply (2)


Htype: Hardware type (Ethernet, ...)
HLen: Length of hardware address
HCount: Maximum number of hops the packet can travel
Transaction ID: An integer set by the client and repeated by the server
Time elapsed: The number of seconds since the client started to boot
Flags: First bit defines unicast (0) or multicast (1); other 15 bits not used
Your IP address: The client IP address sent by the server
Client IP address: Set to 0 if the client does not know it
Server IP address: A broadcast IP address if client does not know it
Gateway IP address: The address of default router
Server name: A 64-byte domain name of the server
Boot file name: A 128-byte file name holding extra information
Options: A 64-byte field with dual purpose described in text

Ravi Kumar S G Dept Of CSE, RNSIT 26


The 64-byte option field has a dual purpose. It can carry either additional information or some
specific vendor information.
The server uses a number, called a magic cookie, in the format of an IP address with the
value of 99.130.83.99. When the client finishes reading the message, it looks for this magic
cookie. If present, the next 60 bytes are options. An option is composed of three fields: a 1-byte
tag field, a 1-byte length field, and a variable-length value field. There are several tag fields that
are mostly used by vendors. If the tag field is 53, the value field defines one of the 8 message
types shown in Figure 18.26. We show how these message types are used by DHCP.

Ravi Kumar S G Dept Of CSE, RNSIT 27


DHCP Operation Steps
DHCP (Dynamic Host Configuration Protocol) enables devices to automatically acquire IP
addresses and network configuration details for seamless network connectivity. Here’s how the
DHCP process unfolds:

1. DHCPDISCOVER:
o The new host (client) sends a DHCPDISCOVER message to locate a DHCP
server. This message includes only a transaction ID, a unique random identifier
to track the session, as the host has no IP address or server information.
o The message is encapsulated in a UDP datagram with source port 68 and
destination port 67 (well-known DHCP ports).
o The IP layer uses source IP address 0.0.0.0 (since the host has no IP address) and
destination IP address 255.255.255.255 (broadcast address) to ensure it reaches
any DHCP server on the network.
2. DHCPOFFER:
o One or more DHCP servers respond with a DHCPOFFER message. This
message includes:
▪ Your IP Address: the offered IP address for the client.
▪ Server IP Address: identifies the server making the offer.
▪ Lease Time: duration for which the IP address is valid.
o The DHCPOFFER message is encapsulated in a UDP datagram with source port
67 and destination port 68 (reverse of the DISCOVER message).
o The IP layer sets the server’s IP address as the source and broadcasts the
destination address so other DHCP servers can see the offer and, if necessary,
make better offers.
3. DHCPREQUEST:
o The client selects the best offer and responds with a DHCPREQUEST message
to the chosen server.
o This message includes the chosen IP address and other relevant details and is sent
with source port 68 and destination port 67.
o The IP source address is the client’s new IP address, while the destination
remains the broadcast address, informing other servers that their offers were not
accepted.

4. DHCPACK or DHCPNACK:

• The selected server confirms the IP assignment with a DHCPACK message,


finalizing the process.
• If the IP is no longer available, the server sends a DHCPNACK message, and the
client restarts the process.

Ravi Kumar S G Dept Of CSE, RNSIT 28


• The server broadcasts this message so other DHCP servers can see if the request
was accepted or rejected.

The DHCP protocol relies on two well-known ports (68 and 67) and includes features for file
retrieval, error control, and address allocation management. Here's a breakdown of these aspects:

1. Two Well-Known Ports (68 and 67):


o Port 68 is used by the DHCP client, while Port 67 is used by the DHCP server.
o The choice of a well-known client port (68) over a temporary (ephemeral) port
helps avoid confusion if multiple applications are running. For example, if both a
DHCP and a different service client (like DAYTIME) were waiting for responses
on the same port, both could mistakenly receive each other's packets if the server
broadcast a response. Using Port 68 isolates DHCP responses to the DHCP client.
o If multiple DHCP clients are on the network after events like a power
restoration, they can be identified by their unique transaction ID, avoiding
interference.
2. Using FTP for Additional Configuration:
o After a client receives a DHCPACK message with basic information, it may need
more configuration details, such as the DNS server address.
o The DHCP server includes a pathname in the DHCPACK message, guiding the
client to a file where additional setup details are stored.
o The client can then retrieve this file using FTP (File Transfer Protocol) or
similar methods.
3. Error Control in DHCP:
o DHCP operates over UDP, which lacks built-in reliability. To manage errors,
DHCP implements:
▪ UDP checksum: Ensures data integrity as UDP’s checksum is mandatory
for DHCP.
▪ Timers and Retransmission: If the client doesn’t receive a response, it
retransmits its request. To avoid congestion, especially if multiple devices
need to retransmit (e.g., after a power outage), DHCP uses a random
timer for retransmissions.
4. Transition States in DHCP:
o DHCP functions as a state machine, where the client transitions through several
states depending on the messages exchanged. The main states include:
▪ INIT: Client starts here when joining a network.
▪ SELECTING: Client waits for DHCPOFFER messages.
▪ REQUESTING: Client selects an offer and sends a DHCPREQUEST.
▪ BOUND: Client is assigned an IP and can use the network.
▪ RENEWING/REBINDING: Client attempts to extend its lease as it
approaches expiration.

Ravi Kumar S G Dept Of CSE, RNSIT 29


▪ REBINDING: If lease renewal fails, the client tries to contact any server
to rebind its lease.

Figure 18.28 shows the transition diagram with the main states.

DHCP Client State Transitions and Timers

The DHCP client progresses through several states as it acquires and manages its IP address
lease. Key stages and timers include:

1. INIT State (Initializing):


o The client begins in the INIT state, where it needs an IP address.
o It broadcasts a DHCPDISCOVER message to find a DHCP server.
2. SELECTING State:
o Upon receiving DHCPOFFER messages, the client enters the SELECTING
state.
o It may receive multiple offers from different servers. The client picks the best
offer.

Ravi Kumar S G Dept Of CSE, RNSIT 30


3. REQUESTING State:
o After selecting an offer, the client sends a DHCPREQUEST message to confirm
its choice.
o It then enters the REQUESTING state, waiting for the server’s acknowledgment
(ACK).
4. BOUND State:
o When the client receives a DHCPACK message, it transitions to the BOUND
state and begins using the assigned IP address.
5. RENEWING State:
o When 50% of the lease time has passed, the renewal timer triggers, moving the
client to the RENEWING state.
o In this state, the client attempts to renew its lease directly with the server.
o If the server renews the lease, the client moves back to the BOUND state.
6. REBINDING State:
o If the lease isn’t renewed and 75% of the lease time expires, the rebinding timer
triggers, moving the client to the REBINDING state.
o The client tries to renew the lease by broadcasting a request to any available
DHCP server.
o If successful, the client moves back to the BOUND state.
7. INIT State (Again):
o If the lease expires (without renewal) or no server responds, the client’s
expiration timer (set to 100% of the lease time) triggers, returning it to the INIT
state to request a new IP address.

DHCP Timers

• Renewal Timer: 50% of lease time (triggers entry to RENEWING state).


• Rebinding Timer: 75% of lease time (triggers entry to REBINDING state).
• Expiration Timer: 100% of lease time (client returns to INIT to get a new IP address).

Network Address Resolution (NAT)

Network Address Translation (NAT) is a technology used to manage IP address shortages by


enabling multiple devices on a local network to share a single or limited number of public IP
addresses. Here’s a breakdown of NAT's role and benefits:

1. The Problem with Limited IP Ranges:


o ISPs provide small blocks of IP addresses to businesses or households. However,
if the business or household needs more addresses (due to growth or increased

Ravi Kumar S G Dept Of CSE, RNSIT 31


device usage), the ISP may not be able to accommodate because adjacent IP
addresses may already be assigned to others.
o Not every device on a local network needs simultaneous internet access. For
example, a business with 20 computers may find that only a maximum of 4 need
access at any given time.
2. How NAT Solves This Problem:
o Private IP Addresses for Internal Use: NAT allows a local network to use
private IP addresses (such as those in the 10.0.0.0, 172.16.0.0, or 192.168.0.0
blocks) for devices communicating within the local network.
o Public IP Addresses for Internet Access: A small number of public IP addresses
(e.g., those provided by the ISP) are shared by multiple devices to access the
Internet through NAT.
3. How NAT Works:
o The NAT-capable router has one public IP address for communication with the
internet and multiple private IP addresses for devices on the local network.
o When a device on the local network requests internet access, the NAT router
translates the private IP address into the router’s public IP address, creating a
mapping table to keep track of active connections.
o Translation Table: NAT maintains a table mapping each internal device’s
private IP and port to an external IP and port, allowing multiple internal devices
to share the same public IP address while still keeping connections unique.
4. Virtual Private Network (VPN) Compatibility:
o NAT supports VPNs by allowing secure and private communication within the
local network, even when some devices communicate with the global internet.
5. Types of NAT:
o Static NAT: Maps a single private IP to a single public IP.
o Dynamic NAT: Maps a private IP to any available public IP from a pool.
o Port Address Translation (PAT): Also known as "overloading," it allows
multiple devices to share one public IP by assigning different port numbers to
each connection.
6. Advantages of NAT:
o Conserves IP Addresses: NAT reduces the number of public IP addresses
needed, which is useful with the limited IPv4 address pool.
o Security: NAT hides internal IP addresses from external networks, adding a layer
of security.

Overview of Address Translation

• Functionality of NAT:
o NAT (Network Address Translation) is a method used to modify IP address
information in packet headers while in transit across a routing device.

Ravi Kumar S G Dept Of CSE, RNSIT 32


o It primarily allows multiple devices on a local network to share a single public IP
address for Internet communication.

Outgoing Packets

• Process:
o When a device within a private network sends a packet to the Internet, the packet
is routed through the NAT router.
o The NAT router modifies the packet:
▪ It replaces the source address (the private IP address of the sending
device) with its own global NAT address (the public IP address assigned
by the ISP).
o This allows the packet to be routed properly through the Internet.

Incoming Packets

• Process:
o Incoming packets from the Internet are also processed by the NAT router.
o The NAT router changes the packet:
▪ It replaces the destination address (the NAT router's global address) with
the appropriate private IP address of the intended recipient within the local
network.

Translation Table

• Purpose:
o The translation table is essential for keeping track of the mappings between
private and public addresses.
o It solves the challenge of identifying which internal device should receive packets
that are addressed to the public IP.
• Structure:
o In its simplest form, the translation table contains two columns:
▪ Private Address: The internal IP address of a device in the local network.
▪ External Address: The corresponding public IP address that the device
used when communicating with the Internet.
• Operation:
o When a packet is sent out:
▪ The NAT router records the destination address of the outgoing packet in
the translation table along with the modified source address.
o When a response packet arrives:

Ravi Kumar S G Dept Of CSE, RNSIT 33


▪ The NAT router checks the source address of the incoming packet (the
public address).
▪ It looks up this address in the translation table to find the corresponding
private address.
▪ The router then modifies the packet's destination address to route it to the
correct internal device.

Overview of NAT with a Pool of IP Addresses

• Challenge with Single Global Address:


o Using only one global address in NAT limits the number of private-network hosts
that can communicate with the same external host simultaneously.
o This can create connectivity issues in scenarios where multiple devices need to
access the same external resource.

Ravi Kumar S G Dept Of CSE, RNSIT 34


Pool of Global Addresses

• Functionality:
o To overcome the limitation of a single global address, a NAT router can utilize a
pool of global addresses.
o For example, instead of just one address (e.g., 200.24.5.8), a NAT router can
manage multiple addresses (e.g., 200.24.5.8, 200.24.5.9, 200.24.5.10, and
200.24.5.11).
• Benefits:
o With a pool of global addresses, multiple private-network hosts can communicate
with the same external host simultaneously.
o Each private address can pair with a unique global address, effectively allowing
up to four private hosts to connect to the same external server at the same time.

Limitations of Using a Pool

• Connection Restrictions:
o Even with a pool of addresses, the NAT router imposes some limitations:
▪ No more than the number of global addresses in the pool can be used to
connect to the same destination simultaneously (in this case, a maximum
of four connections).
▪ A private-network host cannot access multiple external server programs
(e.g., HTTP and TELNET) simultaneously due to the shared global
address.
▪ Two private-network hosts cannot access the same external server
program (e.g., both trying to access an HTTP server) at the same time if
they require the same global address.

Using Both IP Addresses and Port Addresses

• Many-to-Many Relationships:
o To facilitate a many-to-many relationship between private-network hosts and
external server programs, more detailed information must be included in the NAT
translation table.
o The translation table can expand from two columns to five, incorporating:
▪ Private Address: The internal IP address of the private-network host.
▪ Global Address: The external IP address assigned by the NAT router.
▪ Source Port: The port number used by the private-network host for the
outgoing connection.
▪ Destination Port: The port number used by the external server for the
service being accessed.

Ravi Kumar S G Dept Of CSE, RNSIT 35


▪ Transport Layer Protocol: Identifies the protocol used (e.g., TCP, UDP)
for the connection.
• Example Scenario:
o If two hosts (172.18.3.1 and 172.18.3.2) need to access the same HTTP server
(25.8.3.2):
▪ The translation table can differentiate the two requests based on their
source ports.
▪ This eliminates ambiguity and allows both hosts to maintain separate
connections to the external server without conflict.

1.5 IPv6 Datagram

Transitioning from IPv4 to IPv6 involves changing the packet format to accommodate a larger
address space. The designers aimed to address IPv4's limitations while implementing new
features.

Key features in IPv6

1. Better Header Format


o Structure: IPv6 uses a new header format that separates options from the base
header.
o Benefits: This separation simplifies routing by allowing routers to process packets
more quickly, as most options are not checked during routing.
2. New Options
o Functionality: Introduces new options that enhance the protocol's capabilities,
allowing for more advanced networking functions.
3. Allowance for Extension
o Future Readiness: IPv6 is designed to be extensible, facilitating the integration
of new technologies and applications as they emerge.
4. Support for Resource Allocation
o Traffic Class & Flow Label: Replaces the IPv4 type-of-service field.

Ravi Kumar S G Dept Of CSE, RNSIT 36


o
Special Handling: These new fields enable the source to request prioritized
handling for certain types of traffic, which is crucial for real-time applications like
audio and video streaming.
5. Enhanced Security
o Encryption & Authentication: Built-in options for encryption and authentication
improve the confidentiality and integrity of data packets.
o Secure Communications: These security features provide a more robust
framework for safe data transmission.

Packet Format

The IPv6 packet is shown in Figure 22.6. Each packet is composed of a base header followed
by the payload. The base header occupies 40 bytes, whereas payload can be up to 65,535
bytes of information. The description of fields follows.

1. Version

• Definition: A 4-bit field that specifies the version number of the IP protocol.
• Value for IPv6: The version is set to 6.

2. Traffic Class

• Field Size: 8 bits.


• Purpose: Used to differentiate between different types of payloads with varying delivery
requirements.

Ravi Kumar S G Dept Of CSE, RNSIT 37


• Replacement: This field replaces the type-of-service field from IPv4.

3. Flow Label

• Field Size: 20 bits.


• Purpose: Designed to provide special handling for specific flows of data.
• Details: More information will be discussed later regarding its usage.

4. Payload Length

• Field Size: 2 bytes.


• Purpose: Specifies the length of the IP datagram's payload, excluding the header.
• Note: In IPv6, the base header length is fixed at 40 bytes, so only the payload length
needs to be defined.

5. Next Header

• Field Size: 8 bits.


• Purpose: Indicates the type of the first extension header (if present) or the type of data
following the base header.
• Comparison: Similar to the protocol field in IPv4; more details will be covered when
discussing the payload.

6. Hop Limit

• Field Size: 8 bits.


• Purpose: Functions like the TTL (Time to Live) field in IPv4, limiting the number of
hops a packet can make.

7. Source and Destination Addresses

• Source Address: A 16-byte (128-bit) address identifying the original source of the
datagram.
• Destination Address: A 16-byte (128-bit) address identifying the intended recipient of
the datagram.

8. Payload

• Comparison to IPv4: The payload field in IPv6 has a different format and meaning
compared to IPv4, accommodating new types of data and extension headers.

Ravi Kumar S G Dept Of CSE, RNSIT 38


Payload Structure

• Definition: In IPv6, the payload consists of zero or more extension headers followed by
the data from higher-layer protocols (e.g., UDP, TCP).
• Extension Headers: Unlike IPv4, where options are part of the main header, IPv6 treats
options as separate extension headers.

Extension Headers

• Flexibility: The payload can contain multiple extension headers, allowing for
customization based on specific requirements.
• Mandatory Fields:
1. Next Header: Indicates the type of the next header (which can be another
extension header or the data payload).
2. Length: Specifies the length of the extension header in bytes.

Next Header Field

• Field Values: Each next header field value (code) defines the type of the next header:
o Types: This includes options like hop-by-hop options, source routing options, etc.
o Final Header: The last next header field in the chain specifies the protocol type
of the payload data (e.g., UDP, TCP).

Ravi Kumar S G Dept Of CSE, RNSIT 39


Concept of Flow and Priority in IPv6

The Internet Protocol (IP) was originally designed as a connectionless protocol, meaning each
packet operates independently, with no connection between sender and receiver. Over time, there
has been a trend toward using IP as a connection-oriented protocol to improve efficiency and
guarantee certain types of service. In IPv4, the MPLS (Multiprotocol Label Switching)
technology is used to simulate connection-oriented behavior by encapsulating packets with
labels. However, IPv6 integrates a flow label directly into its datagram format, allowing IPv6 to
achieve a similar effect natively.

Flow Label in IPv6

In IPv6, the flow label is a unique identifier for a sequence of packets, known as a flow, that
share common characteristics. For example, packets within the same flow typically travel the
same path, use the same resources, and may have similar security or processing requirements.
The flow label allows routers to efficiently manage packets with different requirements. Routers
that handle flow labels have a flow label table where each active flow label has a corresponding
entry.

1. Flow Label Table:


o The table contains entries with the specific services required by each flow.
o When a packet arrives, the router consults this table based on the packet’s flow
label. This bypasses the need for repeated routing calculations, as the flow label
table directly provides the necessary information, such as the next hop address.
2. Flow Label for Priority and Real-Time Data:
o Flow labels improve efficiency by allowing routers to quickly forward packets
based on pre-established flows.
o They are also crucial for real-time audio and video transmissions, which
require resources such as high bandwidth and large buffers to avoid delays.
With IPv6 flow labels, these resources can be reserved in advance to meet the
demands of real-time data.
3. Supporting Protocols:
o While the flow label identifies the flow, it does not contain all information needed
for the router’s flow label table entries. Instead, other protocols or options like
hop-by-hop options, RTP (Real-Time Transport Protocol), and RSVP
(Resource Reservation Protocol) are used to provide additional context and
enable resource reservations.

Ravi Kumar S G Dept Of CSE, RNSIT 40


Fragmentation and Reassembly

In IPv6, fragmentation and reassembly processes are handled differently than in IPv4, with a few
key distinctions aimed at optimizing network performance.

1. Source-Only Fragmentation:
o IPv6 fragmentation is handled solely by the source, not by intermediate
routers. This change reduces the processing load on routers, enhancing their
efficiency and speed.
o When a source needs to send a large packet, it is responsible for determining
whether fragmentation is necessary. If the packet exceeds the Maximum
Transmission Unit (MTU) of the path, the source fragments it before sending.
2. Router Processing:
o Routers do not fragment packets in IPv6. Fragmenting packets at a router
requires considerable processing, such as recalculating the values of
fragmentation-related fields. By removing this requirement, IPv6 reduces router
processing demands and allows packets to be processed more swiftly.
3. Reassembly at the Destination:
o Fragmented packets are reassembled only at the destination. This approach
reduces the complexity and workload on intermediate routers, which only forward
packets without performing reassembly.
4. MTU Checks and ICMPv6 Messages:
o Routers check the size of each packet against the MTU of the network they are
about to forward it to. If a packet is too large, the router drops the packet and
sends an ICMPv6 “packet-too-big” error message back to the source. This
informs the source that it must fragment the packet or reduce its size to fit the
MTU.

Extension Header

An IPv6 packet is made of a base header and some extension headers. The length of the
base header is fixed at 40 bytes. To give more functionality to the IP datagram, the base header
can be followed by up to six extension headers.

Many of these headers are options in IPv4. Six types of extension headers have been
defined. These are hop-by-hop option, source routing, fragmentation, authentication, encrypted
security payload, and destination option (see Figure 22.8).

Ravi Kumar S G Dept Of CSE, RNSIT 41


Hop-by-Hop Option

The hop-by-hop option is designed for scenarios where information needs to be processed by
every router along the datagram’s path. This is typically used for control functions, debugging,
and packet management. Some defined hop-by-hop options include:

• Pad1: A 1-byte option added for alignment purposes to ensure certain options start at
specific bits within a 32-bit word.
• PadN: Similar to Pad1 but used when more than 1 byte of padding is needed for
alignment.
• Jumbo Payload: Extends payload capacity beyond the typical IPv6 limit of 65,535 bytes,
enabling larger datagrams if necessary.

Destination Option

The destination option is used when information should be read only by the destination node.
Routers along the way do not access this information, keeping it private for the destination. This
option has the same format as the hop-by-hop option and currently includes:

• Pad1 and PadN: Similar to the hop-by-hop options, these padding bytes are used for
alignment in the destination option header.

Source Routing

The source routing extension header allows the sender to specify specific intermediate nodes
or addresses that the packet must visit before reaching its destination. This combines the
functionalities of IPv4's strict and loose source routing options, enabling flexible routing paths
for specific applications.

Ravi Kumar S G Dept Of CSE, RNSIT 42


Fragmentation

IPv6 fragmentation functions similarly to IPv4 but with key differences in where fragmentation
occurs:

• Only the original source is allowed to fragment IPv6 packets, which reduces the load on
routers.
• The source uses Path MTU Discovery to determine the smallest MTU on the packet’s
path and fragments the packet accordingly.
• If Path MTU Discovery is not available or used, the source fragments the packet to a size
of 1280 bytes or smaller, as this is the minimum MTU for networks connected to the
Internet.

Authentication

The authentication extension header ensures that a packet originates from a genuine sender
and maintains data integrity. This prevents impersonation and verifies that data has not been
altered en route, securing the communication between sender and receiver.

Encrypted Security Payload (ESP)

The ESP extension header provides confidentiality for data in transit by encrypting the payload,
protecting it from eavesdropping. This extension helps ensure secure transmission over
potentially untrusted networks. Each of these headers allows IPv6 to be flexible, secure, and
suitable for a wide variety of applications while keeping the base header lightweight.

Comparison of IPv4 Options and IPv6 Extension Headers

IPv6 introduces a new approach to handling packet options by using extension headers instead
of embedding options within the main header as in IPv4. Here’s a comparison of specific options
between IPv4 and IPv6:

1. Padding Options:
o IPv4: Utilizes no-operation and end-of-option fields for alignment.
o IPv6: Replaces these with Pad1 (1 byte) and PadN (for 2+ bytes) to manage
alignment within extension headers.
2. Record Route Option:
o IPv4: Includes a record route option, but it was seldom used.
o IPv6: This option is removed due to limited use.
3. Timestamp Option:
o IPv4: Includes a timestamp option for tracking packet times along the route, but
it was also rarely used.
Ravi Kumar S G Dept Of CSE, RNSIT 43
o IPv6: This option is not implemented.
4. Source Route Option:
o IPv4: Has a source route option, allowing the sender to specify the route.
o IPv6: Implements this as the source route extension header, allowing more
flexible source-routing control.
5. Fragmentation:
o IPv4: Handles fragmentation within the base header, allowing both the source and
routers to fragment packets.
o IPv6: Moves fragmentation control to the fragmentation extension header,
where only the original source handles fragmentation.
6. Authentication:
o IPv4: Lacks built-in support for authentication.
o IPv6: Adds a new authentication extension header to validate the sender’s
identity and ensure data integrity.
7. Encrypted Security Payload (ESP):
o IPv4: Has no built-in option for encryption.
o IPv6: Introduces the ESP extension header for encrypting data, enhancing
confidentiality and protecting against eavesdropping.

IPv6's extension headers streamline packet processing, enhance security, and add flexibility,
while removing outdated or rarely-used options from IPv4. This modular approach makes IPv6
better suited to handle diverse network demands.

Ravi Kumar S G Dept Of CSE, RNSIT 44


MODULE -4

TRANSPORT LAYER

1. INTRODUCTION
1.1 Transport-Layer Services
1.2 Connectionless and Connection-Oriented Protocols
2. TRANSPORT-LAYER PROTOCOLS
2.1 Simple Protocol
2.2 Stop-and-Wait Protocol
2.3 Go-Back-N Protocol (GBN)
2.4 Selective-Repeat Protocol
2.5 Bidirectional Protocols: Piggybacking
3. INTRODUCTION
3.1 Services
3.2 Port Numbers
4. USER DATAGRAM PROTOCOL
4.1 User Datagram
4.2 UDP Services
4.3 UDP Applications
5. TRANSMISSION CONTROL PROTOCOL
5.1 TCP Services
5.2 TCP Features
5.3 Segment
5.4 TCP Connection
5.5 Windows in TCP
5.6 Flow Control
5.7 Error Control
5.8 TCP Congestion Control

Chethana H R, Asst. Prof., RNSIT Dept. of CSE Page 1


1. INTRODUCTION
The transport layer is an essential part of the network architecture, located between the application
layer and the network layer. Its primary function is to facilitate process-to-process communication
between application layers on two different hosts—one local and one remote. This communication is
achieved using a logical connection, meaning that even though the application layers may be on
opposite sides of the world, they interact as if they are directly connected.

Logical Connection
A logical connection at the transport layer is an abstract concept that represents a direct
communication link between two application layers. In reality, the data travels through multiple
intermediate devices like routers and switches, but the transport layer manages the connection in such
a way that the two communicating applications are unaware of the underlying complexity.
For example, consider a scenario where Alice's computer at Sky Research communicates with Bob's
computer at Scientific Books. Even though the data passes through various intermediate devices and
networks, the transport layer makes it appear as though there is a direct link between Alice and Bob's
applications.

Figure 4.1: Logical connection at the transport layer


1.1 Transport-Layer Services
The transport layer is positioned between the network layer and the application layer in the OSI
model. Its primary role is to provide communication services to the application layer while receiving
services from the network layer. The transport layer ensures that data is transferred between processes
running on different hosts in a reliable and efficient manner.
▪ Process-to-Process Communication

Chethana H R, Asst. Prof., RNSIT Dept. of CSE Page 2


▪ Addressing: Port Numbers
▪ Encapsulation and Decapsulation
▪ Multiplexing and Demultiplexing
▪ Flow Control
▪ Error Control
▪ Combination of Flow and Error Control
▪ Congestion Control

1. Process-to-Process Communication
The transport layer's fundamental responsibility is to facilitate process-to-process communication. A
process refers to an application-layer program that utilizes the services provided by the transport
layer. This communication is distinguished from host-to-host communication, which is handled by
the network layer. The network layer ensures that data reaches the correct host, but the transport layer
is responsible for delivering the data to the appropriate process within that host.

2. Addressing: Port Numbers


To achieve process-to-process communication, the transport layer uses port numbers. Each process
is identified by a port number, allowing multiple processes to run on the same host simultaneously.
In a typical client-server model, the client is assigned an ephemeral (temporary) port number, while
the server uses a well-known port number.

• Well-known Ports: These range from 0 to 1023 and are assigned by ICANN for standard
services.
• Registered Ports: These range from 1024 to 49,151 and can be registered with ICANN to
prevent duplication.
• Dynamic or Private Ports: These range from 49,152 to 65,535 and are used temporarily by
client processes.

3. Socket Addresses
A socket address is a combination of an IP address and a port number, uniquely identifying a process
on a networked host. For communication to occur, the transport layer requires the socket addresses
of both the client and the server. This allows data to be directed to the correct process on the correct
host.

Chethana H R, Asst. Prof., RNSIT Dept. of CSE Page 3


4. Encapsulation and Decapsulation

• Encapsulation: At the sender's end, the transport layer encapsulates the message with a
transport-layer header, creating a packet (user datagram, segment, or packet depending on
the protocol).
• Decapsulation: At the receiver's end, the transport layer removes the header and delivers
the message to the appropriate process.

5. Multiplexing and Demultiplexing
• Multiplexing: The transport layer at the sender's side combines data from multiple processes
into a single stream for transmission over the network.
• Demultiplexing: At the receiver's side, the transport layer separates the combined data stream
back into individual messages and delivers them to the correct processes.
6. Flow Control
Flow control ensures that the rate of data transmission is balanced between the sender and receiver to
prevent overwhelming the receiver. Flow control mechanisms can be implemented using buffers at
both the sender and receiver's transport layers. The transport layer at the sender's side manages the
data flow based on feedback from the receiver's transport layer.
• Pushing vs. Pulling: Flow control can be push-based (data is sent as it is produced) or
pull-based (data is sent upon request).

7. Error Control
Error control at the transport layer ensures data integrity and reliability, particularly in environments
where the underlying network layer (IP) is unreliable. The transport layer handles:
• Detection and discarding of corrupted packets.
• Resending lost or discarded packets.
• Identifying and discarding duplicate packets.
• Buffering out-of-order packets until the correct sequence is restored.

Chethana H R, Asst. Prof., RNSIT Dept. of CSE Page 4


Sequence Numbers and Acknowledgments: Sequence numbers in the transport-layer packets help
manage these tasks. The sender assigns a sequence number to each packet, and the receiver uses
acknowledgments (ACKs) to confirm receipt or request retransmission of missing packets.
8. Sliding Window
The sliding window mechanism is used in flow control and error control to manage the transmission
of packets. The window represents a range of sequence numbers for packets that can be sent or have
been sent but not yet acknowledged. When an acknowledgment is received, the window "slides,"
allowing new packets to be sent.
9. Congestion Control
Congestion occurs when the network's load exceeds its capacity, leading to packet delays and losses.
Congestion control mechanisms aim to regulate traffic to prevent congestion, ensuring that the
network operates efficiently. The transport layer, particularly in protocols like TCP, incorporates
congestion control techniques to manage traffic based on network conditions.

1.2 Connectionless and Connection-Oriented Protocols


A transport-layer protocol, like a network-layer protocol, can provide two types of services:
connectionless and connection-oriented.
Connectionless Service In a connectionless service, the source process (application program) needs
to divide its message into chunks of data of the size acceptable by the transport layer and deliver them
to the transport layer one by one. The transport layer treats each chunk as a single unit without any
relation between the chunks. When a chunk arrives from the application layer, the transport layer
encapsulates it in a packet and sends it.

Connection-Oriented Service In a connection-oriented service, the client and the server first need to
establish a logical connection between themselves. The data exchange can only happen after the
connection establishment. After data exchange, the connection needs to be torn down

Chethana H R, Asst. Prof., RNSIT Dept. of CSE Page 5


Finite State Machine
➢ The behavior of a transport-layer protocol, both when it provides a connectionless and when
it provides a connection-oriented protocol, can be better shown as a finite state machine
(FSM).
➢ The machine is always in one of the states until an event occurs.
➢ A horizontal line is used to separate the event from the actions, although later we replace the
horizontal line with a slash. The arrow shows the movement to the next state. The machine is
in the closed state when there is no connection.

Chethana H R, Asst. Prof., RNSIT Dept. of CSE Page 6


2. TRANSPORT-LAYER PROTOCOLS
The TCP/IP protocol uses a transport-layer protocol that is either a modification or a combination of
some of these protocols.

2.1 Simple Protocol


It is a simple connectionless protocol with neither flow nor error control. We assume that the receiver
can immediately handle any packet it receives. In other words, the receiver can never be overwhelmed
with incoming packets.

➢ The transport layer at the sender gets a message from its application layer, makes a packet out
of it, and sends the packet.
➢ The transport layer at the receiver receives a packet from its network layer, extracts the message
from the packet, and delivers the message to its application layer.
➢ The transport layers of the sender and receiver provide transmission services for their
application layers.
FSMs
➢ The sender site should not send a packet until its application layer has a message to send.
➢ The receiver site cannot deliver a message to its application layer until a packet arrives.
We can show these requirements using two FSMs. Each FSM has only one state, the ready state.
➢ The sending machine remains in the ready state until a request comes from the process in the
application layer. When this event occurs, the sending machine encapsulates the message in a
packet and sends it to the receiving machine.
➢ The receiving machine remains in the ready state until a packet arrives from the sending
machine. When this event occurs, the receiving machine decapsulates the message out of the
packet and delivers it to the process at the application layer.
Figure 23.18 shows the FSMs for the simple protocol.

Chethana H R, Asst. Prof., RNSIT Dept. of CSE Page 7


Figure 23.19 shows an example of communication using this protocol. It is very simple. The sender
sends packets one after another without even thinking about the receiver.

2.2 Stop-and-Wait Protocol


This protocol uses both flow and error control. Both the sender and the receiver use a sliding window
of size 1.
➢ The sender sends one packet at a time and waits for an acknowledgment before sending the
next one. To detect corrupted packets, we need to add a checksum to each data packet.
➢ When a packet arrives at the receiver site, it is checked. If its checksum is incorrect, the packet
is corrupted and silently discarded.
➢ The silence of the receiver is a signal for the sender that a packet was either corrupted or lost.
Every time the sender sends a packet, it starts a timer. If an acknowledgment arrives before
the timer expires, the timer is stopped and the sender sends the next packet (if it has one to
send).
➢ If the timer expires, the sender resends the previous packet, assuming that the packet was
either lost or corrupted. This means that the sender needs to keep a copy of the packet until
its acknowledgment arrives.
➢ Figure 23.20 shows the outline for the Stop-and-Wait protocol. Note that only one packet and
one acknowledgment can be in the channels at any time.

The Stop-and-Wait protocol is a connection-oriented protocol that provides flow and error control.
Sequence Numbers

Chethana H R, Asst. Prof., RNSIT Dept. of CSE Page 8


A field is added to the packet header to hold the sequence number of that packet to prevent the
duplicate of packet. Since we want to minimize the packet size, we look for the smallest range that
provides unambiguous communication.
Let us discuss the range of sequence numbers we need. Assume we have used x as a sequence
number; we only need to use x + 1 after that. There is no need for x + 2.
To show this, assume that the sender has sent the packet with sequence number x. Three things can
happen.
1. The packet arrives safe and sound at the receiver site; the receiver sends an acknowledgment.
The acknowledgment arrives at the sender site, causing the sender to send the next packet
numbered x + 1.
2. The packet is corrupted or never arrives at the receiver site; the sender resends the packet
(numbered x) after the time-out. The receiver returns an acknowledgment.
3. The packet arrives safe and sound at the receiver site; the receiver sends an ack, but the ack
is corrupted or lost. The sender resends the packet (numbered x) after the time-out. Note that
the packet here is a duplicate. The receiver can recognize this fact because it expects packet
x + 1 but packet x was received.

Acknowledgment Numbers
❖ Since the sequence numbers must be suitable for both data packets and ack packet
❖ The ack numbers always announce the sequence number of the next packet expected by the
receiver.
✓ For example, if packet 0 has arrived safe and sound, the receiver sends an ACK with
acknowledgment 1 (meaning packet 1 is expected next).
✓ If packet 1 has arrived safe and sound, the receiver sends an ACK with acknowledgment 0
(meaning packet 0 is expected).

FSMs
The Stop-and-Wait protocol is a connection-oriented protocol; both ends should be in the established
state before exchanging data packets.

Sender
The sender is initially in the ready state, but it can move between the ready and blocking state. The
variable S is initialized to 0.
❑Ready state. When the sender is in this state, it is only waiting for one event to occur. If a request
comes from the application layer, the sender creates a packet with the sequence number set to S. A
copy of the packet is stored, and the packet is sent. The sender then starts the only timer. The sender
then moves to the blocking state.
❑Blocking state. When the sender is in this state, three events can occur:
a. If an error-free ACK arrives with the ackNo related to the next packet to be sent, which means
ackNo = (S + 1) modulo 2, then the timer is stopped. The window slides, S = (S + 1) modulo
2. Finally, the sender moves to the ready state.

Chethana H R, Asst. Prof., RNSIT Dept. of CSE Page 9


b. If a corrupted ACK or an error-free ACK with the ackNo ≠ (S + 1) modulo 2 arrives, the ACK
is discarded.
c. If a time-out occurs, the sender resends the only outstanding packet and restarts the timer.

Receiver
The receiver is always in the ready state. Three events may occur:
a. If an error-free packet with seqNo = R arrives, the message in the packet is delivered to the
application layer. The window then slides, R = (R + 1) modulo 2. Finally an ACK with ackNo =
R is sent.
b. If an error-free packet with seqNo ≠ R arrives, the packet is discarded, but an ACK with ackNo
= R is sent.
c. If a corrupted packet arrives, the packet is discarded.
Efficiency
This protocol is very inefficient if our channel is thick and long. By thick, we mean that our channel
has a large bandwidth (high data rate); by long, we mean the round-trip delay is long. The product of
these two is called the bandwidthdelay product.

2.3 Go-Back-N Protocol (GBN)


To improve the efficiency of transmission (to fill the pipe), multiple packets must be in transition
while the sender is waiting for acknowledgment.
The key to Go-back-N is to send several packets before receiving ack, but the receiver can only buffer
one packet. We keep a copy of the sent packets until the ack arrive. Note that several data packets
and ack can be in the channel at the same time

Chethana H R, Asst. Prof., RNSIT Dept. of CSE Page 10


Sequence Numbers
The sequence numbers are modulo 2m, where m is the size of the sequence number field in bits.
Acknowledgment Numbers
An acknowledgment number is cumulative and defines the sequence number of the next packet
expected.

Send Window
The send window is an imaginary box covering the sequence numbers of the data packets that can be
in transit or can be sent. In each window position, some of these sequence numbers define the packets
that have been sent; others define those that can be sent. The maximum size of the window is 2m − 1.
Figure 23.24 shows a sliding window of size 7 (m = 3) for the Go-Back-N protocol

The send window time divides the possible sequence numbers into four regions.
1. The first region, left of the window, defines the sequence numbers belonging to packets that are
already acknowledged.
2. The second region, colored, defines the range of sequence numbers belonging to the packets that
have been sent, but have an unknown status. The sender needs to wait to find out if these packets
have been received or were lost. We call these outstanding packets.
3. The third range, white in the figure, defines the range of sequence numbers for packets that can
be sent; however, the corresponding data have not yet been received from the application layer.
4. Finally, the fourth region, right of the window, defines sequence numbers that cannot be used
until the window slides.

Chethana H R, Asst. Prof., RNSIT Dept. of CSE Page 11


The window is an abstraction of three variables defines its size and location at any time.
We call these variables Sf (send window, the first outstanding packet), Sn (send window, the next
packet to be sent), and Ssize (send window, size).

Receive Window
It ensures the correct data packets are received and that the correct acknowledgments are sent. In Go-
Back-N, the size of the receive window is always 1. The receiver is always looking for the arrival of
a specific packet. Any packet arriving out of order is discarded and needs to be resent. Note that we
need only one variable, Rn (receive window, next packet expected), to define this abstraction.

Timers
Although there can be a timer for each packet that is sent, in our protocol we use only one. The reason
is that the timer for the first outstanding packet always expires first. We resend all outstanding packets
when this timer expires.

Resending packets
When the timer expires, the sender resends all outstanding packets.

FSMs
Sender
The sender starts in the ready state, but thereafter it can be in one of the two states: ready or blocking.
The two variables are normally initialized to 0 (Sf = Sn = 0).
❑Ready state. Four events may occur when the sender is in ready state.
a. If a request comes from the application layer, the sender creates a packet with the sequence number
set to Sn. A copy of the packet is stored, and the packet is sent. The sender also starts the only timer
if it is not running. The value of Sn is now incremented, (Sn = Sn + 1) modulo 2m. If the window is
full, Sn = (Sf + Ssize) modulo 2m, the sender goes to the blocking state.
b. If an error-free ACK arrives with ackNo related to one of the outstanding packets, the sender slides
the window (set Sf = ackNo), and if all outstanding packets are acknowledged (ackNo = Sn), then the
timer is stopped. If all outstanding packets are not acknowledged, the timer is restarted.

Chethana H R, Asst. Prof., RNSIT Dept. of CSE Page 12


c. If a corrupted ACK or an error-free ACK with ackNo not related to the outstanding packet arrives,
it is discarded.
d. If a time-out occurs, the sender resends all outstanding packets and restarts the timer.

❑Blocking state. Three events may occur in this case:


a. If an error-free ACK arrives with ackNo related to one of the outstanding packets, the sender
slides the window (set Sf = ackNo) and if all outstanding packets are acknowledged (ackNo =
Sn), then the timer is stopped. If all outstanding packets are not acknowledged, the timer is
restarted. The sender then moves to the ready state.
b. If a corrupted ACK or an error-free ACK with the ackNo not related to the outstanding packets
arrives, the ACK is discarded.
c. If a time-out occurs, the sender sends all outstanding packets and restarts the timer.

Receiver

The receiver is always in the ready state. The only variable, Rn, is initialized to 0. Three events may
occur:

a. If an error-free packet with seqNo = Rn arrives, the message in the packet is delivered to the
application layer. The window then slides, Rn = (Rn + 1) modulo 2m. Finally an ACK is sent
with ackNo = Rn.
b. If an error-free packet with seqNo outside the window arrives, the packet is discarded, but an
ACK with ackNo = Rn is sent.
Chethana H R, Asst. Prof., RNSIT Dept. of CSE Page 13
c. If a corrupted packet arrives, it is discarded.

2.4 Selective-Repeat Protocol


The Selective-Repeat (SR) protocol, has been devised, which, as the name implies, resends only
selective packets, those that are actually lost.

Windows
The Selective-Repeat protocol also uses two windows: a send window and a receive window
➢ The send window maximum size can be 2m−1. For example, if m = 4, the sequence numbers
go from 0 to 15, but the maximum size of the window is just 8 (it is 15 in the Go-Back-N
Protocol).
➢ The size of the receive window is the same as the size of the send window (maximum 2m−1).
➢ The SR protocol allows as many packets as the size of the receive window to arrive out of order
and be kept until there is a set of consecutive packets to be delivered to the application layer.
Because the sizes of the send window and receive window are the same, all the packets in the
send packet can arrive out of order and be stored until they can be delivered

Chethana H R, Asst. Prof., RNSIT Dept. of CSE Page 14


Timer
Theoretically, Selective-Repeat uses one timer for each outstanding packet. When a timer expires,
only the corresponding packet is resent.
Acknowledgments
In SR, an ackNo defines the sequence number of a single packet that is received safe and sound; there
is no feedback for any other.

FSMs
Sender
The sender starts in the ready state, but later it can be in one of the two states: ready or blocking. The
following shows the events and the corresponding actions in each state.
❑Ready state. Four events may occur in this case:
a. If a request comes from the application layer, the sender creates a packet with the sequence
number set to Sn. A copy of the packet is stored, and the packet is sent. If the timer is not
running, the sender starts the timer. The value of Sn is now incremented, Sn = (Sn + 1) modulo
2m. If the window is full, Sn = (Sf + Ssize) modulo 2m, the sender goes to the blocking state.
b. b. If an error-free ACK arrives with ackNo related to one of the outstanding packets, that packet
is marked as acknowledged. If the ackNo = Sf , the window slides to the right until the Sf points
to the first unacknowledged packet (all consecutive acknowledged packets are now outside the
window). If there are outstanding packets, the timer is restarted; otherwise, the timer is stopped.
c. If a corrupted ACK or an error-free ACK with ackNo not related to an outstanding packet
arrives, it is discarded. d. If a time-out occurs, the sender resends all unacknowledged packets
in the window and restarts the timer.
❑Blocking state. Three events may occur in this case:
a. If an error-free ACK arrives with ackNo related to one of the outstanding packets, that packet
is marked as acknowledged. In addition, if the ackNo = Sf , the window is slid to the right until
the Sf points to the first unacknowledged packet (all consecutive acknowledged packets are
now outside the window). If the window has slid, the sender moves to the ready state.
b. If a corrupted ACK or an error-free ACK with the ackNo not related to outstanding packets
arrives, the ACK is discarded.
c. If a time-out occurs, the sender resends all unacknowledged packets in the window and restarts
the timer.

Receiver
The receiver is always in the ready state. Three events may occur:

a. If an error-free packet with seqNo in the window arrives, the packet is stored and an ACK with
ackNo = seqNo is sent. In addition, if the seqNo = Rn, then the packet and all previously arrived
Chethana H R, Asst. Prof., RNSIT Dept. of CSE Page 15
consecutive packets are delivered to the application layer and the window slides so that the Rn
points to the first empty slot.
b. If an error-free packet with seqNo outside the window arrives, the packet is discarded, but an
ACK with ackNo = Rn is returned to the sender. This is needed to let the sender slide its window
if some ACKs related to packets with seqNo < Rn were lost.
c. If a corrupted packet arrives, the packet is discarded.

2.5 Bidirectional Protocols: Piggybacking


A technique called piggybacking is used to improve the efficiency of the bidirectional protocols.
When a packet is carrying data from A to B, it can also carry acknowledgment feedback about arrived
packets from B; when a packet is carrying data from B to A, it can also carry acknowledgment
feedback about the arrived packets from A.

Chethana H R, Asst. Prof., RNSIT Dept. of CSE Page 16


3.1 Services

➢ UDP: UDP is an unreliable connectionless transport-layer protocol used for its simplicity and
efficiency in applications where error control can be provided by the application-layer
process.
➢ TCP: TCP is a reliable connection-oriented protocol that can be used in any application
where reliability is important.
➢ SCTP: SCTP is a new transport-layer protocol that combines the features of UDP and TCP.

3.2 Port Numbers

Port numbers provide end-to-end addresses at the transport layer and allow multiplexing and
demultiplexing at this layer, just as IP addresses do at the network layer.

4. USER DATAGRAM PROTOCOL


➢ The User Datagram Protocol (UDP) is a connectionless, unreliable transport protocol.
➢ UDP is a very simple protocol using a minimum of overhead. If a process wants to send a
small message and does not care much about reliability, it can use UDP.

4.1 User Datagram


➢ UDP packets, called user datagram’s, have a fixed-size header of 8 bytes made of four fields,
each of 2 bytes (16 bits).

Chethana H R, Asst. Prof., RNSIT Dept. of CSE Page 17


➢ The first two fields define the source and destination port numbers.
➢ The third field defines the total length of the user datagram, header plus data. The 16 bits can
define a total length of 0 to 65,535 bytes.
➢ However, the total length needs to be less because a UDP user datagram is stored in an IP
datagram with the total length of 65,535 bytes. The last field can carry the optional checksum
(explained later).

4.2 UDP Services


1. Process-to-Process Communication: UDP provides process-to-process communication using
socket addresses, a combination of IP addresses and port numbers
2. Connectionless Services: As mentioned previously, UDP provides a connectionless service.
This means that each user datagram sent by UDP is an independent datagram. There is no
relationship between the different user datagram’s even if they are coming from the same source
process and going to the same destination program.
3. Flow Control: There is no flow control, and hence no window mechanism. The receiver may
overflow with incoming messages. The lack of flow control means that the process using UDP
should provide for this service, if needed.
4. Checksum: UDP checksum calculation includes three sections: a pseudoheader, the UDP
header, and the data coming from the application layer. The pseudoheader is the part of the
header of the IP packet in which the user datagram is to be encapsulated with some fields filled
with 0s .
5. Congestion Control: Since UDP is a connectionless protocol, it does not provide congestion
control. UDP assumes that the packets sent are small and sporadic and cannot create congestion
in the network.
6. Encapsulation and Decapsulation: To send a message from one process to another, the UDP
protocol encapsulates and decapsulates messages.
7. Queuing: In UDP, queues are associated with ports. At the client site, when a process starts, it
requests a port number from the operating system. Some implementations create both an
incoming and an outgoing queue associated with each process.
8. Multiplexing and Demultiplexing: In a host running a TCP/IP protocol suite, there is only one
UDP but possibly several processes that may want to use the services of UDP. To handle this
situation, UDP multiplexes and demultiplex

Chethana H R, Asst. Prof., RNSIT Dept. of CSE Page 18


4.3 UDP Applications
The following shows some typical applications that can benefit more from the services of UDP than
from those of TCP.
❑ UDP is suitable for a process that requires simple request-response communication with little
concern for flow and error control. It is not usually used for a process such as FTP that needs to
send bulk data
❑ UDP is suitable for a process with internal flow- and error-control mechanisms. For example,
the Trivial File Transfer Protocol (TFTP) process includes flow and error control. It can easily use
UDP.
❑ UDP is a suitable transport protocol for multicasting. Multicasting capability is embedded in the
UDP software but not in the TCP software.
❑ UDP is used for management processes such as SNMP
❑ UDP is used for some route updating protocols such as Routing Information Protocol (RIP)
❑ UDP is normally used for interactive real-time applications that cannot tolerate uneven delay
between sections of a received message
▪ Finer application-level control over what data is sent, and when.
▪ No connection establishment
▪ No connection state
▪ Small packet header overhead: The TCP segment has 20 bytes of header overhead in every
segment, whereas UDP has only 8 bytes of

5. TRANSMISSION CONTROL PROTOCOL

➢ Transmission Control Protocol (TCP) is a connection-oriented, reliable protocol.


➢ TCP explicitly defines connection establishment, data transfer, and connection teardown
phases to provide a connection-oriented service.
➢ To achieve reliability in TCP uses checksum (for error detection), retransmission of lost or
corrupted packets, cumulative and selective acknowledgments, and timer

5.1 TCP Services

1. Process-to-Process Communication: TCP provides process-to-process communication using port


numbers.
2. Stream Delivery Service: TCP allows the sending process to deliver data as a stream of bytes and
allows the receiving process to obtain data as a stream of bytes.

Chethana H R, Asst. Prof., RNSIT Dept. of CSE Page 19


Sending and Receiving Buffers: Because the sending and the receiving processes may not
necessarily write or read data at the same rate, TCP needs buffers for storage. There are two buffers,
the sending buffer and the receiving buffer, one for each direction.

Segments: Although buffering handles the disparity between the speed of the producing and
consuming processes, we need one more step before we can send data. The network layer, as a service
provider for TCP, needs to send data in packets, not as a stream of bytes. At the transport layer, TCP
groups a number of bytes together into a packet called a segment.

3. Full-Duplex Communication: TCP offers full-duplex service, where data can flow in both
directions at the same time. Each TCP endpoint then has its own sending and receiving buffer, and
segments move in both directions.
4. Multiplexing and Demultiplexing: TCP performs multiplexing at the sender and demultiplexing
at the receiver. However, since TCP is a connection-oriented protocol, a connection needs to be
established for each pair of processes.
5. Connection-Oriented Service TCP, unlike UDP, is a connection-oriented protocol. When a
process at site A wants to send to and receive data from another process at site B, the following three
phases occur:
➢ The two TCP’s establish a logical connection between them.
➢ Data are exchanged in both directions.
➢ The connection is terminated.
6. Reliable Service TCP is a reliable transport protocol. It uses an acknowledgment mechanism to
check the safe and sound arrival of data. We will discuss this feature further in the section on error
control.

5.2 TCP Features

Chethana H R, Asst. Prof., RNSIT Dept. of CSE Page 20


Numbering System
There are two fields, the sequence number and the acknowledgment number. These two fields refer
to a byte number and not a segment number.
Byte Number: TCP numbers all data bytes (octets) that are transmitted in a connection. Numbering
is independent in each direction. When TCP receives bytes of data from a process, TCP stores them
in the sending buffer and numbers them. The numbering does not necessarily start from 0. Instead,
TCP chooses an arbitrary number between 0 and 232 − 1 for the number of the first byte.
Sequence Number:After the bytes have been numbered, TCP assigns a sequence number to each
segment that is being sent. The sequence number, in each direction, is defined as follows:
❖ The sequence number of the first segment is the ISN (initial sequence number), which is a
random number.
❖ The sequence number of any other segment is the sequence number of the previous segment
plus the number of bytes (real or imaginary) carried by the previous segment.
Acknowledgment Number: the acknowledgment number is cumulative, which means that the party
takes the number of the last byte that it has received, safe and sound, adds 1 to it, and announces this
sum as the acknowledgment number.
5.3 Segment
A packet in TCP is called a segment. The segment consists of a header of 20 to 60 bytes, followed
by data from the application program. The header is 20 bytes if there are no options and up to 60
bytes if it contains options.

❑Source port address: 16-bit field that defines the port number of the application program in the
host that is sending the segment.
❑Destination port address: 16-bit field that defines the port number of the application program in
the host that is receiving the segment.

Chethana H R, Asst. Prof., RNSIT Dept. of CSE Page 21


❑Sequence number: This 32-bit field defines the number assigned to the first byte of data contained
in this segment. To ensure connectivity, each byte to be transmitted is numbered. The sequence
number tells the destination which byte in this sequence is the first byte in the segment.
❑Acknowledgment number: This 32-bit field defines the byte number that the receiver of the
segment is expecting to receive from the other party. If the receiver of the segment has successfully
received byte number x from the other party, it returns x + 1 as the acknowledgment number.
Acknowledgment and data can be piggybacked together.
❑Header length: This 4-bit field indicates the number of 4-byte words in the TCP header. The
length of the header can be between 20 and 60 bytes. Therefore, the value of this field is always
between 5 (5 × 4 = 20) and 15 (15 × 4 = 60).
❑Control:This field defines 6 different control bits or flags, as shown in Figure 24.8. One or more
of these bits can be set at a time. These bits enable flow control, connection establishment and
termination, connection abortion, and the mode of data transfer in TCP.

❑Window size: This field defines the window size of the sending TCP in bytes. Note that the length
of this field is 16 bits, which means that the maximum size of the window is 65,535 bytes.
❑Checksum: This 16-bit field contains the checksum. The calculation of the checksum for TCP
follows the same procedure as the one described for UDP. However, the use of the checksum in the
UDP datagram is optional, whereas the use of the checksum for TCP is mandatory.
❑Urgent pointer: This 16-bit field, which is valid, only if the urgent flag is set, is used when the
segment contains urgent data. It defines a value that must be added to the sequence number to obtain
the number of the last urgent byte in the data section of the segment.
❑Options: There can be up to 40 bytes of optional information in the TCP header.

5.4 TCP Connection


In TCP, connection-oriented transmission requires three phases: connection establishment, data
transfer, and connection termination.
Phase1: Connection Establishment
Three-Way Handshaking
➢ The connection establishment in TCP is called three-way handshaking. In our example, an
application program, called the client, wants to make a connection with another application
program, called the server, using TCP as the transport-layer protocol.
➢ The process starts with the server. The server program tells its TCP that it is ready to accept
a connection. This request is called a passive open. Although the server TCP is ready to accept
a connection from any machine in the world, it cannot make the connection itself.

Chethana H R, Asst. Prof., RNSIT Dept. of CSE Page 22


➢ The client program issues a request for an active open. A client that wishes to connect to an
open server tells its TCP to connect to a particular server. TCP can now start the three-way
handshaking process, as shown in Figure

The three steps in this phase are as follows.


1. The client sends the first segment, a SYN segment, in which only the SYN flag is set. This
segment is for synchronization of sequence numbers. The client in our example chooses a
random number as the first sequence number and sends this number to the server. This
sequence number is called the initial sequence number (ISN).
2. The server sends the second segment, a SYN + ACK segment with two flag bits set as: SYN
and ACK. This segment has a dual purpose. First, it is a SYN segment for communication in
the other direction. The server uses this segment to initialize a sequence number for numbering
the bytes sent from the server to the client. The server also acknowledges the receipt of the
SYN segment from the client by setting the ACK flag and displaying the next sequence
number it expects to receive from the client.
3. The client sends the third segment. This is just an ACK segment. It acknowledges the receipt
of the second segment with the ACK flag and acknowledgment number field.

SYN Flooding Attack The connection establishment procedure in TCP is susceptible to a serious
security problem called SYN flooding attack. This happens when one or more malicious attackers
send a large number of SYN segments to a server pretending that each of them is coming from a
different client by faking the source IP addresses in the datagram’s.

Phase2: Data Transfer


The client and server can send data and acknowledgments in both directions.
Pushing Data We saw that the sending TCP uses a buffer to store the stream of data coming from
the sending application program. The sending TCP can select the segment size. The receiving TCP
also buffers the data when they arrive and delivers them to the application program when the
application program is ready or when it is convenient for the receiving TCP.

Chethana H R, Asst. Prof., RNSIT Dept. of CSE Page 23


Urgent Data: CP urgent mode is a service by which the application program at the sender side marks
some portion of the byte stream as needing special treatment by the application program at the
receiver side.
Phase3: Connection Termination
Either of the two parties involved in exchanging data (client or server) can close the connection,
although it is usually initiated by the client.

1. 1. The client TCP, after receiving a close command from the client process, sends the first
segment, a FIN segment in which the FIN flag is set.
2. The server TCP, after receiving the FIN segment, informs its process of the situation and sends
the second segment, a FIN + ACK segment, to confirm the receipt of the FIN segment from the
client and at the same time to announce the closing of the connection in the other direction.
3. The client TCP sends the last segment, an ACK segment, to confirm the receipt of the FIN
segment from the TCP server. This segment contains the acknowledgment number, which is
one plus the sequence number received in the FIN segment from the server.

Chethana H R, Asst. Prof., RNSIT Dept. of CSE Page 24


5.5 Windows in TCP

TCP uses two windows (send window and receive window) for each direction of data transfer, which
means four windows for a bidirectional communication.
Send Window
Figure 24.17 shows an example of a send window. The window size is 100 bytes, but later we see
that the send window size is dictated by the receiver (flow control) and the congestion in the
underlying network (congestion control). The figure shows how a send window opens, closes, or
shrinks.

The send window in TCP is similar to the one used with the Selective-Repeat protocol, but with some
differences:
1. One difference is the nature of entities related to the window. The window size in SR is the
number of packets, but the window size in TCP is the number of bytes. Although actual
transmission in TCP occurs segment by segment, the variables that control the window are
expressed in bytes.
2. The second difference is that, in some implementations, TCP can store data received from the
process and send them later, but we assume that the sending TCP is capable of sending segments
of data as soon as it receives them from its process.
3. Another difference is the number of timers. The theoretical Selective-Repeat protocol may use
several timers for each packet sent, but as mentioned before, the TCP protocol uses only one
timer.

Receive Window

Figure 24.18 shows an example of a receive window. The window size is 100 bytes. The figure also
shows how the receive window opens and closes; in practice, the window should never shrink.

Chethana H R, Asst. Prof., RNSIT Dept. of CSE Page 25


There are two differences between the receive window in TCP and the one we used for SR.
1. The first difference is that TCP allows the receiving process to pull data at its own pace.
2. The second difference is the way acknowledgments are used in the TCP protocol.

5.6 Flow Control

Flow control balances the rate a producer creates data with the rate a consumer can use the data.
TCP separates flow control from error control.
Figure 24.19 shows unidirectional data transfer between a sender and a receiver; bidirectional data
transfer can be deduced from the unidirectional process.

➢ The figure shows that data travel from the sending process down to the sending TCP, from the
sending TCP to the receiving TCP, and from the receiving TCP up to the receiving process (paths
1, 2, and 3).
➢ Flow control feedbacks, however, are traveling from the receiving TCP to the sending TCP and
from the sending TCP up to the sending process (paths 4 and 5).
➢ Most implementations of TCP do not provide flow control feedback from the receiving process
to the receiving TCP; they let the receiving process pull data from the receiving TCP whenever

Chethana H R, Asst. Prof., RNSIT Dept. of CSE Page 26


it is ready to do so. In other words, the receiving TCP controls the sending TCP; the sending TCP
controls the sending process.
➢ Flow control feedback from the sending TCP to the sending process (path 5) is achieved through
simple rejection of data by the sending TCP when its window is full. This means that our
discussion of flow control concentrates on the feedback sent from the receiving TCP to the
sending TCP (path 4).

Opening, Closing and shrinking Windows

▪ The opening, closing, and shrinking of the send window is controlled by the receiver.
▪ new ackNo + new rwnd > last ackNo + last rwnd , send window shrinks

Window Shutdown

▪ The receiver can temporarily shut down the window by sending a rwnd of 0.
▪ This can happen if for some reason the receiver does not want to receive any data from the sender
for a while.
▪ In this case, the sender does not actually shrink the size of the window, but stops sending data until
a new advertisement has arrived.
Chethana H R, Asst. Prof., RNSIT Dept. of CSE Page 27
▪ The sender can always send a segment with 1 byte of data. This is called probing and is used to
prevent a deadlock.

Silly Window Syndrome

▪ A serious problem can arise in the sliding window operation when either the sending application
program creates data slowly or the receiving application program consumes data slowly, or both.

▪ For example, if TCP sends segments containing only 1 byte of data, it means that a 41-byte
datagram (20 bytes of TCP header and 20 bytes of IP header) transfers only 1 byte of user data.
Here the overhead is 41/1, which indicates that we are using the capacity of the network very
inefficiently.

▪ The inefficiency is even worse after accounting for the data-link layer and physical-layer overhead.
This problem is called the silly window syndrome.

Nagle’s algorithm – Sender side

▪ The solution is to prevent the sending TCP from sending the data byte by byte. The sending TCP
must be forced to wait and collect data to send in a larger block. How long should the sending TCP
wait? Nagle’s algorithm is simple:

▪ 1. The sending TCP sends the first piece of data it receives from the sending application program
even if it is only 1 byte.

▪ 2. After sending the first segment, the sending TCP accumulates data in the output buffer and waits
until either the receiving TCP sends an acknowledgment or until enough data have accumulated to
fill a maximum-size segment. At this time, the sending TCP can send the segment.

▪ 3. Step 2 is repeated for the rest of the transmission. Segment 3 is sent immediately if an
acknowledgment is received for segment 2, or if enough data have accumulated to fill a maximum-
size segment.

Clark’s solution - Receiver Side

▪ Send an acknowledgment as soon as the data arrive, but to announce a window size of zero until
either there is enough space to accommodate a segment of maximum size or until at least half of the
receive buffer is empty.

▪ The second solution is to delay sending the acknowledgment. This means that when a segment
arrives, it is not acknowledged immediately. The receiver waits until there is a decent amount of
space in its incoming buffer before acknowledging the arrived segments. The delayed
acknowledgment prevents the sending TCP from sliding its window. After the sending TCP has
sent the data in the window, it stops. This kills the syndrome.

▪ Delayed acknowledgment also has another advantage: it reduces traffic. The receiver does not have
to acknowledge each segment. However, there also is a disadvantage in that the delayed

Chethana H R, Asst. Prof., RNSIT Dept. of CSE Page 28


acknowledgment may result in the sender unnecessarily retransmitting the unacknowledged
segments.

▪ The protocol balances the advantages and disadvantages. It now defines that the acknowledgment
should not be delayed by more than 500 ms.

TCP fast retransmit

If sender receives 3 additional ACKs for same data (“triple duplicate ACKs”), resend unACKed segment
with smallest seq #

▪ likely that unACKed segment lost, so don’t wait for timeout

5.8 TCP Congestion Control


▪ TCP use end to end congestion control as IP layer does not provide explicit feedback to the end
system regarding network congestion.

▪ The approach taken by TCP is to have each sender limit the rate at which it sends the traffic into its
connection as a function of perceived network congestion.

▪ If a TCP sender perceives that there is little or no congestion on the path between itself and
destination, then the TCP sender increases its sender rate increases its send rate, if there is
congestion, then the sender reduces the send rate.

▪ Sender keep tracks of additional variable – cwnd (Congestion Window)

▪ Congestion Window (cwnd) is a TCP state variable that limits the amount of data the TCP can
send into the network before receiving an ACK.

Chethana H R, Asst. Prof., RNSIT Dept. of CSE Page 29


▪ The Receiver Window (rwnd) is a variable that advertises the amount of data that the destination
side can receive.

▪ Together, the two variables are used to regulate data flow in TCP connections, minimize
congestion, and improve network performance. The amount of unacknowledged data at a sender
may not exceed the minimum of cwnd and rwnd, that is:

TCP maintains the sending rate by following the principles namely

1. Lost segment implies congestion and hence the sender’s rate should be decreased when a segment is
lost.
2. An acknowledged segment indicates that the network is delivering the sender’s segment to the receiver
and hence the sender rate can be increased when an ACK arrives for the previously unacknowledged
frame.
3. Bandwidth Probing: sstrsh(slow start threshold )

Congestion Detection:

Signs of Congestion in TCP:


• Time-out: If an acknowledgment (ACK) is not received before the time-out, the sender assumes
segment loss due to severe congestion.
• Three Duplicate ACKs: Receiving four ACKs with the same acknowledgment number indicates a
missing segment, signalling mild or recovering congestion.
Severity of Congestion:
• Time-out indicates strong congestion, as it implies multiple segments may be lost.
• Three duplicate ACKs suggest weak congestion, as most segments are still being delivered.
TCP Versions and Congestion Handling:
• Tahoe TCP: Treats both time-out and duplicate ACKs as equally severe.
• Reno TCP: Differentiates between time-out (strong congestion) and duplicate ACKs (weak
congestion).

TCP Congestion control includes:

1. Slow start.
2. Congestion Avoidance.
3. Fast recovery

1. TCP slow start

▪ when connection begins, increase rate exponentially until first loss event:
• initially cwnd = 1 MSS

Chethana H R, Asst. Prof., RNSIT Dept. of CSE Page 30


• double cwnd every RTT
• done by incrementing cwnd for every ACK received

In the slow-start algorithm, the size of the congestion window increases exponentially until it reaches a
threshold.

When should this exponential growth ends?

1. Lost segment (Time out): Ssthresh = cwnd/2;


2. when cwnd >=ssthresh, Then TCP enters Congestion Avoidance mode.
3. When three DUPACK are received:
Enter Fast recovery state: vCwnd= sstresh+3MSS
Sstresh= cwnd/2

Chethana H R, Asst. Prof., RNSIT Dept. of CSE Page 31


2. Congestion Avoidance: Additive Increase

▪ On entry on congestion state, value of cwnd will be half.


▪ TCP now adopts a more conservative approach
Cwnd=cwnd + MSS[MSS/cwnd]
This increases cwnd by 1/10 MSS for each iteration
▪ Congestion avoidance linear increase ends when timeout occurs or if 3 ACK duplicative is
received.

TCP defines another algorithm called congestion avoidance, which increases the cwnd additively instead of
exponentially. When the size of the congestion window reaches the slow-start threshold in the case where
cwnd = i, the slow-start phase stops and the additive phase begins. In this algorithm, each time the whole
“window” of segments is acknowledged, the size of the congestion window is increased by one. A window
is the number of segments transmitted during RTT. Figure 24.30 shows the idea.

Additive Increase, Multiplicative Decrease

It has been observed that, in this version, most of the time the congestion is detected and taken care of by
observing the three duplicate ACKs. Even if there are some time-out events, TCP recovers from them by
aggressive exponential growth. In other words, in a long TCP connection, if we ignore the slow-start states
and short exponential growth during fast recovery, the TCP congestion window is cwnd = cwnd + (1 /
cwnd) when an ACK arrives (congestion avoidance), and cwnd = cwnd / 2 when congestion is detected, as
though SS does not exist and the length of FR is reduced to zero. The first is called additive increase; the
Chethana H R, Asst. Prof., RNSIT Dept. of CSE Page 32
second is called multiplicative decrease. This means that the congestion window size, after it passes the
initial slow-start state, follows a saw tooth pattern called additive increase, multiplicative decrease
(AIMD), as shown in Figure 24.35.

3. Fast recovery

▪ In fast recovery , the value of cwnd is increased by 1MSS for every duplicate ACK.

▪ TCP enters back :

▪ To Congestion Avoidance: on new ACK

▪ To Slow start: if Time out occurs.

TCP Throughput

▪ The throughput for TCP, which is based on the congestion window behavior, can be easily found if
the cwnd is a constant (flat line) function of RTT.

▪ The throughput with this unrealistic assumption is throughput = cwnd / RTT. In this assumption,
TCP sends a cwnd bytes of data and receives acknowledgement for them in RTT time.

▪ The behavior of TCP is not a flat line; it is like saw teeth, with many minimum and maximum
values. If each tooth were exactly the same, we could say that the throughput = [(maximum +
minimum) / 2] / RTT.

Chethana H R, Asst. Prof., RNSIT Dept. of CSE Page 33


Taho TCP

The early TCP, known as Taho TCP, used only two different algorithms in their conges tion policy: slow
start and congestion avoidance.

Congestion Detection in Tahoe TCP:

• Treats both time-out and three duplicate ACKs equally as signs of congestion.

Slow-Start Algorithm:

• TCP starts with cwnd = 1 MSS and increases the congestion window size aggressively
(exponentially) with each ACK received until congestion is detected or the threshold (ssthresh) is
reached.

Reaction to Congestion:

Chethana H R, Asst. Prof., RNSIT Dept. of CSE Page 34


• On detecting congestion (time-out or duplicate ACKs), TCP:
o Resets cwnd to 1 MSS.
o Adjusts ssthresh to half the current cwnd.
o Restarts the slow-start algorithm.

Congestion Avoidance State:

• When cwnd reaches ssthresh without congestion, TCP switches to a congestion avoidance state.
• In this state, cwnd grows additively, increasing by 1 MSS for every full window of ACKs received
(e.g., if cwnd = 5 MSS, it requires 5 ACKs to increase cwnd to 6 MSS).

Dynamic Adjustment of Threshold:

• ssthresh is continuously adjusted based on congestion events.


• It can increase or decrease depending on the current state of the congestion window. For instance, if
congestion occurs when cwnd = 20 MSS, ssthresh will adjust to 10 MSS (half of cwnd).

Growth Continuity:

• Additive growth of cwnd continues until the end of data transfer unless further congestion is
detected, which resets the process.

Figure 24.32 shows an example of congestion control in a Taho TCP. TCP starts data transfer and sets the
ssthresh variable to an ambitious value of 16 MSS. TCP begins at the slow-start (SS) state with the cwnd =
1. The congestion window grows exponentially, but a time-out occurs after the third RTT (before reaching
the threshold). TCP assumes that there is congestion in the net work. It immediately sets the new ssthresh =

Chethana H R, Asst. Prof., RNSIT Dept. of CSE Page 35


4 MSS (half of the current cwnd, which is 8) and begins a new slow-start (SA) state with cwnd = 1 MSS.
The congestion window grows exponen tially until it reaches the newly set threshold. TCP now moves to the
congestion-avoidance (CA) state and the congestion window grows additively until it reaches cwnd = 12
MSS. At this moment, three duplicate ACKs arrive, another indication of congestion in the network. TCP
again halves the value of ssthresh to 6 MSS and begins a new slow-start (SS) state. The expo nential growth
of the cwnd continues. After RTT 15, the size of cwnd is 4 MSS. After sending four segments and receiving
only two ACKs, the size of the window reaches the ssthresh (6) and TCP moves to the congestion-avoidance
state. The data transfer now continues in the congestion avoidance (CA) state until the connection is
terminated after RTT 20.

Reno TCP

Reno TCP introduces a fast-recovery state to handle congestion more efficiently.

Differentiated Congestion Signals:

• Time-out: Treated as a severe congestion signal. TCP resets to the slow-start state, restarting with
cwnd = 1 MSS.

Chethana H R, Asst. Prof., RNSIT Dept. of CSE Page 36


• Three Duplicate ACKs: Treated as a less severe congestion signal. TCP moves to the fast-
recovery state.

Behaviour in Fast-Recovery:

• Initial cwnd: Starts with ssthresh + 3 MSS (not 1 MSS like in slow start).
• Duplicate ACKs: TCP remains in this state and grows cwnd exponentially.
• Time-out: Indicates serious congestion, transitioning TCP back to slow-start.
• New ACK: Indicates recovery; TCP transitions to congestion avoidance and resets cwnd to
ssthresh.

Fast-Recovery Transition:

• Fast-recovery bridges slow start and congestion avoidance, allowing quicker recovery while still
addressing mild congestion.
• Reno TCP optimizes throughput by treating mild and severe congestion events differently, reducing
unnecessary resets to slow start.

Figure 24.34 shows the same situation as Figure 24.32, but in Reno TCP. The changes in the con
gestion window are the same until RTT 13 when three duplicate ACKs arrive. At this moment, Reno
TCP drops the ssthresh to 6 MSS (same as Taho TCP), but it sets the cwnd to a much higher value
(ssthresh + 3 = 9 MSS) instead of 1 MSS. Reno TCP now moves to the fast recov ery state. We
assume that two more duplicate ACKs arrive until RTT 15, where cwnd grows exponentially. In this
moment, a new ACK (not duplicate) arrives that announces the receipt of the lost segment. Reno TCP
now moves to the congestion-avoidance state, but first deflates the congestion window to 6 MSS (the
ssthresh value) as though ignoring the whole fast-recovery state and moving back to the previous
track.

Chethana H R, Asst. Prof., RNSIT Dept. of CSE Page 37


Module - 5

1. Introduction to Application Layer:


▪ Introduction, Client-Server Programming
2. Standard Client Server Protocols:
▪ World Wide Web and HTTP
▪ FTP
▪ Electronic Mail
▪ TELNET
▪ Secure Shell (SSH)
▪ Domain Name System (DNS)

1.1Introduction:
The Internet was originally designed for the purpose to provide service to users around the
world. The protocols in this layer do not provide services to any other protocol in the suite; they
only receive services from the protocols in the transport layer. This means that protocols can be
removed from this layer easily. New protocols can be also added to this layer as long as the new
protocols can use the services provided by one of the transport-layer protocols.

Standard and Nonstandard Protocols

Application-layer protocols that have been standardized and documented by the Internet
authority, and that are used in interaction with the Internet are Standard Application-Layer
Protocols. A programmer can create a nonstandard application-layer program by writing two
programs that provide service to the user by interacting with the transport layer.

Application-Layer Paradigms;

• Client-server paradigm
• Peer-to-peer paradigm

Client-server paradigm:

• The client-server paradigm is a traditional model where a server process provides


services to client processes over the Internet.
• The server runs continuously, awaiting client requests, while the client process starts only
when service is needed.
• This paradigm is comparable to real-world services, such as a telephone directory center,
where the server (directory) is always available, and the client (caller) uses it as needed.
• The roles of the client and server are distinct, requiring separate application programs for
each type of service.

Chethana H R, Assistant Professor Dept. of CSE, RNSIT 1


• A key issue with this model is the centralized load on the server, which requires powerful
infrastructure to handle multiple simultaneous client connections.
• Another challenge is the cost and maintenance of powerful servers, necessitating a return
on investment for the service provider.
• Despite its limitations, this paradigm is still widely used in services like the World Wide
Web (HTTP), FTP, SSH, and email.

Peer-to-Peer:

• The peer-to-peer (P2P) paradigm eliminates the need for a central server by distributing
responsibilities among peers.

• In this model, computers can act as both service providers and consumers, even
simultaneously.
• Examples of P2P applications include Internet telephony (e.g., Skype) and file sharing
(e.g., BitTorrent), where devices communicate directly without a dedicated server.

Chethana H R, Assistant Professor Dept. of CSE, RNSIT 2


• The P2P paradigm is scalable and cost-effective, reducing the need for expensive,
always-on servers.
• Security challenges arise as distributed communication is harder to secure than
centralized server-based communication.
• Applicability issues exist since not all applications or users are suited for the P2P model.
For instance, some users may resist adopting a peer-based implementation of the web.
• Despite challenges, P2P is widely used in modern applications like BitTorrent, Skype,
IPTV, and Internet telephony.

1.2 Client-Server Programming

• In the client-server paradigm, communication occurs between two running application


programs: client and server.
• The client initializes communication by sending a request, while the server waits to
receive requests, processes them, and sends responses back to the client.
• The server must be continuously running to handle client requests, whereas the client
program runs only when needed and stops after completing its tasks.
• For effective communication, the server program must start before the client program is
executed.
• The server's lifetime is infinite, operating continuously, while the client's lifetime is
finite, limited to the duration required to send requests and process responses.

Application Programming Interface

• Client-server communication requires a process at the application layer to interact with


the lower layers of the TCP/IP protocol suite to establish a connection, exchange data,
and terminate the connection.
• To achieve this, a set of programming instructions called an Application
Programming Interface (API) is used. APIs act as an intermediary between the
application layer process and the operating system.
• APIs provide the necessary commands to manage tasks such as opening connections,
transmitting data, receiving responses, and closing connections.
• These APIs are integrated into the operating system, which implements the lower four
layers of the TCP/IP protocol suite, enabling seamless communication between processes
over the Internet.
• Some of the most common APIs for process communication include:
o Socket Interface
o Transport Layer Interface (TLI)
o STREAM
These APIs simplify the development of networked applications by abstracting the complexities
of lower-layer operations.

Socket:
Chethana H R, Assistant Professor Dept. of CSE, RNSIT 3
• Sockets are treated like other sources as shown in figure 25.5 (e.g., keyboard, files) or sinks
(e.g., monitor, files) in programming languages such as C, C++, or Java.
• They allow programs to send or receive data over a network just as they would with standard
I/O operations.

Chethana H R, Assistant Professor Dept. of CSE, RNSIT 4


• Sockets are not physical entities like files or terminals but are abstract objects created by
application programs.
• Sockets act as communication endpoints for exchanging requests and responses between
client and server processes.
• Client's Perspective: The socket appears as the entity that receives responses to its requests.
• Server's Perspective: The socket appears as the entity that sends requests requiring
responses.
• Each socket must have source and destination addresses properly defined for communication.
• After setup, the operating system and the embedded TCP/IP protocol handle data transfer
between the sockets.
• Sockets simplify programming by acting like terminals or files, enabling developers to use
familiar instructions for reading and writing data.
• Communication occurs between two sockets, one on each end, as illustrated in diagrams like
Figure 25.6.

Socket Addresses

A socket address combines two identifiers:

• IP Address: Uniquely identifies a computer on the Internet.


• Port Number: Identifies the specific application process (client or server) on the
computer.

Finding Socket Addresses

Server Site: The server needs a local (server) and a remote (client) socket address for
communication.
Chethana H R, Assistant Professor Dept. of CSE, RNSIT 5
Local Socket Address for Server:

• The operating system provides the server's local IP address.


• If the server process is standard, it uses a well-known port number (e.g., HTTP uses port
80).
• For non-standard servers, the designer can assign a port number within the range
specified by the Internet authority.
Remote Socket Address for Server:

• The remote socket address corresponds to the client's address making the connection.
• It is determined dynamically from the client's request packet.
• The server's local socket address remains fixed, but the remote address changes with each
client interaction.

Client Site The client also needs a local (client) and a remote (server) socket address for
communication.

Local Socket Address for Client:

• The client's local IP address is provided by the operating system.


• A temporary (ephemeral) port number is assigned by the OS for each client process,
ensuring it is unique.

Remote Socket Address for Client:

• The client must know the server's socket address to initiate communication.
• If the client knows both the server's IP address and port number (e.g., for testing custom
programs), it can directly connect.
• If only the port number is known, the IP address is resolved using the Domain Name
System (DNS), which maps server names (e.g., URLs) to their IP addresses.

DNS functions like a telephone directory, mapping server names to IP addresses, enabling clients
to find servers for communication.

Using Services of the Transport Layer

Application layer processes communicate via transport layer protocols since there is no direct
physical communication. Common transport-layer protocols in the TCP/IP suite are UDP, TCP,
and SCTP.

UDP Protocol:

• Provides connectionless, unreliable, and message-oriented datagram service.


• Each message is independent, with no logical connection between packets.
• Suitable for applications prioritizing simplicity and speed over reliability, such as
multimedia and management applications.
Chethana H R, Assistant Professor Dept. of CSE, RNSIT 6
TCP Protocol:

•Provides connection-oriented, reliable, and byte-stream service.


• Uses a handshake to establish communication parameters, ensures data continuity
through byte numbering, and supports flow and congestion control.
• Ideal for applications requiring long messages and reliability, but it lacks message-
oriented boundaries.
SCTP Protocol:

• Combines the benefits of TCP and UDP by offering connection-oriented, reliable, and
message-oriented services.
• Supports multi-streaming for multiple network-layer connections, maintaining
communication even during partial network failures.
• Suitable for applications needing reliability and multi-streaming capabilities.

Iterative Communication: Handles clients one at a time, in a serial manner. Iterative servers are
simple and work well for short transactions, but can build up queues for longer transactions.

Concurrent Communication: Handles multiple clients simultaneously. Concurrent servers can


create child processes for each client, allowing them to process requests without waiting for
other transactions to complete.

• Iterative Communication Using UDP

Chethana H R, Assistant Professor Dept. of CSE, RNSIT 7


Servers can respond iteratively (one client request at a time) or concurrently (multiple requests
simultaneously). In an iterative server, requests are handled sequentially in a first-in, first-out
(FIFO) manner.

• UDP provides connectionless communication, with no connection establishment or


termination.
• Each client request is treated as a separate entity, even if sent by the. The socket cre ated at
the server site lasts forever; the socket created at the client site is closed (destroyed) when the
client process terminates. same client. In UDP communication, the client and server use only
one socket each. Figure 25.8 shows the lifetime of the sockets in the server and client
processes.
• Different clients use different sockets, but the server creates only one socket and changes
only the remote socket address each time a new client makes a connection. This is logical,
because the server does know its own socket address, but does not know the socket addresses
of the clients who need its services; it needs to wait for the client to connect before filling this
part of the socket address.
• There are multiple clients, but only one server. Each client is served in each iteration of the
loop in the server. Note that there is no connection establishment or connection termination.
Each client sends a single datagram and receives a single datagram. In other words, if a client
wants to send two datagrams, it is considered as two clients for the server. The second
datagram needs to wait for its turn. The diagram also shows the status of the socket after each
action.
Chethana H R, Assistant Professor Dept. of CSE, RNSIT 8
Server Process:
• A server makes a passive open, in which it becomes ready for the communication, but it
waits until a client process makes the connection creating an empty socket bound to a
well-known port.
• The server then issues a receive request command, which blocks until it receives a
request from a client. The server waits for client requests, processes them, and sends
responses in an infinite loop.
• After each iteration, the server's socket address resets partially, awaiting a new request.

Client Process:
• A client makes an active open, creating an empty socket and sending a request.
• The client waits (blocks) for the server's response, processes it, and then destroys the
socket.
Socket Usage:
• The server uses a single socket throughout its lifetime, dynamically updating the remote
socket address for each new client.
• Each client creates and destroys its socket during communication.

Iterative Communication Using TCP

Before sending or receiving data, a connection needs to be established between the client and the
server. After the connection is established, the two parties can send and receive chunks of data as
long as they have data to do so.

• Sockets Used in TCP


The TCP server uses two different sockets :one for connection establishment (listen socket) and
the other for data transfer (Socket). The reason for having two types of sockets is to separate the
connection phase from the data exchange phase. A server uses a listen socket to listen for a new
client trying to establish connection. After the connection is established, the server creates a
socket to exchange data with the client and finally to terminate the connection. The client uses
only one socket for both connection establishment and data exchange (see Figure 25.10).

Chethana H R, Assistant Professor Dept. of CSE, RNSIT 9


Flow Diagram:

Figure 25.11 shows a simplified flow diagram for iterative communication using TCP. There are
multiple clients, but only one server. Each client is served in each iteration of the loop.

Server Process:

• In Figure 25.11, the TCP server process, like the UDP server process, creates a socket
and binds it, but these two commands create the listen socket to be used only for the
connection establishment phase.
• The server process then calls the listen procedure, to allow the operating system to start
accepting the clients, completing the connection phase, and putting them in the waiting
list to be served. The server process now starts a loop and serves the clients one by one.
• In each iteration, the server process issues the accept procedure that removes one client
from the waiting list of the connected clients for serving. If the list is empty, the accept
procedure blocks until there is a client to be served.
• When the accept procedure returns, it creates a new socket for data transfer. The server
process now uses the client socket address obtained during the connection establishment
to fill the remote socket address field in the newly created socket. At this time the client
and server can exchange data.

Client Process:
The client flow diagram is almost similar to the UDP version except that the client data-transfer
box needs to be defined for each specific case.

Chethana H R, Assistant Professor Dept. of CSE, RNSIT 10


Application Layer overview:

▪ Application layer determines how a specific user application should use network.
▪ Application layer is built on transport layer and provides network services to user application.
▪ Application layer defines and performs such applications as e-mail; file transfers, remote access
to computers, real-time video conferencing.
▪ Application layer has its own software dependencies; when a new application is developed its
software must run on multiple machines.

Standard Client Server Protocols:


Chethana H R, Assistant Professor Dept. of CSE, RNSIT 11
1. World Wide Web: It is the repository of globally distributed web pages, connected by
links. The two key aspects are:
a. Distributed: Web servers worldwide can add and share web pages without central
server overload.
b. Linked: Hypertext enables one web page to refer to another anywhere in the world.

Web Client (Browser) : A web browser is an application for accessing websites. Each browser
usually consists of three parts: a controller, client protocols, and interpreters.

The controller receives input from the keyboard or the mouse and uses the client programs to
access the document. After the document has been accessed, the controller uses one of the
interpreters to display the document on the screen. The client protocol can be one of the
protocols described later, such as HTTP or FTP. The interpreter can be HTML, Java, or
JavaScript, depending on the type of document. Some commercial browsers include Internet
Explorer, Netscape Navigator, and Firefox.

Web Server: The web page is stored at the server. Each time a request arrives, the
corresponding document is sent to the client. To improve efficiency, servers normally store
requested files in a cache in memory; memory is faster to access than a disk. A server can also
become more efficient through multithreading or multiprocessing. In this case, a server can
answer more than one request at a time. Some popular web servers include Apache and
Microsoft Internet Information Server.

Uniform Resource Locator (URL): A web page, as a file, needs to have a unique identifier to
distinguish it from other web pages. To define a web page, we need three identifiers: Protocol,
host, port, and path.
• Protocol: The first identifier is the abbreviation for the client-server program that we
need in order to access the web page. Ex: HTTP (Hypertext Transfer Protocol), FTP (File
Transfer Protocol).
• Host: The host identifier can be the IP address of the server or the unique name given to
the server. IP addresses can be defined in dotted decimal notation, the name is normally
the domain name that uniquely defines the host, such as forouzan.com.

Chethana H R, Assistant Professor Dept. of CSE, RNSIT 12


• Port: The port, a 16-bit integer, is normally predefined for the client-server application.
For example, if the HTTP protocol is used for accessing the web page, the well-known
port number is 80. However, if a different port is used, the number can be explicitly
given.
• Path: The path identifies the location and the name of the file in the underlying operating
system. The format of this identifier normally depends on the operating system. In UNIX,
a path is a set of directory names followed by the file name, all separated by a slash. For
example, /top/next/last/myfile is a path that uniquely defines a file named myfile, stored
in the directory last, which itself is part of the directory next, which itself is under the
directory top. In other words, the path lists the directories from the top to the bottom,
followed by the file name.

Web Documents: Web documents are broadly classified into static, dynamic, and active
documents.
• Static Documents: Fixed-content documents stored on a server.
• Characteristics:
o Content is determined at creation and cannot be altered by users.
o A copy is sent to the client, viewable via a browser.
• Technologies Used:
o Created using languages like HTML, XML, XSL, and XHTML.

• Dynamic Documents: Created by the server in real-time upon a browser's request.


• Characteristics:
o Content varies with each request, e.g., displaying the current date/time.
o The server runs a program or script to generate the content dynamically.
• Technologies Used:
o Common Gateway Interface (CGI) (historical).
o Modern options:
▪ Java Server Pages (JSP) – Java-based scripting.
▪ Active Server Pages (ASP) – Microsoft’s Visual Basic-based
scripting.
▪ ColdFusion – Embeds SQL queries in HTML.

• Active Documents: Require scripts or programs to run at the client site (browser).
• Characteristics:
o Used for applications like animation or user interaction.
o Program/script is executed on the client’s device.
• Technologies Used:
o Java Applets: Pre-compiled Java programs sent in binary (bytecode) format.
o JavaScript: Downloaded and executed directly on the client browser.

2. HyperText Transfer Protocol (HTTP): The HyperText Transfer Protocol (HTTP) is used
to define how the client-server programs can be written to retrieve web pages from the Web.

Chethana H R, Assistant Professor Dept. of CSE, RNSIT 13


An HTTP client sends a request; an HTTP server returns a response. The server uses the port
number 80; the client uses a temporary port number.
• Hypertext and Multiple Requests: Retrieving web page objects often involves multiple
requests and responses, especially when objects are hosted on different servers.
• TCP Connections:
• For objects on different servers, a new TCP connection is required for each object.
• For objects on the same server, there are two approaches:
• Nonpersistent Connection: A new TCP connection for each object.
• Persistent Connection: A single TCP connection is used to retrieve all objects.
• HTTP Versions:
• HTTP (pre-1.1): Defaults to nonpersistent connections.
• HTTP 1.1 and beyond: Defaults to persistent connections, though users can modify this
behavior.

Nonpersistent Connections: In a nonpersistent connection, one TCP connection is made for


each request/response. The following lists the steps in this strategy:
1. The client opens a TCP connection and sends a request.
2. The server sends the response and closes the connection.
3. The client reads the data until it encounters an end-of-file marker; it then closes the
connection.
In this strategy, if a file contains links to N different pictures in different files (all located on the
same server), the connection must be opened and closed N + 1 times. The nonpersistent strategy
imposes high overhead on the server because the server needs N + 1 different buffers each time a
connection is opened.

Figure 26.3 shows an example of a nonpersistent connection. The client needs to access a file
that contains one link to an image. The text file and image are located on the same server. Here
we need two connections. For each connection, TCP requires at least three handshake messages
to establish the connection, but the request can be sent with the third one. After the connection is
established, the object can be transferred. After receiving an object, another three handshake
messages are needed to terminate the connection. This means that the client and server are
involved in two connection establishments and two connection terminations. If the transaction
involves retrieving 10 or 20 objects, the round trip times spent for these hand shakes add up to a
big overhead. When we describe the client-server programming at the end of the chapter, we will
show that for each connection the client and server need to allocate extra resources such as
buffers and variables. This is another burden on both sites, but especially on the server site.

Chethana H R, Assistant Professor Dept. of CSE, RNSIT 14


Persistent Connections:

Chethana H R, Assistant Professor Dept. of CSE, RNSIT 15


• The server keeps the connection open for additional requests after a response is sent.
• The connection is closed either on client request or after a timeout.
• Typically, the sender includes the data length in the response.
• When the data length is unknown (e.g., for dynamically generated documents), the server
signals this by closing the connection after sending the data, indicating the end.
• Persistent connections save time and resources by reducing the need for multiple
connection setups and terminations.
• Only one set of buffers and variables is maintained per connection, and the round-trip time
for establishing connections is eliminated.

Figure 26.4 shows the same scenario as in Example 26.3, but using a persistent connection. Only
one connection establishment and connection termination is used, but the request for the image is
sent separately.

Message Formats

The HTTP protocol defines the format of request and response messages, structured in four
sections. In request messages, the first section is the request line, while in response messages, it
is the status line. The other three sections share the same names in both message types but differ
in content. These similarities are limited to naming conventions, with distinct details in each
message type.

Request Message:

• The HTTP request message begins with a request line containing three fields: method,
URL, and version, separated by spaces and terminated with carriage return and line feed.

Chethana H R, Assistant Professor Dept. of CSE, RNSIT 16


• Methods define the request type:
o GET: Retrieves data; body is empty.
o HEAD: Retrieves metadata or tests URL validity; body is empty.
o PUT: Uploads a new web page to the server (if permitted).
o POST: Sends data to modify or add to a web page.
o TRACE: Debugging; echoes the request back.
o DELETE: Deletes a web page (if permitted).
o CONNECT: Reserved for proxy server use.
o OPTIONS: Retrieves properties of a web page.
• The URL specifies the address and name of the web page.
• The version indicates the HTTP protocol version, e.g., 1.1.
• Header lines may follow, providing additional information from the client to the server.
Each header has a name, colon, space, and value.
• The body is optional and contains data or files to be sent, typically with PUT or POST
methods.

Response Message:
• The HTTP response message consists of a status line, header lines, a blank line, and
sometimes a body.

Chethana H R, Assistant Professor Dept. of CSE, RNSIT 17


• The status line includes three fields separated by spaces:
• Version: Specifies the HTTP protocol version (e.g., 1.1).
• Status code: A three-digit number indicating the request status:
o 100 range: Informational.
o 200 range: Success.
o 300 range: Redirection to another URL.
o 400 range: Client-side error.
o 500 range: Server-side error.
• Status phrase: A textual explanation of the status code.
• Response header lines provide additional information from the server to the client,
formatted as a header name, colon, space, and value.
• The body, if present, contains the document or data being sent to the client; it is absent in
error responses.

Conditional Request:

• A client can include conditions in its HTTP request.


• Common Condition - Time/Date: The client uses the If-Modified-Since header to
request the page only if it has been modified after a specified date and time.
• This mechanism helps reduce unnecessary data transfer by avoiding the delivery of
unmodified content.

Chethana H R, Assistant Professor Dept. of CSE, RNSIT 18


Cookies: Cookies are small pieces of data stored on the user's device by a web browser. They
are created by websites to store information about the user's session or preferences as HTTP is a
stateless protocol.

Creating and Storing Cookies:

1. When a server receives a request from a client, it stores information about the client in a file or
a string. The information may include the domain name of the client, the contents of the cookie
(information the server has gathered about the client such as name, registration number, and so
on), a timestamp, and other information depend ing on the implementation.
2. The server includes the cookie in the response that it sends to the client.
3. When the client receives the response, the browser stores the cookie in the cookie directory,
which is sorted by the server domain name.

Functionality of Cookies:
• Cookies are stored on the client side and included in requests to the server if a match is
found.
• Servers use cookies to identify returning clients without revealing their content to the
browser or user.
Applications of Cookies:
• E-commerce:
o Track shopping cart items (e.g., item details and prices) and update the cookie
with new selections.
o Retrieve the cookie for calculating the total charge at checkout.
• Restricted Access:
o Sites send cookies to registered users during their first visit.
Chethana H R, Assistant Professor Dept. of CSE, RNSIT 19
o On subsequent visits, only clients with valid cookies can access restricted content.
• Personalized Web Portals:
o Cookies store user preferences for favorite pages.
o On revisit, the server uses the cookie to personalize the user experience.
• Advertising:
o Advertising agencies use cookies to track user interactions with banners across
websites.
o These cookies build a user profile for targeted ads and may be sold, raising
privacy concerns.
Privacy Concerns:
• Cookies used by advertising agencies for tracking user behavior are controversial.
• There is a need for regulations to protect user privacy.

Cookies help the server maintain continuity and provide personalized shopping experiences,
even during intermittent interactions.
Use of Cookies in an Electronic Store (Scenario) as shown in daigram 26.8
1. Shopping Cart Creation:
o The store server creates an empty shopping cart (list) for the client and assigns a
unique ID (e.g., 12343).
o The server sends a response containing product images and links, along with a
Set-Cookie header storing the cart ID.
2. Cookie Storage on the Client:
o The browser saves the cookie (ID 12343) in a file named after the store (e.g.,
BestToys).
o The cookie is not disclosed to the shopper.
3. Toy Selection by the Shopper:
o When a toy is selected, the client sends a request to the server, including the
cookie (ID 12343) in the Cookie header.
o The server uses the cookie to identify the shopper and retrieves their shopping
cart.
4. Updating the Shopping Cart:
o The selected toy is added to the cart on the server-side.
o The server sends a response with the updated cart details, including the total price.
5. Payment Processing:
o The shopper provides payment details (e.g., credit card information) and sends a
new request with the same cookie value (12343).
o The server retrieves the shopping cart, processes the payment, and sends a
confirmation response.
6. Client Information Storage:
o Additional client information is stored on the server for future interactions.

Chethana H R, Assistant Professor Dept. of CSE, RNSIT 20


Web Caching: Proxy Servers:

Chethana H R, Assistant Professor Dept. of CSE, RNSIT 21


• A proxy server stores cached copies of responses to frequently accessed requests.
• The HTTP client sends its request to the proxy server first.
• The proxy server checks its cache:
o If a response is found, it acts as a server and sends the response directly to the
client.
o If no response is found, it acts as a client, forwards the request to the target
server, and stores the received response for future use.
Benefits of Proxy Servers:
• Reduces Load: Decreases the demand on the original web server.
• Improves Latency: Speeds up response time for cached requests.
• Minimizes Traffic: Limits the amount of data flowing between the client and the
server.
Locations of Proxy Servers:
• Client-Side Proxy: Installed on individual computers for small-scale caching.
• LAN Proxy: Used within companies or organizations to manage requests for a local
network.
• ISP Proxy: Installed by Internet Service Providers to handle requests for multiple
customers.
Example Scenario (Figure 26.9):
• In a campus or company network:
o HTTP requests from clients are routed to the proxy server.
o If the proxy server has the cached page, it sends it directly to the client.
o Otherwise, it forwards the request to the web server, caches the response, and
delivers it to the client.

Cache Update :

• Proxy servers need strategies to determine how long to retain cached responses before
deletion or replacement.
• One approach involves maintaining a list of sites that update content infrequently, such as
a news agency updating its page daily.
• Proxy servers can retrieve such content once and keep it until the next expected update.
• Another method uses headers indicating the last modification time, allowing the proxy
server to estimate the validity of the cached information.

3. FTP
FTP (File Transfer Protocol) is a standard TCP/IP protocol for copying files between hosts,
designed to handle challenges like differing file name conventions, data representations, and
directory structures. FTP is more suitable than HTTP for transferring large files or files in
various formats.
• FTP operates with two connections: control connection and data connection.
• Control connection uses TCP port 21 and remains active during the entire FTP session,
handling commands and responses.

Chethana H R, Assistant Professor Dept. of CSE, RNSIT 22


• Data connection uses TCP port 20, opening and closing for each file transfer, enabling
efficient file handling.
• The client has three components: user interface, client control process, and client data
transfer process.
• The server has two components: server control process and server data transfer process.

Control Connection:
• Communication occurs through ASCII-based commands and responses, similar to
TELNET.
• Commands are sent from the client, and responses are sent by the server.
• Commands are uppercase ASCII strings, optionally followed by arguments.
• Responses have a numeric code and text explanation.
Data Connection:
• Data connection is initiated by the client with a passive open using an ephemeral port.
• The client uses the PORT command to notify the server of the port, and the server opens
the connection using port 20.
Data Transfer:
• The data connection handles file transfers, with the following attributes defining transfer:
o File Type: ASCII, EBCDIC, or image files.
o Data Structure: File structure (stream of bytes), record structure (divided into
records), or page structure (divided into pages with headers).
o Transmission Mode: Stream mode (default continuous stream), block mode (data
in blocks with headers), or compressed mode.
Efficiency:
• FTP separates commands (handled via control connection) and data transfers (handled
via data connection) to enhance efficiency.
• File transfer includes retrieving files (server to client), storing files (client to server), and
directory listing (server to client).

Chethana H R, Assistant Professor Dept. of CSE, RNSIT 23


Example 26.10 Figure 26.11 shows an example of using FTP for retrieving a file. The figure
shows only one file to be transferred. The control connection remains open all the time, but the
data connection is opened and closed repeatedly. We assume the file is transferred in six
sections. After all records have been transferred, the server control process announces that the
file transfer is done. Since the client control process has no file to retrieve, it issues the QUIT
command, which causes the service connection to be closed.

Chethana H R, Assistant Professor Dept. of CSE, RNSIT 24


Chethana H R, Assistant Professor Dept. of CSE, RNSIT 25
Security for FTP: The FTP protocol was designed when security was not a big issue. Although
FTP requires a password, the password is sent in plaintext (unencrypted), which means it can be
intercepted and used by an attacker. The data transfer connection also transfers data in plain text,
which is insecure. To be secure, one can add a Secure Socket Layer between the FTP application
layer and the TCP layer. In this case FTP is called SSL-FTP.

4. ELECTRONIC MAIL

• E-mail is a one-way transaction; responses are optional and separate one-way


transactions.
• Users run client programs on demand, while intermediate mail servers handle client-
server interactions.
• E-Mail Architecture:

o Alice (sender) and Bob (receiver) use a User Agent (UA) to send/receive
messages via their respective mail servers.
o Mail servers use Message Transfer Agents (MTAs) to send messages between
them.
o Bob retrieves messages from the server using a Message Access Agent (MAA).
o Mailboxes (special files) store received messages, and queues (spools)
temporarily hold messages waiting to be sent.
o The electronic mail system needs two UAs, two pairs of MTAs (client and
server), and a pair of MAAs (client and server).
• Key Agents in E-Mail:
1. User Agent (UA):
▪ Handles composing, sending, receiving, replying, and forwarding
messages.
▪ Types:
Chethana H R, Assistant Professor Dept. of CSE, RNSIT 26
▪Command-driven (e.g., mail, pine).
▪ GUI-based (e.g., Eudora, Outlook).
2. Message Transfer Agent (MTA):
▪ Handles sending messages between mail servers using the SMTP protocol.
▪ Operates as a push mechanism, transferring messages automatically.
3. Message Access Agent (MAA):
▪ Handles retrieving messages from the mail server using a pull mechanism.
• Mail Sending Process:
o Mail includes an envelope (sender/receiver addresses) and a message (header and
body).
o Header includes sender, recipient, subject, and additional details.
o Body contains the actual content to be read.

• Mail Receiving Process:


o The UA informs the user about new mail and displays a summary of messages.
o The user selects messages to view their content.
• E-Mail Addresses:
o Composed of a local part (user mailbox) and a domain name, separated by @.
o Domain names represent mail servers, defined by DNS or logical organizational
names.
• Mailing Lists:
o Alias names represent multiple addresses; messages are distributed to all
addresses in the list.

SMTP (Simple Mail Transfer Protocol):


o Protocol for message transfer between MTAs:
▪ Used between the sender's client and sender's mail server.
Chethana H R, Assistant Professor Dept. of CSE, RNSIT 27
▪ Also used between sender and receiver mail servers.
o SMTP exchanges commands and responses, terminated by a two-character end-
of-line token.

Commands and Responses : SMTP uses commands and responses to transfer messages
between an MTA client and an MTA server. The command is from an MTA client to an MTA
server; the response is from an MTA server to the MTA client. Each command or reply is
terminated by a two character (carriage return and line feed) end-of-line token. Commands
Commands are sent from the client to the server. The format of a command is shown below:

Keyword: argument(s)

Chethana H R, Assistant Professor Dept. of CSE, RNSIT 28


Responses : Responses are sent from the server to the client. A response is a three digit code that
may be followed by additional textual information. Table 26.7 shows the most common response
types.

Connection Establishment:
• Step 1: SMTP server sends code 220 (service ready) to indicate readiness. If unavailable,
it sends 421 (service not available).
• Step 2: Client sends HELO message with its domain name to identify itself.
• Step 3: Server responds with code 250 (request command completed) or another status
code.
Message Transfer:
• Step 1: Client sends MAIL FROM message with the sender's email address (mailbox and
domain).
• Step 2: Server responds with code 250 (OK) or another appropriate code.

Chethana H R, Assistant Professor Dept. of CSE, RNSIT 29


• Step 3: Client sends RCPT TO message with the recipient's email address.
• Step 4: Server responds with code 250 (OK) or another appropriate code.
• Step 5: Client sends DATA message to start the actual message transfer.
• Step 6: Server responds with code 354 (start mail input) or another appropriate code.
• Step 7: Client sends the email content line by line, with each line ending in a two-
character end-of-line token. The message ends with a line containing a single period (.).
• Step 8: Server responds with code 250 (OK) or another appropriate code.

Connection Termination : After the message is transferred successfully, the client ter minates
the connection. This phase involves two steps.
1. The client sends the QUIT command.
2. The server responds with code 221 or some other appropriate code

To show the three mail transfer phases, we show all of the steps described above using the
information depicted in Figure 26.16. In the figure, we have separated the messages related to the
envelope, header, and body in the data transfer section. Note that the steps in this figure are
repeated two times in each e-mail transfer: once from the e-mail sender to the local mail server

Chethana H R, Assistant Professor Dept. of CSE, RNSIT 30


and once from the local mail server to the remote mail server. The local mail server, after
receiving the whole e-mail message, may spool it and send it to the remote mail server at another
time.

Message Access Agent: POP and IMAP :

Mail Delivery Protocols


1. SMTP Usage:
o Used in the first and second stages of mail delivery.
o Push protocol: sends messages from the client to the server.
2. Third Stage Protocol:
o Requires a pull protocol: retrieves messages from the server to the client.
o Involves a Message Access Agent.
o Common protocols: POP3 and IMAP4.

POP3 (Post Office Protocol, Version 3)

1. Functionality:
o Simple but limited.
o Client software connects to the mail server via TCP port 110.
o User provides credentials to access the mailbox.
2. Modes:
o Delete Mode: Mail is deleted after retrieval; used on permanent computers.
o Keep Mode: Mail remains on the server; suitable for accessing mail on temporary
devices.

Chethana H R, Assistant Professor Dept. of CSE, RNSIT 31


3. Limitations:
o Cannot organize mail on the server (e.g., no folders).
o Does not allow previewing or searching mail before downloading.

IMAP4 (Internet Mail Access Protocol, Version 4)


1. Features:
o More powerful and complex than POP3.
o Allows header preview and content search before downloading.
o Supports partial downloads for bandwidth efficiency.
o Enables mailbox organization:
▪ Creating, deleting, and renaming mailboxes.
▪ Hierarchical folder structure for mail storage.

MIME (Multipurpose Internet Mail Extensions)

1. Purpose:
o Overcomes email limitations (e.g., ASCII-only format).
o Supports non-ASCII data (e.g., different languages, binary files, multimedia).
2. Functionality:
o Converts non-ASCII data to NVT ASCII for transmission.
o Converts ASCII data back to original format at the receiving end.
3. Applications:
o Enables sending multimedia and international language content through email.

MIME Headers : MIME defines five headers, as shown in Figure 26.19, which can be added to
the origi nal e-mail header section to define the transformation parameters:
MIME-Version : This header defines the version of MIME used. The current version is 1.1.
Content-Type: This header defines the type of data used in the body of the message. The
content type and the content subtype are separated by a slash. Depending on the subtype, the
header may contain other parameters. MIME allows seven different types of data, listed in Table
26.8.
Content-Transfer-Encoding
• Purpose: Specifies the encoding method for converting messages into binary (0s and 1s)
for transport.
• Encoding Methods (Table 26.9): Five types, with focus on:

Chethana H R, Assistant Professor Dept. of CSE, RNSIT 32


1. Base64 Encoding:
▪ Divides data into 6-bit chunks.
▪ Converts each chunk into one ASCII character (8 bits).
▪ Results in a 25% overhead due to redundancy.
▪ Suitable for transmitting binary or non-ASCII data.
2. Quoted-Printable Encoding:
▪ Sends ASCII characters as is.
▪ Encodes non-ASCII characters as three characters:
▪ = followed by two hexadecimal digits representing the byte.
▪ Example: A non-ASCII byte 9D16 is encoded as =9D.

Content-ID : Provides a unique identifier for the entire message in environments where multiple
messages are present.

Chethana H R, Assistant Professor Dept. of CSE, RNSIT 33


Web Based Mail :
• Web-based mail services (e.g., Hotmail, Yahoo, Gmail) allow users to send and receive
emails via web browsers using HTTP instead of traditional email client protocols like
POP3 or IMAP4.
• Common use cases: Two scenarios based on the type of mail servers used by sender and
receiver.
Case I: Traditional to Web-Based Mail Server
1. Sender (Alice):
o Uses a traditional mail server to send an email to the recipient's mail server via
SMTP.
2. Receiver (Bob):
o Has an account on a web-based mail server.
o Retrieves emails from the web server using HTTP instead of POP3 or IMAP4.
o Workflow:
▪ Bob sends an HTTP request to the website to log in.

Chethana H R, Assistant Professor Dept. of CSE, RNSIT 34


▪ After authentication, the list of emails is sent in HTML format.
▪ Individual emails are retrieved using additional HTTP transactions.

Case II: Web-Based Mail Servers on Both Ends


1. Sender (Alice):
o Uses HTTP to send an email to her web server.
o The web server acts as an SMTP client, forwarding the email to the recipient's
mail server (Bob's server) using SMTP.
2. Receiver (Bob):
o Retrieves emails from his web server using HTTP transactions.
3. Key Protocols:
o SMTP: Transfers emails between the sender's and receiver's servers.
o HTTP: Handles interactions between users and their respective web servers.

Key Differences from Traditional Mail


• HTTP replaces POP3/IMAP4 for mail retrieval.
• HTML format is used for email presentation in the browser.

Chethana H R, Assistant Professor Dept. of CSE, RNSIT 35


4. TELNET
• TELNET (Terminal Network) is a remote logging protocol enabling users to log into a
remote server and access its services.
• Purpose: Provides a generic client/server pair for accessing remote resources without
needing specialized client/server programs for every service (e.g., Java compiler usage on
a university server).

Features of TELNET

1. Plaintext Communication:
o Data, including login credentials, is sent without encryption.
o Vulnerable to hacking through eavesdropping.
2. Authentication:
o Requires a login name and password to access the remote server.
3. Use Cases:
o Historical: Once widely used for remote access to servers.
o Current: Used by network administrators for diagnostic and debugging tasks
despite security limitations.

Limitations
o Lack of encryption makes TELNET susceptible to unauthorized access.
o Replaced by Secure Shell (SSH), which offers encrypted communication.

Local vs. Remote Logging


1. Local Logging:
Chethana H R, Assistant Professor Dept. of CSE, RNSIT 36
o
User logs into a local system via a terminal or terminal emulator.
o Process:
▪ Keystrokes are processed by the terminal driver and passed to the OS.
▪ OS interprets input and invokes appropriate programs.
2. Remote Logging:
o User logs into a remote system to access applications or utilities.
o Process:
▪ Keystrokes are sent to the local OS but not interpreted.
▪ Forwarded to TELNET client, converted to NVT characters, and
transmitted over the Internet.
▪ Remote TELNET server receives and converts the NVT characters into
the format the remote OS understands.
▪ A pseudoterminal driver simulates input from a physical terminal,
enabling the OS to process the input.

Network Virtual Terminal (NVT) : The mechanism to access a remote computer is complex.
This is because every computer and its operating system accepts a special combination of
characters as tokens. For example, the end-of-file token in a computer running the DOS
operating system is Ctrl+z, while the UNIX operating system recognizes Ctrl+d. We are dealing
with heterogeneous systems. If we want to access any remote com puter in the world, we must
first know what type of computer we will be connected to, and we must also install the specific
terminal emulator used by that computer. TELNET solves this problem by defining a universal
interface called the Network Virtual Terminal (NVT) character set. Via this interface, the client
TELNET translates characters (data or commands) that come from the local terminal into NVT
form and delivers them to the network. The server TELNET, on the other hand, translates data
and commands from NVT form into the form acceptable by the remote computer.

1. Purpose:

Chethana H R, Assistant Professor Dept. of CSE, RNSIT 37


oStandardizes communication between heterogeneous systems by using a universal
character set.
o Eliminates the need to know the specifics of the remote system or install its
terminal emulator.
2. Functionality:
o TELNET client converts local characters/commands to NVT form and sends
them to the network.
o TELNET server converts NVT form characters/commands into the format used
by the remote system.
3. Character Sets:
o Data Characters (NVT ASCII):
▪ 8-bit characters; lower 7 bits follow US ASCII; highest bit is 0.
o Control Characters:
▪ 8-bit characters with the highest bit set to 1.

TELNET Options
1. Negotiation:
o Client and server negotiate optional features before or during the session.
o Supports sophisticated terminals with advanced features while providing defaults
for simpler terminals.

User Interface
1. Simplified Commands:
o Operating systems like UNIX provide user-friendly TELNET commands (e.g., as
listed in Table 26.11).
o Enables easy interaction with remote systems through a standardized interface.

Benefits of TELNET
• Provides access to remote systems without the need for specialized client/server pairs for
each application.
• The NVT character set simplifies interaction with diverse operating systems and
terminals.
User Interface ; The operating system (UNIX, for example) defines an interface with user-
friendly commands. An example of such a set of commands can be found in Table 26.11.

Chethana H R, Assistant Professor Dept. of CSE, RNSIT 38


SECURE SHELL (SSH)

Secure Shell (SSH) is a secure application program that can be used today for several purposes
such as remote logging and file transfer, it was originally designed to replace TELNET. There
are two versions of SSH: SSH-1 and SSH-2, which are totally incompatible. The first version,
SSH-1, is now deprecated because of security flaws in it. In this section, we discuss only SSH-2.
SSH is an application-layer protocol with three components, as shown in Figure 26.25.

SSH Transport-Layer Protocol (SSH-TRANS) : SSH first uses a protocol that creates a
secured channel on top of the TCP. This new layer is an independent protocol referred to as
SSH-TRANS. When the procedure implementing this protocol is called, the client and server
first use the TCP protocol to establish an insecure connection. Then they exchange several
security parameters to establish a secure channel on top of the TCP.
1. Privacy or confidentiality of the message exchanged .
2. Data integrity, which means that it is guaranteed that the messages exchanged between the
client and server are not changed by an intruder.
3. Server authentication, which means that the client is now sure that the server is the one that it
claims to be.
4. Compression of the messages, which improves the efficiency of the system and makes attack
more difficult.

SSH Authentication Protocol (SSH-AUTH) :


• Authenticates the client for the server after the secure channel is established.
• Similar to authentication in Secure Socket Layer (SSL).
• The client sends a request message to the server containing:
o Username.
o Server name.
o Authentication method.
o Required authentication data.
• The server responds with either:
o Success message: Confirms client authentication.
o Failed message: Client must resend a new authentication request

Chethana H R, Assistant Professor Dept. of CSE, RNSIT 39


SSH Connection Protocol (SSH-CONN):
• Provides additional functionality after the secure channel is established and both client
and server are authenticated.
• Key Feature: Multiplexing:
• Allows multiple logical channels to be created over the single secure channel.
• Each logical channel can serve different purposes, such as:
o Remote logging.
o File transfer.

Applications of SSH :
• SSH for Remote Logging
• SSH for File Transfer : One of the application programs that is built on top of SSH for
file transfer is the Secure File Transfer Program (sftp). The sftp application program uses
one of the channels pro vided by the SSH to transfer files. Another common application
is called Secure Copy (scp). This application uses the same format as the UNIX copy
command, cp, to copy files.
• Port Forwarding : One of the interesting services provided by the SSH protocol is port
forwarding. We can use the secured channels available in SSH to access an application
program that does not provide security services. Applications such as TELNET and
Simple Mail Transfer Protocol (SMTP), can use the services of the SSH port forwarding
mechanism.
The SSH port forwarding mechanism creates a tunnel through which the
messages belonging to other protocols can travel. For this reason, this mechanism is
sometimes referred to as SSH tunneling. Figure 26.26 shows the concept of port
forwarding for securing the FTP application. The FTP client can use the SSH client on
the local site to make a secure connection with the SSH server on the remote site. Any
request from the FTP client to the FTP server is carried through the tunnel provided by
the SSH client and server. Any response from the FTP server to the FTP client is also
carried through the tunnel provided by the SSH client and server.

Chethana H R, Assistant Professor Dept. of CSE, RNSIT 40


Format of the SSH Packets :

• The length field defines the length of the packet but does not include the padding.
• One to eight bytes of padding is added to the packet to make the attack on the security
provision more difficult.
• The cyclic redundancy check (CRC) field is used for error detection.
• The type field designates the type of the packet used in different SSH protocols.
• The data field is the data transferred by the packet in different protocols.

DOMAIN NAME SYSTEM (DNS)

Purpose of DNS
1. Mapping Names to IP Addresses:
o Human-friendly names (e.g., afilesource.com) are mapped to machine-friendly IP
addresses required for communication.
o Similar to a phone directory mapping names to numbers.
2. Why Not a Central Directory?:
o The Internet's scale makes a central directory impractical.
o Central failure risks collapse of the entire system.
o Solution: Distributed directory system, where multiple DNS servers share the
information.
DNS Process

Chethana H R, Assistant Professor Dept. of CSE, RNSIT 41


Components:
o DNS Client: Resides on the user’s computer and makes requests.
o DNS Server: Responds to mapping queries.
Steps to Map Host Name to IP Address:
1. User enters the hostname (e.g., afilesource.com) in the application (e.g., file
transfer client).
2. File transfer client sends the hostname to the DNS client.
3. DNS client queries a known DNS server (its IP is pre-configured at boot).
4. DNS server responds with the corresponding IP address of the hostname.
5. DNS client passes the IP address to the file transfer client.
6. File transfer client uses the IP address to connect to the desired server.

Benefits of DNS
• Scalability: Distributed architecture avoids overloading a single server.
• Resilience: No single point of failure ensures continuity of service.
• Convenience: Users interact with familiar names instead of numeric addresses.

Name Space :

• Ensure unambiguous naming of machines by binding unique names to unique IP


addresses.
• Names must be carefully managed to avoid duplication and ambiguity.

Types of Name Spaces


1. Flat Name Space:
o Names are sequences of characters with no structure.
o May have common sections, but they lack meaning.
o Limitation: Unsuitable for large systems (e.g., the Internet) because it requires
centralized control, which is impractical.
2. Hierarchical Name Space:
o Names are composed of multiple parts, representing organizational structure.
Example: Parts may define nature of the organization, name of the organization,
and internal departments.
▪ Central authority assigns the initial parts (e.g., organization type and name).
▪ Organizations manage their internal parts, ensuring uniqueness within their
namespace.
▪ Scalable and avoids ambiguity, as names are distinct across organizations.

Example:
• Two organizations, first.com and second.com, both name a computer caesar.
• Final names are:
o caesar.first.com
o caesar.second.com

Chethana H R, Assistant Professor Dept. of CSE, RNSIT 42


• Result: Unique and distinguishable names.

Domain Name Space : To have a hierarchical name space, a domain name space was designed.
In this design the names are defined in an inverted-tree structure with the root at the top. The tree
can have only 128 levels: level 0 (root) to level 127 (see Figure 26.29).

Label:
• Each node in the DNS tree has a label (string up to 63 characters).
• The root label is a null string (empty).
• Uniqueness: Children of the same node must have unique labels to ensure unique domain
names.
Domain Name:

• Full domain names consist of labels separated by dots (.).


• Domain names are read from the node to the root, with the last label being the root (a null
string, represented as a dot) as shown in figure 26.30.
• Fully Qualified Domain Name (FQDN): Ends with a dot and represents the complete
path to the root.
• Partially Qualified Domain Name (PQDN): Does not reach the root and is resolved
using a local suffix.

Chethana H R, Assistant Professor Dept. of CSE, RNSIT 43


Hierarchy of Name Servers
Centralized storage of the entire DNS hierarchy is inefficient and unreliable.
Hierarchical Name Servers:
• Divide the DNS hierarchy into domains and subdomains, with servers responsible for
different zones.
• Delegation ensures scalability and reliability.

DNS Hierarchy in Practice


• A root server delegates to TLD servers (e.g., .com, .org), which delegate further to
domain-level servers.
• Each level is responsible for its portion of the hierarchy, ensuring a scalable and fault-
tolerant system.

Chethana H R, Assistant Professor Dept. of CSE, RNSIT 44


DNS in the Internet: In the Internet, the domain name space (tree) was originally divided into
three different sections: generic domains, country domains, and the inverse domains.

Generic Domains : The generic domains define 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 (see Figure 26.34).

Country Domains : The country domains section uses two-character country abbreviations (e.g.,
us for United States). Second labels can be organizational, or they can be more specific national
designations. The United States, for example, uses state abbreviations as a sub division of us
(e.g., ca.us.). Figure 26.35 shows the country domains section. The address uci.ca.us. can be
translated to University of California, Irvine, in the state of California in the United States.

Resolution in DNS : Name-address resolution refers to the process of mapping a domain name
to its corresponding IP address (or vice versa). This process is essential for network
communication. DNS operates as a client-server application, where:
1. A DNS resolver (client) on the requesting host initiates the process.
2. The resolver interacts with a local or remote DNS server to obtain the mapping.
Chethana H R, Assistant Professor Dept. of CSE, RNSIT 45
3. The process concludes either with a resolution (successful mapping) or an error message.

There are two types of resolution mechanisms: Recursive Resolution and Iterative Resolution.

Recursive Resolution
• Process:
1. The resolver sends a query to the local DNS server.
2. If the local server lacks the answer, it forwards the query to a root DNS server.
3. The root server refers the query to a top-level domain (TLD) server (e.g., .com).
4. The TLD server directs the query to the authoritative DNS server for the
destination domain.
5. The authoritative server resolves the query and sends the IP address back through
the chain (TLD server → root server → local server → resolver).
6. The local DNS server may cache the result for future requests.
• Example:
o A host (some.anet.com) needs the IP of engineering.mcgraw-hill.com.
o The recursive resolution flow:
▪ Local DNS server → Root DNS server → TLD server (.com) →
McGraw-Hill's DNS server → IP address returned via the same path.

Iterative Resolution
• Process:
1. The resolver queries the local DNS server.
2. If the local server doesn’t have the answer, it replies with the IP address of the
next server (e.g., a root server).
3. The resolver then queries the next server directly.
4. This process repeats with referrals to subsequent servers (e.g., TLD server,
authoritative server) until the resolver receives the final mapping.
• Example:
o Using the same scenario:
▪ The resolver first queries the local DNS server.
▪ The local server provides the IP address of the root server.
Chethana H R, Assistant Professor Dept. of CSE, RNSIT 46
▪ The resolver queries the root server, which provides the TLD server's IP.
▪ The resolver queries the TLD server, which refers to McGraw-Hill's DNS
server.
▪ The resolver queries the authoritative server for the final IP address.

DNS Caching:

• DNS servers use caching to store mappings temporarily after resolving queries to reduce
search time and improve efficiency.
• If the same or another client requests the same mapping, the server retrieves it from cache
memory, marking the response as "unauthoritative" to indicate it's not from an authoritative
source.
• Cached mappings may become outdated, leading to incorrect responses.
▪ Solution - Time to Live (TTL):
▪ Authoritative servers include a TTL value with each mapping, specifying how
long it can be cached.
▪ After the TTL expires, the mapping is invalidated, requiring a fresh query to the
authoritative server.
• DNS servers maintain TTL counters for each cached mapping and periodically purge expired
entries to prevent outdated information.

Resource Records : The zone information associated with a server is implemented as a set of
resource records. In other words, a name server stores a database of resource records. A resource
record is a 5-tuple structure, as shown below:
(Domain Name, Type, Class, TTL, Value)
The domain name field is what identifies the resource record. The value defines the information
kept about the domain name. The TTL defines the number of seconds for which the information
is valid. The class defines the type of network; we are only interested in the class IN (Internet).
The type defines how the value should be interpreted.

Chethana H R, Assistant Professor Dept. of CSE, RNSIT 47


DNS Messages : To retrieve information about hosts, DNS uses two types of messages: query
and response. Both types have the same format as shown in Figure 26.38.

• Identification Field: Used by the client to match responses with their corresponding queries.
• Flag Field: Indicates whether the message is a query or response and includes error status.
• Header Fields: Define the number of records of each type in the message.
• Question Section: Contains one or more question records; present in both query and
response messages.
Chethana H R, Assistant Professor Dept. of CSE, RNSIT 48
• Answer Section: Includes one or more resource records; present only in response messages.
• Authoritative Section: Provides information about authoritative servers for the query.
• Additional Information Section: Offers extra details to assist the resolver in processing the
query.

Registrars :

• New domains are added to DNS through registrars, which are commercial entities accredited
by ICANN.
• Registrars ensure the requested domain name is unique before adding it to the DNS database.
• Required Information for Registration:
• Name of the server.
• IP address of the server.
• For example, an organization "wonderful" with a server "ws" and IP "200.200.200.5"
would provide this information to the registrar.
Domain name: ws.wonderful.com IP address: 200.200.200.5

Dynamic DNS (DDNS):

Dynamic DNS (DDNS) was developed to handle the increasing frequency of address changes on
the Internet. Unlike traditional DNS, which requires manual updates to the master file for
changes like adding or removing hosts or updating IP addresses, DDNS updates the DNS master
file dynamically. When a binding between a name and an address is established, the information
is sent (usually via DHCP) to a primary DNS server, which updates the zone. Secondary servers
are notified of changes either actively (via messages) or passively (via periodic checks) and then
request zone transfers.
To ensure security and prevent unauthorized changes, DDNS can incorporate authentication
mechanisms.
DNS is critical to Internet infrastructure, supporting essential applications like web access and
email. It is vulnerable to several attacks:
1. Data Profiling: Attackers can read DNS responses to analyze user behavior.
Confidentiality can prevent this.
2. Spoofing: Attackers can intercept and modify DNS responses or create bogus ones,
redirecting users. Message origin authentication and integrity mechanisms address this.
3. Denial-of-Service (DoS): Attackers can flood DNS servers, causing crashes. DNS
caching helps mitigate this, though DNSSEC lacks specific DoS protections.
DNSSEC enhances security with digital signatures for authentication and integrity but does not
provide confidentiality for messages.

Chethana H R, Assistant Professor Dept. of CSE, RNSIT 49

You might also like