Download as pdf or txt
Download as pdf or txt
You are on page 1of 537

M.Sc.

(Computer Application) Sem-II


Computer Networks

Chapter 1

Introduction to Computer Networks

Prof. Vidya Bankar


Dr. D. Y. Patil ACS College Pimpri Pune-18.
Data Communication

Communication:
Sharing information, Sharing can be local (face to face) or
remote (over distance)
Tele communication:
(telephone, television, telegraphy) means communication at a
distance remote communication. (tele: far)
Data communication:
exchange of data between two devices via some form of
transmission medium such as a wire cable
Communicating devices for data communication to occur:
made up of Hardware (physical equipment ) and Software
(programs)
Characteristics of Data Communication
The effectiveness of data communication system depends on following
four fundamental characteristics:

• Delivery:
System must deliver data to the correct destination. Data must be
received by only intended device or user.
• Accuracy:
The system must deliver data accurately because altered and incorrect
data is unusable.
• Timeliness:
The system must deliver data in a timely manner called real-
time transmission. Data delivered later are useless.
• Jitter:
Variation in the packet arrival time. It is the uneven delay in the
delivery of audio or video packets.
Components of Data communication

Above figure shows five components of Data Communication


1. Message: It is the information (data) to be communicated, it includes Text,
Numbers, Pictures, Audio or Video
2. Sender: It is a device that sends data message. It can be a computer,
workstation, telephone, handset etc.
3. Receiver: It is device that receives the message. It can be a computer,
workstation, telephone, handset etc.
4. Transmission Medium: It is a physical path which message travels from
sender to receiver. It includes different cable and radio waves.
5. Protocol: It is a set of rules that governs data communications. It represents an
agreement between the communicating devices. Without a protocol two devices
may be connected but not communicating.
Data representation
Information today comes in different forms such as text,
numbers, images, audio, and video
• Text: In data communication, text is represented as a bit pattern, a sequence of bits
(0s or 1s). Different sets of bit patterns have been designed to represent text
symbols.

• Numbers: represented by bit pattern (binary number)


• Images : represented by bit patterns , matrix of pixels (picture element), where each
pixel is a small dot. The size of pixel depends on the resolution. After an image is
divided into pixels, each pixel is assigned a bit pattern.
• Audio: represent sound by continuous (analog) signal, audio refers to the recording or
broadcasting of sound or music. It is continuous, not discrete.

• Video: can be analog or digital signal, video refers to the recording or broadcasting of
a picture or movie .
Types of data flow
Communication between two devices can be Simplex,
Half-duplex or Full-duplex. It refers to the direction in
which data moves between two devices.
1. Simplex: In this mode, Communication is unidirectional. (one-way-street).
Only one of the two devices on a link can transmit; the other can only receive.
Data flows in one direction only.

Ex: As Keyboard (only input) and monitors (only output), TV, radio
In this mode entire capacity of the channel is used to send data in one
direction.
A B
Simplex A to B only
2. Half duplex:
Each station can both transmit and receive , but not at the same time. When one
device is sending the other can receive and vice versa. Data can flow in both
directions but not simultaneously.

Ex: Walkie-talkie is an example of half duplex.


In this mode entire capacity of the channel is taken over by whichever of
the two devices is transmitting at the time.

A B
Half-duplex A to B or B to A
3. Full-Duplex:
Both stations can transmit and receive simultaneously. Like two-way-street with
traffic flowing in both directions at the same time.

Ex: Telephone Network is an example of Full-duplex.


In this mode, signals going in one direction share the capacity of the link
with signals going in the other direction, that is channel capacity has to
be shared by the two entities, one for each direction.

A B
Full-duplex A to B and B to A
Computer Network
Network:
Network is a set of devices (often referred to as nodes) connected
by communication links. A node can be a computer, printer, or
any other device capable of sending and/or receiving data
generated by other nodes on the network.
Computer Network:
A computer network is essentially collection of autonomous
computers interconnected by a single technology. Two computers
are said to be interconnected if they are able to exchange
information. It is a system which allows communication among
the computers connected in the network.
Goals of Computer Network
1. Resource sharing: Make all programs, data and equipment
available to anyone on the network regardless of the physical
location of the resource and user.
2. Provide high reliability: Ensures that network devices, data
and links are available at all time by having alternative sources
of supply i.e. backup servers, replication of files on more than
one machine to ensure availability. Useful for military,
banking, air traffic control application.
3. Distribution of workload: Big and complex task can be
distributed among multiple processors in the network.
4. Saving money: It is economical to set up network of a large
number of small computers than to invest in a few large ones
like mainframe.
5. Expandability: Network size and performance enhanced
gradually by adding more processors and communication
devices.
6. Powerful communication medium: people in distant
geographical areas can easily exchange and share information,
ideas and technology to enhance communication.
Advantages of Computer Network
1. Increased speed: network provide fast means for sharing and
transfer of files as compare to CDs and Pen drive
2. Reduced cost: popular versions of software usable for the
entire network as compare to individual licensed copies.
3. Improved security: protect program and files from illegal
copying by restricting access to authorized users only.
4. Centralized software management: All software can be
loaded on one computer instead of installing updates and
tracking files on independent computers. All other computers
can use centralized software.
5. Electronic mail: computer network makes hardware available
which is necessary to install an email system for person-to-
person communication.
6. Flexible access: It is possible for authorized users to access
their files from any computer connected on the network.
Disadvantages of Computer Network
1. High cost of installation: Initial installation cost of
network is high due to cost of cables, network cards,
computers and cost of services of technicians
2. Requires time for administration: Computer networks
needs proper and careful administration and maintenance
which is time consuming job.
3. Failure of server: If the file servers “goes down” then the
entire network comes to standstill.
4. Cable faults: Cable faults can paralyze a network.
Physical Structure
The physical structure of a network refers to the
way in which network elements are connected.
Transmission technology is an important aspect
which guides the design of networks.

Transmission Technology:
This refers to the way in which two devices can
be connected.

Two types of transmission technology:


1. point-to-point
2. Broadcast
1. Point-to-point
•A point-to-point connection provides a dedicated link between two
devices. The entire capacity of the link is reserved for transmission
between those two devices.
•The link between the two devices or machines may be a physical
cable or wireless media such as microwave or satellite link.
•In this network data packet may have to visit one or more
intermediate machines to go from source to destination.
•Network located over wide geographical areas (such as WAN) use
point-to-point transmission.

change T.V channel by infrared remote control is


point- to -point connection
2. Broadcast
These networks have a single communication channel that is
shared by all the machines on the network, such connection is also
called as multipoint or multidrop connection.
In a broadcast system, a packet sent by one machine is received by
all others. If packet is intended for other machine, it is ignored.
It is possible to transmit data to a subset of the network that is
transmission to only a group of few machines known as
multicasting. Point-to-point transmission with one sender and one
receiver is called unicasting.
Small localized networks (such as LAN) use broadcast
transmission.

Single sender many receivers example TV, Radio


Network Topologies
• Network topology refers to the manner in which devices are
connected in the network.
• It is the geometric representation of all links and devices in the
network.
1. Bus Topology
• This is a multipoint topology, that is all the devices in a network are
linked by a single cable which acts like a backbone.
• The devices are connected to the cable by drop lines and taps.
• When one computer sends a signal on the cable; all the computers on
the network receive the information. Intended destination computer
only accept information all others will reject information.
• Bus topology speed is slow because only one computer can send a
message at a time.
• It needs n+1 links, n for n computers and 1 for backbone.
• Cable end absorbs electrical energy and stop reflection.
Bus Topology Advantages:
• Easy to install.
• Main cable can be laid out to attach new node when
required.
• Less cabling required as compare to mesh.
Bus Topology Disadvantages:
• As the signal travels along the backbone, it becomes
weaker. Hence there is limit on the number of devices that
a bus can support.
• It is difficult to identify and isolate fault(determine cause
of a problem).
• Signal reflection/loss of signal at taps cause degradation
in quality of the signal.
• A fault or break in the bus cable stops all transmission.
2. Star Topology
• Each device has a dedicated point-to-point link only to a central
controller device that is hub or switch.
• Controller acts as an exchange, which relays (receive and pass
on) data from one device to another.
• Since no direct connections among the computers, two devices
cannot communicate directly.
• If one device want to send data to another , it send it to the hub,
which send it to other device, communication is done through
controller.
• It is used in concentrated networks, where endpoints are directly
reachable from a central location.
Star Topology Advantages:
• Since each device requires only one link and one I/O
port to the controller, it is less expensive.
• Easy to install and reconfigure.
• It is robust because even if one link fails, the other
remain active.
• Fault identification and isolation is easy.
Star Topology Disadvantages:
• Performance of network depends entirely on the hub. If
the hub fails entire network stops.
• Speed of communication depends upon number of
devices connected to the hub.
• Cabling cost is more since cables must be pulled from
all computers to the central hub.
3. Mesh Topology
• It is also called as fully interconnected topology.
• Every device has a dedicated point-to-point link to
every other device in the network.
• Fully connected mesh network has n(n-1)/2 physical
connection to link n devices where each physical link
allows communication in both directions (duplex
mode).
• Every device on the network must have n-1 input/output
(I/O) ports.
Mesh Topology Advantages:
• It offers highest reliability, privacy and security. Every
message travels along a dedicated line, only the intended
recipient sees it.
• Traffic problems are eliminated because there is a
dedicated link between any two devices which guarantees
that each connection can carry its own data load.
• Mesh topology is robust because the network does not
crash if one link becomes unusable.
• Fault identification and fault isolation is easy. This
enables the network manager to discover the precise
location of fault and aids in finding its cause and solution.
Mesh Topology Disadvantages:
• Main disadvantage is the amount of cabling required to
interconnect the devices and the number of I/O ports
needed at each device.
• Installation of new devices and reconnection is difficult.
• Mesh topology is expensive due to large number of
hardware requirement (cables/ports)
4. Ring Topology
• Each device has a dedicated point-to-point
connection only with the two devices on either side
of it.
• A signal is passed along the ring in one direction from
device until it reaches its destination. It has n links.
• Each device in the ring incorporate as repeater.
• Repeater: regenerates the signal.
• It receives a weakened signal, creates a copy, bit for
bit, at the original strength.

Repeater Repeater

Repeater Repeater

Repeater
Ring Topology Advantages:
• Since each device is linked only to its immediate neighbors, the
ring network is easy to install or reconfigure.
• Fault isolation is easy since the faulty device can be bypassed by
altering the connections.
• Only one device can send data at a time. The device which
wants to send data must capture a special frame called token.
Ring Topology Disadvantages:
•A break in the ring (such as disabled station) can disable the
entire network.
•The major constraint is the maximum ring length and the
number of devices connected.
•Since the traffic is unidirectional, data transfer is slow.
•Failure of one computer on the ring can affect the whole
network.
Categories of Networks
Computer network can be classified based on the
geographical area they cover, i.e. the area over which the
network is spread.
Following are three primary categories of networks:
LAN (Local-Area Network)
LAN is a network which is designed to operate over a small physical area such
as an office, factory or a group of buildings.
LAN
• Privately owned network connecting devices within a
single room, building or campus, extending upto a few
kilometers in size.
• LANs designed to allow resources to be shared
between PCs or workstations. The resources may be
hardware (e.g. printer) or software ( applications
program) or data.
• In LANs one of the computers has a large capacity drive
and becomes a server to other clients.
• S/W stored on server and used as needed by the whole
group.
• LAN size determined by licensing restrictions( Number
of users per copy of S/W)
LAN
• LANs are restricted in size which makes it possible to
determine transmission speed and also simplifies network
management.
• LAN is used for connecting two or more personal
computers through a communication medium such as
twisted pair, coaxial cable etc.
• The most common LAN topologies are Bus, Ring and
Star.
• Traditional LANs have data rates of 10Mbps to 100
Mbps. Newer LANs are capable of speed upto 10 Gbps.
• Many organizations have multiple LANs which can be
connected by devices like bridges or switches.
• A bridge is used to connect two LAN segment and passes
data from one segment to another. It helps in extending
LAN as well as segmenting a LAN into smaller LANs.
• Local Area Network provides higher security.
Advantages of LAN
1. High reliability: Failure of individual computer does not
affect the entire LAN.
2. It is possible to add a new computer easily.
3. The transmission of data is at a very high rate.
4. Sharing of peripheral devices such as printer is possible.
Applications of LAN
1. File transfer and file access
2. Office automation: create, collect, store, manipulate and
relay office information.
3. Document distribution
4. Remote access to database
5. Electronic message handling
6. Distributed computing
MAN (Metropolitan Area Network)
A MAN is a network which extends over an entire city.
MAN
•MAN may be a single network such as common cable
television network, or it may connect several LANs into
a large network.
•A company may use a MAN to connect all LAN’s in its
offices spread throughout a city.
•The ownership of MAN may be wholly private or a
public service company such as local telephone company.
•MAN is a network with the size between a LAN and a
WAN.
•e.g. Network between Banks in a city
WAN (Wide Area Network)
• A WAN provides long distance transmission of data, image,
audio and video information over large geographic areas that
may comprise a state, a country, a continent or even the
whole world.
•WANs generally use public, private or leased
communication equipments or combination.
•Example: A 4G mobile network is widely used across country, A
bank private network that connects many offices.
WAN
•A Wide Area Network is not limited to a single location, but it
spans over a large geographical area through a telephone
line, fiber optic cable or satellite links.
•The switched WAN connects the end systems, which usually
comprise a router that connects to another LAN or WAN.
•WANs typically use point-to-point transmission technology.
•The point-to-point WAN is normally a line leased from a
telephone or cable TV provider that connects a home
computer or small LAN to an Internet Service Provider to
provide Internet access.
•The internet is one of the biggest WAN in the world.
•A Wide Area Network is widely used in the field of
Business, government, and education.
Internetwork : Interconnections of networks
A collection of interconnected networks is called as an
internetwork or internet. Two or more computer
network LANs or WAN or computer network segments are
connected using devices, and they are configured by a
local addressing scheme. This process is known
as internetworking.
• Today it is very rare to see a LAN or a MAN in
isolation; they are connected to one another called
as internetwork.
• There exist a large number of diverse and
heterogeneous networks. The uses of one type of
network often require to communicate with uses of
other.
• Individual networks are joined into internetworks by
the use of internetworking devices like bridges,
routers and gateways.
• Gateways are the special computers which are
required to make the connection and translation in
terms of hardware and software between the
incompatible networks
Types Of Internetwork:
1. Extranet:
• It is used for information sharing.
• The access to the extranet is restricted to only those
users who have login credentials.
• An extranet cannot have a single LAN, at least it must
have one connection to the external network.
2. Intranet:
• An intranet is a private network.
• An intranet belongs to an organization which is only
accessible by the organization's employee or members. The
main aim of the intranet is to share the information and
resources among the organization employees.
• An intranet provides the facility to work in groups.
Protocols and Standards
Network Software:
Network software is an equally important aspect of
computer networks.
Two terms are widely used regarding network software:
1. Protocols 2. Standards
Protocols:
A protocol is a set of rules that governs data
communication. A protocol is an agreement between
communicating entities on how communication is to take
place. A protocol defines: What is communicated, How
it is communicated, When it is communicated.
A communicating entity is anything capable of sending and
receiving information.
A protocol has following three key elements:
1. Syntax
2. Semantics
3. Timing
1. Syntax:
The term syntax refers to the structure or format of the
data, meaning the order in which they are presented.
Example:
A simple protocol might expect the first 8 bits of data to be
the address of the sender, the second 8 bits to be the
address of the receiver, and the rest of the stream to be the
msg itself.
2. Semantics:
The word semantics refers to the meaning of data. How
is a particular pattern to be interpreted, and what action is
to be taken based on that interpretation?
Example:
Does an address identify the route to be taken or the final
destination of the msg?

3. Timing:
The term timing refers to two characteristics:
When data should be sent?
How fast they can be sent?
Example:
If a sender produces data at 100 Mbps but the receiver
can process data at only 1 Mbps, the transmission will
overload the receiver and some data will be lost.
Standards:
Standards are essential in creating and maintaining an open
and competitive market for equipment manufacturers. Since
number of networks and network users has increased in the last
few decades there are a large number of equipment
manufacturers in the market today. To ensure that there is
compatibility between these devices, some standards have to
be followed so that data communication is possible.
Need for standards:
• To guarantee that the technology and processes used for data
communication operate at national as well as international
levels.
• Standards provide guidelines for equipment manufacturers,
vendors, government agencies and other service providers to
ensure that interconnectivity is achieved in international
communications.
Data communication standards fall into two categories:

i. de facto (by fact or by conventions):


Standards falling into this category are those which have not
been approved by any regulatory body but have been
adopted through widespread use.
Example: QWERTY layout is the de-facto standard for
keyboard.

ii. de jure (by law or by regulation):


These standards have been formally accepted by an
officially recognized body.
Example:
International Organization for Standardization (ISO)
American National Standards Institute (ANSI)
Institute of Electrical and Electronics and Engineers (IEEE)
Layer
The network software is designed or organized as a series of
layers or levels to reduce their design complexity. The
number of layers, their names and functions vary from
network to network.
Services
The purpose of each layer is :
• Offer certain services to the higher layers.
• Use the services of the layer below it.

A layer on one machine carries on a conversation only with


its corresponding layer on another machine that is layer 'n' on
one machine communicates only with layer 'n' on another
machine. The rules and conventions used for this
conversation are known as layer-n-protocol.
Peers
Corresponding layer entities on different machines are
called peers i.e. peers communicate using a protocol.
The peers may negotiate on different parameters in the
protocol like maximum packet size, timer values, etc.
Layers, Protocols and Interface

A set of layers and protocol is called Network Architecture.


Interface
• Between each pair of adjacent layers, there is an
interface. This defines which primitive operations
and services the lower layer offers to the upper
one. Interfaces should be clear-cut and the amount of
Information passed between the layers should be
minimum.
• Actual communication between layers occurs only
through the physical medium. Virtual
communication is depicted by dotted lines.
Sending a letter
Person A (French) Person B (German)

(Layer 3) Msg in French Msg in German (Layer 3)


A B

(Layer 2) (Layer 2)
Msg in English Msg in English
Translator Translator

(Layer 1) e-mail e-mail (Layer 1)


Secretary Secretary

Physical
Medium

Example: Multi-Layered Communication


Example of multi-layer communication:
•Let us consider that a person A speaking French wants to
send a message to B, speaking German.

•They will represent the highest layer of the layered model.

•At the lower level, there may be translators whose service


they will utilize to communicate. The translators will have to
agree upon a common language of communication, say
English.

•After translation, they may hand over the translated msg to


secretaries (at a lower layer) for transmission again, both
secretaries may choose a common transmission mode, i.e.
phone, fax, email, post etc.
•When the msg arrives at B's end, the secretary will
forward it to the translator who then converts it from
English to German.

•The advantage of breaking down the complexity into


distinct layers is that each layer has a definite function to
perform and it is independent of other layers. Thus, if the
protocol of one layer is changed, it will not affect the
working of the other layers.

•For example, if both the translators switch from


English to Spanish as the common language, it will not
affect the other layers.
Design issues for the layers:
•There should be a mechanism for identifying senders and
receivers. Some form of addressing is needed in order to
identify machines.
•Another designs issue is the rules for data transfer. In
some cases, data transfer is simplex; in others it may be
half duplex or full duplex.
•Both ends must agree upon the error detecting and
correcting methods to be used. Receiver must have some
way of telling the senders which msg have been received
correctly and which have not.
•In some communication channels, the messages are not
delivered in the same order that they are sent. So some
provisions have to be made, like to have sequence
numbers.
•Flow control is another design issue. A fast sender should
not be allowed to flood a slow receiver with data.
•When the msg is very long then there should be
mechanisms to fragment msgs, transmit and then
reassemble the fragments. On the other hand, if the data
units are very small, it is inefficient to transmit them
separately. Here, several small msgs to the same
destination are gathered into a single msg, transmitted
and then separated at the other end.
•Multiplexing and de-multiplexing needs to be done to
share a single communication channel among several
unrelated conversations.
•Routing is another design issue, when there exist multiple
paths from source to destination.
Types of services:
There are two types of services offered by layers.
1. Connection oriented Services
2. Connection less Services
Services
Connection oriented services:
Requires the user to first establish a connection, use the
connection and then terminate it. It is similar to the
telephone system.
This connection acts like a tube, the sender pushes data in at
one end and the receiver takes it out in the same order from
the other end. With this service, all data arrives in the same
order in which it was sent.
A connection oriented service can be either reliable or
unreliable
1. Reliable service: A reliable service guarantees that data
is not lost. The receiver acknowledges the receipt of each
message. This introduces an overhead, which may be
required in some cases but undesirable in others.
Example: file transfer requires reliable service.
There are two variations:
a. Message stream:
Here, data is sent as a series of msgs. The msg boundaries
are preserved. Two 1k msgs when sent, arrive as two distinct
1k msgs.
Example: Required if pages of a book are sent over the
network to a remote printer. Here, it is important to preserve
page boundaries.

b. Byte streams:
Data is sent as a sequence of bytes. No boundaries are
preserved and even if distinct msgs are sent, they arrive as a
continuous byte stream.
Example: Logging into a remote time-sharing system.
2. Unreliable service:
For some applications, loss of data bits is tolerable but
the delay introduced by reliable communication is
unacceptable.
Example: Digitized voice traffic (real-time). It is
preferable to hear a bit of noise on the line rather than
have gaps in conversation. (telephone)
Connectionless Services:
No connection is established for data communication. Each
message carries the full destination address and each one
is routed independent of the others. In such a case, it is
possible that messages arrive out of order. Its types are:
i. Unreliable datagram service: A msg is sent with a high
probability of arrival but no guarantee and no
acknowledgement. Example: Electronic junk mail.
ii. Acknowledged datagram service: It is used where
connection oriented service is not required but reliability is
essential. The receiver is made to acknowledge receipt of
message. Example: Registered mail.
iii. Request - reply service: In this service, the sender
transmits a single datagram containing a request and the
reply contains the answer. Example: Database query.
Service Primitives :
A service is formally specified by a set of primitives (basic
operations) available to a user or other entity to access the
service. Primitives are called calling functions between the
layers that are used to manage communication among the
adjacent protocol layers.
Example: five service primitives for implementing a
simple connection-oriented service.
Relationship between services and protocol:
A service is a set of operations that a layer (service
provider) provides to the layer above it (service user). These
operations are specified in an abstract manner with no
details of how to provide that service.
On the other hand, a protocol specifies a set of rules to carry
out communication between peers i.e. communicating
entities in the same layer on different machines. Protocols
clearly define "how to carry out the communication.
Entities use protocols to implement services. Different
layers use different protocols for communication.
Thus, services correspond to the interface between
adjacent layers while protocols correspond to
communication between peer entities in the
corresponding or same layer on different machines.
M.Sc. (Computer Application) Sem-II

Computer Networks
Chapter 2

Network Models

Prof. Vidya Bankar


Dr. D. Y. Patil ACS College Pimpri Pune-18.
Network Models:

A network model is a conceptual structure


which allows better understanding of how
networking tasks are performed.

Two important network models:

1. OSI Reference Model

2. TCP/IP Reference Model


OSI Reference Model:
• To standardize network design, the International
Standards Organization (ISO), developed a model in
1984. It was called the ISO - OSI (Open Systems
Interconnection) reference model.

• An open system is a set of protocols which allows


communication between two different systems
irrespective of their underlying architecture.

• The model simply defines which tasks need to be done


and which layer handles those tasks.

• The OSI model breaks the various aspects of a


computer network into seven distinct layers which are
shown in figure below.
ISO-OSI reference model
1. Physical Layer:
It is connected with transmitting raw bits over a
communication channel from one node to the next. It deals
with physical devices required for data communications.

The physical layer deals with the following issues:

•Mechanical: Consider the physical properties of the


medium and interfaces between devices like connectors,
cables, etc.

•Signal representation: How to represent data bits on the


transmission medium encoding mechanisms.

•Timing: Number of bits sent per second i.e. Transmission


rate, bit duration.
•Synchronization: Sequence of events, synchronization
between sender and receiver, connection establishment,
release etc, simplex or duplex communication.

•Line configuration: Connection of devices to


communication links - point to point, multipoint etc.

•Physical topology: How to connect the devices - mesh,


star, ring etc.

Devices operating at physical layer: Hub, Repeater


2. Data Link Layer:
This layer is responsible for error-free transmission of
frames from one hop to the next. Its main task is to
transform raw data bits into a frame that is free of
transmission errors.
It accomplishes this task by breaking the data into frames
and takes care of identification of frames.

The IEEE(Institute of Electrical and Electronics


Engineers) splits this layer into two sub-layers:
•Logical Link Control (LLC), which establishes and
maintains links between communicating devices.
•Media Access control (MAC), which controls the way
multiple devices share the same communication channel.
The main functions of the Data link layer are:
•Framing: The stream of bits is divided into logical units
called frames.

•Error control: Provides mechanisms to detect or correct


errors.

•Flow control: Ensures that a fast sender does not


overwhelm a slow receiver.

•Physical addressing - Identifies a machine (sender as well.


receiver) in the network using its physical address.
•Multiple access control for multipoint links, it provides
mechanisms to access the shared communication channel
between multiple machines.
Devices operating at Data Link layer: Bridge, switch
3. Network Layer:
The network layer is responsible for the transfer of data
packets from source to destination machines across the
communication subnet i.e. across multiple networks.
The main functions of the Network layer are:
•Addressing: The network layer identities a machine on the
basis of its logical address. The logical address identifies the
network to which the machine belongs.
•Routing: A key design issue is to route packets from source
to destination. Therefore routine algorithms are used.
•Congestion control: since the data packet has to travel
through the communication subnet, congestion control is
another function of this layer.

Devices operating at Network layer: Router


4. Transport Layer:
This is an end-to-end layer, which ensures process-to-
process delivery from the source application to the
destination application.
Its job is to ensure that the whole message arrives intact and
in order, at the destination.
It isolates the upper layers from the lower layers so that the
complexities, physical and logical characteristics of the
subnet are hidden from the end users.

The main functions of the Transport layer are:

•Port addressing: The transport layer has to identify the


application in the host machine for whom the data is
intended. It does this by an address called port address.
•Segmentation and reassembly: A large message may be
split up if needed. This layer takes care of sequencing and
reassembly at the destination.

•Services: It also determines what type of service to provide


to the upper layers, connection-less or connection-oriented.

•Flow and Error control: It provides end-to-end flow


control and also ensures end-to-end error free delivery of
data.

Devices operating at Transport Layer: Gateway


