CN Notes
CN Notes
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:
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.
• 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. 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.
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).
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 Delay: Time taken for data to reach its destination. Optimizing both often leads to
trade-offs.
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).
2. Physical Topology: Refers to how devices are physically arranged in a network. Four main
topologies include:
o Mesh Topology:
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.
o Bus Topology:
o Ring Topology:
▪ Disadvantages: A break in the ring can disable the entire network, though
dual rings or switches can mitigate this.
3. NETWORK TYPES
Which is used to connect networks to form an internetwork (a network of networks).
Characteristics:
Examples: The Internet itself is a WAN, Private networks connecting different company
branches.
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:
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.
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
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.
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.
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.
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.
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.
3. Message Switching:
o Entire messages are stored and forwarded from one switch to another (obsolete in
modern networks).
Components:
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
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.
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.
• Data transmission over the internet where multiple types of data (emails, videos, web
pages) are transmitted using different protocols at each layer.
• Telecommunication systems, where layered protocols ensure voice signals are transmitted
efficiently and correctly.
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.
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.
In protocol layering, the objects processed by each layer at both communicating sites must be
identical. For instance:
Consistency in the objects at each layer ensures proper communication and processing across
different 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.
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.
In this scenario, imagine that Host A (the source) communicates with Host B (the destination).
The communication process involves five devices:
Each of these devices operates at different layers of the TCP/IP protocol stack, depending on its
role in the network:
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:
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
• 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.
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.
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."
Another important way to understand these connections is by considering the data units created
at each layer.
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.
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.
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.
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.
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.
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.
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.
• 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.
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
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.
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.
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.
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.
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.
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.
4. Link Layer:
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.
• 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:
• 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.
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.
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.
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
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
• 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.
• 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.
This design helps coaxial cables transmit signals with less interference and at higher frequencies
compared to twisted-pair cables.
Coaxial cables are classified based on Radio Government (RG) ratings. Each RG number specifies
certain physical characteristics of the cable, such as:
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
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:
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.
Properties of Light
• 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.
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.
Propagation Modes
Optical fibers use two main modes for light propagation:
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.
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.
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.
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.
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.
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
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.
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
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.
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.
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:
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.
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.
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.
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.
Advantages:
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.
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).
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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?
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?
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.
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.
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.
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.
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.
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
Solution
• 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)
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
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.
Encoder
The encoder takes the dataword and augments it with n - k number of 0s. It then divides the
augmented dataword by the divisor.
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.
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
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.
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.
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.
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.
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.
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.
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.
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.
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.
The sender sends one frame and waits for feedback from the receiver. When the ACK
arrives, the sender sends the next frame.
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.
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.
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,
Control Field
The control field determines the type of frame and defines its functionality.
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.
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
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.
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:
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:
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
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
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
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
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.
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.
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
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.
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.
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.
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.
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
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.
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.
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.
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.
1. NETWORK-LAYER
2.1 Introduction
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.
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.
• 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.
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.
o QoS ensures the network layer delivers data with a certain performance level,
managing delays, throughput, and packet loss.
Today, a packet-switched network can use two different approaches to route the packets: the
datagram approachand the virtual circuit approach.
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:
o Acknowledgment Packet:
1. Destination B sends an acknowledgment packet back to Router R4:
▪ Router R4 fills the outgoing label as 77.
• 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.
3. Teardown Phase
• 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.
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).
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
• An IPv4 address is a 32-bit identifier used to uniquely define the connection of a device
(host or router) to the Internet.
• 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.
• Classful Addressing divides the IPv4 address space into five classes (A, B, C, D, E),
designed to accommodate different network sizes.
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.
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.
• 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.
• Simplicity: The class of an address is easily identifiable from the address itself.
• 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.
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.
• 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.
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.
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.
• 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.
• 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.
1. Overview of Subnetting:
2. Designing Subnets:
Example:
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.
• 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.
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:
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.
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
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
This method ensures efficient utilization of IP addresses while allowing for potential future
expansions.
IPv4 includes several special-purpose addresses used for specific functions in networking. Here
are five important types:
• 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).
• 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.
• 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.
These addresses serve distinct roles in networking, ensuring proper communication, testing, and
private address use within internal networks.
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.
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 is a client-server protocol in which the client sends a request message and the server
returns a response message
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 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:
Figure 18.28 shows the transition diagram with the main states.
The DHCP client progresses through several states as it acquires and manages its IP address
lease. Key stages and timers include:
DHCP Timers
• 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.
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:
• 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.
• 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.
• 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.
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.
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
3. Flow Label
4. Payload Length
5. Next Header
6. Hop Limit
• 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.
• 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.
• 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).
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.
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.
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).
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.
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.
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.
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.
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
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.
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.
• 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.
• 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.
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
➢ 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.
The Stop-and-Wait protocol is a connection-oriented protocol that provides flow and error control.
Sequence Numbers
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.
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.
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.
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.
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.
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
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.
➢ 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.
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.
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.
❑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.
❑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.
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.
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.
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.
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
▪ 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.
▪ 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.
▪ 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.
▪ 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
▪ The protocol balances the advantages and disadvantages. It now defines that the acknowledgment
should not be delayed by more than 500 ms.
If sender receives 3 additional ACKs for same data (“triple duplicate ACKs”), resend unACKed segment
with smallest seq #
▪ 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.
▪ 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.
▪ 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:
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:
1. Slow start.
2. Congestion Avoidance.
3. Fast recovery
▪ when connection begins, increase rate exponentially until first loss event:
• initially cwnd = 1 MSS
In the slow-start algorithm, the size of the congestion window increases exponentially until it reaches a
threshold.
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.
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 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.
The early TCP, known as Taho TCP, used only two different algorithms in their conges tion policy: slow
start and congestion avoidance.
• 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:
• 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).
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 =
Reno TCP
• Time-out: Treated as a severe congestion signal. TCP resets to the slow-start state, restarting with
cwnd = 1 MSS.
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.
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.
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:
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.
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.
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 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.
• 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.
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:
• 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.
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.
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.
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.
▪ 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.
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.
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.
• 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.
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.
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.
Response Message:
• The HTTP response message consists of a status line, header lines, a blank line, and
sometimes a body.
Conditional Request:
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.
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.
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).
4. ELECTRONIC MAIL
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.
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)
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.
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
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.
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:
Content-ID : Provides a unique identifier for the entire message in environments where multiple
messages are present.
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.
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:
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.
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.
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.
• 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.
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
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 :
Example:
• Two organizations, first.com and second.com, both name a computer caesar.
• Final names are:
o caesar.first.com
o caesar.second.com
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:
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.
• 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) 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.