5. Session Layer:
This layer allows users on different machines to establish
sessions between them.
Sessions offer various services like dialog control (half-
duplex, full-duplex), token management (preventing two
parties from performing the same critical operations
simultaneously), authorization, synchronization, checkpoint
mechanism to allow transmission to continue from the last
point in case of a crash.
The main functions of the session Layer are:
•Dialog control: This layer allows communicating entities to
establish a dialog which is either half or full duplex.
•Synchronization: It allows processes to add checkpoints so
that the communication can continue from that point in the
event of a crash or disconnection.
6. Presentation layer:
This layer is concerned with the syntax and semantics of data
transmitted i.e. it defines the format of data to be exchanged
between applications and offers services like format
transformation, encryption, compression etc.

The main functions of the Presentation layer are:


•Translations: This layer translates data from an application
dependent format to a standard format which can be
transmitted over the network.
•Encryption: This allows communicating entities to encrypt
data to ensure secrecy of sensitive data.
•Compression: Large volumes of data can be compressed
and sent over the network so that bandwidth utilization is
less. It is required for data like video, images and audio.
7. Application Layer:
This layer provides a means for user applications to access
the network. It contains a variety of services commonly
needed by users like file transfer, e-mail, remote terminal
access, access to the World-Wide-Web etc one widely used
application protocol is HTTP.

Services provided by Application layer are:


•File transfer: This service allows a user to send, access
and retrieve files on remote machines.
•e-mail: This service allows users to create, send and
receive mails.
•Remote access: This is also called network virtual
terminal service which allows a user to login into remote
machine.
Organization of layers:

The 7 layers are organized into two logical subgroups:

Lower layers: The physical, data link and network layers


deal with the physical aspects of transmitting data from
one machine to another. They are also called Network
support layers.

Upper Layers: The Transport, session, presentation and


application layers deal with end-to-end communication
between unrelated systems. They are also called User
support layers.
Communication between layers
The data generated by an application (such as email or file
transfer) in the Application layer is handed down layer by
layer till it reaches the physical Layer which does the
actual transmission. Each layer adds its own header (data
link layer also adds a trailer) to the data. The headers and
trailers are meant only for the peer's in the same layer on
the destination machine.
Another important feature used by the layers is
encapsulation. The data + header of layer N is
encapsulated in a packet at layer N-1. For example the data
and healer at layer 4 is encapsulated in a layer 3 packet.
When the data reaches the destination machine, it makes it
way from layer 1 to layer 7. At each layer, the
corresponding header and trailer (if any) is removed.
Summary of Layers:
•Application: To allow access to network resources.
•Presentation: To translate, encrypt and compress data.
•Session: To establish, manage and terminate sessions.
•Transport: To provide reliable process-to-process message
delivery and error recovery.
•Network: To move packets from source to destination; to
provide internetworking. Host-to-host delivery.
•Data Link: To organize bits into frames; to provide hop-to-
hop or node-to-node delivery.
•Physical: To transmit bits over a medium; to provide
mechanical and electrical specifications.
OSI Model
Layer Data Unit Function
Application Access to Network Resources

Presentation Data representation:


translate compress and
DATA encryption
User support Session Controls the dialogues ,
Establishes, manages and
layer terminates the connections
between the local and
remote application
Transport Segment End-to-end connections
Link and reliability
Network Datagram/Packet Path determination (Routing)
and logical Addressing

Network Data link Frame Hop to Hop delivery and


support layer Physical addressing
Physical Bit Media, signal and
binary transmission,…
TCP/IP protocol Suite:
The TCP/IP reference model is the most widely used model
for internetworking. It allows diverse networks to
communicate with each other.
An Internetwork (also called Internet) is a vast collection of
interconnected and diverse networks. These networks
contain different types of computers, different data
formats different addressing mechanisms etc. they can
communicate with each other using TCP/IP model.
History:
The TCP/IP model was built on the ARPANET modes
which was developed by Advanced Research Projects
Agency (ARPA) of the U.S. Dept. of Defense (DOD) in the
late 1960's. ARPANET was very successful but was unable
to connect diverse networks. This led to the development of
a new architecture for internetworking.
Goals:
• Connect multiple networks in a seamless way.
• The network should be able to survive the loss of subnet
hardware.
• Flexible architecture is needed since the applications on
different networks were diverse.

The TCP/IP model is a 4 layered model as shown below:


TCP/IP model protocol Suite: Protocols used in the various
layers of TCP/IP model are as shown in following diagram:
1. Host-to-Network Layer:
• The TCP/IP model does not define any specific
protocol at physical and data link layer.
• It supports all the standard and proprietary protocols.
• This layer corresponds to the physical and Data link
layer of the OSI model.

2. Network (Internet) Layer:


• The main job of this layer is to transport data packets
from the source machine to the destination.
• In order to connect multiple diverse networks in a
seamless manner, the internet is based on a packet -
switching network which is connection less.
• This layer takes care of delivering data from the
source host to the destination host.
• The fundamental protocol operating in this
layer is the Internet Protocol (IP).
• IP takes care of addressing and routing the
packets through the internetwork.
• It is an unreliable, connectionless protocol and
provides best-effort delivery. This means that
the protocol does not take any responsibility for
error free delivery.
Other protocols at Network Layer:

i. ICMP (Internet Control Message Protocol):


Used by routers and hosts to send notifications.

ii. IGMP (Internet Group Message Protocol):


Used to send messages to a group.

iii. ARP (Address Resolution Protocol):


Associates a logical address with a physical address.

iv. RARP (Reverse Address Resolution Protocol):


Used to find logical address from physical address.
3. Transport Layer (Process-to-Process)
This layer is designed to allow communication between
applications running on the source and destination hosts,
just as in the OSI transport layer. Thus it is an end-to-end
layer.
i. TCP (Transmission Control Protocol)
• This is a reliable connection oriented protocol. It
ensures end-to-end, error - free delivery.
• It also handles reassembling of packets at the receiver
and flow control to ensure that a fast sender does not
flood a slow receiver.
• It breaks data into small units called segments which are
encapsulated within IP packets and transmitted. The
receiving TCP reassembles these into a single stream
and gives them to the application layer.
ii. UDP (User Data gram Protocol):
• This is an unreliable connection less protocol.
• It is mainly used in client-server, request-reply
applications where prompt delivery is more important
than accurate delivery.
• Because it is connection-less, UDP require less
overhead as compared to TCP.

iii. SCTP (Stream Control Transmission Protocol):


Combines features of TCP and UDP and used for newer
applications like voice over IP (voice call using internet)
4. Application Layer:
The application layer contains all higher level protocols
for commonly required user service like

SMTP (Simple Mail Transfer protocol):


Used for electronic mail (email) transmission.

FTP (File Transfer Protocol):


Used for the transfer of computer files between a client and
server as a computer network.

TELNET (Telecommunications Network):


Used for accessing remote computers / terminals.
DNS (Domain Name System):
Used for mapping host names to network address.

HTTP (Hypertext Transfer Protocol):


Used to access the World Wide Web.

Comparison of OSI and TCP/IP model:


Both, the OSI and TCP/IP network models are very
important to understand how network architectures are
implemented. There are many similarities between the two
but there are major differences.
Similarities:
• Both are layered network models based on the concept of
an independent protocol stack.
• The functionalities of the Network, transport and
application layers are similar.
• The higher layers are end-to-end layers, whereas the
lower ones deal with host to intermediate processors.

Differences:
• OSI has 7 while TCP/IP has 4 layers. The common layers
are Network, Transport and Application layer.
• OSI model supports connection oriented and connection
less service in the Network layer and only connection –
oriented communication in the Transport layer.
• TCP/IP has only connectionless mode in the Internet
layer but supports connection oriented and connection
less in the Transport layer.
• The OSI model makes a clear distinction between
services, interfaces and protocols, whereas TCP/IP
model does not clearly distinguish between them.
• The OSI reference model is a general purpose model.
Hence, this model was not biased toward one particular
set of protocols.
• In TCP/IP, the protocols were developed first and the
model fits the protocol description. Hence, it does not fit
any other protocol stack.
• OSI model does not take care of internetworking. The
TCP/IP protocols were designed first and the main goal
was to handle internetworking.
• The session and presentation layers in the OSI model
are nearly empty whereas the data link and network
layers are overfull.
• The TCP / IP model on the other hand, does not
distinguish - nor mention physical and data link layers.
• The OSI model is very useful to discuss and
understand - computer networks but the OSI model has
not been implemented. In contrast, the protocols in the
TCP/IP model are universally used.
Addressing:
An internetwork or internet is a collection of several
independent and diverse networks which are connected.
Thus, it is a network of networks. For communication to
take place in an internet there should be a mechanism of
identifying
• A network among several networks.
• A computer/device in the network.
• A process running in that computer.
For these purposes four levels of addresses are used in an
internetwork using TCP/IP protocols.
Each address is used at a different layer in the TCP/IP model
as shown in the following diagram.
1. Physical address:

This address is used by the Data link layer and it is also


called as the MAC Address (Medium Access Control).
Every frame contains the source and destination physical
address.
This address is assigned by hardware vendors and depends
on the media access method used in the LAN or WAN.
For example, Ethernet LAN, which is the most common
LAN, uses a 6 byte i.e. 48 bit address which is stored in
the Network Interface Card.
It is written as 12 hexadecimal digits separated by a
colon(:)
Example: 23:1A:03:FF:2C:7B
2. Logical address:
Logical addresses are independent of the underlying
physical network and can uniquely identify a network and a
machine in that network. The physical address depends on
the underlying physical network. Different network types
can have different format of physical addresses.
However, when multiple networks have to communicate with
each other, there has to be a standard and uniform
mechanism of identifying a network and a machine in
that network. The network layer uses logical address to
deliver data to the correct machine in the internet.
In the TCP/IP network, the logical address is called an IP
address which is a 32 bit address. It is usually written in the
dotted decimal format A.B.C.D. where each number is in
the range 0 to 255.
Example: 192.9.100.2
3. Port address:
• A single machines can have several applications
running. Hence, we need a mechanism to identify the
application to which the data has to be delivered.
• Every process is identified by a port address.
• The IP address along with the port address is called the
"socket" address.
• The transport layer does the job of process to process
delivery of data. It uses the port address to identify the
process to which the data has to be given.
• Port addresses are 16 bits ranging from 0 to 65535.
The IANA (Internet Assigned Numbers Authority) has
divided these port numbers into three ranges:

i. Well-known ports: Ports ranging from 0 to 1023 are


assigned and controlled by IANA.

ii. Registered ports: Ports from 1024 to 49,151 can be


registered with IANA to prevent duplication.

iii. Dynamic ports: Ports from 49,152 to 65,535 are


neither controlled nor registered. Hence they can be
used by any process. These are ephemeral(short term)
ports.
The following diagram illustrates how a packet is delivered
using the IP address and port address.
4. Specific address:

• It may be difficult for users to remember numeric


addresses. Some applications use user friendly
addresses that represent a logical or physical address.
• For example, a URL like www.google.com represents
a page on the www or admin@somecompany.com
represents the recipient of e-mails.
• These represent a specific address and are only used
for convenience.
• However, they are ultimately converted to a port, IP
and physical address for actual communication.
Example:
• The server machine has physical address 23:1A:03:FF:2C:7B.
However it is not possible to locate the machine using its
physical address.
• The server is in a remote network. Hence, it must be assigned
a logical address which depends on the network it is
connected to.
• The network IP address is 20.100.0.0 and the server IP
address is 20.100.5.2. The server has one process running at
port number 80.
• The client machine has physical address 2D:00:FF:3A:02:1B.
• The client is in network which is identified by IP address
195.60.20.0. The client machine's IP address is 195.60.20.1.
• The client has three processes running at port numbers 12558,
3500 and 8080 respectively. As shown in the diagram, the
client process on port number 8080 communicates with
server process running on port number 80.
M.Sc. (Computer Application) Sem-II

Computer Network

Chapter 3

Physical Layer

Prof. Vidya Bankar


Dr. D. Y. Patil ACS College Pimpri Pune-18.
Physical Layer Services:
• The physical layer is the lowest layer in the OSI network
model.
• It is mainly concerned with the transmission of raw bits
over a communication channel.
• It uses the transmission media to move bits from one
node to another in the network. It provide services to the
data link layer as well as takes care of the underlying
physical communication medium.
Duties of physical layer:
1. Bit-to-signal transformation (Signal Representation)
2. Bit-rate control
3. Bit-synchronization
4. Multiplexing
5. Switching
1. Bit-to-Signal Transformation (Signal Representation):
• The physical layer sends a stream of bits from one node
to another using a transmission medium.
• For transmission, the data bits have to be represented by
an appropriate signal, which can propagate through the
medium.
• For example, if the medium is a copper wire,
electromagnetic signals are used, and if it is a fiber optic
cable, light signals are used.
2. Bit-Rate Control (Timing):
• The physical layer has to determine the rate of
transmission.
• It has to take into consideration the upper limit of the
transmission medium and control the rate of data flow.
3. Bit-Synchronization:
• For the data to be correctly received and interpreted, bit
timing is very crucial.
• Various encoding methods are used to synchronize the
receiver to the sender.
• This layer also provides clocking mechanisms that
control the sender and receiver.
4. Multiplexing:
• This is the process of sharing a single physical medium
among multiple transmissions.
• The physical layer uses different techniques like
Frequency and Time Division Multiplexing for sharing
the medium.
5. Switching:
• Switching creates a temporary connection between two
or more devices in the network.
Data and Signals:
• Computer networks are used for sharing data.
• To be transmitted, data must be transformed into a signal
that can be sent across the medium.

The data as well as signals which represent the data can be of


two types:
1. Analog data: This refers to information that is continuous
in nature. For example, human voice, data collected by
sensors (temperature, pressure) are having continuous
varying pattern . These are analog in nature.
2. Digital data: This refers to information that is discrete in
nature. It has well defined states. For example, computer data
has only two discrete values 0 and 1. A digital clock has
discrete states.
Analog and Digital Signals
The term signaling refers to methods for using electromagnetic
energy to communicate.
Two forms of signaling are used:
1. Analog signals: An analog signal is a continuously varying
signal over a period of time. Thus, an analog signal has infinite
number of states. The following diagram shows an analog signal
which varies over time. The signal curve passes over an infinite
number of points.

Analog transmission has dominated communication for many


years. For example, telephone and television systems have used
analog signals to transmit analog data.
2 Digital signals: A digital signal is a signal having finite
number of states, i.e., it is a discrete signal. The signal
maintains a constant level for some time and then changes
to another level.

For digital transmission, the source data may be either


analog i.e. continuous values or digital i.e. having discrete
values, for example, in the form of bits, viz. computer
data. If the information is an analog signal, the signal has
to be first digitized and then transmitted
Comparison of Analog and Digital Signals
Analog Signal Digital Signal
Analog signals are continuous in Digital signals have discrete
nature values
An analog signal has infinitely A digital signal, can have only a
many levels of intensity over a limited number of defined values
period of time

Analog signals are more accurate Digital signals are less accurate
The curve representing the analog The lines of the digital signal,
signal passes through an infinite demonstrate the sudden jump that
number of points. the signal makes from value to
value.

All analog signals exhibit some Digital signals do not exhibit non
form of non linearity linearity
Analog Signal Digital Signal
The noise on the channel affects Noise does not affect digital
analog signals considerably signals much
Analog signals are weakened or Digital signals can be regenerated
attenuated during transmission. or restored to their original values
Attenuation is different for exactly
different frequencies
Low data rates are possible Higher data rates are possible
There are Storage and Digital techniques overcome
transmission overheads many of the transmission and
storage limitations of analog
technology
Analog Signal Digital Signal
Encryption techniques cannot be Encryption techniques can be
applied easily to analog signals. readily applied to digital data as
Hence, they are less secure compared to analog data
To effectively utilize capacity of Multiplexing is more easily and
high bandwidth links such as cheaply achieved with digital
satellite, a high degree of signals
multiplexing is needed which is
not easily applied on analog
signals
Bit Rate and Bit Length of Digital Signal:
Consider transmission of binary data (digital) using a digital
signal. Binary data has only bits - 0 and 1. If we use a digital
signal with two levels - high and zero, we can transmit one
bit per level. This is shown below.
Since a digital signal can have many discrete levels, more
than one bit can be transmitted for each level. If a digital
signal has L levels, the number of bits each level represents
can be calculated as:

Bits per level = log2L bits

For example, if the digital signal has 2 levels, each level can
represent log22=1 bit.
If L=4, each level can represent 2 bits.
For example, if the levels are L1, L2, L3 and L4, each level
can represent two bits as follows:
L1:00
L2:01
L3:10
L4:11
If the data to be transmitted is 1110010100000010, it can
be represented as follows:

If L is not a power of 2, consider the nearest higher power


of 2 to calculate number of bits.
Bit Rate:
The bit rate of a digital signal is the number of bits
transmitted per second. It is expressed as bps. The bit rate
also depends on the channel bandwidth.
For example, if the digital signal shown in figure-a is
transmitted in 1 second, the bit rate is 8 bps and for figure-b,
it is 16 bps.
Bit Length:
The bit length is the amount of distance one bit occupies on
the transmission medium. It depends on the bit duration i.e.
time for which one bit is transmitted and the propagation
speed i.e. the speed at which the bit travels on the
medium. This concept corresponds to wavelength for analog
signals.
Bit length = bit duration x propagation speed
Problems
1. A digital signal has 8 levels. How many bits are needed
per level?
Solution
Number of bits = log2L. Here, L = 8.
Hence, log28 =log223=3
Hence, 3 bits are needed.

2. A digital signal has 10 levels. How many bits are needed


per level?
Solution
Number of bits = log2L. Here, L = 10 which is not a power of
2. So we need to consider the nearest power of 2 i.e. 16.
Hence, log216 = log224 = 4 Hence, 4 bits are needed per
level.
3. Calculate the bit length in a channel with propagation
speed of 2 x 108 m/s if the channel bandwidth is
i. 1Mbps ii. 10Mbps iii. 100Mbps
Solution
Bit length = bit duration x propagation speed

i. Bit duration = 1/bandwidth = 1/106 = 10-6s


Bit length = 10-6s x 2 x 108m/s = 200m.

ii. Bit duration = 1/bandwidth = 1/107 = 10-7s


Bit length = 10-7sx 2 x 108m/s = 20m.

iii. Bit duration=1 / bandwidth = 1/108 = 10-8s


Bit length = 10-8s x 2 x 108m/s = 2m.
Baseband and Broadband Transmission:
To transmit a digital signal over a transmission medium, two
mechanisms are used:
1. Baseband transmission 2. Broadband transmission
1. Baseband transmission:
In this method, the digital signal is transmitted over the
communication link without converting the digital signal to
analog. In this case, only one signal can occupy the channel
at a time. Baseband transmission requires that we have a
low-pass channel, a channel with a bandwidth that starts
from zero.
2. Broadband transmission:
In this method, the digital signal is converted to analog using
modulation. A high frequency carrier signal is modulated
according to the digital signal and transmitted. Thus, several
signals can be transmitted at the same time in different
frequency bands (Frequency multiplexing). At the receiver,
the analog signal is reconverted back to digital. Broadband
transmission requires a bandpass channel - a channel with a
bandwidth that does not start from zero.
Differences between Baseband & Broadband transmissions
Baseband transmission Broadband transmission
Transmit digital signals Transmit analog signals
To boost signal strength, use To boost signal strength, use
repeaters amplifiers
Can transmit only a single data Can transmit multiple signal
stream at a time waves at a time
Support TDM based Support FDM based
multiplexing multiplexing
Use coaxial, twisted-pair, and Use radio waves, coaxial
fiber-optic cables cables, and fiber optic cables
Mainly used in Ethernet LAN Mainly used in cable TV and
networks telephone networks
Transmission Impairment:
Communication channels are not perfect. When a signal
travels through a communication medium, the signal
undergoes several impairment, i.e., the quality of the signal
does not remain the same but weakens.

There are three causes of signal impairment:


1. Attenuation
2. Distortion
3. Noise
1. Attenuation
Attenuation means a loss of signal energy. As a signal
travels through a communication medium, it loses its
energy. This is because the signal has to overcome the
resistance of the medium. The amount of attenuation
depends on the medium characteristics and the distance
traveled.

Attenuation is measured in decibels (dB),


Attenuation = 10 log10(P2/P1)

where P1 is the initial signal power and P2 is the attenuated


signal power.
Example
A signal loses half its power during transmission. Calculate
the attenuation.
Solution
Its attenuation can be calculated as:
Attenuation =10 log10(P2/P1)
=10 log10(0.5 P1/P1)
=10 x-0.3 = -3 dB
Example
Consider a signal which is amplified and its power is
increased 10 times.
Here, P2=10 P1. Hence, its amplification can be calculated as:
Amplification = 10 log10(P2/P1)
= 10 x log10(10 P1/P1)
= 10 dB
2. Distortion
When a signal travels over a medium, not only does it lose
power but it also gets distorted. Distortion means that the
signal changes its shape or form. This happens because
different frequency components of a composite signal
have different propagation delays and different phase
shifts as they travel. Hence, they do not arrive at the same
time at the receiver due to which the received signal does not
have the same shape as the original.
3. Noise
Noise is nothing but other signals near the medium which
corrupt the data signal. This is an important cause of
impairment. There are several types of noise:
Thermal noise: This is caused due to the random motion of
molecules (electrons) in the medium.
Crosstalk: This is caused due to the interference of signals in
channels or wires close to each other.
Induced noise: This comes from sources such as motors and
other appliances like microwaves etc.
Impulse noise: This is a spike which is a signal having a very
high power but for a very short time. It is caused by high
power lines, lightning and fluctuations in voltages.
Measure of noise is the Signal to Noise Ratio (SNR) :
SNR=average signal power / average noise power
SNR is an important characteristics of the transmission
system. More the SNR, better is the quality of transmitted
signal. It is often represented in decibels as:
SNRdB=10log10SNR
Problems
1. The power of a signal is 10 mW and the power of the
noise is 1µW: What are the values of SNR and SNRdB?
Solution
The values of SNR & SNRdB can be calculated as follows:
SNR = (10,000 µW) / (1 µW) =10,000
SNRdB=10log1010000 =10log10104 =40
2. Consider a noiseless channel. Calculate values of SNR and
SNRdB.
Solution
SNR=average signal power/average noise power
SNR=signal power / 0 = ∞ SNRdB=10log ∞=∞
Data Rate Limits
In the previous sections, we have studied the concept of bit
rate. We want to send maximum number of bits in less
time so that communication is fast. However, the rate at
which data can be sent over the medium is finite.

Data rate depends on three important characteristics of a


communication channel:
i. The bandwidth of the communication channel.
ii. The number of signal levels.
iii. The amount of noise present.
All these factors have a significant impact on the rate at
which bits can be transmitted. Two important formulae
were developed which calculate the data rate of a
communication channel.
1. Noiseless Channel: Nyquist's Formula for noiseless
channel
Henry Nyquist derived an equation in 1924 to calculate the
maximum data rate for a finite bandwidth noiseless channel.
The maximum data rate for a noiseless channel having
bandwidth W and carrying a signal having L levels is:
Maximum data rate = 2 x W x log2 L

Example 1: A noiseless 3 kHz channel can transmit a binary


signal (2 levels) at a maximum rate of 2 x 3000 x log22 i.e.
6000 bps.

Example 2: The maximum data rate for a noiseless 3 kHz


channel carrying a signal having 8 levels is 2 x 3000 x log28
i.e. 2 x 3000 x 3 = 18000 bps.
2. Shannon's Formula for Noisy Channel
Claude Shannon extended Nyquist's work to consider a
channel with noise. Practically, it is not possible to have
noiseless channels. In 1944, he proposed a formula to
calculate the data rate (Shannon capacity) for a noisy
channel having bandwidth W.
Shannon capacity = W x log2(1 + S/N)
where S/N is the Signal to Noise Ratio (SNR)

Example: The data rate for a telephone line having


bandwidth 3000 Hz and a S/N ratio of 2047 is 3000 x log 2
(1 + 2047) = 3000 x log2 2048 = 3000 x 11 = 33kbps.

If the S/N ratio is given in decibels, it should be converted


to SNR using the formula
SNRdB = 10 log SNR.
Problems
1. If a binary signal is sent over a 3 KHz channel whose
signal-to-noise ratio is 20 dB, what is the maximum
achievable data rate?
Solution
Signal-to-noise ratio is in dB
SNRdB=10 log10SNR
20=10 log10SNR
2=log10SNR (m = logax is equivalent to am = x)
102=SNR
SNR=100
Maximum data rate =W x log2(1+S/N)
=3 x log2(1+100)
=3 x log2(101)
=3 x 6.66
=19.975kbps
2. Given a channel with an intended capacity of 20 Mbps.
The bandwidth of channel is 3MHz. What signal-to-noise
ratio is required in order to achieve this capacity?
Solution
According to Shannon's formula C=B log2(1 + SNR)
Given B = 3 MHz = 3 x 106Hz,
C = 20 Mbps

20 x 106 = 3 x 106 log2 (1 + SNR)


log2 ( 1 +S/N) = 20/3 = 6.667
1 +S/N = 26.67=102.

Hence, S/N = 101


3. A digital signaling system is required to operate at 9600
bps. If a signal element encodes a 4-bit word, what is the
minimum required bandwidth of the channel?
Solution
By Nyquist's formula,
C = 2B log2L,
Here C = 9600 bps, log2L = 4

2B=C/log2L
2B=9600/4
Hence, B = 1200 Hz.
Performance of the Network
A computer network consists of several communicating
devices, connecting devices and communication links. All
these factors have an important impact on the performance
of the network.

The important criteria which are used to measure


performance of a network are:
1. Bandwidth
2. Throughput
3. Latency (Delay)
4. Bandwidth –Delay Product
5. Jitter
1. Bandwidth:
Bandwidth represents the capacity of the communication
channel. It can be measured in Hertz or Bits per second.

Bandwidth in Hz is the range of frequencies that the


communication channel can carry. It is calculated as the
difference between the lowest and highest frequency.
e.g. We can say that bandwidth of a telephone line is 4KHz.
Bandwidth Hz = fh - fl

Bandwidth in bits per second refers to the maximum bits


that the channel can transmit in one second over a network.
An increase in bandwidth in Hertz increases the bandwidth
in bits per second.
e.g. Bandwidth of a fast Ethernet is 100Mbps.
2. Throughput:
The throughput of a network is a measure of the actual
speed at which data was transmitted through the
network. The throughput T of a network is always <= the
bandwidth B in bps. For example, if two communication
lines each having a bandwidth of 1 Mbps are connected to a
single device which is capable of handling only 100 kbps,
the throughput will be 100 kbps.

3. Latency (Delay):
The latency is a measure of the total time taken for an entire
message to reach the destination from the time its first bit
was transmitted at the source. It is calculated as:
Latency = Propagation time + Transmission time +
Queuing time + Processing time
i. Propagation time is the time required for a single bit to
travel from the source to destination. It is calculated as:
Propagation time = Distance/Propagation speed
ii. Transmission time is the time required for all bits of a
message to arrive at the destination. It depends on the
message size and the bandwidth.
Transmission time = Message Size/Bandwidth
iii. Queuing time is the time taken by intermediate or end
devices to store the entire message before it is processed. It
depends on the network traffic and the device
characteristics.
iv. Processing time is the time taken by a device to process
the message. The processing includes inspecting message
headers to read source and destination address, calculate
checksum to identify errors etc.
4. Bandwidth-Delay Product:
The bandwidth-delay product defines the number of bits that
can fill the communication link. This is used to calculate how
many bits can be sent at a time before the acknowledgement
is received so that the channel does not remain idle.
For example, let us consider a channel having bandwidth of
1bps and a delay of 5 seconds. This means that when the
sender sends 1 bit, it reaches the receiver after 5 seconds. If
the sender has to wait for an acknowledgement before
sending the next bit, the channel will be idle for 4 seconds.
Instead of keeping the channel idle, calculate the bandwidth-
delay product and transmit those many bits. Here, it is 1 x 5
= 5 bits. The following figure shows this scenario.
5. Jitter:
Latency refers to the delay in the message reaching the
receiver. Jitter is the variation in this delay. If the delay is
fixed, a buffering mechanism can be used so that the
receiver is given data at a constant speed. However, if
there is jitter, there are lags and gaps in the data. Time
sensitive data like audio and video cannot tolerate jitter.
Problems
1. Calculate the propagation and transmission time for a 10
kbytes message through a network having a bandwidth of
1Gbps. The transmission medium is vacuum and the signal is
transmitted using light pulses over a distance of 3000km.
Solution
Since the medium is vacuum the speed of light in vacuum is
3x108 m/s.
Propagation time = distance / propagation speed
= (3000 x 1000) / 3 x 108
= 1/102 s = 0.01s
= 10ms
Transmission time = message size/bandwidth
= (10 x 1000 x 8) / 109
= 8/105 = 0.00008 s
= 0.08 ms
2. What are the propagation time and the transmission time
for a 5-Mbyte message (an image) if the bandwidth of the
network is 1 Mbps? Assume that the distance between the
sender and the receiver is 12,000 km and that light travels at
2.4 x 108 m/s.
Solution
Propagation time =(12000 x 1000)/2.4 x 108
=12x106 / 2.4x108
=0.05s

Transmission time =(5,000,000 x 8)/106


=40x106/106
= 40s
3. A network with bandwidth of 10 Mbps can pass only an
average of 12,000 frames per minute with each frame
carrying an average of 10,000 bits. What is the throughput of
this network?
Solution
We can calculate the throughput = (12000 x 10000)/60
= 12x107/60
= 2Mbps

4. How many bits can fit on a link with a 2ms delay if the
link bandwidth is 1Mbps?
Solution
Number of bits = bandwidth x delay = 1 Mbps x 2 ms
= 1x106bps x 0.002s = 2000 bits
5. Calculate the total delay for a frame of size 5 million bits
which is sent on a link with 10 routers, each having queuing
time of 2µs and a processing time of 1µs. The length of the
link is 2000 km and speed of light is 2 x 108m/s in the link.
The link has bandwidth 5Mbps.
Solution
Latency = Propagation time + Transmission time +
Queuing time + Processing time
i. Propagation time = Distance/Propagation speed
=2000 x 103/2 x 108 =1/102= 0.01s
ii. Transmission time = Message size/ Bandwidth
=5 x 106/5 x 106 = 1s
iii. Queuing time = 10 x 2µs = 20µs =20x10-6= 0.00002s
iv. Processing time = 10 x lµs = 10µs = 0.00001s
Latency = 0.01 + 1 + 0.00002 + 0.00001 = 1.01003s
Line Coding
Line coding is a process of converting a series of bits into a digital
signal. Several encoding schemes have been developed. This is
done so that the receiver can clearly determine the start, stop or the
middle of each bit in order to correctly receive the data.

Characteristics of Line encoding schemes:

1. Signal element vs data element: A data element is the smallest


entity that represents piece of information. A signal element is the
shortest unit in a digital signal that carries data elements. More
than one data elements can be carried in a single signal
element and more than one signal element can carry a single
data element. r is the number of data elements carried by a signal
element.
2. Signal rate vs data rate
Signal rate (baud rate) represents the number of signal elements in
the digital signal sent per second. The data rate(bit rate) is the
number of data elements sent per second. The goal of data
communication is to increase the bit rate while keeping the
baud rate low.

3. Bandwidth: This represents the range of frequencies supported


by the communication channel. The theoretical bandwidth of a
digital signal is infinite, however, practically, it is finite. The
bandwidth is proportional to the signal rate.
4. Baseline wandering: When the receiver receives a digital
signal, it has to identify the bits. This is done by calculating the
average of the received signal power called baseline. The
received signal power is compared with this baseline to identify
a 1 or a 0. However, a long string of 0's or l’s can cause this
baseline to drift (baseline wandering) making it difficult for
the receiver to identify bits correctly. The encoding scheme
should prevent baseline wandering.

5. DC components: The transmitted digital signal sometimes


creates very low frequencies called DC components. These can
cause problems to systems which cannot handle low
frequencies or systems which use electrical coupling since DC
components may cause damage. Hence, the encoding
scheme must not generate DC components.
6. Self synchronization: A long sequence of 0's or l’s may cause
the receiver to go out of sync and hence identify data bits
wrongly. The encoding scheme must include information by
having transitions in the beginning, middle or end of the pulse
so that the receiver can synchronize itself.

7. Built-in error detection: If the code is such that the receiver


can detect some or all errors it will be preferred.

8. Immunity to noise and interference: Noise and interference


distort the signal. It will be preferable to use an encoding scheme
which is immune to noise and interference.

9. Complexity: A complex encoding scheme is more difficult and


expensive to implement. For example, a multi-level encoding
scheme is more complex compared to a two level scheme.
Encoding Schemes
Binary encoding schemes fall into five broad categories as
shown in the figure below. These are Unipolar, Polar,
Bipolar, Multilevel and Multitransition.
1. Unipolar:
This is the simplest encoding scheme. In Unipolar encoding,
only one polarity is used; i.e. all signal levels are on one
side of the time axis - above or below.
NRZ - Non Return to Zero: NRZ means the signal does not
return to zero in the middle of the bit. In this scheme,
Bit 1 is represented by a positive voltage
Bit 0 is represented by zero voltage signal
Example: Binary data – 10110

Figure: Unipolar NRZ


Disadvantages:
• The main problem with unipolar encoding is that it
becomes difficult for the receiver to synchronize,
especially if the data contains a long series of l's or
0's, where there is no change in the signal for a long
period.
• Another problem is the presence of DC component.
Since the average voltage on the line is non-zero, a DC
component is created, which can interfere with device
operation.
2. Polar:
Polar encoding uses two voltage levels, positive and
negative on both sides of the zero axis. The types of polar
encoding are:

i. NRZ - Non Return to Zero


1. NRZ-L (NRZ- Level)
2. NRZ-I (NRZ- Invert)

ii. RZ- Return to Zero

iii. Manchester

iv. Differential Manchester


i. NRZ (Non Return to Zero): Here, the signal level is always either
positive or negative but never zero. It has two variations -
NRZ-L (NRZ- Level): where 0 is usually a positive voltage and 1 is a
negative voltage. However, for a long series of l's or 0's it can lead to
synchronization problems.
NRZ-I (NRZ- Invert): In this method, fixed voltage levels are not
assigned to represent 0 or 1 but an inversion of existing voltage level
represents a 1 and non-inversion of level represents 0.
Example: Binary data 01001110

Figure: Polar NRZ-L and NRZ-I


ii. RZ (Return to Zero): In the above schemes, a long string of 0's or
l’s can make the receiver lose synchronization. To ensure
synchronization, there should be a signal change for each bit.
RZ uses three levels - positive, negative and zero. The RZ code
requires the signal to return to 0 in the middle of its bit period i.e. for
every bit, there has to be a transition in the middle. Bit 1 is represented
as Positive to 0 and 0 is represented as Negative to zero signal.
Example: Binary data 01001

Figure: Polar RZ
Disadvantage:
The RZ code occupies more bandwidth because it requires two signal
changes to encode one bit.
iii. Manchester: This code also requires a transition in the
middle of each bit interval.
Negative-to-positive transition represents 1
Positive-to-negative represents 0
Thus, by using just two levels of amplitude, it can achieve
the same level of synchronization as RZ code.
Example: Binary data 010011

Figure: Manchester encoding


iv. Differential Manchester: This combines RZ and NRZ-I.
A transition at the beginning of the next bit means 0 and no
transition means 1. Here, a transition in the middle is used
for synchronization but the presence or absence of a
transition at the beginning identifies the bit.
Example: Data: 01001110

Figure: Differential Manchester encoding


Transmission Modes
Transmission modes deal with methods of sending a stream
of data bits from the sender to the receiver across a link.
The various transmission modes are shown below.
1. Parallel Transmission
In this method of transmission, a stream of data bits is
divided into groups of n bits each. These n bits are sent at a
time using n wires: each wire carrying one bit. All n bits are
delivered simultaneously to the receiver using a clock to
synchronize transmission. e.g. If we have n=8 then 8 wires
are bundled in a cable with a connector at each end.
Figure: Parallel transmission
Advantages
1. Very high speed of data transfer.

Disadvantages
1. It requires n communication lines between the devices
2. Higher cost

2. Serial Transmission
In this method of transmission, the streams of bits are sent
serially, one after the other and hence, only one
communication channel is needed.
Figure: Serial Transmission

Advantages
1. Requires only one communication channel.
2. Reduced cost of transmission.
Disadvantage
1.The sender requires a parallel to serial converter and the
receiver needs a serial to parallel converter.
Types of Serial Transmission

1. Synchronous transmission:
• Synchronous transmission is used to send a long
uninterrupted series of bits from sender to receiver.
• In this the bit stream is combined together into long
“frames” which contain multiple bytes.
• The bits do not have any delimiters markers to identify
end of a frame or byte.
• The receiver receives the bits and groups them
appropriately. Since there are no delimiters, the receiver
has to receive the bits accurately.
• As the name suggests, there should be synchronization
between the sender and receiver Hence, timing is very
critical. e.g. webcam, video conferencing
Figure: Synchronous Transmission

Advantages
1. Very high speed of data transfer.
2. No need of extra bits as delimiters to identify start and
end of data.

Disadvantage
1. Requires precise timing and synchronization.
2. Asynchronous transmission:
• In this type of transmission, the data bits are grouped
into logical units like a character or byte and sent as a
unit.
• Special bits called start bit(0 bit) and stop bit(1 bit) are
used to indicate start and end of the group so that the
receiver knows when the group starts and when it ends.
• When the receiver receives a start bit, it synchronizes
itself to the incoming stream and continues accepting till
a stop bit pattern is encountered. The next group may
follow immediately or after some gap.
• It is typically used for request reply kind of
applications where data is sent in bursts.
• It is called Asynchronous because sender and receiver
does not have to synchronize. e.g. email, social media
Figure: Asynchronous Transmission

Advantages
1. Timing is not an important criteria.
2. The sender can send data when required without the
receiver being synchronized.
3. It is a cheap and effective method of communication.
Disadvantages
1. Data has to be grouped into logical units.
2. Start and stop bits have to be added to each unit to identify
start and end of a group.

3. Isochronous transmission:
• This type of transmission is used in applications which
do not tolerate any jitter (variation in delay). These
include real-time audio and video applications.
• If the video is sent as a sequence of frames, all frames
must be viewed at the same rate. Although synchronous
transmission allows a long series of bits to be sent
without delay, there may be gaps between frames.
• In isochronous transmission, the entire stream is
synchronized so that there are no gaps.
• It guarantees that the data arrives at the fixed rate.
Multiplexing
•It is not possible to set up a separate connection between
each pair of communicating devices. In such cases, a single
communication link may be shared among multiple
devices.
•This communication link is usually of a high capacity.
Such links are called “trunks”. Multiplexing is a technique
which allows simultaneous transmission of multiple
signals across a single communication channel.

•High bandwidth media such as fiber optic cables and


satellite links have the capacity to accommodate several
signals. Here, multiplexing schemes are used so that the
bandwidth can be efficiently shared among multiple
simultaneous transmissions.
The following figure depicts multiplexing. A multiplexer
takes several inputs, which are transmitted over a high
capacity signal link. At the receiving end, the
demultiplexer separates the data and delivers it to
appropriate output line.

Two basic multiplexing schemes are used:


1. Frequency Division Multiplexing (FDM)
2. Time Division Multiplexing (TDM)
Figure: Multiplexing
Frequency Division Multiplexing
• Here, the frequency spectrum of the communication
channel is divided among several logical channels,
each channel carrying one signal.
• A station is assigned one channel and it has exclusive
possession of that frequency band as long as it wants to
communicate. This scheme is used when the bandwidth
of the transmission medium exceeds the required
bandwidth of the signal to be transmitted.
• A guard band is a small unused frequency channel
between two channels to prevent interference.
• Example: Radio Broadcasting is a common example
where we receive multiple stations. Each station is
assigned a frequency range. To prevent interference,
unused portions of the spectrum called 'guard bands'
separate the channels.
Figure illustrates three voice channel multiplexed using
FDM. Each channel has a usable bandwidth of 3 kHz with
guard bands of 500 Hz on either side. Each channel is
modulated over a carrier signal so that it occupies a different
portion of frequency spectrum.

Figure : Frequency Division Multiplexing


Advantages
1. Multiple stations can share the same communication
channel simultaneously.
2. Each station gets full use of the channel for the duration
of the communication.

Disadvantages
1. Since the channel bandwidth is divided into smaller
channels, each station gets only a small bandwidth for
communication.
2. If there are many stations, it may not be possible to assign
a channel to each station. Moreover, this will reduce the
transmission bandwidth for each channel.
Time Division Multiplexing

• In TDM, time is divided into short periods called time


slots.
• Each user is assigned a time slot or time slice for
communication in a round robin fashion.
• During a time slot, the user can use the entire channel
capacity for transmission.
• In the figure, portion of the signals 1,2,3 & 4 occupy the
link sequentially.
Figure: Time Division Multiplexing

Example: Radio transmission where the stations are


transmitted using FDM but each station is subdivided into
two logical stations – one for music and other for advertising
which are transmitted one after the other using TDM.
Advantages
1. Each station can use the entire bandwidth for the
duration of a time slice.
2. Stations can be assigned priorities and assigned more
time slots.

Disadvantages
1. If some station does not have data to send, the time
slot is wasted and the channel is underutilized.
2. If the number of stations are very large, a station has
to wait for a long time for its time slot.
Comparison between FDM and TDM
Frequency Division Time Division
Multiplexing (FDM) Multiplexing (TDM)
FDM divides a channel into TDM divides a channel by
smaller frequency bands allocating a time period for
each station.
Each station can use the sub A station can use the whole
channel for the entire duration. channel for a time slot
assigned to it.
There is no delay in data A station has to wait for its
transmission. time slot.
The receiver has to demodulate The demultiplexer has to
the signal. separate portions of signals
and recombine them to create
the whole signal.
Frequency Division Time Division
Multiplexing (FDM) Multiplexing (TDM)
FDM can accommodate only a TDM can accommodate more
limited number of stations stations compared to FDM
Signals are separated by guard Signals are separated by time
bands between sub channels. slots.
Used in applications where the Used when the signal
signal bandwidth is small and bandwidth requires the entire
channel bandwidth is very large. channel bandwidth.
Example: radio channels. Example: television channels
Problems
1. Ten signals, each requiring 4000 Hz, are multiplexed onto
a single channel using FDM. What is the minimum
bandwidth required for the multiplexed channel ? Assume
that the guard bands are 400 Hz wide.
Solution
There are 10, 4000 Hz signals. We need nine guard bands to
avoid any interference.
The minimum bandwidth required is
4000 x 10 + 400 x 9 = 43,600Hz.
Wavelength Division Multiplexing (WDM)
• Fiber Optic communication use WDM. The concept of WDM
relates to Physics. When a white light beam goes through a
prism, it separates into individual colored light beams by the
prism. Each light beam has different wavelengths. This
scenario works vice versa as well. The individual color beams
combine back to generate a white light beam.
• Wavelength division multiplexing is a technique of multiplexing
multiple optical carrier signals through a single optical fiber
channel by varying the wavelengths of laser lights.
• It combines multiple light beams from channels using a
multiplexer and sends them as a single light beam through an optic
fiber strand. They are combined so that their wavelengths are
different.
• On the receiving end, the demultiplexer separates the single light
beam back into multiple light beams and sends them to their own
channels.
• WDM is similar to FDM but, the transmission occurs through
fiber optic channels. Therefore, the multiplexing and
demultiplexing involve optical signals, whereas FDM uses analog
signals and TDM uses digital and analog signals.

• WDM systems are popular with telecommunications companies


because they allow them to expand the capacity of the network
without laying more fiber by using WDM and optical amplifiers. It
is used in cable networks and in cloud data centers.
Switching
When there are multiple devices, how to have one-to-one
communication between two communicating devices? One
solution is to have a mesh topology or star topology.
However, for very large networks, this is highly impractical.
A multipoint connection like bus is also not possible due to
the distances involved.
A better solution is switching. A switched network consists
of a series of interlinked nodes called switches which are
capable of creating temporary connections between two or
more devices.

Types of Switching
1. Circuit Switching
2. Message Switching
3. Packet Switching
1. Circuit Switching
This is a method in which an end-to-end path or circuit is
established between communicating machines. The
machines have exclusive use of this path until connection is
released.
This involves three phases:
i. Circuit Establishment: Before any data transfer can
begin, an end-to-end path has to be set up. Some setup time
is required.
ii. Data Transfer: Once the circuit is established, analog or
digital data can be transmitted depending upon the nature of
the network. The only delay now is the propagation delay.
There is no danger of congestion or a busy signal.
iii. Circuit Disconnection: The circuit can be released by
either of the connected stations after data transfer takes
place.
An example of circuit switching is the telephone system
where a physical circuit is setup between the source and
destination machine.

The schematic of circuit switching is shown in figure (a).


Here, the six rectangles represent switching offices, each
having 3 incoming and 3 outgoing lines. When a call is
placed, a physical connection is established between the
incoming line and one of the output lines (shown by dotted
lines).
Advantage
1. This method transfers data in real time with the only
delay being in circuit setup and propagation delay.

Disadvantages
1. Circuit switching can be inefficient. Even if no data is
being transferred, the channel remains dedicated for the
duration of the connection.
2. Problems occur when two or more stations attempt to
establish a link with the same station. Such situations have
to be resolved.
2. Message Switching

• In message switching, a physical path is not set up


between the sender and the receiver.
• When the sender has a block of data to send, it is sent to
intermediate switching station which store it and
sends it to the appropriate station when an output line is
free.
• This mechanism is referred to as 'Store and Forward'
method.
• Each block is received as a whole checked for errors and
retransmitted. Thus, a block may 'visit' several switching
stations, before reaching the destination.
• An example of message switching is the e-mail system
which is now replaced by packet switching.
Advantages
1. No circuit has to be set-up in advance.
2. The sender can send data whenever it wants to and does
not need to check the status of the receiver-whether it is
busy or idle.

Disadvantages
1. The system implementing message switching requires
sufficiently large data buffers to hold the messages.
2. A single block may tie up a line for a long time, thereby
causing delay to the other messages queued up on that link.
3. If there's a lot of traffic on the network, the delay will
be very high thereby, reducing throughput.
4. Complicated routing algorithms are required.
3. Packet Switching

• In packet switching, a message is broken into several


small blocks called “packets".
• A limit is placed on the maximum block size, thereby,
making it easier to store packets and route them through
the network.
• Each packet contains control information including
source and destination address and are routed
independent of the other packets to the same destination,
i.e. two packets for the same destination may be sent via
different paths.
• Thus, it is possible that the packets arrive out of order.
So, some identification scheme has to be employed.
Advantages
1. Call setup phase is avoided.
2. This is more flexible. Thus, if congestion develops in one
part of the network, the packets can be routed via different
paths.

Disadvantages
1. There is no guarantee that packets will be delivered.
2. Requires more overheads since each packet has to carry a
lot of control information.
3. The packets may arrive out of order.
The difference between Circuit, Message and Packet switching is
illustrated in figure
Figure: Timing of Events
(a) Circuit Switching (b) Message Switching (c) Packet Switching
Comparison of Circuit, Message and Packet Switching
Circuit switching Message switching Packet switching

Requires circuit set No circuit set-up is No circuit set-up is


up before required. required.
transmission.
Channel bandwidth Channel bandwidth is Channel bandwidth
is pre-allocated for allocated separately is allocated
the duration of for each message. separately for each
transmission. packet.
Data is not divided Data is divided into Data is divided
into separate units. messages. into small chunks
called packets.
All data bits follow All messages may not All packets may
the same path from follow the same path. not follow the
sender to receiver. same path.
Circuit switching Message switching Packet switching

Source and Each message Each packet


destination contains source and contains source
addresses are used destination address. and destination
only during circuit address.
setup.
A fixed-size buffer Large buffers are Small buffers are
is allocated for the needed to store and needed to store and
entire circuit. forward messages. forward packets.
Call setup requires No need of call setup. No need of call
time. setup.
The routing decision The routing decision The routing
has to be made only has to be made decision has to be
during call setup. separately for each made separately
message. for each packet.
Circuit switching Message switching Packet switching

Data Transmission Store and forward Store and forward


time is negligible. requires processing requires processing
time for each time for each
message. packet.
Data is always Messages may arrive Packets may arrive
received in order at out of order. out of order
the receiver.
Centralized control Distributed control Distributed control
mechanism with mechanism where mechanism where
global knowledge of most nodes require most nodes require
the network very little very little
configuration. information about the information about
network the network
configuration. configuration.
Circuit switching Message switching Packet switching

The sender and The network and The network and


receiver can use any carrier determine the carrier determine
bit rate, format or basic parameters. the basic
framing mechanism parameters.
during
transmission.
The charges are The charges are The charges are
based on the based on the number based on the
connection time. of messages sent. amount of data
transmitted.
Slower than Faster than circuit Fastest
message and packet switching but slower transmission
switching. than packet
switching.
Circuit switching Message switching Packet switching
Inefficient use of Efficient use of Optimal use of
network network bandwidth. network
bandwidth. bandwidth
Any failure in Only messages Packets can be
network device or already in re-routed via
channel will cause transmission will be other paths.
data transfer to be affected.
aborted.
Congestion may Large message size Less susceptible
occur only during can cause to congestion
call setup congestion in the because of small
network packet size
M.Sc. (Computer Application) Sem-II

Computer Networks
Chapter 4
The Data Link Layer

Prof. Vidya Bankar


Dr. D. Y. Patil ACS College Pimpri Pune-18.
Introduction
• The Data link layer is the layer between the physical
layer and network layer.
• The physical layer deals with raw transmission of bits
across the medium. It does not understand the syntax of
meaning of the data bits i.e. it is not concerned with
what the data represents, addressing, errors, speed of
transmission etc.
• The data link layer takes care of all these factors. This
layer is responsible for achieving reliable, efficient
communication between two adjacent machines which
are directly connected by a communication channel.
• Hence, it is a very important layer and takes the
responsibility of transmitting data from one node in
the network to the next.
Framing
One of the important function performed by the data link
layer is framing. The sending data link layer takes a packet
from the network layer and puts it into frames for
transmission. The structure of frame is as shown. The frame
contains a frame header, a payload field for storing the
packet and a frame trailer.

Figure: Packets and Frames


In order to identify the start and end of a frame, it must
have delimiters.

Four commonly use methods for framing are:

1. Character Count
2. Flag bytes with byte stuffing
3. Starting and Ending flags with bit stuffing
4. Physical Layer Coding Violations

1. Character Count:
In this method of framing, a field in the frame header is
used to store the number of characters in the frame.
• When the receiving data link layer receives the frame,
it reads the character count and knows how many
characters are in the frame. Hence, it can detect the end
of the frame. The following example shows this
technique for four frames of sizes 5, 5, 8, 8 respectively.
• One problem with this method is that a transmission
error can modify the count value. If this happens, there
is no way of telling where the next frame starts or
ends.
• Even if the receiver detects a transmission error, the
receiver cannot ask for retransmission of a specific
frame since it does not know which frame had the error.
Thus, the entire data need to be retransmitted.
• For example, if the count in the second frame gets
modified from 8 to 7, the length of the next frame will be
interpreted as 1.
2. Flag Bytes with Byte Stuffing:
• Some protocols use special bytes as frame delimiter. This
byte is called flag byte and is used as the starting as
well as the ending delimiter for a frame. This flag byte
is used to identify start and end of the frame.
• However, a problem occurs when the flag byte's
binary code occurs as a part of the data itself.
• The receiver will mistakenly interpret it as a frame
delimiter, this problem can be solved using byte stuffing
or character stuffing.

Figure: Flag bytes


• Here, a special byte called Escape byte is inserted or
stuffed before each accidental flag byte in the data.
The receiving data link layer removes the escape byte
from the frame.
• In case an escape byte occurs in the data, it is also
preceded by an inserted escape byte.
• The problem with this method is that it allows only 8 bit
characters and cannot be used for arbitrary sized
characters.
Figure: Character stuffing
3. Starting and Ending Flags with Bit Stuffing:
• In this method, the data frames can contain an arbitrary
number of bits and allows character codes with
arbitrary number of bits per character.
• Each frame begins and ends with a special bit
pattern called the flag byte which is 01111110.
• Here again, this bit pattern could occur in the data. To
distinguish it from the flag byte, bit stuffing is used.
• When the sending data link layer encounters five
consecutive l's in the data, it stuffs a '0' into the bit
stream. The receiving data link layer de-stuffs the '0’
following five consecutive 1’s.
(a) Original data
011011111111111010010

(b)After bit stuffing


01101111101111101010010

stuffed bits
(c) After destuffing
011011111111111010010
Figure: Bit Stuffing

Thus if the receiver loses track, it scans the input for flag
sequences. Since they can only occur at frame
boundaries, and never within the data, the receiver can
identify frame boundaries easily.
4. Physical Layer Coding Violations:

• This method of framing is used for networks in which


the encoding scheme used for data contains some
redundancy, i.e. there are some signal levels which
are not used for transmitting data bits.
• Normally, bit 1 is encoded as a high-low pair and 0 is
a low-high pair.
• Thus, every data bit has a transition in the middle and
so, the receiver can easily identify bit boundaries. The
high-high and low-low pairs are not used for data.
• These pairs can be used to represent frame
boundaries.
Solved Problems
1. The following character encoding is used in a data link
protocol:
A: 01000111; B:11100011; FLAG: 01111110; ESC:
11100000. Show the bit sequence transmitted (in binary) for
the four-character frame: A B ESC FLAG when each of the
following framing methods are used:
a. Character count.
b. Flag bytes with byte stuffing.
c. Starting and ending flag bytes, with bit stuffing.
Solution
a. 00000101 01000111 11100011 11100000 01111110
(5 A B ESC FLAG)
b. 01111110 01000111 11100011 11100000 11100000
11100000 01111110 01111110
(FLAG A B ESC ESC ESC FLAG FLAG)
c. 01111110 01000111 110100011 11100000 011111010
01111110

2. The following data fragment occurs in the middle of a data


stream for which the byte-stuffing algorithm is output after
stuffing?
A B ESC C ESC FLAG FLAG D. What is the output after
stuffing?
Solution
The solution is: A B ESC ESC C ESC ESC ESC FLAG ESC
FLAG D.
3. A bit string, 0111101111101111110, needs to be
transmitted at the data link layer. What is the string actually
transmitted after bit stuffing?
Solution
The solution is: 011110111110011111010.

4. Byte stuff the following data: A ESC ESC FLAG B


Solution
We stuff an ESC before every ESC and every FLAG byte.
A ESC ESC ESC ESC ESC FLAG B
Error Control
• The data link layer has to ensure that the frames are sent and
received properly at the receiving end. It has to take into
consideration transmission errors.
• One way to deal with errors is to include enough redundant
information along with the data so that receiver can deduce
what the transmitted data must have been (Error correcting
codes).
• The other strategy is to include only enough redundant
information so that the receiver can deduce that an error has
occurred but not which error, and request a retransmission.
(Error-detecting codes).
• On highly reliable channels like fiber, it is faster and
cheaper to use error detecting codes, and retransmit if the
frame is found faulty. However, if the channel is very noisy,
such as a wireless link, it is better to use error-correcting
codes so that the receiver is able to rectify the error.
In most cases, error detection with retransmission is
preferred because it is more efficient. Methods used to detect
errors include Parity bit, CRC codes, Hamming distance
Cyclic Redundancy Code (CRC)
• This is one of the most widely used error detection
method. In this method, the 'm' bit frame is regarded as a
coefficient list for a polynomial with 'm' terms from xm-l to
x0.
• Both the sender and the receiver have to agree upon a
generator polynomial G (x) in advance.
• A check-sum is appended to the m bit frame such that the
check-summed frame is divisible by G(x).
• When the receiver gets the check-summed frame, it
divides all received bits by G(x).
• If the remainder is 0, there were no transmission errors.
If there is a remainder, there is an error.
The checksum is calculated as follows:
1. Let r be the degree of G(x). Append ‘r’ zero bits to the end
of 'm' message bits. This represents polynomial xr M(x).
2. Divide the bit stream corresponding to xr M(x) by G(x)
using modulo 2 division.
3. Subtract the remainder having 'r' bits from the bit stream of
xr M(x) using modulo 2 subtraction. The result is the check
summed frame to be transmitted: T(x).

Example: Consider message 1101011011 and G(x)=x4+x+1


Generator = 10011.
Since the degree of G(x) = r = 4, append four zeros to the
message.
Message after appending = 11010110110000.
Now, we divide this stream by the generator.
Now subtract the remainder from m+r.
xr M(x) =11010110110000
Remainder - 1110
r =11010110111110

Thus, the transmitted frame is:

11010110111110

When the receiver receives this frame, it divides the frame by


the same polynomial G(x). If the remainder is 0, there were
no transmission errors.
Hamming Distance
• Hamming distance is used for error detection as well as
correction.
• Hamming distance is the number of bits that need to
change to convert one valid codeword into another.
• For example, Consider two valid codewords 100 and 111.
Here, two bits need to change for one codeword to be
converted to another during transmission.
• But if one bit changes, the receiver will know that it's an
error. Hence, 1 bit error can be detected.
• To detect ‘n’ bit errors in transmission, a hamming
code with distance n+1 is needed and to correct 'n' bit
errors, hamming distance of 2n + 1 is needed.
• For example, to detect 1 bit errors, the hamming distance
should be 2 and to correct 1 bit errors, the hamming
distance should be at least 3.
To calculate the hamming distance, XOR the two codewords
and count the number of 1's in the result.
For example,
Hamming distance between (110011, 101010) is 3
since XOR(110011, 101010) = 011001.

Ex. Find the minimum hamming distance of the following


coding scheme: 000, 011, 101, 110
Solution:
First we find the Hamming distance between two pairs of
code words:
d(000,011)=2, d(000, 101)=2, d(000,110)=2
d(011, 101=2, d(011,110)=2,
d(101,110)=2
Hence minimum Hamming distance = 2
Ex. Find the minimum Hamming distance of the following
coding scheme:
00000, 01011, 10101, 11110
Solution
First we find the Hamming distance between two pairs of
codewords:
d (00000,01011) = 3,
d (00000,10101) = 3,
d (00000,11110) = 4,
d (01011, 10101) = 4,
d (01011,11110) = 3,
d (10101,11110) = 3
Hence minimum Hamming distance = 3
To generate the Hamming code
• For a message with ‘m' bits, 'r' additional hamming bits
or check bits are inserted such that (m + r + 1) <= 2r.
• Therefore for a 4-bit message, 3 check bits are required.
• These check bits are placed at positions that are powers
of 2 in the codeword (i.e. 1, 2, 4 etc.) The remaining are
data bits. For n = 7, (m = 4 and r = 3), the positions are:

1 2 3 4 5 6 7
C1 C2 D1 C3 D2 D3 D4

where C1, C2, and C3 are check bits and D1 to D4 are data
bits.
The check bits are calculated such that the check bit along-
with some data bits has even (or odd) parity.
• C1 is calculated from bit position 1, 3, 5, 7, 9, i.e.,
position numbers having bit l in their LSB.
• C2 is calculated from 2, 3, 6, 7, 10, i.e., having bit 1 in
the second place from LSB.
• C3 is calculated from 4, 5, 6, 7, ... , i.e., having bit l in
the third place from LSB.
Ex: Calculate the Hamming bits for data message 1001.
Here, m= 4. Thus, r = 3,
since (m + r + 1) <= 2r i.e. 4 + 3+1 <=23.
1 2 3 4 5 6 7
C1 C2 D1 C3 D2 D3 D4
1 0 0 1

We will now calculate the check bits C1, C2 and C3


C1 = even parity on bits (1, 3, 5, 7) = even parity on bits
(C1, 1, 0, 1) ∴ C1 = 0
C2 = even parity on bits (2, 3, 6, 7) = even parity on bits
(C2, 1, 0, 1) ∴ C2 = 0
C3 = even parity on bits (4, 5, 6, 7) = even parity on bits
(C3, 0, 0, 1) ∴ C3 = 1
Thus, the transmitted message will be
C1 C2 D1 C3 D2 D3 D4
0 0 1 1 0 0 1

When the codeword arrives at the receiver, it calculates


each check bit.
If the parity is correct, it accepts the codeword.
If it is incorrect, it adds the positions of the wrong check-
bits to give the position of the erroneous bit.
For example, if the message arrives as 0011011
1 2 3 4 5 6 7
C1 C2 D1 C3 D2 D3 D4
0 0 1 1 0 1 1

D3 has changed during transmission. Now, C2 and C3 will be


incorrect since they use bit no. 6. Their sum is 6 (position 2
and 4). This means that the 6th bit, i.e., D3 has changed.
Elementary Data Link Protocols
The services provided by the data link layer are implemented
by protocols. Certain assumptions are made by these
protocols:
1.We assume that the physical layer, data link layer and
network layer are independent processes and
communicate by passing messages back and forth.
2. Machine A wants to send a long stream of data to machine
B using a reliable, connection oriented service.
3. A is assumed to have infinite supply of data and never
has to wait for data to be produced.
4.For the data link layer, every bit coming from the
network layer has to be delivered to the destinations
network layer. The fact that the packet also contains a
header is of no concern to the data link layer.
5. We assume that there exists suitable procedures to get
data and send data to and from the network and physical
layer.
6. The transmitting hardware computes the checksum
and adds it to the data. The data link layer need not worry
about it.
7. Initially the receiver has nothing to do. It is just
waiting for something to happen. Events could be Frame
Arrival, Error or Time-Out.
8. When a frame arrives, the hardware computes the
checksum. If there is no error, the data link layer is
informed. It then takes the frame, inspects the header and if
it is correct, passes only the packet portion to the network
layer but not the header.
These protocols are classified as follows:

Data link protocols

• For noiseless channel


1. Simplex
2. Stop-and-wait

• For noisy channel


1. Stop-and-wait ARQ
2. Go back n ARQ
3. Selective repeat ARQ
1. Simplex Protocol
This is the simplest protocol and nicknamed "Utopia"
because it is thoroughly unrealistic, here the assumptions
made are:
1. Data transmission is simplex, i.e., in one direction only.
2. Both the transmitting and receiving network layers are
always ready.
3. Processing time can be ignored.
4. Infinite buffer space is available.
5. The communication channel is ideal, i.e., it never loses or
damages frames.
In this protocol, there are two distinct procedures:
1. A sender, which runs in the data link layer of the source
machine.
2. A receiver which runs in the data link layer of the
destination machine.
Since the channel is ideal, there is no possibility of an error
or lost frames. Thus, the only event possible is the arrival of
an undamaged frame. The protocol operation is shown in the
following diagram.

Figure: Simplex Protocol


Algorithm Sender
1. The sender is in an infinite loop sending data to the receiver.
2. When it gets a RequestToSend event from the network layer
It fetches data from the Network layer Constructs a frame
Sends the frame to the Physical Layer for transmission.

Algorithm sender()
{ while (true)
{ WaitForEvent();
if (event (RequestToSend))
{ GetData();
MakeFrame ();
SendFrame();
}
}
}
Algorithm Receiver
1. The receiver is waiting for an event to occur.
2.When it is notified of a frame arrival, the frame is taken from
the Physical Layer.
3. The Data is extracted from the frame and sent to the Network
layer.
4.The receiver goes back into the wait state.
Algorithm receiver()
{ while(true)
{ WaitForEvent();
if (Event(ArrivalNotification))
{ ReceiveFrame();
ExtractData();
DeliverData();
}
}
}
The following diagram shows the communication between
the sender and receiver. The sender does not worry about the
receiver, it keeps on sending frames whenever the network
layer gives it data.

Figure: Simplex Protocol Operation


2. Stop-and-Wait Protocol
• In this protocol, we drop the unrealistic assumption
that the receiving network layer can process incoming
data infinitely fast.
• In such a case, the receiver must have some buffer space
to store the frames. However, this space is limited. If
more frames are sent, they will be discarded.
• Hence, there must be some feedback from the receiver to
the sender. The sender should be prevented from
transmitting the next frame before the receiver sends an
acknowledgement for the received frame.
• The sender transmits the next frame only after it has
received an acknowledgement. Hence it is called Stop
and Wait protocol.
Figure: Stop and Wait Protocol
Algorithm Sender
1. The sender begins by accepting a packet from the network
layer, constructs a frame and sends it.
2. It now has to wait until an acknowledgement frame arrives
from the receiver (Since the channel is ideal, the only
possibility again is FrameArrival).
3. After it gets an acknowledgement, it sends the next frame.

Here, canSend is used as a Boolean flag which decides


whether the sender can send a frame or it must wait for an
acknowledgement of a sent frame.
Algorithm sender()
{
while (true)
{ canSend = true;
WaitForEvent();
if (Event (RequestToSend) and canSend==true)
{ GetData();
MakeFrame();
SendFrame();
canSend=false;
}
WaitForEvent ();
if (Event (FrameArrival)
{ ReceiveFrame ();
canSend=true;
}
}
}
Algorithm Receiver
1. The receiver is initially waiting for an event.
2. When a frame arrives, it accepts the frame, sends the data
to the network layer.
3. The receiver sends an acknowledgement frame back to the
sender and enters the wait loop again.
Algorithm receiver()
{
while(true)
{
WaitForEvent();
if(Event(ArrivalNotification))//Data frame arrives
{
ReceiveFrame();//Accept frame
ExtractData();
DeliverData(); //Send data to network layer
SendFrame(); // Send acknowledgement
}
}
}
In this case, the communication channel has to be capable of
bi-directional information transfer. But since the data frame
and acknowledgement frame do not have to travel
simultaneously, a half-duplex physical channel would be
sufficient. The operation of this protocol is shown below:

Figure: Stop and Wait Protocol operation


The problems with this method is that the sender has to
wait till the receiver sends back an acknowledgement.
Hence, the bandwidth utilization is below optimum.
The above two protocols are for a noiseless channel which
is unrealistic. Hence, these protocols are not implemented.

The protocols defined below are for a Noisy channel.

Simple Protocol For Noisy Channel


This protocol is also called PAR (Positive
Acknowledgement with Retransmission) or Stop and
Wait ARQ (Automatic Repeat reQuest).
In this protocol, we will drop the assumption that the
communication channel is ideal. We will consider the
situation of a communication channel that makes errors.
Frames may either get damaged or lost.
• A simple scheme would be that a sender sends a frame.
• If it arrives properly at the receiver, it will send an
acknowledgement, otherwise not.
• If the sender does not receive the acknowledgement, it
will time-out and retransmit the frame.
• However, this scheme could pass duplicate frames to
the receiver.
• This will happen if the receiver receives a frame, sends
an acknowledgement and it gets lost.
• The sender retransmits the frame and the receiver
accepts it because it does not know it is a duplicate
frame.
• This problem can be avoided by using sequence
numbers for every frame.
• A one-bit sequence number (0 or 1) is enough since at
any given instant of time, we will be dealing with only
two frames: the frame sent and the next frame to send.
• Initially, the sender sends frame 0.
• The receiver expects frame 0.
• If it arrives correctly, the receiver increments its frame
expected number to 1.
• When the sender receives acknowledgement for frame 0,
the sender increments next frame to send to 1.
• In modulo2 arithmetic, the sequence number will be
incremented from 0101 and so on.
Algorithm Sender
1. The sender remembers the sequence number of next
frame to be sent in Sn.
2. After transmitting a frame, the sender starts the
timer. (Time interval is chosen to allow enough time
for the frame to travel, the receiver to process it and the
acknowledgement to come back).
3. If the timer times out, the sender sends a duplicate
frame.
4. If a valid acknowledgement comes in, the sender
clears the buffer (PurgeFrame), advances the
sequence number and sends another frame if there is
data from the network layer.
Algorithm sender()
{Sn=0;// initialize sequence number to 0
canSend = true;
while(true)
{ Wait ForEvent ();
if (Event (RequestToSend) and canSend==true)
{
GetData();
MakeFrame (Sn);
StoreFrame (Sn);
SendFrame (Sn);
StartTimer();
Sn = Sn+1;
canSend=false;
}
WaitForEvent ();
if (Event (FrameArrival))
{ ReceiveFrame (ackno);
if (notCorrupted and ackNo==Sn)
{ StopTimer();
PurgeFrame (Sn-1);
canSend=true;
}
}
if (Event (TimeOut))
{
ResendFrame (Sn-1);
StartTimer();
}
}
Algorithm Receiver

1. The receiver remembers the number of the expected


Frame in Rn.
2. The receiver waits for a frame to arrive.
3. If an undamaged frame arrives and it is the expected
frame, the receiver receives the frame, sends an
acknowledgement and increments Rn.
4. If it is a duplicate frame, i.e., Rn is not equal to seqNo,
the receiver simply sends an acknowledgement of the
previous received frame.
5. If the frame arrives with an error, the receiver goes
into the sleep state waiting for an event to occur.
Algorithm receiver()
{ Rn=0; //expected frame seq. number to 0
while(true)
{ WaitForEvent();
if (Event (ArrivalNotification))
{ ReceiveFrame();
if(CorruptedFrame())
sleep();
if (seqNo == Rn)
{
ExtractData();
Deliverdata();
Rn = Rn + 1;
}
SendFrame (Rn);
}
}
}
Efficiency of Stop and Wait ARQ
Channel utilization = the fraction of the transmission
capacity of a communication channel that contains data
(frames) transmissions.
This protocol is very inefficient if the channel bandwidth is
large (thick) and the propagation delay is large (long).
Consider the following diagram:
Figure: Efficiency of ARQ Protocol
• Here, t_data is the time to transmit the frame, t_prop is
the propagation delay, t_ack is the time to send the
acknowledgement frame.
• The total time taken for the sender to receive the
acknowledgement is t_data + t_ack + 2t_prop.
• Since the acknowledgement frame is very small, we can
ignore t_ack.
• Out of the total time of t_data + t_ack + 2t_prop, only
t_data time is used to transmit the frame.
Hence, Channel Utilization = t_data/t_data + 2t_prop
If the frame length is l bits, b = channel capacity in bits/sec
and R = Round trip, propagation delay in sec, then
t_data = l/b, R = 2t_prop. Substituting in the above equation
gives:
Channel Utilization = l/(l+bR)
Sliding Window Protocols

In the protocols studied so far, data transfer was simplex,


i.e. in one direction only. However, in practical situation
full duplex transmission is required, i.e., the two
communicating machines send data simultaneously.

Three strategies can be used.

i. Use two separate communication channels. Each


channel is used for simplex traffic in one direction.
Further, each host would have a “forward" channel
for data and a "reverse channel for
acknowledgements. Here, the bandwidth of reverse
channel will be almost entirely wasted.
ii. Use the same physical channel in both directions.
Data frames from A to B are intermixed with
acknowledgement frames from A to B in the forward
channel and the reverse is used for traffic from B to A.

iii. Piggybacking: Sending the acknowledgement along


with the data frame is called piggybacking. When a
frame is received, instead of sending an
acknowledgement immediately, the receiver waits for
an outgoing frame from it. The acknowledgement is
attached to the outgoing data frame (using the ack field
in the header). In effect, the acknowledgement gets a
free ride on the next outgoing data frame.
Advantages of Piggybacking

• Better use of available channel bandwidth.


• The acknowledgement field is only of a few bits
whereas an entire acknowledgement frame would
consist of many bits (header, checksum, etc)
• Fewer frames sent means fewer frames received, thereby,
reducing the requiring fewer buffers in the receiver.

Disadvantages of Piggybacking

• A separate timer has to be maintained. One issue is


how long should the receiver wait for an outgoing
frame to send the acknowledgement. If it waits too long,
the sender will timeout and retransmit.
Concept of Sliding Window Protocol

• In a sliding window protocol, the data link layer of the


sender and receiver maintains a set of sequence
numbers corresponding to frames it is permitted to
send and receive respectively.

• These lists are called 'sending window' and 'receiving


window' respectively.

• The sizes and limits of the windows need not be the


same in the sender and receiver.
All protocols belonging to this category have common
features listed below:
• Each outbound frame contains a sequence number
ranging from 0 to some maximum (usually 2n-1, so n
bit field can be used).
• At any instant of time, the sender and receiver maintain
a sending and receiving window respectively.
• The communication channel must deliver frames in the
order that they were sent.
• The sender's window represents frames sent but not
acknowledged. A new frame is given the next highest
sequence number and the upper edge of the window is
advanced by one. When an acknowledgement arrives, the
lower edge is advanced by one.
• Since the sent frames may be lost or damaged, the
sender has to store them in buffers. If the maximum
window size is 'n', 'n' buffers are required.
• The receiver's window corresponds to the frames it
may accept. Any frame falling outside the window is
discarded. When a frame whose number is equal to the
low edge arrives, an acknowledgement is generated and
the window is rotated by one. If the window size is one,
the receiver only accepts frames in order. For larger
size window, this is not true but the network layer is
always given data packets in order.
One Bit Sliding Window Protocol

This is also called stop-and-wait one bit sliding window


protocol. In this protocol

1. The size of the sending and receiving window is 1,


i.e., the sender can send only one frame at a time and the
receiver can receive only one frame at a time.
2. The sender transmits a frame and waits for an
acknowledgement before sending the next one.
3. Since only one frame is sent or received at a time, a
one-bit sequence number is enough. The sequence
numbers go upto MAX_SEQ but incremented one at a
time. But since only one frame is outstanding at a time,
we can use only two sequence numbers 0 and 1.
Mechanism
• The sender initializes sequence-number to 0. The sender
builds a frame with sequence number 0 and sends it.
The receiver expects frame 0.
• When the receiver receives a frame, it checks to see if it
is a duplicate one. If it is the expected frame, it is
accepted, an acknowledgement is sent and the receiver
window is slide up, i.e., it expects frame 1.
• The acknowledgement field contains the number of
the last frame received without error.
• If the sender receives an acknowledgement with
correct sequence number, it slides up its sequence-
number to 1 and sends a new frame.
• If they do not match, it has to resend the same frame.
• The notation is (Seq, ack, packet).
This protocol ensures that no duplicate frames will be
delivered to the network layer if one transmits before the
other.

Peculiar Situation
• If both, A and B send simultaneously, a peculiar situation
arises. There will be a synchronization problem if
both A and B transmit simultaneously.
• This causes duplicate frames to be delivered even
though there is no transmission error.
• Figure (b) shows that duplicate frames will be delivered
since A and B send at the same time.
• The * indicates where a frame is accepted.
Figure: Two scenarios for one bit sliding window protocol.
(a) Normal Operation (b) Duplicate frames delivered
Pipeline Technique
• In the previous protocol, the sender had to wait till it
received an acknowledgement before sending the next
frame.
• In order to achieve better efficiency, the sender can
transmit 'w' frames instead of 1 such that by the time it
has transmitted the w frame, the acknowledgement for
frame 1 arrives, thus eliminating the sender's waiting
period.
• Thus, 'w' unacknowledged frames are outstanding at all
times. The sender's window size is thus 'w'.
• This technique is used when the propagation delay is
large and the line cannot be kept idle during this time.
Thus, more frames can be sent at a time to utilize the
channel bandwidth efficiently.
Design Considerations
Since multiple frames are transmitted at the same time,
two strategies are used to deal with errors in the
pipelining technique:
1. Go back n ARQ
2. Selective repeat ARQ

Go back N Automatic Repeat Request


• In this strategy, pipelining technique is used. If a frame
gets lost or corrupted in transit, the receiver simply
discards the damaged frame and all subsequent ones,
sending no acknowledgement.
• It accepts frames only in order.
• The sender will eventually time out and retransmits
all unacknowledged frames.
Sequence Numbers: Since each frame must be identified, it
is assigned a sequence number. If ‘m' bits are allocated in
the frame header for sequence number, sequence numbers
are from 0 to 2m-1. For example, if m=3, the sequence
numbers are:
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 ....

Sender Sliding Window: The sender and receiver maintain


a sliding window of frame numbers. The sender sliding
window is an abstract concept or box having size 2m-1. It
has 4 parts:
a. Frames numbers which have been sent and
acknowledged
b. Frames which have been sent and not yet acknowledged
c. Frames within the window size which can be sent
d. Frames falling out of the window
For example, consider m = 3. Frame numbers can be 0 - 7.
The window size = 7. The four parts of the sender window
are shown below.
Figure : Sender sliding window
Here,
Sf = first outstanding frame
Sn = next outstanding frame
Ssize = size of the sending window
Sf Sn

5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4
a b c d

Ssize=2m-1
Receiver Sliding Window: The receiver only accepts
frames in order. Hence, the receiver window size is 1. It
stores the expected frame number in Rn. When the expected
frame arrives, Rn is incremented.

Method:
• The sender sends multiple frames and maintains a timer
for each sent frame.
• The receiver sends a separate acknowledgement for
each correctly received frame. If it receives a frame
with error, the receiver discards the damaged frame
and all subsequent frames.
• When the sender does not receive an acknowledgement
for a frame, the timer times out. The sender then
retransmits all the outstanding frames.
The Go-back-N strategy is illustrated in figure. Here, frame
2 is arrived with an error, hence it is discarded. The
receiver also discards all subsequent frames 3-8. The
sender retransmits frames 2-8.

Figure : Go back n strategy


Selective Repeat Automatic Repeat Request
• In Go-back-N, the receiver window size is 1 and it only
accepts frame in order. This causes a lot of
retransmissions at the sender.
• In selective repeat ARO, the receiver does not discard
but buffers all frames following a damaged or lost
frame.
• The sender only resends the damaged or lost frame. This
is more efficient that Go-back-n.

Window Sizes
• The sender and receiver maintain a sliding window of
frame numbers. The sender and receiver window sizes
are the same.
• The receiver window corresponds to the frame numbers
which the receiver can accept and buffer.
Operation
• The sender sends multiple frames corresponding to its
sending window.
• The receiver window corresponds to frame numbers
which it can accept.
• If a frame arrives damaged or is lost, the receiver
sends a NAK (negative acknowledgement) for that frame
and stores all subsequent frames.
• When the sender receives the NAK, it just resends that
frame. The following diagram shows the operation of
Selective Repeat ARQ.
Figure : Selective Repeat ARQ protocol

Restriction on Sender and Receiver window size


• The window sizes in Selective Repeat ARQ is maximum
2m/2 (or 2m-1).
• This restriction is to prevent the receiver from
accepting duplicate frames.
• When the receiver slides its window after accepting
frames, the new frame numbers must not be identical to
the frame numbers before sliding the window.
Go-back-N ARQ Selective Repeat ARQ
The sender window size is 2m -1 The sender window size is 2m/2 or
2m-1
The receiver window size is 1 The receiver window size is same as
sender window size i.e. 2m/2 or 2m-1
The receiver accepts frames only The receiver accepts any frame
in order falling within its window
All frames after a lost or corrupted All frames after a lost or corrupted
frame are discarded by the frame are buffered by the receiver
receiver
The sender resends all outstanding The sender resends only the
frames corrupted/lost frame
The receiver requires only a single The receiver needs multiple buffers
buffer
Simple to implement Complex implementation
No NAK's are send by the receiver The receiver sends a NAK for the
corrupted or lost frame
Less efficient Better use of available bandwidth
M.Sc. (Computer Application) Sem-II

Computer Networks
Chapter 5
The Medium Access Sub Layer

Prof. Vidya Bankar


Dr. D. Y. Patil ACS College Pimpri Pune-18.
Medium Access Control
The MAC layer is an important sublayer of the data link
layer. This layer is responsible for controlling access to a
shared communication channel. Many protocols have been
devised:
The three main categories are:

1. Random access protocols: In these protocols, any


station can transmit at will. The use of the channel is
not controlled by any station.

2. Controlled access protocols: In these protocols, some


mechanism is used to decide which station can send
data. Only that station is allowed to transmit.

3. Channelization: In this mechanism, the available


channel bandwidth is shared either frequency, time or
code.
Random Access Protocols:

• In the random access method, each station can use the


channel anytime; without being controlled by any other
station.
• This means that there will be a possibility that two or
more stations transmit simultaneously. This leads to an
access conflict called collision and frames will be
damaged.
• So the stations have to either avoid collision or resolve
collision when it occurs.
• Systems where multiple users share a common channel
in a way that can lead to conflicts are known as
Contention systems.
Some of the most important random access methods are:
1. ALOHA
2. Carrier Sense Multiple Access (CSMA)
3. Carrier Sense Multiple Access with Collision Detection
(CSMA/CD)
4. Carrier Sense Multiple Access with Collision Avoidance
(CSMA/CA)

ALOHA
• This protocol was developed in 1970 in the University
of Hawaii to solve the channel allocation problem
among users trying to use a single shared channel.
• It uses a wireless medium because University of Hawaii
had its departments spread across several islands where
cabling was not possible.
There are two versions of ALOHA:
1. Pure ALOHA
2. Slotted ALOHA

Pure ALOHA
• The basic idea of pure ALOHA is simple. Users can
transmit whenever they have data to be sent.
• There will be collisions and the colliding frames will be
destroyed. The station has to wait for acknowledgement.
• If a collision has occurred, the station does not receive a
feedback. It then waits for a random amount of time
(back-off time) and retransmits the frame.
• The waiting period has to be random or the same
frames will collide again. After a maximum number of
retransmission attempts Kmax, the station must stop
and try again later.
The figure shows a pure ALOHA system with 5 stations- A, B, C, D
and E transmitting whenever they have data.

The ALOHA procedure is illustrated in flowchart:


• Here, K is the attempt number initialized to 0. When K
reaches Kmax, the station stops the process.
• When the station sends a frame, it should wait for a time
which is twice the propagation delay, i.e., 2 x Tp.
• If an acknowledgement arrives, the process ends. If not,
the counter is incremented and a random backoff-time
TB is calculated. The calculation is done using the
binary exponential back-off formula
Figure: Pure ALOHA flowchart
Throughput of Pure ALOHA
The throughput (efficiency) of Pure ALOHA is given by:
S = Ge-2G
where S = average number of successful transmissions, G is
the average number frames generated during one
transmission time. The maximum throughput occurs at G =
0.5 with S=1/2e= 0.184. Best channel utilization is 18%.

Slotted ALOHA
• In slotted ALOHA, time is divided into discrete intervals.
All stations are synchronized in time. All stations are
forced to transmit frames only at the slot boundary.
• Thus, whenever a station has data to send, it cannot do so
immediately but has to wait for the beginning of the next
time slot.
In the following figure, stations B and C have data to send
but have to wait for the next slot to begin. If two or more
frames are sent in a time slot, there will be collision.
Figure: Slotted ALOHA
Throughput
In slotted ALOHA, the probability of collision is reduced
and throughput is better. The channel utilization of slotted
ALOHA is:
S = Ge-G
This gives a maximum utilization when G = 1, i.e., S = 1/e =
0.368, i.e., 36.8% (twice that of Pure ALOHA).
Figure: Throughput versus traffic
Difference between Pure and Slotted ALOHA
• Pure ALOHA uses continuous time principle, i.e., time is
not divided into discrete intervals.
In slotted ALOHA, time is divided into discrete slots or
intervals.

• Pure ALOHA does not require a master clock for


global time synchronization.
Slotted ALOHA requires a master clock to divide time
and synchronize all stations.

• In pure ALOHA, frame transmission can begin at any


instant, users transmit data whenever they want to.
In slotted ALOHA, frame transmission always begin at
the start of a slot.
• In pure ALOHA, the vulnerable time period is 2Tfr
where Tfr is the time required to send a frame.
The vulnerable period for slotted ALOHA is Tfr.

• The throughput S for pure ALOHA is S = Ge-2G. This


gives a best channel utilization of 18%.
The throughput of slotted ALOHA is S = Ge-G. It gives
channel utilization of 36.8%. Hence it is better than
pure ALOHA.
Carrier Sense Multiple Access (CSMA)
• The collision problem in ALOHA is caused by two or
more stations transmitting simultaneously without
knowing whether the medium is busy.
• The chance of collision can be reduced if the station
senses the medium before trying to use it.
• Protocols in which stations listen for a carrier and act
accordingly are called Carrier Sense Protocols. It is also
known as “Listen Before Talk” (LBT).
• In CSMA, when a station has data to transmit, it first
senses whether the channel is idle or busy.
• If the channel is found idle, the stations will transmit.
• If the channel is found busy, the stations will wait for a
random period of time before sensing the medium
again.
• Collisions may occur when two or more stations find
the channel free and transmit simultaneously.
• Due to propagation delay, one station may not know
that another station has started sending a frame, hence a
collision will occur.
• The following figure depicts collision in CSMA.
• At time t1,A sends a frame.
• At time t2, also sends a frame because it finds the
channel idle because it has not received the signal sent
by A.
• The two frames collide at t3 and the collision
information reaches Z at time t4 and A at time t5 due to
propagation delay.
Figure: Collision in CSMA
Persistence:
It refers to how frequently the station examines the
channel to check its status. The different persistence
strategies used in CSMA are:

Types of CSMA:

1. 1-persistent

2. Non persistent

3. p-persistent
1. 1-Persistent CSMA:

• This is the simplest strategy.


• When a station has data to send, it first listens to the
channel.
• If the channel is busy, it continuously listens to the
channel till the channel becomes idle.
• If the station detects an idle channel, it transmits
immediately.
• If collision occurs, the station waits for a random
amount of time and starts all over again.
• It is called l-persistent because the station transmits
with a probability of 1 whenever it finds the channel
idle.
Figure (a) Behavior
(b) Flowchart of 1-persistent CSMA
2. Non Persistent CSMA:

• A major issue with the 1-persistent CSMA is that the


stations are sensing the channel continuously. As soon
as it becomes free, the stations transmit simultaneously,
leading to collision.
• In Non-Persistent CSMA, the channel is sensed at
random intervals.
• If the station senses an idle channel, it transmits the
frame immediately. However, if the channel is busy, it
does not sense it continuously but waits for a random
period of time before sensing the channel.
• Since two stations wait for different times, the chances
of collision minimized. This leads to a better channel
utilization but longer delays than 1-persiste CSMA.
Figure (a) Behavior
(b) Flowchart of non persistent CSMA
3. p-Persistent CSMA:

• This combines the advantages of 1-persistent and non-


persistent CSMA.
• In this strategy, when a station finds the channel idle, it
decides whether to transmit or defer the
transmission. This decision is based on a probability
factor 'p'.
• The probability of a station transmitting after the
medium is idle p. The probability of a station failing to
transmit (deferring to next slot) is 1-p.
• If this slot is also idle, it either transmits or defers. This
process continues till the frame has been transmitted
channel becomes busy. In the latter case, it waits for a
random time and starts again.
Figure: (a) Behavior of p-Persistent CSMA
For example, if p = 0.3, the station transmits with a
probability of 0.3, i.e., 30% of the time and defers 70% of
the time. It does this by generating a random number
between 1 and 100. If the number is less than 30, the station
transmits otherwise it refrains from sending.
Figure: (b) Flowchart of p-Persistent CSMA
Comparison of
1-persistent, non-persistent and p-persistent CSMA
1-persistent Non-persistent p-persistent
Transmits with probability 1 Transmits with probability 1 Transmits with probability p
when it finds channel idle when it finds channel idle when it finds channel idle

Does not defer transmission Does not defer transmission Defers transmission with
when the channel is idle when the channel is idle probability 1-p when the channel
is idle

Senses the channel Senses the channel at Senses the channel continuously
continuously if it is busy random intervals if it is busy

Maximum chances of Number of collisions is Number of collisions is reduced


collision reduced

Time is not divided into slots Time is not divided into Applies for slotted channels
slots
Carrier Sense Multiple Access with Collision Detection
(CSMA/CD)
• In CSMA, a station cannot find out if a collision has
occurred during transmission.
• In CSMA/CD (CSMA with Collision Detection),
stations are able to detect collisions. The advantage of
this is that when the stations detect a collision, they can
abort the transmission immediately.
• This saves time and bandwidth. CSMA/CD is widely
used on LAN and it is the basis for a popular LAN
standard called Ethernet.
• The conceptual model of CSMA/CD is as shown in the
following figure:
Figure: CSMA/CD Model
• A station that wants to send a frame senses the channel
continuously.
• If the channel is free, the station transmits the frame.
• If a collision takes place, the station stops transmission.
• To reduce the probability of collision the second time,
the station waits a random amount of time (back-off
time) before repeating the process.
• Thus, this model will contain alternating contention
and transmission periods with idle periods occurring
when all stations are quiet.

Procedure
The CSMA/CD procedure is shown in the following
flowchart. It is similar to CSMA except that a station can
detect a collision and when it occurs, a jamming signal is
sent on the channel to inform stations of the collision.
Figure: CSMA/CD procedure
Carrier Sense Multiple Access with Collision Avoidance
(CSMA/CA)
In CSMA/CD protocol, stations have to abort transmission
when a collision is detected and then retransmit.
This scheme works well if the channel bandwidth is large
and the stations are in a limited distance.
However, in case of wireless systems, the bandwidth is not
very high, so retransmissions are not very efficient.
Moreover, all stations may not detect the collision
immediately.
In such situations, it is better to avoid collisions. CSMA/CA
is mainly employed in Wireless LAN.
Collisions are avoided using three strategies:
i. Interframe Space
ii. Contention Window
iii. Acknowledgements
1. Interframe Space: In this mechanism, when a station finds the
channel idle, it does not transmit immediately but defers
transmission by a period of time called Interframe Space (IFS).
The IFS allows the signal from the remote stations to reach. If
the channel is still idle after the IFS, the station sends the frame
after waiting for contention time.
2. Contention Window: The contention window is a period of
time divided into contention slots. When a station is ready to
transmit, it chooses a random number of slots and waits. If the
channel is idle after waiting, the frame is sent and the station
waits for a time-out period for an acknowledgement to arrive.
If it is found busy, the timer is stopped and process is
restarted.
3. Acknowledgement: A station will know that the frame
transmission was successful if it receives a positive
acknowledgement within the time-out period. If not, it means
the data got corrupted due to error.
Figure: CSMA/CA Procedure
Controlled Access
In controlled access, the stations decide which station should
be allowed to transmit. Only that station has a right to
transmit. A station cannot send unless it has been
authorized to do so by other stations.

Three controlled-access methods are:


1. Reservation
2. Polling
3. Token Passing
Reservation
• In this method, a station has to reserve a slot before
transmission. A special reservation frame contains N
reservation minislots - one for each station.
• When a station wants to send data it has to reserve its
own minislot by setting the reservation bit to 1.
• The reservation frame contain information regarding
which station wants to transmit and which does not.
• After the reservation period, there is a transmission
period. Only if a station has reserved its slot in the
reservation frame, it is allowed to transmit in that slot.
• In the following example, N = 5. Initially, only stations
1, 3 and 4 have reserved the slots. Hence, only they are
allowed to transmit. In the next reservation frame, only
station 1 has reserved its slot so it is allowed to transmit
in the transmission period.
Figure: Reservation
Advantages

1. Since reservations are made in advance, there will not


be any collisions.
2. The size of the reservation frame is very small; hence
it does not increase overheads.

Disadvantages

1. The transmission period is preceded by a reservation


period.
2. If there are many stations, a station has to wait for a
long time to send the next frame.
Polling
• Polling uses a central controller or arbiter. This
method is used on topologies in which device is
designated as a primary station or controller. The others
are secondary stations.
• The primary device controls the link. It acts as the
media access administrator. It decides which station is
allowed to use the channel at a given time.
• It does this by asking the secondary devices if they have
any data to send. This is called Polling.
• It uses the poll function to ask each secondary station
turn by turn. The secondary responds with NAK frame if
it has nothing to send or with a data frame.
• When the primary receives a data frame, it returns an
acknowledgement (ACK) frame as shown in the
following figure.
Figure: Polling
Advantages

1. Priorities can be assigned to stations. High priority


stations are polled more times.
2. Since only one station is transmitting at a time, there are
no collisions.

Disadvantages

1. It requires a central controller.


2. All data communication takes place through the
primary station.
3. If the primary station goes down, the whole system
crashes.
4. A station may have to wait for a long time for its turn
to transmit.
Token Passing
• The token passing mechanism is used in broadcast
networks having logical ring topology like IEEE 802.5.
• In this method, a station is allowed to transmit data
when it acquires a special frame called token.
• The token keeps circulating within the network. When a
station wants to transmit data, it has to wait for the
token. When it gets the token, only then it can transmit
data.
• After its transmission is over, the station has to release
the token so that it can be used by another station.
Figure: Token Ring
Advantages

1. Only one station can have the token at a time. Hence


only one station can transmit at a time.

Disadvantage

1. In conditions of high load, a station may have to wait


for a long time for the token.
2. It requires a token management system to ensure that
the token is released by the transmitting station.
3. A token may get lost in the network.
Comparison of a Controlled Access methods
Reservation Polling Token Passing
There is no controlling Polling requires a central There is no controlling
station. controller or arbiter station.
A special reservation A special poll signal is A special token frame is
frame is transmitted sent to each station. circulated in the
network.
There are two separate Station responds to a Station which grabs the
phases: Reservation and poll with a data frame token sends the frame
Transmission. immediately. immediately.
Failure of one station If the controller fails, the Failure of one station
does not affectentire communication does not affect
transmission. fails. transmission
Requires coordination Does not require Does not require
among stations. coordination among coordination among
stations. stations.
No additional No additional Requires special token
management is needed. management is needed. management mechanism
Channelization

Channelization is a multiple-access method in which the


available bandwidth of a link is shared in frequency, time
and code.

Thus, we have three channelization protocols.

1. Frequency sharing - FDMA


2. Time sharing - TDMA
3. Code sharing - CDMA
Frequency Division Multiple Access (FDMA)

• This method is primarily used when the available


channel bandwidth is very high and the stations
require low bandwidth for their transmission.

• Here, the bandwidth is shared by all the stations. The


bandwidth is logically divided into several bands.

• A band is allotted to a specific station. The station has


complete use of its band all the time. There are guard
bands between channels to avoid interference.
Figure : FDMA
• FDMA is different from FDM. FDM is a physical layer
protocol which does multiplexing to transmit data
from multiple low-bandwidth sources on the same high-
bandwidth physical channel.
• FDMA is a data link layer access method which tells
the physical layer to transmit the signal in a specific
band only.
• The physical layer simply puts this signal onto the
common channel where signals from different sources
(which occupy different frequency bands) are simply
mixed in the channel.
Advantages

1. Each station is allotted a separate channel.


2. The channel is available to the station for the entire
duration of the transmission.
3. Simple system to implement.

Disadvantages

1. If the number of stations is large, the size of the


channel is very small.
2. If the station does not have data to send the channel
bandwidth is wasted.
3. It uses guard bands to prevent interference. This
wastes very useful frequency resources.
Time Division Multiple Access (TDMA)

• In TDMA, the stations share the channel bandwidth in


time. Time is divided into discrete slots and each station
is allocated a time slot during which it can transmit.
• The station can use the entire channel bandwidth
during its time slot.
• TDMA requires precise synchronization between
stations. Each station should transmit within its own time
slot.
• However, if the distance between stations is large,
propagation delays can cause problems. Hence, guard
spaces are inserted between slots.
Figure: TDMA
Advantages

1. Each station can use the whole channel bandwidth for


transmission.
2. Priorities can be assigned to stations. More slots are
allotted to high priority stations.

Disadvantages

1. If the number of stations is large, a station has to wait


for a long time to get its time slot.
2. If a station does not have data to transmit, the time slot
will be wasted.
3. Needs proper time synchronization between
machines
4. More difficult to implement compared to FDMA.
Code Division Multiple Access (CDMA)
• CDMA does not divide the channel bandwidth into
channels nor does it assign a time slot to each machine.
• Here, each station is allowed to transmit over the
entire bandwidth all the time.
• It uses a coding theory which is used to separate
multiple simultaneous transmissions.
• Each station is assigned a special code using which it
transmits its data.
CDMA Concepts
1. Chip Sequence
Each station is assigned a unique m-bit code called chip
sequence. Each data bit is split into m-bits by multiplying
the bit and chip sequence. If the chip sequence of a station
is [+1 +1 +1 +1] and this station wants to transmit bit 0
(represented as -1), it transmits [- 1 -1 -1 -1].
2. Data Representation
i. Bit 0 is encoded as -1
ii. Bit 1 is encoded as +1.
iii. When a station is idle, it does not send a signal. This is
interpreted as 0.
3. Encoding and Decoding
Encoding: Each station multiplies the data bit with its chip
sequence. The inputs from all stations are given to a CDMA
multiplexer. The CDMA multiplexer simply adds the
sequences received from each source and transmits the
multiplexed data.
Decoding: The CDMA de-multiplexer separates the
received bits by multiplying the multiplexed bits by the chip
sequence of each station. The sum of chips divided by N
gives the transmitted bit by that station.
The steps are as shown in the example below.
i. There are four stations each with a chip sequence
designated A, B, C, D
respectively.
A (1,1,1,1) -> [+1,+1, +1, +1]
B (1,0,1,0) ->[+1,-1,+1,-1]
C (1,1,0,0) ->[+1,+1,-1,-1]
D (1,0,0,1)-> [+1,-1,-1,+1]

ii. Station 1 sends 0, Station 2 sends 0, Station 3 is silent,


Station 4 sends 1
This input is multiplied with each chip in the chip sequence
and the outputs are added.
Figure: CDMA Multiplexer
iii. The received output is given to a CDMA demultiplexer.
Each chip in the output chip sequence is multiplied with the
corresponding chip sequence and the chips in each sequence
are added. This sum is divided by 4 which gives the sent bit.
Figure: CDMA Demultiplexer
Advantages

1. All stations can transmit simultaneously.


2. Each station uses the whole channel bandwidth for the
whole duration of the transmission.
3. More secure compared to FDMA and TDMA.

Disadvantages

1. CDMA multiplexing and demultiplexing are complex


operations.
2. Require complex synchronization between all
machines.
Comparison of Channelization Methods
FDMA TDMA CDMA
Frequency is divided into Stations can use the entire Stations can use the entire
sub channels. bandwidth for bandwidth for
transmission. transmission.
A station is allotted a sub A station is allotted a A station is allotted a
channel for transmission. time slot for special code for
transmission. transmission.
Multiple stations can Only one station can All stations can transmit
transmit at a time (in a transmit at a time. at the same time using the
different band). entire bandwidth.
Guard spaces are unused Guard spaces are small Guard spaces are
frequency bands between gaps between two time orthogonal codes.
channels. slots.
Easy to implement; Easy to implement; Complex to implement;
requires modulation and requires stations to be CDMA multiplexers and
band pass filters. synchronized in time. Demultiplexers requires.
No. of users are limited Station may have to wait Handle many users; each
by channel bandwidth. for a long time for its slot. assigned a different code.
Solved Problems
1. Consider a CDMA system with 1, 2 and 4 stations. What
will be their chip sequences?
Solution
In Walsh table N should be power of 2.

The Walsh table

W2N = WN WN
WN WN

For 1 station, N = 1. Hence, we use the Walsh table W1.


Hence the chip sequences are:
W1 = [+1]
For 2 stations, N = 2. Hence, we use the Walsh table W2.
Hence the chip sequences are:

W2 = +1 +1
+1 -1

For 4 stations, N = 4. Hence, we use the Walsh table W4.


Hence the chip sequences are:

W4= +1 +1 +1 +1
+1 -1 +1 -1
+1 +1 -1 -1
+1 -1 -1 +1
M.Sc. (Computer Application) Sem-II

Computer Networks

Chapter 6

The Network Layer

Prof. Vidya Bankar


Dr. D. Y. Patil ACS College Pimpri Pune-18.
Network Layer
• The network layer is concerned with getting
packets from the source all the way to the
destination.

• Unlike the DLL which has the more modest goal of


just moving frames from one end of a wire to the
other.

• Network Layer is the lowest layer that deals with


end-to-end transmission.
Network layer design issues
• Store-and-Forward Packet Switching

• Services Provided to the Transport Layer

• Implementation of Connectionless Service

• Implementation of Connection-Oriented Service

• Comparison of Virtual-Circuit and Datagram Networks


Store-and-Forward Packet Switching
• A host with a packet to send transmits it to the nearest
router.
• The packet is stored there until it has fully arrived and the
link has finished its processing by verifying the checksum.
• Then it is forwarded to the next router along the path until it
reaches the destination host.
• This mechanism is store-and- forward packet switching.
Services Provided to the Transport Layer

Before providing these services to the transport layer


following goals must be kept in mind:

• The services should be independent of the router


technology.
• The transport layer should be isolated from the
number, type, and topology of the routers present.
• The network addresses made available to the
transport layer should use a uniform numbering
plan, even across LANs and WANs.
• Connection-oriented service : is a network communication
mode, where a communication session or a semi-permanent
connection is established before any useful data can be
transferred, and where a stream of data is delivered in the
same order as it was sent.
• Connectionless service : is a data transmission method used in
packet switching networks by which each data unit is
individually addressed and routed based on information
carried in each unit, rather than in the setup information of a
prearranged, fixed data channel as in connection-oriented
communication.
• Packet switching is a digital networking communications
method that groups all transmitted data into suitably sized
blocks, called packets
• A datagram is a basic transfer unit associated with a packet-
switched network. The delivery, arrival time, and order of arrival
need not be guaranteed by the network.
• A virtual circuit : is a means of transporting data over a packet
switched computer network in such a way that it appears as
though there is a dedicated physical layer link between the
source and destination end systems of this data.
Implementation of Service
• If connection-oriented service is used, a path from
the source router all the way to the destination router
must be established before any data packets can be
sent. This connection is called a VC (virtual circuit)
and the network is called a virtual-circuit network.

• If connectionless service is offered, packets are


injected into the network individually and routed
independently of each other. No advance setup is
needed. In this context, the packets are frequently
called datagrams and the network is called
datagram network.
Implementation of Connectionless Service
• Suppose that the process P1 in Fig. has a long message for P2
It hands the message to the transport layer, with instructions to
deliver it to process P2 on host H2.
• The transport layer code runs on H1, typically within the
operating system. It prepends a transport header to the
front of the message and hands the result to the network
layer, probably just another procedure within the operating
system.
Implementation of Connection-Oriented Service
• For connection-oriented service, we need a virtual-circuit
network. The idea behind virtual circuits is to avoid having to
choose a new route for every packet sent.
• With connection-oriented service, each packet carries an
identifier telling which virtual circuit it belongs to.
• Assigns a different connection identifier to the outgoing traffic
for the second connection. Avoiding conflicts of this kind is why
routers need the ability to replace connection identifiers in
outgoing packets. In some contexts, this process is called label
switching
Comparison of Virtual-Circuit and Datagram
Networks
• The network layer is the layer above the data link layer
and below the transport layer in the OSI model.
• The need for a network layer arises when the two end
systems are attached to different networks. In such
cases, there has to be a method to identify the separate
networks.
• Moreover, the source and destination networks may be a
part of a larger internetwork. So, there has to be a
mechanism to find out the best route from the source
to the destination.
• Hence, the basic purpose of the network layer is to
send packets from a source machine all the way to the
destination machine.
• Thus, for following reasons, a network layer is needed:
1. Logical addressing 2. Routing
Logical Addressing:
• Each machine has a MAC address which is also called
the physical address. This is the address of the
network interface card of the machine.
• But if we know the MAC address of a machine, how do
we know where the machine is? It is impossible to
locate a machine among millions of machines based
on its MAC address.
• Hence, we need another addressing scheme which is
global and depends on the network to which the
machine is connected.
• This is required so that we can identify the network to
which the destination machine belongs to. This global
address is called logical address.
• The TCP/IP protocol model uses IP addresses to
uniquely identify a router and machine in the
internet.
• No two machines on the internet can have the same IP
address.

There are two versions of IP:


1. IPv4
2. IPv6

IPv4 Addresses:
The Internet protocol version 4 (IPv4) is the most important
protocol in the network layer of the TCP/IP model.
Address Space:
• If we have an ‘n' bit address, there can be 2n unique
addresses. For example, suppose we have a 2 bit
address, we can create 4 unique addresses:00,01,10 & 11.
• IPv4 uses 32 bit addresses. Hence, the IPv4 address
space is 232 i.e., 4,294,976,296 addresses in all.

Notations:
An IPv4 address can be represented using two notations:
1. Binary notation
2. Dotted-decimal notation

Binary notation:
In this notation, the address is represented as 32 bits. Thus it
is a 4-byte address.
Example: 10010101 00000010 00011101 01110101
Dotted-decimal notation:
• It is usually difficult to read and write IP addresses in
binary. To make it easier, the dotted-decimal format is
used.
• In this case, each byte (8 bits) are converted to decimal
and separated by a dot (.). The general form is A.B.C.D
where A, B, C and D are positive integers in the range 0
to 255.
• No leading zeroes are allowed. For example, 0004 is not
allowed.

Example: 128.5.3.16
10000000 00000101 00000011 00010000

128. 5. 3. 16
Figure: Binary and dotted-decimal format
Classful Addressing:

• The entire IP address space of 232 addresses is divided


into five “classes”, A, B, C, D and E.
• Each class is allotted a portion of the address space.

Netid and Hostid:

• The addresses in classes A, B and C are divided into two


parts: netid and hostid.
• The length of the netid and hostid vary according to
the class. The following diagram shows the 5 address
classes along with the netid and hostid.
• The shaded part is the netid.
a. Binary notation
The class of an IP address can be identified from the value
of the first byte. The range of values are given below.

Identifying IP address classes

First byte
Class A 0-127

Class B 128-191

Class C 192-223

Class D 224-239

Class E 240-255
Class A, B and C addresses are used in internetworks.
Class D and E are reserved. Class A networks are the
largest networks with maximum number of hosts while
class C networks are the smallest networks with 256 hosts.
Thus, if an organization has 100 machines, it should take a
class C address.
Class Netid Hostid First No. of No. of Hosts
byte Networks
range
Class A 1 byte 3 bytes 0-127 27 = 128 224 = 16,777,216
Class B 2 bytes 2 bytes 128-191 214 = 16,384 216 = 65,536
Class C 3 bytes 1 byte 192-223 221 = 2,097,152 28 = 256
Class D - - 224-239 Not divided further. Used for
multicasting
Class E - - 240-255 Not divided further. Used as
reserved addresses
Network Address

A network address is the IP address which identifies a


network among multiple networks. It has both net-id and
host-id, with all host-id bits zero.
Example: 109.0.0.0, 164.25.0.0 and 200.11.8.0 are network
addresses which identify a specific network.
109.11.14.200 109.90.123.4 164.25.0.1 164.25.15.20 200.11.8.50 200.11.8.66

109.0.0.0 164.25.0.0 200.11.8.0

Class A network Class B network Class C network

Figure: Network Addresses


1. The router uses the network address to identify the
destination network.
2. The network address is the first address in the block. It
is not assigned to a host in the network.
3. An organization is assigned the network address.
4. The network administrator of the organization assigns
host addresses.

Problems
1. Convert the following binary notation to dotted-decimal
notation
a. 01101111 00111000 00101101 01001110
b. 11111111 00000000 11111111 00000000
Solution
a. 111.56.45.78
b. 255.0.255.0
2. Convert from dotted-decimal to binary notation:
129.11.5.27
Solution
10000001 00001011 00000101 00011011

3. Find errors in the following IP addresses


100.15.257.7
192.156.002.100
171.25.255.100.2
129.10001010.34.100
Solution
a. Maximum integer = 255. Hence, 257 is not allowed.
b. 002. Leading zero's are not allowed.
c. Only 4 decimal numbers are allowed. The given address
has 5 numbers
d. Binary and decimal notation cannot be combined.
4. Identify the address classes for the following IP addresses
a. 192.168.10.5
b. 71.224.183.10
c. 140.25.1.100
d. 10001111 00001100 11001010 00000000
e. 00110001 00001011 00000101 00011011
Solution
a. Class C since the first byte is in the range 192-223
b. Class A since the first byte is in range 0-127.
c. Class B since the first byte is in the range 128-191.
d. Class B since the first 2 bits are 10
e. Class A since the first bit is 0
5. Find the network address for the following IP addresses
a. 192.168.10.5
b. 71.224.83.10
Solution
a. This is a class C address. Here, the first 3 bytes are netid
and last byte is hostid. Hence the network address is
192.168.10.0
b. This is a class A address. Here, the first 1 byte is netid and
last 3 bytes are hostid. Hence the network address is 71.0.0.0
Classless Addressing

• The problem with classful addressing is that it is a fixed


scheme.
• Due to the fixed number of address ranges, most of the
addresses are wasted. For example, an organization
having 20 hosts only will have to take a class C address.
This will waste 236 addresses.
• Hence, the classful scheme is now replaced with a
classless addressing scheme.
• Here the addresses are assigned in blocks but there are
no classes. An organization can take only the required
number of addresses.
Address Blocks

IP addresses are assigned in blocks. However, the following


rules apply:

1.The addresses must be contiguous.


2.The number of addresses must be a power of 2.
3.The first address in the block must be divisible by the
number of addresses.

Example: The figure shows a block of 16 addresses assigned


to an organization.
Figure: Assigning Address block

Block Block
First
205.16.37.32 11001101 00010000 00100101 00100000
205.16.37.33 11001101 00010000 00100101 00100001
. .
. . 16
addresses
. .
. .
Last 205.16.37.47 11001101 00010000 00100101 00101111

a. Decimal b. Binary
Address Masks
To identify a network and route packets to the network,
the routers outside the network use a default mask to get
the network address.

1. The default mask is a 32 bit mask with the net-id


portion containing l’s and the host-id portion containing
0's.
2. The router looks at the first byte of the IP address to
know the class and then applies a default mask.
(ANDs the masks with the IP address).
3. The number of l’s in the mask are also written using
the slash notation.
The following table shows the default masks for classes A, B
and C. The last column shows the mask in the /n form.
Table: Default Masks
Class In Binary In Dotted- CIDR
Decimal

А 11111111 00000000 00000000 00000000 255.0.0.0 /8


B 11111111 11111111 00000000 00000000 255.255.0.0 /16
C 11111111 11111111 11111111 00000000 255.255.255.0 /24

• In classless addressing, there is no class and hence,


there is no default mask which can be applied.
• To solve this problem, a mask is defined using the /n
notation.
• The format of the mask is: a.b.c.d/n. Here, /n defines
the mask. It is also called the CIDR (Classless Inter
Domain Routing) notation.
Subnetting and Supernetting
• An organization having a single network has one
network address. The outside world recognizes the
organizations network by this network address.
• However, the organization may want to divide all its
hosts into different groups, i.e., the network is further
divided into subnetworks.
Subnetting is the process of dividing a network into
smaller subnetworks, each having its own subnetwork
address.
To achieve subnetting, some part of the host-id is
borrowed as the subnet-id.
The number of bits borrowed will depend upon the
number of subnets to be made. For example: If 8
subnetworks are to be made, 3 bits will be used as the
subnet-id.
We thus have three levels of hierarchy
1. Net-id (gives network address)
2. Subnet-id (gives subnet address)
3. Host-id (gives host address in subnet)

a) Net-id Host-id
b) Net-id Subnet-id Host-id

Figure: Subnetting
a) IP address without subnetting b) IP address with subnetting

Net-id Host-id Net-id Subnet-id Host-id


With subnetting, we have a three level hierarchy. If we use
the classless scheme, the 32 bits will be divided as shown.
n bits 32-n bits
Network prefix
Host prefix
Fig: Two level Hierarchy

n bits x bits 32 – (n + x) bits


Network prefix
Subnet prefix

Host prefix

Fig: Three level Hierarchy


For example:

A university may want to divide its hosts according to


departments. Thus, each department forms a subnetwork.
The university will now have one network address and
many subnetwork addresses.
Let us consider that the university has 4 departments with
50 hosts each. Since its total hosts are < 256, a class C
address is suitable.
The first 3 bytes will be used for netid. The last 8 bits are the
host id. Out of these 8 bits, we need few bits to identify the
subnetid. Since there are 4 subnetworks, 2 bits will be
enough. The remaining 6 bits will be used for the hosts in
each network.
If the network address is 201.100.10.0, the subnetwork and
host addresses are shown below.

Class Netid Subnetid Host id Address range

Subnet 1 201.100.10 00 000000 to 111111 201.100.10.0 to


201.100.10.63
Subnet 2 201.100.10 01 000000 to 111111 201.100.10.64 to
201.100.10.127
Subnet 3 201.100.10 10 000000 to 111111 201.100.10.128 to
201.100.10.191
Subnet 4 201.100.10 11 000000 to 111111 201.100.10.192 to
201.100.10.255
1. For the given IP address 205.16.37.39/28 in some block of
addresses, calculate:
a. Address mask b. First address of the block
c. Last address of the block d. No. of addresses in the block
Solution
a. To find address mask: n = 28. Hence,
mask = 11111111 11111111 11111111 11110000 or
255.255.255.240
b. First address of block is obtained by setting rightmost 32-n
bits to 0. Given IP = 205.16.37.39 = 11001101 00010000
00100101 00100111
Setting last 4 bits to 0, we get 11001101 00010000 00100101
00100000 = 205.16.37.32 OR
IP address = 11001101 00010000 00100101 00100111
Mask = 11111111 11111111 11111111 11110000
AND = 11001101 00010000 00100101 00100000
c. Last address of block is obtained by setting rightmost 32-n
bits to 1.
Given IP = 205.16.37.39 = 11001101 00010000 00100101
00100111
Setting last 4 bits to 1, we get 11001101 00010000 00100101
00101111 = 205.16.37.47 OR
IP address = 11001101 00010000 00100101 00100111
Complement Mask = 00000000 00000000 00000000
00001111
OR = 11001101 00010000 00100101 00101111
d. The range of addresses = 232-n = 232-28 = 16 addresses in the
block. These are from 205.16.37.32 to 205.16.37.47
We can also use the mask to calculate total addresses.
Complement Mask = 00000000 00000000 00000000
00001111 = 15
Total addresses = 15+1 = 16.
Supernetting

• Supernetting the opposite of subnetting. It is the process


of combining subnets to create larger networks.

• Multiple subnetworks are aggregated back in a single


large network so that they can be managed as a single
network.

• The main purpose of supernetting is to reduce the


number of entries in the routing tables and for faster
routing. It is also known as route summarization and
route aggregation.
Network Address Translation

• Every machine in an internetwork must have a unique IP


address.
• As the number of users keep growing, it is not possible to
assign each user a separate IP address since the available
addresses are not enough.
• A solution to this problem is Network Address
Translation (NAT).
• To conserve IP address space, networks which are not
directly connected to the Internet are often given private
address space.
• The following table shows the private IP addresses.
Start End Network Size
10.0.0.0 10.255.255.255 224
172.16.0.0 172.31.255.255 220
192.168.0.0 192.168.255.255 218

• A network which uses private IP addresses internally is


assigned a single public IP address to communicate with
machines outside the network.
• All machines will use the public IP address to
communicate outside. The following diagram shows an
example.
• Here, all machines have a private IP address for
communication inside their network.
• The whole network has a public IP address 200.24.5.8
for communicating outside the network.
Figure : Public and Private IP addresses
Address Translation:
• An address translation must take place between the
internal private IP address and the public IP address
outside. The outside world only knows the public IP of
the entire network.
• The NAT router stores a translation table. The
translation table stores the mapping between the private
IP address and the public IP address.
Table: Translation table structure
Private Private External External Transport
Address Port Address Port Protocol
172.18.3.1 1400 200.24.5.8 80 TCP
172.18.3.2 1401 200.24.5.8 80 TCP
… … … … …

The translation takes place as follows:


• All outgoing packets go through the NAT router which
replaces the private source address with the public IP
address.
• All incoming packets are received by the NAT router. It
replaces the destination IP address (public) of the packet
with the correct private IP address.
This is shown below. Here, the machine in the network has a
private IP address of 172.18.3.1 and the public IP address of
the entire network is 200.24.5.8
Figure: Address translation
IPv4
The Internet Protocol (IP) is the network layer protocol in the
TCP/IP protocol stack. It is unreliable, connectionless,
datagram oriented protocol.
1. Best-effort: It does not give any guarantee and does not
provide flow or error control.
2. Connectionless: No connection is established between
sender and receiver.
3. Datagram oriented: An internet packet in the IP layer
is called IP datagram. Each datagram is routed
independently of other datagrams. Hence, they may
arrive out of order and also may have to be fragmented
and reassembled.
Currently two IP versions are in use - the older IPv4 and
the newer IPv6.
IPv4 Datagram
• The datagram has a header followed by a data area.
• The maximum datagram size is 65536 bytes, including
the header.
• A header is minimum 20 bytes to maximum 60 bytes in
length. The structure of an IP datagram is shown below.
The various fields are:
• Version (VER): This 4-bit field defines the version of
the IP protocol. The current version is 4 (IPv4), with a
binary value of 0100. IPv6 is the new version.

• HLEN: This 4-bit field defines length of the header in


multiples of four bytes. The four bits can represent a
number between 0 and 15, which then multiplied by 4,
gives maximum header size, i.e., 60 bytes. The minimum
header size is 20 bytes (when there are no options) and is
represented by number 5 in the HLEN field.

• Type Of Service (TOS): This 8-bit field defines the


priority of datagram.
• Total Length: This 16-bit field defines the total length
of IP datagram (header + data). Since the maximum size
of datagram is 65536 bytes, it is a 16-bit field.

• Identification: This 16-bit field is used in fragmentation


to identify a fragment. A datagram may be divided into
fragments when it passes through another network.

• Flags: This 3-bit field is used with fragmentation. The


flags are D and M. D = Don’t fragment, M = More
which indicates whether more fragments follow. If it is
0, it indicates that it is the last fragment.

• Fragment offset: This 13-bit field is used as a pointer


that shows the location of the data in the original
datagram if it is fragmented.
• Time-to-Live (TTL): This 8-bit field is the lifetime of
the datagram. It is initialized by the sender and
decremented by each router that handles the datagram.
When this field reaches 0, the datagram is thrown away,
and the sender is notified with an ICMP(Internet Control
Message Protocol) message.

• Protocol: This field indicates which upper layer protocol


data are encapsulated in the datagram (TCP, UDP, ICMP
etc.).

• Header Checksum: This 16-bit field is used to check


for errors in the header only and not for the rest of the
packet.
• Source IP address and Destination IP address: Every
IP datagram contains 32-bit source IP address of the
sender and 32-bit IP address of the receiver for the
destination of the datagram

• Options: This field is of variable length, allows the


packet to request special features such as security level,
route to be taken by the packet, and timestamp at each
router. They are normally used for network testing
and debugging.
Fragmentation
• From the source to the destination machine, a datagram may
have to travel across several heterogeneous networks.
• Each network has its own MTU (Maximum Transfer Unit)
size. Hence, it may be broken into smaller units. This is
called fragmentation.
• The fragmentation takes place at the source or any router in
the path. Each fragment is sent independently of other
fragments and reassembly is only done at the receiver.

Fields in the datagram header related to fragmentation:

Identification: This 16 bit field identifies all fragments


belonging to a single datagram. When a datagram is
fragmented, this value is copied into all fragments. This helps in
reassembling the datagram.
Flags: It is a 3 bit field. The first bit is not used. The second
is D, i.e., Do not fragment. If set, the datagram cannot be
fragmented. The second flag is M, i.e., More Fragments. If
set, it indicates that there are more fragments of the same
datagram, and if 0, this fragment is the last fragment.

D M
D: Do not fragment M: More fragment
Figure: Flags

Offset: This 13 bit field gives the relative position of the


fragment in the datagram. If 0, it indicates that this is the
first fragment. It is measured in units of 8 bytes. For
example, if the second fragment carries bytes 800 to 1000,
the offset field will have value 800/8 = 100.
The following diagram shows a datagram carrying 4000
bytes fragmented into 3 fragments.
Fragment 1 carries bytes 0 - 1399
Fragment 2 carries bytes 1400 - 2799
Fragment 3 carries bytes 2800 – 3999
Figure: Fragmentation
To reassemble fragments, the receiver uses the following
process:
• Find the fragment having offset 0. This is the first
fragment.
• Divide its length by 8. This gives the offset of the
second fragment.
• Locate the second fragment (having same identification
and offset = calculated offset value)
• Calculate position of third fragment using
[length(fragment 1) + length fragment 2)]/ 8
• Continue in the same manner till a fragment with M
flag = 0 is reached.
Checksum:
The checksum field in the datagram is used for error
control. It is an error-detection method. The checksum is
calculated only for the datagram header and not the data.

The process to calculate checksum is:


• Initialize checksum to 0.
• The header is divided into blocks of 16 bits.
• These blocks are added together.
• The sum is complemented and used as checksum.
The checksum is only calculated for the header for three
reasons:

• The data part contains data of high level protocols which


already has a checksum field in the data.

• When a datagram travels through routers, the data


remains the same, only the header changes. Hence, it
is necessary to calculate the checksum of the header
only.

• Processing time increases if the checksum of the whole


packet is calculated at each router.
Options:
• The IPv4 datagram header contains a fixed header of 20
bytes and a variable part which can be of maximum 40
bytes.
• Options allow additional information to be put into the
datagram.
Options can be of two broad types:
Options
1. Single byte options
• No operation
• End of option
2. Multiple-byte options
• Record route
• Strict source route
• Loose source route
• Timestamp
Single byte options:
• No operation: It is a 1-byte option used as filler
between options.
• End of option: It is a 1-byte option used to indicate end
of options.

Remaining four options are multibyte options:


They requires the length and data field. These are:

• Record route: It is used to record the IP addresses of


internet routers that handle the datagram. It can store
upto 9 addresses.
• Strict source route: It is used to specify a fixed route
that the datagram should follow as it travels through the
internet.
• Loose source route: It is similar to strict source route,
i.e., a predetermined path is given. But it is less rigid.
The datagram may visit other routers as well.
• Timestamp: This option is used to record the time when
the datagram reaches a router. It is expressed in
milliseconds. This helps in tracking the delays in the
network.
IPv6:
• IPv6 is the recent version of IP.
• It was designed to overcome the limitations of IPv4.
• One of the main limitation of IPv4 is the limited address
space (32 bit address divided into classes). As more and
more devices are connected to the internet, this address
space is not enough. IPv6 provides a 128 bit address
and can accommodate 2128 devices.
• IPv6 addresses are represented as eight groups of four
hexadecimal digits with the groups being separated by
colons.
• Example 2001:0db8:0000:0042:0000:8a2e:0370:7334
Advantages of IPv6 over IPv4 :

1. Larger address space: IPv6 has a 128 bit address


thereby allowing 2128 devices.
2. Better header format: Options are separated from base
header. This allows faster routing of packets.
3. New options: Provide additional flexibility and options
4. Allows for extension of protocol: There is a provision
for the protocol to be extended for new technologies and
applications.
5. Supports resource allocation: Allows special handling
of packet especially video, audio etc.
6. More security: IPv6 has support for security
mechanisms like confidentiality and integrity.
IPv6 Address:
An IPv6 address consists of 128 bits. These 128 bits are
logically divided into eight 16-bits blocks. Each block is
then converted into 4-digit Hexadecimal numbers
separated by colon symbols.
0010000000000001 0000000000000000 0011001000111000 1101111111100001
0000000001100011 0000000000000000 0000000000000000 1111111011111011

Each block is then converted into Hexadecimal and separated


by ":' symbol:
0010000000000001 0000000000000000 0011001000111000 1101111111100001
2001 0000 3238 DFE1

0000000001100011 0000000000000000 0000000000000000 1111111011111011


0063 0000 0000 FEFB

Thus, address is: 2001:0000:3238:DFE1:0063:0000:0000:FEFB


As seen above, the address is very long. There are some
ways to reduce the length of the address:

1. Remove leading Zero(es): Any 0's appearing at the


beginning of a block can be discarded. For example,
0063 can be written as 63.
2. Replace consecutive blocks of zeroes with:: If two of
more blocks contain consecutive zeroes, omit them all
and replace with double colon sign (::) for example, 6th
and 7th block. Consecutive blocks of zeroes can be
replaced only once by ::. So if there are still blocks of
zeroes in the address, they can be shrunk down to a
single zero, such as the 2nd block.
Thus the address reduces to:
2001:0:3238:DFE1:63::FEFB
IPV6 Address Space:
The main advantage of IPv6 over IPv4 is its larger address
space. The length of an IPv6 address is 128 bits, compared to
32 bits in IPv4. The address space therefore has 2128 or
approximately 3.4x1038 addresses.

IPv6 Packet format:


The IPv6 packet format is shown in the diagram below:
The Internet Protocol version 6 (IPv6) data packet comprises
of two main parts:
i. Header
ii. Payload

The header is the first 40 bytes of the IPv6 packet. It


contains the following fields:
1. Version (4 bits): The constant 6 (bit sequence 0110).

2. Traffic Class (8 bits): The bits of this field hold two


values. The 6 most-significant bits are used for
differentiated services, which is used to classify packets.
The remaining two bits are used for congestion control.

3. Flow Label (20 bits): The flow label is used to specify


that packets should follow the same route.
4. Payload Length (16 bits): This represents the size of the
payload in octets, including any extension headers

5. Next Header (8 bits): Specifies the type of the next


header, i.e., the type of upper packet contained within the
IPv6 datagram.

6. Hop Limit (8 bits): Same as the time to live field of IPv4.


This value is decremented by one at each intermediate node
visited by the packet. When the counter reaches 0 the packet
is discarded.
7. Source Address (128 bits): The IPv6 address of the
sending node.

8. Destination Address (128 bits): The IPv6 address of the


destination node.
Extension Headers : The base header consists of 40 bytes.
To give more flexibility, IPv6 supports extension headers.
The base header can be followed by upto 6 extension
headers.
Hop-by-Hop option

Source routing

Fragmentation
Extension
Headers Authentication

Encrypted Security Payload

Destination option
These extension headers are described below:
1. Hop-by-hop option: This option is used when the
source needs to pass information to all routers which the
datagram visited.
2. Source routing: Specifies the path to be taken by the
datagram.
3. Fragmentation: Only the source can fragment the
datagram.
4. Authentication: Validates the sender and ensures
message integrity.
5. Encrypted Security Payload: Provides confidentiality
and guards against eavesdropping.
6. Destination Option: This option allows a sender to
send some information only to the destination.
Intermediate routers cannot access this information.
IPv4 IPv6
IPv4 address is 32 bits. IPV6 address is 128 bits.
IPv4 is a numeric address, andIPv6 is an alphanumeric
its binary bits are separated by
address whose binary bits are
a dot (.). separated by a colon (:). It
also contains hexadecimal.
Limited address space. Very large address space.
Classful addressing (A, B, C, IPv6 uses subnetting to adjust
D, E classes). network sizes with a given
requirement.
Header length is variable Header length is fixed
(20-60 bytes). (40 bytes).

In IPv4 checksum field is In IPv6 checksum field is not


available. available.
No. of fields in header = 12. No. of fields in header = 8.
IPv4 IPv6
Fragmentation is done by Fragmentation is done only by
sending and forwarding sender.
routers.
Networks need to be manually Supports auto configuration.
configured or by using DHCP.
Widespread use of NAT due to No need to use NAT due to
limited address space. vast address space.
Security is optional feature Security is mandatory.
(IPSec).
Header contains optional No optional fields. But
fields. supports extension headers.
MTU fragment size is 576 MTU fragment size is 1280
bytes. bytes.
Transition from IPv4 to IPv6
• When we want to send a request from an IPv4 address
to an IPv6 address, but it isn’t possible because IPV4
and IPv6 transition is not compatible. For a solution to
this problem, we use some technologies. These
technologies are Dual Stack Routers, Tunneling, and
NAT Protocol Translation.
• Complete transition from IPv4 to IPv6 might not be
possible because IPv6 is not backward compatible. This
results in a situation where either a site is on IPv6 or it is
not. It is unlike implementation of other new technologies
where the newer one is backward compatible so the
older system can still work with the newer version
without any additional changes.

• So we have above technologies that can be used to ensure


slow and smooth transition from IPv4 to IPv6.
Dual Stack Routers
• A router can be installed with both IPv4 and IPv6 addresses
configured on its interfaces pointing to the network of relevant IP
scheme.
• In the following diagram, a server having IPv4 as well as IPv6
address configured for it can now speak with all the hosts on
both the IPv4 as well as the IPv6 networks with the help of a Dual
Stack Router.
• The Dual Stack Router, can communicate with both the
networks. It provides a medium for the hosts to access a server
without changing their respective IP versions.
Tunneling
• In a scenario where different IP versions exist on intermediate
path or transit networks, tunneling provides a better solution
where user’s data can pass through a non-supported IP
version.

• The following diagram depicts how two remote IPv4 networks


can communicate via a Tunnel, where the transit network was
on IPv6. Vice versa is also possible where the transit network is
on IPv4 and the remote sites that intend to communicate are on
IPv6.
NAT Protocol Translation/Header Translation
• This is another important method of transition to IPv6 by means
of a NAT-PT (Network Address Translation – Protocol
Translation) enabled device.

• A host with IPv4 address sends a request to an IPv6 enabled


server on Internet that does not understand IPv4 address. In this
scenario, the NAT-PT device can help them communicate.
When the IPv4 host sends a request packet to the IPv6 server, the
NAT-PT device/router strips down the IPv4 packet, removes
IPv4 header, and adds IPv6 header and passes it through the
Internet. When a response from the IPv6 server comes for the
IPv4 host, the router does vice versa.
Routing Concepts
• In order to transfer the packets from source to the destination, the
network layer must determine the best route through which
packets can be transmitted.
• Whether the network layer provides datagram service or virtual
circuit service, the main job of the network layer is to provide the
best route. The routing protocol provides this job.
• The routing protocol is a routing algorithm that provides the
best path from the source to the destination. The best path is the
path that has the "least-cost path" from source to the destination.
• Routing is the process of forwarding the packets from source to the
destination but the best route to send the packets is determined by
the routing algorithm.
Classification of a Routing algorithm
• Adaptive Routing algorithm
• Non-adaptive Routing algorithm
Properties of Routing Algorithm

• Correctness and simplicity: Packets should be


delivered to correct destination. Routing algorithm
should be simple.
• Robustness: Ability of the network to deliver packets
via some route even in face of failures.
• Stability: The algorithm should meet to equilibrium
fast in the face of changing environment.
• Fairness and optimality: Obvious requirement but
conflicting.
• Efficiency: Minimum overhead.
Adaptive Routing Algorithms
• Adaptive routing algorithms, also known as dynamic routing
algorithms, makes routing decisions dynamically depending on the
network conditions. It constructs the routing table depending
upon the network traffic and topology. They try to compute the
optimized route depending upon the hop count, transit time and
distance.

The three popular types of adaptive routing algorithms are −

• Centralized algorithm − It finds the least-cost path between


source and destination nodes by using global knowledge about the
network. So, it is also known as global routing algorithm.
• Isolated algorithm − This algorithm obtains the routing
information by using local information instead of gathering
information from other nodes.
• Distributed algorithm − This is a decentralized algorithm that
computes the least-cost path between source and destination
iteratively in a distributed manner.
Non – Adaptive Routing Algorithms
• Non-adaptive Routing algorithms, also known as static routing
algorithms, construct a static routing table to determine the path
through which packets are to be sent. The static routing table is
constructed based upon the routing information stored in the
routers when the network is booted up.

The two types of non – adaptive routing algorithms are −

• Flooding − In flooding, when a data packet arrives at a router, it


is sent to all the outgoing links except the one it has arrived
on. Flooding may be uncontrolled, controlled or selective
flooding.

• Random walks − This is a probabilistic algorithm where a data


packet is sent by the router to any one of its neighbors
randomly.
Comparison of Adaptive and Non-Adaptive Routing Algorithms
Basis Of Adaptive Routing algorithm Non-Adaptive Routing
Comparison algorithm

Define Adaptive Routing algorithm is an The Non-Adaptive Routing


algorithm that constructs the routing algorithm is an algorithm that
table based on the network constructs the static table to
conditions. determine which node to send
the packet.
Usage Adaptive routing algorithm is used The Non-Adaptive Routing
by dynamic routing. algorithm is used by static
routing.
Routing decision Routing decisions are made based on Routing decisions are the static
topology and network traffic. tables.

Categorization The types of adaptive routing The types of Non Adaptive


algorithm, are Centralized, isolation routing algorithm are flooding
and distributed algorithm. and random walks.

Complexity Adaptive Routing algorithms are Non-Adaptive Routing


more complex. algorithms are simple.
M.Sc. (Computer Application) Sem-II

Computer Networks

Chapter 7

The Transport Layer

Prof. Vidya Bankar


Dr. D. Y. Patil ACS College, Pimpri Pune-18
Introduction

• The job of the network layer is to deliver data to the


destination machine.
• However, applications cannot depend on the network
layer to deliver data properly. The network may lose
data packets, reorder packets, deliver duplicate
packets or cause errors in packets.
• The transport layer lies between the application layer
and the network layer. It acts as a shield between the
network and the user applications.
• It is an end-to-end layer, i.e., it takes care of process-to-
process delivery.
Need of Transport Layer
1. The network layer is a part of the communication
subnet which is essentially unreliable.
2. The IP protocol provides unreliable, connectionless
service - "best effort" service.
3. Datagrams may be lost or reordered.
4. Datagrams can be duplicated or delivered after long
delays.

Services Provided by Transport Layer


1. Process to Process delivery.
2. Multiplexing and De-multiplexing.
3. Connection-oriented and Connection-less service.
4. Flow and error control.
Process to Process Delivery
Data communication in a network takes place between two
processes running in different machines in the same or
different networks.
1. The data link layer takes care of node-to-node
delivery, i.e., between two adjacent nodes on the link.
2. The network layer is responsible for data
communication between these two machines. This is
called host-to-host delivery.

However, the data link layer and the network layer do not
guarantee that the receiving application will receive data
correctly. The transport layer delivers data to the correct
application running in that machine. This is called process-
to-process delivery.
Figure: Delivery domains of layers

To achieve process-to-process delivery, there should be some


method to identify the process. For example, processes like
e-mail, file transfer, remote login etc may be running in a
machine. There are several ways to achieve process-to-
process communication. The most common method is by
using the client-server method.
Client-Server Paradigm
In the client-server communication, a process on local host
(client) uses services from process on remote host
(server). Both processes have the same name so that they
can communicate. For the process-to-process
communication, we need to use the following information:
1. Local and remote host physical address.
2. Local and remote host logical address.
3. Local and remote host process name/id.

Thus, we need to use different levels of addressing.


Addressing
1. For node-to-node communication, the data link layer
uses a MAC address.
2. For host-to-host communication, the network layer
uses an IP address.
3. For process-to-process communication, the transport
layer needs to use an address to identify the process.
This address is called the port number which identifies
a process among multiple processes.
Port Numbers : Each port is identified by a port number,
which is a positive integer in the range 0 to 65535. Using a
port number, we can uniquely identify a communication
endpoint as (IP address, port).
Servers bind to well-known port numbers (<1024).
Example: HTTP 80, SMTP 25, DNS 53. Clients use
temporary (ephemeral) ports.
The IANA (Internet Assigned Number Authority) has
classified port numbers into
1. Well-known ports: The port numbers from 0-1023 are
well-known ports. Assigned and controlled by IANA.
2. Registered ports: The port numbers from 1024-49151
are not assigned or controlled by IANA but have to be
registered before use in order to prevent duplication.
3. Dynamic or Ephemeral ports: The port numbers from
49152-65535 are not assigned or controlled by IANA.
They need not be registered & can be used by any
process. Figure: Port number ranges
Socket: The combination of an IP address and a port
number is called a socket address. This defines the end-point
of a connection. It identifies a specific host and a process
within the host.

Figure: Socket address


The following diagram illustrates how a packet is delivered
using the IP address and port address.
Figure: IP and port address

In the diagram, the packet is sent to machine having IP


address 192.1.46.7 and to an application running on port
number 13.
Multiplexing and De-multiplexing

• In the sending machine, there may be several processes


which need to send data.
• All these processes use the services of the transport layer
to send the data. Hence, the transport layer receives
data from multiple processes (port numbers).
• Thus, it performs multiplexing to combine data from
multiple applications.
• The receiving transport layer has to separate the
received data and send it to the appropriate applications.
Hence, it has to perform demultiplexing based on the
port number of the data.
Figure: Multiplexing and De-multiplexing

Connectionless and Connection-Oriented Service:


The transport layer provides two types of services to
applications:
Connectionless service: In this type of service, no
connection is established between the sender and receiver.
Each packet is sent as an independent packet. This means
that packets can get lost, arrive out of order or get
duplicated. Some applications require data to be delivered
fast without the additional overheads for reliable data
transfer. Such applications prefer connectionless service.
Ex.: UDP is a connectionless protocol in the transport layer.

Connection-oriented service: In this type of service, a


connection is established between the sender and receiver.
The data is sent as a stream of bytes. This means that the
bytes are delivered in the same order as sent. Applications
which require reliable data transfer use connection-oriented
service.
Ex.: TCP is a connection-oriented protocol in transport layer
Differences between connection-oriented and connectionless
service:
Connectionless Service Connection-Oriented Service
No connection is set up A connection is established
between sender and receiver between the sender and
receiver
All packets are sent Data is sent as a stream of
independently. bytes along established path.
Packets can get lost or arrive Data arrives in the order that it
out of order. was sent.
Requires lesser overheads. Requires more overheads.
Fast communication. Slow communication.
The connectionless service is provided by User Datagram
Protocol (UDP) and connection-oriented service is provided
by Transmission Control Protocol (TCP) in TCP/IP model.
Reliable versus Unreliable
• Transport layer provides reliable as well as unreliable services.
• If the application layer program needs reliability, transport layer
uses a reliable protocol with error control and flow control. If the
service does not demand flow and error control, transport layer
uses unreliable UDP protocol.
• TCP and SCTP are connection oriented and reliable protocol.
UDP is connectionless and unreliable.
• Data link layer provides reliability between two nodes and
transport layer provides reliability between two ends. Since the
network layer is unreliable, we need reliability at transport layer.
Fig: Error control of Data Link and Transport Layer
User Datagram Protocol (UDP)
UDP is a connectionless, unreliable protocol in the transport layer. It
does not add any new functionality to the services provides by IP to
deliver datagrams.

1. No connection is established between the sender and receiver


beforehand.
2. “Best effort" service, i.e., UDP segments may be lost or
delivered out of order.
a. It does not provide flow and error control.
b. The sender and receiver applications are identified by
ports.
c. It does multiplexing at the source and de-multiplexing at
the receiver.
3. If a process wants to send a small message and does not care much
about reliability, it can use UDP.
4. It is suitable protocol for streaming applications such as VoIP
(Voice over Internet Protocol), multimedia streaming.
UDP Datagram Format

The UDP packet is also called as user datagram which has


a fixed sized header of 8-bytes. The fields include:

• Source port: This is a 2-byte field used for representing


port address of the source (sending) application. Port
address can range from 0 to 65,535.
• Destination port: This field also represents 2-byte port
address of the destination (receiving) application.
Usually source port is optional in a UDP datagram and
is included only if a reply is expected. If a reply is not
required, the source port is set to zero.

• Total length: This 16-bit length field defines the total


length of user datagram, i.e., header + actual data. As it
is 16-bit number, the total length can be 0 to 63,535
bytes.

• Checksum: This 16-bit field is used to detect the errors


over the entire datagram. The checksum is optional; if
not used, the checksum is set to zero.
Checksum

The checksum is used for error control. The checksum


calculation in UDP uses three sections:

i. The pseudoheader: This contains some fields from the


IP header (IP packet encapsulates the UDP packet) in
order to identify the datagram.

i. The UDP header: This is the entire header of the UDP


datagram.

i. Data from the application layer: For checksum


calculation, the entire data carried by the UDP
datagram is included.
The following diagram shows the fields used for
checksum calculation.

Figure: Fields used for checksum calculation


How checksum is calculated

1. Add padding to data to make data a multiple of 16 bits.


2. Group the data from all three sections: pseudoheader,
UDP header and data into units of 16 bits.
3. Add all units of 16 bits by performing binary addition.
4. Complement the sum and use it as checksum.

The following diagram shows how the checksum is


calculated for a UDP datagram which carries 7 bytes of data
(TESTING). Note that eight zero's are padded at the end to
make it a multiple of 16.
10011001 00010010 → 153.18 153.18.8.105
00001000 01101001 → 8.105 171.2.14.10
10101011 00000010 → 171.2
All 0s 17 15
00001110 00001010 → 14.10
00000000 00010001 → 0 and 17 1087 13
00000000 00001111 → 15 15 All 0s
00000100 00111111 → 1087 T E S T
00000000 00001101 →13
I N G All 0s
00000000 00001111 → 15
00000000 00000000 → 0 (checksum)
01010100 01000101 → T and E
01010011 01010100 →S and T
01001001 01001110 → I and N
01000111 00000000 → G and 0 (padding)
10010110 11101011 → Sum
01101001 00010100 → Checksum

Figure: UDP checksum calculation


UDP Operation
1. UDP provides connectionless service.
2. Each datagram is sent independently and all datagrams to
the same destination may not follow the same path.
3. The datagrams are not numbered. Hence, UDP does not
check whether the datagrams have arrived in order.
4. It does not perform flow and error control.
5. It provides an optional checksum mechanism to detect an
error. If a datagram arrives with error, it is simply discarded.
6. It performs encapsulation and de-capsulation, i.e., a UDP
datagram is encapsulated in an IP datagram.
7. Since multiple applications may be using UDP, UDP
performs multiplexing and de-multiplexing.
8. UDP uses queues to handle multiple messages coming in
and going out from an application. A queue is associated
with a port number. Separate queues used for incoming and
outgoing messages.
Figure: UDP De-multiplexing
Figure: UDP queues
UDP Applications

1. For processes which require request-response


communication like DNS, SNMP. Some processes have
inbuilt error and flow control mechanisms. They can use
UDP, which will be faster.
Example: Trivial File Transfer Protocol (TFTP).
2. Used in multimedia applications where a stream of
multimedia data has to be sent from the source to the
receiver.
3. Applications requiring multicasting or broadcasting use
UDP.
4. Used in router protocols for updating router tables.
Example: Routing Information Protocol. (RIP)
5. UDP is used for management processes such as SNMP
(Simple Network Management Protocol).
Advantages of UDP
1. It is a very simple protocol.
2. Requires minimum overhead.
3. Communication is much faster.
4. UDP is ideal for applications which perform flow and
error control themselves.

Disadvantages of UDP
1. It does not guarantee reliable data transfer.
2. Packets may get lost or arrive out of order.
3. It does not perform flow control.
Transmission Control Protocol (TCP)
Many applications require reliable and sequenced delivery of
data. TCP is specifically designed to provide a reliable end-
to-end byte stream over unreliable network.
TCP Services
TCP provides the following services to the application layer
protocols:
1. Process-to-Process Communication
i. Allows one process to communicate with another
process using port numbers.
ii. Only unicast transmission, i.e., one sender and
one receiver.
iii. Does not support broadcasting or multicasting.
iv. Well known ports used by TCP are FTP (20 and
21), TELNET (23), SMTP (25) etc.
2. Stream Delivery Service
i. TCP is a stream-oriented protocol; sender
sends "bytes” of data.
ii. No “message boundaries”.
iii. TCP creates a connection which allows the
sending process to push bytes into the stream
and a receiver to read bytes from the stream.

Figure: Stream oriented communication


Sending and Receiving Buffers
• The sender and receiver use buffers to store bytes sent
and received respectively. They are used for flow
control.
• Sending buffers store unacknowledged data.
• Receiving buffers store received data for ordering and
error control.
• They are implemented as circular byte-arrays.
• On the sending side, the dark grey area indicates bytes
sent but not acknowledged. The light grey area indicates
bytes to be sent and white area indicates empty array
positions.
• On the receiver side, the light grey area indicates bytes to
be given to the application and white area indicates
empty buffer positions.
Figure: Sending and receiving buffers
Segments
• TCP does not send data byte-by-byte. It groups a set of
bytes into packets called segments.
• A segment is then sent to the network layer for delivery.
• The sending and receiving applications are not aware
that the bytes have been put into separate segments.
• As far as they are concerned, the sender sends data byte
by byte and the receiver receives the data byte by byte
in the same order and without any error.
Figure: TCP segments
3. Full duplex communication
i. Data can flow in both directions at the same
time.
ii. This can be implemented using, sending and
receiving buffers.
iii. Each communicating host has a sending and
receiving buffer.

4. Connection-Oriented service
Sender and receiver set up a connection beforehand and
terminate it after communication is over.
Communication takes place in three phases:
a. Connection establishment
b. Data transfer
c. Connection release
It is not a physical connection since the network layer is
connection-less. It is simply a virtual connection between
the two processes.
TCP takes responsibility of providing the two processes the
feel that the communication is taking place in a connection-
oriented manner. But in reality, it is taking place in a
connection-less manner.

5. Reliable Service
i. TCP provides the application a reliable service.
ii. Bytes are received in the same order and
without error.
iii. TCP uses sequence numbers and checksum to
achieve reliability.
TCP Features
To provide the services discussed above, TCP has some
important features which allow TCP to provide a reliable,
stream-oriented connection-oriented service to the
applications.

1. Numbering System:
TCP has to keep a track of the bytes which have been sent
and acknowledged. Further, a set of bytes are grouped into a
segment. Hence, TCP has to also keep a track of the
number of bytes sent in a segment. To do this, TCP uses
three numbers:
Byte Number: Each byte transferred from sender to receiver
is numbered. The bytes are numbered consecutively. The
starting number is a random number between 0 and 232- 1.
Sequence Number: This number identifies a segment. The
sequence number of a segment is the byte-number of the
first byte in the segment.
Acknowledgement Number: This number confirms the
number of bytes a receiver has received correctly. The
acknowledgement number specifies the next byte expected.
For example, if the receiver has received 'x' bytes correctly, it
will send the acknowledgement number as 'x+l'.
Acknowledgements are cumulative, i.e., a single
acknowledgement number acknowledges all previous
byte numbers. For example, if it sends an acknowledgement
number as 501, it means that it has received 500 bytes
correctly. Acknowledgements are piggybacked.
The following diagram shows the communication between a
client and server machine.
Figure: TCP operation
Flow Control: TCP provides flow control to prevent a fast sender
from overloading a slow receiver. It is achieved using buffers and
sliding windows. When the receiver's buffer does not have any more
space, it informs the sender to stop sending by advertising a receiver
window size of 0.When buffers have space, TCP informs sender to
start sending.

Error Control: To ensure that the bytes are given to the receiver in an
error-free manner, TCP uses checksum for error control. It has
mechanisms for detecting corrupted / lost/ out of order/ duplicated
segments.

Congestion Control: When the number of packets in a part of the


network become more than it can handle, congestion occurs in
network. For reliability, TCP also performs congestion control by
reducing the rate of sending data so that additional packets are not
added to the network.
TCP Segment
Every TCP segment contains a TCP header followed by
data. The header has a fixed 20 bytes and some options
upto 40 bytes. Thus the maximum header size is 60 bytes.
The TCP segment is shown in the following diagram.

Figure: TCP segment


• Source Port (16 bits): This 16-bit field defines the port
number of the application program in the host that is
sending the segment.
• Destination Port (16 bits): This 16-bit field defines the
port number of the application program in the host
that is receiving the segment.
• Sequence Number (32 bits): This 32-bit field defines
the number assigned to the first byte of data contained
in this segment.
• Acknowledgement Number (32 bits): This 32-bit field
defines the byte number the receiver of the segment is
expecting to receive from the other party. If the
receiver receives a byte number x, then it defines x+1 as
the acknowledgement number.
• Header Length (4 bits): This 4-bit field defines the
number of 4-byte words in the TCP header. The length of
header can be between 20 and 60 bytes. Thus the value
of this field can be between 5 (5x4=20) and 15
(15x4=60).
• Reserved (6 bits): This 6-bit field is reserved for future
use.
• Flags (6 bits) : There are 6 control bits or flags
URG - Urgent pointer is valid
ACK - Acknowledgement is valid
PSH - Request for push
RST - Reset the connection
SYN - Used for connection setup
FIN - Terminate the connection
• Window Size (16 bits): This 16-bit field defines the size
of window in bytes. This indicates the maximum size of
the window. The maximum window size is 65,536 bytes.
• Checksum (16 bits): This 16-bit field contains the
checksum. While performing computations, the TCP
checksum field is set to zero and the data field is padded
out with additional zero byte if its length is odd number..
The checksum algorithm is to simply add up all 16-bit
word's one's complement and then take one's
complement of the sum
• Urgent Pointer (16 bits): This 16-bit field is valid only
if the urgent flag is set. It is used when the segment
contains urgent data.
• Options (variable): There can be up to 40-bytes of
optional information. It is used for adding extra
facilities not covered in header. Example: maximum
segment size, timer settings option.
• Data: This field contains the data bytes.
TCP Applications
1. Applications requiring reliable, full duplex
communication to send bulk data like file transfer use
TCP.
2. Mail protocols like SMTP and POP3(Post Office
Protocol 3) use TCP.
3. HTTP uses TCP for communication between the HTTP
client (browser) and the HTTP server.
4. Some Transport Layer Security Protocols like TLS
(Transport Layer Security) uses TCP for security of
transactions on the Internet.
Comparison between TCP and UDP
Feature TCP UDP
Data handling TCP is, a byte- UDP handles data as
oriented protocol. It individual datagrams
does not preserve which are sent
message boundaries. independently.
Type of service Connection-oriented. Connectionless.
Overheads TCP is heavyweight Light-weight protocol
since it has overheads since it does not
due to flow and error perform error and
control. flow control.
Reliability Guarantees reliable Does not guarantee
data transfer. reliability.
Communication Speed Slower due to Faster due to less
connection set-up and overheads.
release phase.
Error control Performs error No error control.
checking.
Flow control Ensures that sender Does not perform flow
and receiver are control.
synchronized.
Ordering Bytes are received in Datagrams can arrive
the same order as they out of order.
were sent.
Types of applications Most protocols and Applications where
that use the protocol applications sending data delivery speed
data that must be matters more than
received reliably, reliability, where
including file and small amounts of data
message transfer are sent; or where
protocols. multicast/broadcast
are used.
Examples FTP, SMTP, HTTP DNS, SNMP
Introduction to SCTP

• Stream Control Transmission Protocol (SCTP): This transport layer


protocol combines some aspects of UDP and TCP. SCTP provides
reliability similar to TCP but maintains a separation between data
transmissions (called “chunks”) similar to datagrams in UDP. Further,
SCTP supports multiple parallel streams of chunks (for both data and
control information).

• It is a connection- oriented protocol in computer networks which


provides a full-duplex association i.e., transmitting multiple streams of
data between two end points at the same time that have established a
connection in network. It is sometimes referred to as next generation
TCP or TCPng, SCTP makes it easier to support telephonic
conversation on Internet. A telephonic conversation requires transmitting
of voice along with other data at the same time on both ends, SCTP
protocol makes it easier to establish reliable connection.

• SCTP is also intended to make it easier to establish connection over


wireless network and managing transmission of multimedia data.
SCTP is a standard protocol and is developed by Internet Engineering Task
Force (IETF).
Characteristics of SCTP
• Unicast with Multiple properties
It is a point-to-point protocol which can use different paths to reach
end host.

• Reliable Transmission
It uses SACK(selective acknowledgement) and checksums to detect
damaged, corrupted, discarded, duplicate and reordered data. It is
similar to TCP but SCTP is more efficient when it comes to
reordering of data.

• Message oriented
Each message can be framed and we can keep order of datastream
and tabs on structure. For this, In TCP, we need a different layer for
abstraction.

• Multi-homing
It can establish multiple connection paths between two end points
and does not need to rely on IP layer for resilience.
Advantages of SCTP :

• It is a full- duplex connection i.e. users can send and receive data
simultaneously.
• It allows half- closed connections.
• The message’s boundaries are maintained and application doesn’t
have to split messages.
• It has properties of both TCP and UDP protocol.
• It doesn’t rely on IP layer for resilience of paths.

Disadvantages of SCTP :

• One of key challenges is that it requires changes in transport


stack on node.
• Applications need to be modified to use SCTP instead of
TCP/UDP.
• Applications need to be modified to handle multiple simultaneous
streams.
M.Sc. (Computer Application) Sem-II

Computer Networks

Chapter 8

The Application Layer

Prof. Vidya Bankar


Dr. D. Y. Patil ACS College, Pimpri Pune-18
Application Layer Protocols

• The Application layer is the topmost layer in the layered


network model.
• It is the layer with which users interact directly. The
application layer enables the user, whether human or
software, to access the network.
• It provides user interfaces and support for various
services such as remote file access, electronic mail,
and access to the World Wide Web etc.
• It contains all higher-level protocols. The virtual terminal
(TELNET), file transfer (FTP), electronic mail
(SMTP), Domain Name System (DNS), HTTP for
accessing web page are some of the protocols included in
this level.
Domain Name System

• Machines on the internet are identified by a unique IP


address. However, it is difficult for people to remember
these addresses.
• Humans are more comfortable with names rather than
numbers. Hence, it would be easier to identify a machine
using a name instead of an address.
• A system is needed that can map a name to an address.
This task is handled by Domain Name System (DNS).
• It is basically a client server application that maps host
names to IP addresses on the Internet.
• DNS server runs on port number 53 and uses either TCP
or UDP transport layer protocols.
Domain Name Space
In this space, the names are defined in an inverted tree
structure with the root at the top. The hierarchical structure
(tree) can have only 128 levels; level 0 for root to level 127.
Figure: Domain name space in hierarchy (tree)
Label: Each node in the tree is labeled. The label is a string
of maximum of 63 characters. The root label is a null
string. The children of a node should have unique labels.
This ensures uniqueness of the entire domain name.
Domain name: Each node in a tree has a domain name. A
full domain name is a sequence of labels separated by
dots(.). The domain names are always read from node up to
the root and the last label of root is null.
Figure: Domain name
Distribution of Name Space
The domain name system needs to store a lot of information.
However, all this information cannot be stored at a
central place in a single server. This would be inefficient
due to the following reasons:
1. There will be a lot of traffic to the central server.
2. The server may not be able to process all requests
leading to higher delays.
3. Any failure in the central server will make the
information inaccessible.

DNS server: The domain information is distributed


among several computers across the world. These
computers are called DNS servers. Each server is
responsible for storing a domain or a subdomain.
Since there is a hierarchy between domains and subdomains,
the DNS Servers will also form a hierarchy as shown below.

Figure: Hierarchy of DNS servers


Zone: Each server has authority over a zone. The authority
over each DNS zone is delegated to a legal entity or
organization (i.e., a country-code top-level domain registry)
or a company/individual. A zone is created mainly for
administrative purposes.
Figure: Domains and zones
Types of Servers
1. Root server: A root server is a DNS server whose zone
consists of the whole tree. Normally, the root server
does not store any information about domains but
delegates authority to other servers. There are many
root servers around the world, each covering a whole top
level domain hierarchy.
2. Primary server: A primary server stores information
about the zone in a file. It is responsible for updating
and maintaining all information about that zone. It
sends this information to other secondary servers when
requested.
3. Secondary server: A secondary server retrieves
information from another primary or secondary
server and stores this information (Zone transfer). It
does not create or update the file.
DNS in the internet
The DNS for internet provides a mechanism that implements
machine name hierarchy for TCP/IP. The domain name tree
classification is shown below.
Figure: DNS for Internet
The DNS tree is divided into three sections:
1. Generic domain: It allows organizations to be grouped
by organizational types. When an organization wants to
participate in DNS, it registers under that scheme. There
are around 14 generic domains available.
Domain Description
com commercial organization
edu educational institute
gov government organizations
int international organizations
mil Military
net network support centers
org organization (non profit)
aero aerospace /airlines companies
biz business
coop cooperative business org
info information services
museum museums and other non profit org
name personal names
pro professional organization
2. Country domain: This divides the servers by country.
For example, uk-for United Kingdom, us-for United states,
in-for India etc. This country domain scheme utilizes two
character country abbreviations.

3. Inverse domain: This is used to map an address to a


name. For example, if a server receives a request from a
client and the server has only the IP addresses of the clients
in its list then the server asks its resolver to query to the DNS
server to map the IP address to name to verify if the client
is authorized. This type of query is also called inverse
query or pointer query (PTR query).
E-mail
Electronic mail normally referred to as e-mail, is probably
the most widely used service associated with computer
networks. Today, emails are capable of containing text,
audio, video and images. The email system is a store-and-
forward type of system

Architecture
We will consider four scenarios to understand the emailing
process. Let us assume that Alice (A) wants to send an email
to Bob (B).
Scenario 1: Sender and Receiver Connected to the same
system
In this scenario, the sender and receiver are users on the
same system. Each user has a mailbox in the system. Each
message carries the mailbox address of the sender and
receiver. ‘A’ uses a User Agent (UA) to create the message
and sends the mail to B's mailbox. ‘B’ can read the messages
in B's mailbox anytime according to convenience.
Figure: Email architecture - Scenario 1
Scenario 2: Sender and Receiver connected to different
systems
In this scenario, the sender and receiver are users on
different systems. The email has to be sent from user A in
one system to user B in another system. The mail may have
to be sent over the internet. Thus we need two User Agents
(UA) and two Message Transfer Agents (MTA). The UA's
will allow A and B to send and retrieve messages. The
MTA's are needed to actually do the transmission from
A's server to B's server.
Figure: Email architecture - Scenario 2
Scenario 3: One user is a remote user
In this scenario, the receiver B is connected directly to his
system. But A is not connect directly to her system. A is a
remote user.
A connects to her system using a LAN or a WAN link.

In this case
• A uses a UA to create the message.
• The message is now sent through the LAN or WAN to
the email server by an MTA client to the MTA server
running in the email server.
• The MTA client then sends the message to B's MTA
mail server.
• B retrieves the mail from his mail server using a UA.
Figure: Email architecture - Scenario 3
Scenario 4: Both users are remote users

This is the most common scenario. In this scenario, A


connects to her mail server using a LAN or WAN link.
Receiver B also connects to his mail server using a LAN or
WAN connection, i.e., both A and B are not directly
connected to the mail server.
In this case:
A uses a UA and MTA to send the mail to her mail server
The MTA client at A's mail server sends it to B's mail server.
B uses a Mail Access Agent (MAA) to retrieve the
message.
The MAA client pulls the messages from the mail server.
B uses a MAA client to retrieve messages from the MAA
server.
Figure: Email architecture - Scenario 4
User Agent
A User Agent is an important component of the email
architecture. It is a software that provides the following
important services:
1. Composing messages: Process of creating mails. The
mails. The user agent provides a template which helps the
user fill in different fields like recipients, subject, message
body, attachments etc. It can also perform spell check and
provide text formatting capabilities.

2. Reading messages: Process of displaying messages in


the appropriate format. When a mail is received, this
information is presented to the user. Normally, it is shown in
a one-line summary format which shows a sequence
number, a flag indicating whether it is new, replied etc,
the message size, the sender and a part of the subject.
3. Replying to messages: Process of replying to received
messages. The user agent allows the recipient to reply to the
received message. It provides options to include the
original message in the reply, to reply to original sender
or all recipients of the message.

4. Forwarding messages: Process of sending a received


message to other users. Forwarding sends the message to a
third party.

5. Handling mailboxes: Process of handling inbox, outbox


and customized mailboxes. Users can create mailboxes to
store the mails efficiently. The UA provides the facility to
create mailboxes, arrange mails in mailboxes and manage
the mailboxes.
Types of User Agents
1. Command driven
2. GUI based

1. Command driven: This type of user agent uses a


Command based Interface, i.e., a Character User
Interface (CUI). The user has to type the commands to
perform various UA actions. Example: mail, pine, elm
etc.

2. GUI based: Modern UA's are GUI based. They use


GUI components like buttons, menu's, lists etc. to
make the mail creation task easier and more interactive.
Example: Eudora, Outlook etc.
Message Transfer Agent: SMTP
The protocol that defines the communication between MTA
client and MTA server is called Simple Mail Transfer
Protocol (SMTP), SMTP is a Push Protocol, i.e., it pushes
the message from the client to server.
It uses TCP for communication at port 25. The MTA client
and server establishes a connection before communicating.
In the figure given, SMTP is used between the user A and
A's mail server and between A's mail server and B's mail
server. POP3
Figure: Use of SMTPIMAP4
SMTP defines several commands and responses between the
MTA client and MTA server.
Figure: SMTP communication

The following table shows the SMTP commands.

The first 5 commands are mandatory commands and must


be supported by every SMTP software.
Table: SMTP commands Argument (s)
Command Argument(s) Description
HELO Sender's host name For setting identity of client.
MAIL FROM Sender of message e-mail address of sender.
RCPT TO Address of recipient e-mail address of recipient.
DATA Body of message Actual Message
QUIT - Terminate message.
REST - Abort mail transfer.
VRFY Recipient address Varieties address of recipient.
NOOP - checks status of recipient.
TURV - Allows to switch sender and
recipient.
EXPN Mailing list of Asks recipient to expand mailing list.
recipients
HELP Command name Asks recipient to send information.
SEND FROM Recipient of message Deliver the message to recipient not
to mail box.
SMOL FROM Recipient of message Deliver the message to logged
terminal or mailbox.
SMAL FROM Recipient of message Deliver message to both logged
terminal and mail box.
The response is sent back as a 3 digit number which
specifies the result of the command. Example: 450 means
mailbox not available. 220 means service ready, 421 means
service not ready etc. Typical SMTP procedure is given
below.
Web Based Mail
Due to the growing number of email users, several websites
provide a web based mail facility for sending, storing and
receiving mails. Gmail, Hotmail and Yahoo are some
commonly used web based email sites.

The process is done as follows:

1. A and B create web based mail accounts.


2. A wants to send a mail to B. A's browser sends the mail
to A's mail server using HTTP.
3. A's mail server uses SMTP to send the mail to B's mail
server.
4. B retrieves the mail from the mail server using HTTP.
Message Access Agent: POP3(Post Office Protocol version 3)

• The Post Office Protocol is an email protocol. Using this


protocol, the end user can download emails from the mail
server to their own email client. Once the emails are
downloaded locally, they can be read without an internet
connection. Also, once the emails are moved locally, they get
deleted from the mail server, freeing up space.
• POP3 is a protocol that was developed when the internet
connections were with no flat rate, so the idea was to
download the emails quickly and disconnect the internet
connection, to save on cost.
• While the POP3 protocol assumes that your email is being
accessed only from one application, IMAP allows
simultaneous access by multiple clients.
Advantages:
• Read emails on local devices without internet
connection.
• The mail server need not have high storage
capacity, as the emails get deleted when they're
moved locally.

Disadvantages:
• If the local device on which the emails were
downloaded crashes or gets stolen, the emails are
lost.
IMAP (Internet Message Access Protocol)
The most differentiating features of the IMAP protocol is that that the
emails and inboxes are not stored on your computer but
somewhere in the cloud. This allows all your mails to be perfectly
synchronized when usually read emails from different computers or
devices, as all devices and platforms will show exactly same emails.
Advantages:
• Two-way synchronized communication between the email server
and the email client, which allows several devices to work on the
same account seeing the changes made by everyone.
• Emails are on the server all the time, so accessing them can be
done from any place by having a device with internet access.
• In case of a computer crash or accidental deletion of data, since
emails are on the mail server, it is possible to get the emails back.
• As the emails are stored on mail server, it utilizes minimal local
storage.
Disadvantages:

• Mails won’t work without an active internet


connection.
• In case email usage is more, you would need a
larger mailbox storage which might cost more.
• Accessing mails little slower as compared to
POP3, as all folders get synchronized everytime
there is a Send / Receive
• Also, as the emails are stored on the web server, it is
important to keep checking the available storage
space for your mailbox, else if the mailbox is full,
mails will start bouncing back.
World Wide Web
• The World Wide Web (WWW) is a repository of
information linked together from various computers
in the internet.
• It provides a framework for accessing these
documents and resources which consist of text,
graphics, audio, video and other media, and are
connected by hyperlinks that appears within the
documents.
• Usually Hypertext Markup Language (HTML) is used to
prepare these documents.
• The www is accessed through a browser program that
interprets HTML, displays documents, and allows user
to access resources by clicking on hyperlinks.
Architecture
• Web is a set of distributed clients and servers, using
the Hyper Text Transport Protocol.
• Each server holds one or more documents referred to as
web pages. Each page contains links to other pages. A
user can access web pages through a graphical client
program or web browser.
• A client needs to fetch some information from server A.
It sends a request from its browser. The request
contains information about the document and the address
of the site in a URL.
• The server A sends the document to the client. In the
document, the client finds some reference to another
document at server B. It sends a request to server B for
the document.
Figure: Architecture of World Wide Web
Client (Browser)
Client machine utilizes a browser program for displaying
web pages. When user clicks on some hypertext, the browser
follows the hyper link by sending request for the page to a
server. Server responds to the request by sending the
requested page. Each browser consists of three parts:
1. Controller: The controller communicates with the
user to accept input from keyboard or mouse. It uses
the client protocol to access the document and uses an
interpreter to display the page in the appropriate
format on the screen.
2. Client protocol: The protocol is used to fetch the page.
It could be FTP or HTTP.
3. Interpreter: The interpreter is required to display the
data in the correct format & also run background
scripts. The interpreter can be HTML, java, javascript
Server
The server stores web pages. Normally, the server runs in a
loop waiting for client requests. When a client requests a
page, it fetches the page from its disk and sends it to the
client as response. For faster operation, the server stores
frequently accessed pages in a cache memory so that they
can be accessed faster.

URL
To access any web document in a standard manner, HTTP
uses Uniform Resource Locators. It identifies any type of
information on the internet.
A URL consists of:
1. Protocol: Software used to retrieve the document.
Example: ftp, http.
2. Host computer: Computer on which the web document
is located.
3. Port number: Optional field which specifies the port
from which the resource can be obtained
4. Path and filename: Specifies the document name and
path in the host computer.
Figure: URL Syntax
Example,
http://www.google.com/welcome.html
http://192.168.200.3:80/examples/intro.html
Web Documents
• Web document is a document viewed on the world
wide web. Web documents are formatted in a
markup language like HTML or XML and can also
contain content produced with scripting languages
like Javascript, PHP, and Perl.
• The web documents in the WWW can be grouped
into three broad categories: static, dynamic, and
active.
• The category is based on the time at which the
contents of the document are determined.
Three basic types of web documents
Static web document
• A static web document resides in a file that it is associated with a web
server. The author of a static document determines the contents at the
time the document is written. Because the contents do not change,
each request for a static document results in exactly the same
response.

Dynamic web document


• A dynamic web document does not exist in a predefined form. When
a request arrives the web server runs an application program that
creates the document. The server returns the output of the program as a
response to the browser that requested the document. Because a fresh
document is created for each request, the contents of a dynamic
document can vary from one request to another.

Active web document


• An active web document consists of a computer program that the
server sends to the browser and that the browser must run locally.
When it runs, the active document program can interact with the user
and change the display continuously.
Static web document

• Advantages: simplicity, reliability and performance.


The browser can place a copy in a cache on a local
disk.

• Disadvantages: inflexibility, changes are time


consuming because they require a human to edit the
file.
Dynamic web document

• Advantages: ability to report current information


(current stocks prices, current weather conditions,
current availability of tickets for a concert).Because
both static and dynamic documents use HTML, a
browser does not know whether the server extracted
the page from a disk file or obtained the page
dynamically from a computer program.

• Disadvantages: increased cost, information in a


dynamic document begins to age as soon as it has
been sent to the browser (stock prices). Server
needs to run the programs periodically and sends
the new document to the browser.
Active web document

• Advantages: ability to update information


continuously. For example, only an active document can
change the display quickly enough to show an animated
image. More important, an active document can access
sources of information directly and update the display
continuously. For example, an active document that
displays stock prices can continue to retrieve stock
information and change the display without requiring
any action from the user.

• Disadvantages: cost of creating, testing, and running;


requires more sophisticated browser and more
powerful computer; care must be taken that the
programs are portable.
HTTP
HTTP is HyperText Transfer Protocol. It is used in the www
for clients (browsers) and servers to communicate. The
communication is simple request-response type, i.e., the
client sends a request to the server and the server responds. It
uses only a single connection between client and server on
well-known port 80.
HTTP Transaction
The following diagram shows the transaction between client
and server.
1. The client sends a request message to the server by
establishing a TCP connection on port 80.
2. The client can now send requests for web pages and the
server responds by sending the required pages.
The request and response messages have the syntax as shown
below.
Figure: HTTP request and response messages
Each message contains
1. Request and status lines: These are the first lines of the
request and response message respectively.
Figure: Request and Status lines
i. Request type: HTTP supports operations called methods
which allow a variety of operations to be performed.

Some of the built-in HTTP request methods are:


a. GET: To retrieve a document from server.
b. HEAD: Request to read web page header.
c. POST: Provide some information to the server.
d. PUT: Request to store web page on server.
e. TRACE: Echoes the incoming request.
f. CONNECT: Reserved.
g. OPTION: Ask server about available options.

ii. URL: The URL of the document

iii. Version: The HTTP version


iv. Status code: Used to indicate response. It is an integer
containing 3 digits. Codes starting with 1 are
informational, those with 2 indicate successful request,
those with 3 redirect to another URL and those with 4
indicate an error at the server site.
v. Status phrase: Explains the status code in text form.
2. Header: This contains additional information between
the client and server.
i. General header: General information about the message.
It can be present in both, request and response.
ii. Request header: Specifies client configuration and other
information.
iii. Response header: Specifies server configuration and
other information.
iv. Entity header: Gives information about body of
document.
3. Body: The body contains the document to be sent or
received.
Example: Client sends a GET request for image named
image1 and tells server that it can accept images in jpeg/gif
format. Response contains status line & header.
Figure: HTTP Request and Response
Persistent and Non-persistent connections
• HTTP protocol used to deliver all resources on the World
Wide Web. HTTP defines how the messages are formatted
and transmitted. When a client requests some information
(say, clicks on a hyperlink), the browser sends a request
message to the HTTP server for the requested objects. The
server receives the requests and sends the response message
with the objects. However, the HTTP server maintains no
information about the clients, and if the client asks for
the same object again, the server resends the object.
Therefore, HTTP is called a stateless protocol.

• HTTP can use both nonpersistent connections and


persistent connections. A nonpersistent connection is the
one that is closed or released after the server sends the
requested object to the client. In other words, the
connection is used exactly for one request and one response,
it get automatically close after a transaction.
• With persistent connections, the server leaves the
TCP connection open after sending responses and
hence the subsequent requests and responses between
the same client and server can be sent. The server
closes the connection only when it is not used for a
certain configurable amount of time. With
persistent connections, the performance is improved
by 20%. This strategy is also called as connection
reuse.

• Nonpersistent connections are the default mode for


HTTP/1.0 and persistent connections are the default
mode for HTTP/1.1.
Proxy server
• Proxy is an application or program or system, which
helps to protect the information of its users and
computers. It acts as a barrier between computer and
internet user. One can go to any site and search or request
anything on the internet. Due to this barrier the site you
are using cannot see your information. Thus, hiding IP
address and protecting your privacy.

• When you type any site and request for it, the internet
servers takes you to that site and give access to it. When
you are surfing on the internet and requesting for
something then with that request your IP address goes
to the proxy.

• Proxy server then searches the cache and looks up for


the same request. If the request is available in the cache, it
is produced right away saving the bandwidth.
• If it is not in the cache, the proxy accesses the internet
and produces the result and stores it in the cache as
well. It will hide your original IP address and
generates public IP address for your privacy. As soon
as the public IP is generated, the request goes to internet.
Internet servers will not know which user has requested
for it. Thus, protecting your identity.

• When request will be accepted, it goes back to proxy.


Now, proxy knows the original IP address so, it will
change the public IP address into the original IP
address of the user and gives it back to the user. Thus,
viewing the requested site.

• Proxy servers are already pre-installed in Windows in


a type of program or a application. It is automatically
saved in the settings section. You can also make customs
that for which site you want to use proxy.
Advantages of Proxy Server :
• It acts as a repository and stores the knowledge about
internet usage, website visited by all employees in an
organization, etc.
• It hides the IP address of a local computer from
malicious users available on the internet.
• It is a filtering tool that is used to block access to certain
websites in an organization.
• It improves network performance and speed up the
system by storing requests in its cache.

Disadvantages of Proxy Server :


• As it is a good cache system, then sometimes your
passwords or browser websites can easily be seen by
proxy servers providers.
• Using the technique of TLS and SSL, your data and
information can be leaked.
TELNET
• The main task of the Internet and its TCP/IP protocol suite is to
provide services for users. For example, users may want to run
application programs at a remote site and create results that
can be transferred to their local site. One way to satisfy that
demand and others is to create a client-server application
program for each desired service. Programs such as file transfer
programs (FTP and TFTP), email (SMTP), and so on are currently
available. However, it would be impossible to write a specific
client-server program for each demand.

• The better solution is a general-purpose client-server program


that lets a user access any application program on a remote
computer; in other words, allow the user to log on to a remote
computer. After logging on, a user can use the services
available on the remote computer and transfer the results back
to the local computer.
• TELNET is a general-purpose client-server
application program.

• TELNET is an abbreviation for TErminaL


NETwork. It is the standard TCP/IP protocol for
virtual terminal service as proposed by ISO.
TELNET enables the establishment of a connection
to a remote system in such a way that the local
terminal appears to be a terminal at the remote
system.
Time-Sharing Environment
• TELNET was designed at a time when most operating
systems, such as UNIX, were operating in a time-sharing
environment. In such an environment, a large computer
supports multiple users. The interaction between a user
and the computer occurs through a terminal, which is
usually a combination of keyboard, monitor, and mouse.

• In a time-sharing environment, all of the processing must


be done by the central computer. When a user types a
character on the keyboard, the character is usually sent to
the computer and echoed to the monitor. Time-sharing
creates an environment in which each user has the
illusion of a dedicated computer. The user can run a
program, access the system resources, switch from one
program to another, and so on.
Login

• In a time-sharing environment, users are part of


the system with some right to access resources.

• Each authorized user has an identification and


probably a password. The user identification
defines the user as part of the system.

• To access the system, the user logs into the system


with a user id or login name. The system also
includes password checking to prevent an
unauthorized user from accessing the resources.
Local Login

• When a user logs into a local time-sharing


system, it is called local login. As a user types at
a terminal or at a workstation running a terminal
emulator, the keystrokes are accepted by the
terminal driver.

• The terminal driver passes the characters to the


operating system. The operating system, in turn,
interprets the combination of characters and
invokes the desired application program or
utility (see Figure).
• The mechanism, however, is not as simple as it seems because the
operating system may assign special meanings to special characters. For
example, in UNIX some combinations of characters have special
meanings, such as the combination of the control character with the
character “z,” which means suspend.
• Whereas these special situations do not create any problem in local
login because the terminal emulator and the terminal driver know
the exact meaning of each character or combination of characters,
they may create problems in remote login. Which process should
interpret special characters? The client or the server?
Remote Login

• When a user wants to access an application program


or utility located on a remote machine, he or she
performs remote login. Here the TELNET client and
server programs come into use.

• The user sends the keystrokes to the terminal driver


where the local operating system accepts the characters
but does not interpret them.

• The characters are sent to the TELNET client, which


transforms the characters to a universal character set
called NVT(Network Virtual Terminal) characters and
delivers them to the local TCP/IP stack (see Figure).
The commands or text, in NVT form, travel through the Internet
and arrive at the TCP/IP stack at the remote machine. Here the
characters are delivered to the operating system and passed to the
TELNET server, which changes the characters to the
corresponding characters understandable by the remote computer.
However, the characters cannot be passed directly to the operating
system because the remote operating system is not designed to
receive characters from a TELNET server: It is designed to receive
characters from a terminal driver. The solution is to add a piece of
software called a pseudoterminal driver which pretends that the
characters are coming from a terminal. The operating system then
passes the characters to the appropriate application program.
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 computer 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. For an illustration of this
concept, see Figure.
NVT CHARACTER SET

• NVT uses two sets of characters, one for data and one for
control. Both are 8-bit bytes.

• Data Characters
For data, NVT normally uses what is called NVT ASCII.
This is an 8-bit character set in which the seven lowest order
bits are the same as US ASCII and the highest order bit is
0 (see Figure). Although it is possible to send an 8-bit
ASCII (with the highest order bit set to be 0 or 1), this must
first be agreed upon between the client and the server using
option negotiation.
Format of Data Characters
Control Characters
• To send control characters between computers
(from client to server or vice versa), NVT uses an 8-
bit character set in which the highest order bit is set
(see Figure).

Format of Control Characters


Some NVT control characters
EMBEDDING
• TELNET uses only one TCP connection. The server
uses the well-known port 23 and the client uses an
ephemeral port. The same connection is used for
sending both data and control characters. TELNET
accomplishes this by embedding the control characters in
the data stream. However, to distinguish data from
control characters, each sequence of control
characters is preceded by a special control character
called interpret as control (IAC).
• For example, imagine a user wants a server to display a
file (file1) on a remote server.
user can type: cat file1
• However, the name of the file has been mistyped (filea
instead of file1). The user uses the backspace key to
correct this situation.
user will type: cat filea<backspace>1
However, in the default implementation of TELNET, the
user cannot edit locally; the editing is done at the remote
server. The backspace character is translated into two
remote characters (IAC EC), which is embedded in the
data and sent to the remote server. What is sent to the
server is shown in Figure.
OPTIONS
• TELNET lets the client and server negotiate options
before or during the use of the service. Options are
extra features available to a user with a more
sophisticated terminal. Users with simpler terminals
can use default features. Some control characters dis-
cussed previously are used to define options.
• Table shows some common options.
• Binary. This option allows the receiver to interpret
every 8-bit character received. except IAC, as binary
data. When IAC is received, the next character or
characters are interpreted as commands. However, if
two consecutive IAC characters are received, the first is
discarded and the second is interpreted as data.

• Echo. This option allows the server to echo data


received from the client. This means that every
character sent by the client to the sender will be echoed
back to the screen of the client terminal. In this case, the
user terminal usually does not echo characters when
they are typed but waits until it receives them from
the server.
• Suppress go-ahead. This option suppresses the go-ahead (GA)
character.

• Status. This option allows the user or the process running on the
client machine to get the status of the options being enabled at the
server site.

• Timing mark. This option allows one party to issue a timing mark
that indicates all previously received data has been processed.

• Terminal type. This option allows the client to send its terminal
type.

• Terminal speed. This option allows the client to send its terminal
speed.

• Line mode. This option allows the client to switch to the line
mode.
MODE OF OPERATION
• Most TELNET implementations operate in one of
three modes: default mode, character mode, or line
mode.

Default Mode

• The default mode is used if no other modes are


invoked through option negotiation. In this mode, the
echoing is done by the client. The user types a character
and the client echoes the character on the screen (or
printer) but docs not send it until a whole line is
completed. After sending the whole line to the server, the
client waits for the GA (go ahead) command from the
server before accepting a new line from the user. The
operation is half-duplex. Half-duplex operation is not
efficient when the TCP connection itself is full-duplex,
and so this mode is becoming outdated.
Character Mode
• In the character mode, each character typed is sent by
the client to the server. The server normally echoes
the character back to be displayed on the client screen. In
this mode the echoing of the character can be delayed
if the transmission time is long (such as in a satellite
connection). It also creates overhead (traffic) for the
network because three TCP segments must be sent for
each character of data:
– The user enters a character that is sent to the server.
– The server acknowledges the received character and
echos the character back (in one segment).
– The client acknowledges the receipt of the echoed
character.
Line Mode
• A new mode has been proposed to compensate for
the deficiencies of the default mode and the
character mode. In this mode, called the line
mode, line editing (echoing, character erasing,
line erasing, and so on) is done by the client.
The client then sends the whole line to the server.
• Although the line mode looks like the default
mode, it is not. The default mode operates in
the half-duplex mode; the line mode is full-
duplex with the client sending one line after
another, without the need for an intervening GA
(go ahead) character from the server.
FTP

What is FTP?
• One of the most popular uses of the Internet is to
download files - that is, transfer files from a computer
on the Internet to your computer. Many thousands of
files are downloaded every day from the Internet.

• Most of these files are downloaded using the Internet's


File Transfer Protocol, commonly referred to as FTP. This
protocol can also be used to upload files from your
computer to another computer on the Internet.
FTP (File Transfer Protocol)
• File Transfer Protocol is a standard network protocol used to
exchange and manipulate files over a TCP/IP-based
network, such as the Internet.

• FTP is built on client-server architecture and utilizes


separate control and data connections between the client
and server applications. FTP is used with user-based
password authentication or with anonymous user access.

• Applications were originally interactive command-line tools


with standardized command syntax, but graphical user
interfaces have been developed for all desktop operating
systems in use today. The Trivial File Transfer Protocol
(TFTP) is a similar, but simplified, not interoperable, and
unauthenticated version of FTP.
• Numerous FTP servers all over the world allow users
anywhere on the Internet to log in and download files
placed on them.

• The main competitor for FTP is HTTP (Hyper Text


Transfer Protocol) and the day is not very far when sites
would run HTTP servers instead of the FTP servers. It is so
because HTTP servers can do whatever FTP server can
do and do it more efficiently.

• As the Web gains popularity, downloading software is


becoming even easier. You can use your Web browser and
click on links to files; behind the scenes, FTP is often still
downloading the files.
• One problem with downloading files over the Internet
is that some files are so large that it can take a
tremendous amount of time to download them.

• As a way to speed up file transfers and save space on


the FTP server, files are commonly compressed.
Many different methods are used to compress files.

• After the files have been downloaded, you will need


to run the decompression software such as PK
UNZIP to decompress the files to use them. Once
you have the compressed file such as data.zip, you
will need to unzip or decompress it to get to the setup
file and install the program. You can use the WinZip
file to uncompress this file.
Features of FTP
1. Data representation

• FTP handles three types of data representations-ASCII


(7 bit), EBCDIC (8-bit) and 8binary data.

• The ASCII file is the default format for transferring


text files

• Each character is encoded using 7-bit ASCII. The sender


transforms the file from its own representation into
ASCII characters and the receiver transforms the
ASCII character to its own representation.

• The image file is the default format for transferring binary


files. The file is sent as continuous streams of bits
without any interpretation or encoding.
2. File organization and Data structures
• FTP supports both unstructured and structured file.

• An unstructured file contains string of bytes and is


ended by EOF (End of file). The data structure that
corresponds to such a file is called file structure.

• A structured file contains a list of records and each


record is delimited by EDR (End of Record). The data
structure of such file is called record structure i.e. file is
divided into records.

• Another structured file contains pages, with each


page having a page number and a page header. The
pages can be stored and accessed randomly or
sequentially. The corresponding data structure is called
page structure i.e. file is divided into pages.
3. Transmission modes
• FTP can transfer a file by using one of the following three modes:

Stream mode
• It is the default mode.
• File is transmitted as continuous stream of bytes to TCP.
• TCP is responsible for chopping data into segments of appropriate size.

Block mode
• Data is delivered from FTP to TCP in blocks.
• Each block is preceded by 3 bytes header.
• The first byte is called the block descriptor.
• The second and third byte defines the size of the block in bytes.

Compressed mode
• Data is usually compressed if the file to be transmitted is very big.
• The compression method normally used in Run-length encoding.
• In a text file, usually spaces (blanks) are removed.
• In a binary file, null characters are compressed.
4. Error control
• Since TCP is used for data transfer no additional
error recovery mechanism is required.

5. Access control
• File access protection is done using login procedure
with login name and password.
FTP operation
• FTP uses client/server model for communication.
• Two TCP connections are used for file transfer.
• On one connection control signals (commands and
responses) are exchanged and the other connection is used
for actual data transfer. These two connections are called
control connection and data connection respectively.
Control Connection
The Control connection has following features:
1. It is used to transfer control signals (commands and responses)
between the client and server.
2. This connection is used by the control process of client and
server. The control process is called Protocol Interpreter (PI).
3. The TCP connection for control signal uses well-known FTP
server port 21.
4. This control connection remains connected during the entire
interactive FTP session.
5. The control connection uses very simple rules of communication.
We need to transfer only a line of command or a line of response
at a time.
Data Connection
The Data connection has following features:
1. Data connection is used for actual data transfer.
2. This connection is established between the Data Transfer
Process (DTP) of client and server
3. The server port used for data connection is Port 20.
4. The data connection is opened and then closed for each file
transferred. It opens each time commands that involve
transferring files are used, and it closes when the file is transferred
File transfer in FTP means one of three things:

1. A file is to be copied from the server to the client.


This is called retrieving a file. It is done with help of
RETR command.

2. A file is to be copied from the client to the server.


This is called storing a file. It is done with STOR
command.

3. A list of directory or file names is to be sent from the


server to the client. This is done with LIST command.
Anonymous FTP

• To Use FTP, a user needs an account (user name)


and a password on the Remote server.

• Some sites have a set of files available for public


access; to enable anonymous FTP.

• To access these files, a user does not need to have


an account or password. Instead, the user can use
Anonymous as the user name and guest as the
password.
FTP Servers
• Similar to the Web servers, the Internet also has the installations of
FTP servers. Many organizations use FTP servers to handle the
distribution of files. When a user links to download something, the
link actually redirects to FTP, instead of HTTP. Some files in the
FTP servers may be accessible to the general public, while
others are accessible only by the user. To separate the general
public from the more private users, FTP servers are divided into
two parts: Anonymous server Non-anonymous server

1. Anonymous Server: Anonymous server is the most common use


of FTP, the Internet file transfer protocol. FTP sites that allow
anonymous FTP do not require a password for access. You only
have to log in as anonymous and enter your e-mail address as
password (for their records).

2. Non-anonymous Server: If you use a non-anonymous server,


then you will log in as yourself and give your password.

You might also like