Sei sulla pagina 1di 190

ISO-OSI 7-Layer Network Architecture

This lecture introduces the ISO-OSI layered architecture of Networks. According to the
ISO standards, networks have been divided into 7 layers deending on the co!le"ity of
the fucntionality each of these layers rovide. The detailed descrition of each of these
layers is given in the notes below. #e will first list the layers as defined by the standard
in the increasing order of function co!le"ity$
%. &hysical 'ayer
(. )ata 'ink 'ayer
*. Network 'ayer
+. Transort 'ayer
,. Session 'ayer
-. &resentation 'ayer
7. Alication 'ayer
Physical Layer
This layer is the lowest layer in the OSI !odel. It hels in the trans!ission of data
between two !achines that are co!!unicating through a hysical !ediu!, which can be
otical fibres,coer wire or wireless etc. The following are the !ain functions of the
hysical layer$
%. Hardware Specification: The details of the hysical cables, network interface
cards, wireless radios, etc are a art of this layer.
Coaxial Cable Hybrid Cable irele!! Card Network Card
(. "ncodin# and Si#nallin#: .ow are the bits encoded in the !ediu! is also
decided by this layer. /or e"a!le, on the coar wire !ediu!, we can use
differnet voltage levels for a certain ti!e interval to reresent 010 and 0%0. #e !ay
use 2,!3 for %nsec to reresent 0%0 and -,!3 for %nsec to reresent 010. All the
issues of !odulation is dealt with in this layer. eg, we !ay use 4inary hase shift
keying for the reresentation of 0%0 and 010 rather than using different volatage
levels if we have to transfer in 5/ waves.
$inary %ha!e Shift &eyin#
*. 'ata (ran!)i!!ion and *eception: The transfer of each bit of data is the
resonsibility of this layer. This layer assures the trans!issoin of each bit with a
high probability. The trans!ission of the bits is not co!letely reliable as their is
no error correction in this layer.
+. (opolo#y and Network 'e!i#n: The network design is the integral art of the
hysical layer. #hich art of the network is the router going to be laced, where
the switches will be used, where we will ut the hubs, how !any !achines is
each switch going to handle, what server is going to be laced where, and !any
such concerns are to be taken care of by the hysical layer. The variosu kinds of
netoologies that we decide to use !ay be ring, bus, star or a hybrid of these
toologies deending on our re6uire!ents.
Data Link Layer
This layer rovides reliable trans!ission of a acket by using the services of the hysical
layer which trans!its bits over the !ediu! in an unreliable fashion. This layer is
concerned with $
%. /ra!ing $ 4reaking inut data into fra!es 7tyically a few hundred bytes8 and
caring about the fra!e boundaries and the si9e of each fra!e.
(. Acknowledg!ent $ Sent by the receiving end to infor! the source that the fra!e
was received without any error.
*. Se6uence Nu!bering $ To acknowledge which fra!e was received.
+. :rror )etection $ The fra!es !ay be da!aged, lost or dulicated leading to
errors.The error control is on link to link basis.
,. 5etrans!ission $ The acket is retrans!itted if the source fails to receive
acknowledg!ent.
-. /low ;ontrol $ Necessary for a fast trans!itter to kee ace with a slow receiver.
'ata Link Layer
Network Layer
Its basic functions are routing and congestion control.
*outin#: This deals with deter!ining how ackets will be routed 7transferred8 fro!
source to destination. It can be of three tyes $
Static $ 5outes are based on static tables that are <wired into< the network and are
rarely changed.
)yna!ic $ All ackets of one alication can follow different routes deending
uon the toology of the network, the shortest ath and the current network load.
Se!i-)yna!ic $ A route is chosen at the start of each conversation and then all
the ackets of the alication follow the sa!e route.
*outin#
The services rovided by the network can be of two tyes $
Connection le!! !er+ice: :ach acket of an alication is treated as an
indeendent entity. On each acket of the alication the destination address is
rovided and the acket is routed.
Connection oriented !er+ice: .ere, first a connection is established and then all
ackets of the alication follow the sa!e route. To understand the above
concet, we can also draw an analogy fro! the real life. ;onnection oriented
service is !odeled after the telehone syste!. All voice ackets go on the sa!e
ath after the connection is established till the connection is hung u. It acts like a
tube = the sender ushes the ob>ects in at one end and the receiver takes the! out
in the sa!e order at the other end. ;onnection less service is !odeled after the
ostal syste!. :ach letter carries the destination address and is routed
indeendent of all the others. .ere, it is ossible that the letter sent first is delayed
so that the second letter reaches the destination before the first letter.
Con#e!tion Control: A router can be connected to +-, networks. If all the networks send
acket at the sa!e ti!e with !a"i!u! rate ossible then the router !ay not be able to
handle all the ackets and !ay dro so!e?all ackets. In this conte"t the droing of the
ackets should be !ini!i9ed and the source whose acket was droed should be
infor!ed. The control of such congestion is also a function of the network layer. Other
issues related with this layer are trans!itting ti!e, delays, >ittering.
Internetworkin#: Internetworks are !ultile networks that are connected in such a way
that they act as one large network, connecting !ultile office or deart!ent networks.
Internetworks are connected by networking hardware such as routers, switches, and
bridges.Internetworking is a solution born of three networking roble!s$ isolated 'ANs,
dulication of resources, and the lack of a centrali9ed network !anage!ent syste!. #ith
connected 'ANs, co!anies no longer have to dulicate rogra!s or resources on each
network. This in turn gives way to !anaging the network fro! one central location
instead of trying to !anage each searate 'AN. #e should be able to trans!it any acket
fro! one network to any other network even if they follow different rotocols or use
different addressing !odes.
Inter-Networkin#
Network 'ayer doe! not guarantee that the acket will reach its intended destination.
There are no reliability guarantees.
Transport Layer
Its functions are $
,ultiplexin# - 'e)ultiplexin# : Nor!ally the transort layer will create distinct
network connection for each transort connection re6uired by the session layer.
The transort layer !ay either create !ultile network connections 7to i!rove
throughut8 or it !ay !ultile" several transort connections onto the sa!e
network connection 7because creating and !aintaining networks !ay be
e"ensive8. In the latter case, de!ultile"ing will be re6uired at the receiving end.
A oint to note here is that co!!unication is always carried out between two
rocesses and not between two !achines. This is also known as rocess-to-
rocess co!!unication.
.ra#)entation and *e-a!!e)bly : The data acceted by the transort layer fro!
the session layer is slit u into s!aller units 7frag!entation8 if needed and then
assed to the network layer. ;orresondingly, the data rovided by the network
layer to the transort layer on the receiving side is re-asse!bled.
.ra#)entation *ea!!e)bly
(ype! of !er+ice : The transort layer also decides the tye of service that should
be rovided to the session layer. The service !ay be erfectly reliable, or !ay be
reliable within certain tolerances or !ay not be reliable at all. The !essage !ay
or !ay not be received in the order in which it was sent. The decision regarding
the tye of service to be rovided is taken at the ti!e when the connection is
established.
"rror Control : If reliable service is rovided then error detection and error
recovery oerations are also erfor!ed. It rovides error control !echanis! on
end to end basis.
.low Control : A fast host cannot kee ace with a slow one. .ence, this is a
!echanis! to regulate the flow of infor!ation.
Connection "!tabli!h)ent - *elea!e : The transort layer also establishes and
releases the connection across the network. This re6uires so!e sort of na!ing
!echanis! so that a rocess on one !achine can indicate with who! it wants to
co!!unicate.
ession Layer
It deals with the concet of Se!!ion! i.e. when a user logins to a re!ote server he should
be authenticated before getting access to the files and alication rogra!s. Another >ob
of session layer is to establish and !aintain sessions. If during the transfer of data
between two !achines the session breaks down, it is the session layer which re-
establishes the connection. It also ensures that the data transfer starts fro! where it
breaks keeing it transarent to the end user. e.g. In case of a session with a database
server, this layer introduces check point! at various laces so that in case the connectoin
is broken and reestablished, the transition running on the database is not lost even if the
user has not co!!itted. This activity is called Synchroni/ation. Another function of this
layer is 'ialo#ue Control which deter!ines whose turn is it to seak in a session. It is
useful in video conferencing.
Presentation Layer
This layer is concerned with the synta" and se!antics of the infor!ation trans!itted. In
order to !ake it ossible for co!uters with different data reresentations to
co!!unicate data structures to be e"changed can be defined in abstract way alongwith
standard encoding. It also !anages these abstract data structres and allows higher level of
data structres to be defined an e"change. It encodes the data in standard agreed
way7network for!at8. Suose there are two !achines A and 4 one follows 04ig :ndian0
and other 0'ittle :ndian0 for data reresentation. This layer ensures that the data
trans!itted by one gets converted in the for! co!atibale to othe !achine. This layer is
concerned with the synta" and se!antics of the infor!ation trans!itted.In order to !ake
it ossible for co!uters with different data reresentations to co!!unicate data
structures to be e"changed canbe defined in abstract way alongwith standard encoding. It
also !anages these abstract data structres and allows higher level of data structres to be
defined an e"change. Other functions include co!ression, encrytion etc.
Application Layer
The seventh layer contains the alication rotocols with which the user gains access to
the network. The choice of which secific rotocols and their associated functions are to
be used at the alication level is u to the individual user. Thus the boundary between
the resentation layer and the alication layer reresents a searation of the rotocols
i!osed by the network designers fro! those being selected and i!le!ented by the
network users./or e"a!le co!!only used rotocols are .TT&7for web browsing8,
/T&7for file transfer8 etc.
Network Layers as in Practice
In !ost of the networks today, we do not follow the OSI !odel of seven layers. #hat is
actually i!le!ented is as follows. The functionality of Alication layer and
&resentation layer is !erged into one and is called as the Alication 'ayer.
/unctionalities of Session 'ayer is not i!le!ented in !ost networks today. Also, the
)ata 'ink layer is slit theoretically into ,AC 0,ediu) Acce!! Control1 Layer and
LLC 0Link Layer Control1. 4ut again in ractice, the ''; layer is not i!le!ented by
!ost networks. So as of today, the network architecture is of , layers only.
Network Layer! in Internet (oday
Some Related Links on OSI Model and TCP Model
htt$??en.wikiedia.org?wiki?OSI@!odel
htt$??www.tciguide.co!?free?t@OSI5eferenceAodel'ayers.ht!
htt$??www.geocities.co!?Silicon3alley?Aonitor?*%*%?ne?osi!odel.ht!l
htt$??www.tech-fa6.co!?osi-!odel.sht!l
htt$??www.networkdictionary.co!?rotocols?osi!odel.h
%hy!ical Layer
&hysical layer is concerned with trans!itting raw bits over a co!!unication channel.
The design issues have to do with !aking sure that when one side sends a % bit, it is
recieved by the other side as % bit and not as 1 bit. In hysical layer we deal with the
co!!unication !ediu! used for trans!ission.
Types of Medim
Aediu! can be classified into ( categories.
%. 2uided ,edia : Buided !edia !eans that signals is guided by the rescence of
hysical !edia i.e. signals are under control and re!ains in the hysical wire. /or
eg. coer wire.
(. 3n#uided ,edia : Cnguided Aedia !eans that there is no hysical ath for the
signal to roogate. Cnguided !edia are essentially electro-!agnetic waves.
There is no control on flow of signal. /or eg. radio waves.
Commnication Links
In a nework nodes are connected through links. The co!!unication through links can be
classified as
%. Si)plex : ;o!!unication can take lace only in one direction. eg. T.3
broadcasting.
(. Half-duplex : ;o!!unication can take lace in one direction at a ti!e. Suose
node A and 4 are connected then half-dule" co!!unication !eans that at a ti!e
data can flow fro! A to 4 or fro! 4 to A but not si!ultaneously. eg. two ersons
talking to each other such that when seaks the other listens and vice versa.
*. .ull-duplex : ;o!!unication can take lace si!ultaneously in both directions.
eg. A discussion in a grou without disciline.
'inks can be further classified as
%. %oint to %oint : In this co!!unication only two nodes are connected to each
other. #hen a node sends a acket then it can be recieved only by the node on the
other side and none else.
(. ,ultipoint $ It is a kind of sharing co!!unication, in which signal can be
recieved by all nodes. This is also called broadcast.
Benerally two kind of roble!s are associated in trans!ission of signals.
%. Attenuation : #hen a signal trans!itts in a network then the 6uality of signal
degrades as the signal travels longer distances in the wire. This is called
attenuation. To i!rove 6uality of signal a!lifiers are used at regular distances.
(. Noi!e : In a co!!unication channel !any signals trans!its si!ultaneously,
certain rando! signals are also resent in the !ediu!. )ue to interference of
these signals our signal gets disruted a bit.
!andwidth
4andwidth si!ly !eans how !any bits can be trans!itted er second in the
co!!unication channel. In technical ter!s it indicates the width of fre6uency sectru!.
Transmission Media
2uided (ran!)i!!ion ,edia
In Buided trans!ission !edia generally two kind of !aterials are used.
%. ;oer
o ;oa"ial ;able
o Twisted &air
(. Otical /iber
%. Coaxial Cable: ;oa"ial cable consists of an inner conductor and an outer
conductor which are seerated by an insulator. The inner conductor is usually
coer. The outer conductor is covered by a lastic >acket. It is na!ed coa"ial
because the two conductors are coa"ial. Tyical dia!eter of coa"ial cable lies
between 1.+ inch to % inch. The !ost alication of coa"ial cable is cable T.3. The
coa"ial cable has high bandwidth, attenuation is less.
(. (wi!ted %air: A Twisted air consists of two insulated coer wires, tyically
%!! thick. The wires are twisted togather in a helical for! the urose of
twisting is to reduce cross talk interference between several airs. Twisted &air is
!uch cheaer then coa"ial cable but it is suscetible to noise and electro!agnetic
interference and attenuation is large.
Twisted &air can be further classified in two categories$
3n!hielded twi!ted pair: In this no insulation is rovided, hence they are
suscetible to interference.
Shielded twi!ted pair: In this a rotective thick insulation is rovided but
shielded twisted air is e"ensive and not co!!only used.
The !ost co!!on alication of twisted air is the telehone syste!. Nearly all
telehones are connected to the telehone co!any office by a twisted air.
Twisted air can run several kilo!eters without a!lification, but for longer
distances reeaters are needed. Twisted airs can be used for both analog and
digital trans!ission. The bandwidth deends on the thickness of wire and the
distance travelled. Twisted airs are generally li!ited in distance, bandwidth and
data rate.
*. Optical .iber: In otical fiber light is used to send data. In general ter!s
rescence of light is taken as bit % and its absence as bit 1. Otical fiber consists
of inner core of either glass or lastic. ;ore is surrounded by cladding of the sa!e
!aterial but of different refrective inde". This cladding is surrounded by a lastic
>acket which revents otical fiber fro! electro!agnetic interferrence and harshy
environ!ents. It uses the rincile of total internal reflection to transfer data over
otical fibers. Otical fiber is !uch better in bandwidth as co!ared to coer
wire, since there is hardly any attenuation or electro!agnetic interference in
otical wires. .ence there is less re6uire!ent to i!rove 6uality of signal, in long
distance trans!ission. )isadvantage of otical fiber is that end oints are fairly
e"ensive. 7eg. switches8
)ifferences between different kinds of otical fibers$
%. )eending on !aterial
Aade of glass
Aade of lastic.
(. )eending on radius
Thin otical fiber
Thick otical fiber
*. )eending on light source
':) 7for low bandwidth8
In>ection lased diode 7for high bandwidth8
"ireless Transmission
%. *adio: 5adio is a general ter! that is used for any kind of fre6uency. 4ut higher
fre6uencies are usually ter!ed as !icrowave and the lower fre6uency band co!es
under radio fre6uency. There are !any alication of radio. /or eg. cordless
keyboard, wireless 'AN, wireless ethernet. but it is li!ited in range to only a few
hundred !eters. )eending on fre6uency radio offers different bandwidths.
(. (erre!trial )icrowa+e: In terrestrial !icrowave two antennas are used for
co!!unication. A focused bea! e!erges fro! an antenna and is recieved by the
other antenna, rovided that antennas should be facing each other with no
obstacle in between. /or this reason antennas are situated on high towers. )ue to
curvature of earth terristial !icrowave can be used for long distance
co!!unication with high bandwidth. Teleco! deart!ent is also using this for
long distance co!!unication. An advantage of wireless co!!unication is that it
is not re6uired to lay down wires in the city hence no er!issions are re6uired.
*. Satellite co))unication: Satellite acts as a switch in sky. On earth 3SAT73ery
S!all Aerture Ter!inal8 are used to trans!it and recieve data fro! satellite.
Benerally one station on earth trans!itts signal to satellite and it is recieved by
!any stations on earth. Satellite co!!unication is generally used in those laces
where it is very difficult to obtain line of sight i.e. in highly irregular terristial
regions. In ter!s of noise wireless !edia is not as good as the wired !edia. There
are fre6uency band in wireless co!!unication and two stations should not be
allowed to trans!it si!ultaneously in a fre6uency band. The !ost ro!ising
advantage of satellite is broadcasting. If satellites are used for oint to oint
co!!unication then they are e"ensive as co!ared to wired !edia.
'ata "ncodin#
Di#ital data to analo# si#nals
A !ode! 7!odulator-de!odulator8 converts digital data to analog signal. There are *
ways to !odulate a digital signal on an analog carrier signal.
%. A)plitude !hift keyin# 0AS&1: is a for! of !odulation which reresents digital
data as variations in the a!litude of a carrier wave. Two different a!litudes of
carrier fre6uency reresent 010 , 0%0.
(. .re4uency !hift keyin# 0.S&1: In /re6uency Shift Deying, the change in
fre6uency define different digits. Two different fre6uencies near carrier fre6uency
reresent 010 ,00%0.
*. %ha!e !hift keyin# 0%S&1: The hase of the carrier is discretely varied in relation
either to a reference hase or to the hase of the i!!ediately receding signal
ele!ent, in accordance with data being trans!itted. &hase of carrier signal is
shifted to reresent 010 , 0%0.
Di#ital data to di#ital si#nals
A digital signal is se6uence of discrete , discontinuous voltage ulses. :ach ulses a
signal ele!ent. :ncoding sche!e is an i!ortant factor in how successfully the receiver
interrets the inco!ing signal.
$ncodin# Techni%es
/ollowing are several ways to !a data bits to signal ele!ents.
Non return to /ero0N*51 N5E codes share the roerty that voltage level is
constant during a bit interval. .igh level voltage F bit % and 'ow level voltage F
bit 1. A roble! arises when there is a long se6uence of 1s or %s and the volatage
level is !aintained at the sa!e value for a long ti!e. This creates a roble! on
the recieving end because now, the clock synchroni9ation is lost due to lack of
any transitions and hence, it is difficult to deter!ine the e"act nu!ber of 1s or %s
in this se6uence.
The two variations are as follows$
%. N*5-Le+el: In N5E-' encoding, the olarity of the signal changes only
when the inco!ing signal changes fro! a % to a 1 or fro! a 1 to a %. N5E-
' !ethod looks >ust like the N5E !ethod, e"cet for the first inut one
data bit. This is because N5E does not consider the first data bit to be a
olarity change, where N5E-' does.
(. N*5-In+erted: Transition at the beginning of bit interval F bit % and No
Transition at beginning of bit interval F bit 1 or vicecersa. This techni6ue
is known as differential encoding.
N5E-I has an advantage over N5E-'. ;onsider the situation when two data wires
are wrongly connected in each other0s lace.In N5E-' all bit se6uences will get
reversed 740co9 voltage levels get swaed8.#hereas in NAE-I since bits are
recogni9ed by transition the bits will be correctly interreted. A disadvantage in
N5E codes is that a string of 10s or %0s will revent synchroni9ation of trans!itter
clock with receiver clock and a searate clock line need to be rovided.
$ipha!e encodin#: It has following characteristics$
%. Aodulation rate twice that of N5E and bandwidth corresondingly
greater. 7Aodulation is the rate at which signal level is changed8.
(. 4ecause there is redictable transition during each bit ti!e,the receiver
can synchroni9e on that transition i.e. clock is e"tracted fro! the signal
itself.
*. Since there can be transition at the beginning as well as in the !iddle of
the bit interval the clock oerates at twice the data transfer rate.
Tyes of :ncoding --G
o $ipha!e-)anche!ter: Transition fro! high to low in !iddle of interval F
% and Transition fro! low to high in !iddle of interval F 1
o 'ifferential-)anche!ter: Always a transition in !iddle of interval. No
transition at beginning of intervalF% and Transition at beginning of
interval F 1
o 6$-7$ "ncodin#: In Aanchester encoding sche!e , there is a transition
after every bit. It !eans that we !ust have clocks with double the seed to
send sa!e a!ount of data as in N5E encodings. In other words, we !ay
say that only ,1H of the data is sent. This erfor!ance factor can be
significantly i!roved if we use a better encoding sche!e. This sche!e
!ay have a transition after fi"ed nu!ber of bits instead of every other bit.
'ike if we have a transition after every four bits, then we will be sending
I1H data of actual caacity. This is a significant i!rove!ent in the
erfor!ance.
This sche!e is known as 6$-7$. So here we convert +-bits to ,-bits,
ensuring at least one transition in the!. The basic idea here is that ,-bit
code selected !ust have $
one leading 1
no !ore than two trailing 1s
Thus it is ensured that we can never have !ore than three consecutive 1s.
Now these ,-bit codes are trans!itted using N5EI coding thus roble! of
consecutive %s is solved.
The e"act transfor!ation is as follows $
6-bit 'ata 7-bit code 6-bit 'ata 7-bit code
1111 %%%%1 %111 %11%1
111% 1%11% %11% %11%%
11%1 %1%11 %1%1 %1%%1
11%% %1%1% %1%% %1%%%
1%11 1%1%1 %%11 %%1%1
1%1% 1%1%% %%1% %%1%%
1%%1 1%%%1 %%%1 %%%11
1%%% 1%%%% %%%% %%%1%
Of the re!aining %- codes, 7 are invalid and others are used to send so!e
control infor!ation like line idle7%%%%%8, line dead7111118, .alt711%118
etc.
There are other variants for this sche!e vi9. ,4?-4, I4?%14 etc. These
have self suggesting na!es.
o 8$-9( "ncodin#: In the above sche!es, we have used two?three voltage
levels for a signal. 4ut we !ay altogether use !ore than three voltage
levels so that !ore than one-bit could be send over a single signal. 'ike if
we use si" voltage levels and we use I-bits then the sche!e is called
8$-9(. ;learly here we have 7(J7*K-8 co!binations for signal and
(,-7(KI8 co!binations for bits.
$ipolar AI,: .ere we have * voltage levels$ !iddle,uer,lower
o 5eresentation %$ Aiddle level F1 Cer,'ower level F% such that
successive %0s will be reresented alternately on uer and lower levels.
o 5eresentation ( 7seudoternary8$ Aiddle level F% Cer,'ower levelF1
Analo# data to di#ital si#nal&
The rocess is called digiti9ation. Sa!ling fre6uency !ust be at least twice that of
highest fre6uency resent in the the signal so that it !ay be fairly regenerated.
Luanti9ation - Aa". and Ain values of a!litude in the sa!le are noted. )eending on
nu!ber of bits 7say n8 we use we divide the interval 7!in,!a"8 into (7Kn8 nu!ber of
levels. The a!litude is then aro"i!ated to the nearest level by a 0n0 bit integer. The
digital signal thus consists of blocks of n bits.On recetion the rocess is reversed to
roduce analog signal. 4ut a lot of data can be lost if fewer bits are used or sa!ling
fre6uency not so high.
%ul!e code )odulation0%C,1: .ere intervals are e6ually saced. I bit &;4 uses
(,- different levels of a!litude. In non-linear encoding levels !ay be une6ually
saced.
'elta ,odulation0',1: Since successive sa!les do not differ very !uch we
send the differences between revious and resent sa!le. It re6uires fewer bits
than in &;A.
Di#ital Data Commnication Techni%es&
/or two devices linked by a trans!ission !ediu! to e"change data ,a high degree of co-
oeration is re6uired. Tyically data is trans!itted one bit at a ti!e. The ti!ing 7rate,
duration,sacing8 of these bits !ust be sa!e for trans!itter and receiver. There are two
otions for trans!ission of bits.
%. %arallel All bits of a byte are transferred si!ultaneously on searate arallel
wires. Synchroni9ation between !ultile bits is re6uired which beco!es difficult
over large distance. Bives large band width but e"ensive. &ractical only for
devices close to each other.
(. Serial 4its transferred serially one after other.Bives less bandwidth but cheaer.
Suitable for trans!ission over long distances.
(ran!)i!!ion (echni4ue!:
%. A!ynchronou!: S!all blocks of bits7generally bytes8 are sent at a ti!e without
any ti!e relation between consecutive bytes .when no trans!ission occurs a
default state is !aintained corresonding to bit %. )ue to arbitrary delay between
consecutive bytes,the ti!e occurrences of the clock ulses at the receiving end
need to be synchroni9ed for each byte. This is achieved by roviding ( e"tra bits
start and sto.
Start bit: It is refi"ed to each byte and e6uals 1. Thus it ensures a transition
fro! % to 1 at onset of trans!ission of byte.The leading edge of start bit is used as
a reference for generating clock ulses at re6uired sa!ling instants. Thus each
onset of a byte results in resynchroni9ation of receiver clock.
Stop bit: To ensure that transition fro! % to 1 is always resent at beginning of a
byte it is necessary that default state be %. 4ut there !ay be two bytes one
i!!ediately following the other and if last bit of first byte is 1, transition fro! %
to 1 will not occur . Therefore a sto bit is suffi"ed to each byte e6ualing %. It0s
duration is usually %,%.,,( bits.
Asynchronous trans!ission is si!le and chea but re6uires an overhead of * bits
i.e. for 7 bit code ( 7start ,sto bits82% arity bit i!lying *1H overhead..owever
H can be reduced by sending larger blocks of data but then ti!ing errors between
receiver and sender can not be tolerated beyond M,1?no. of bits in blockN H
7assu!ing sa!ling is done at !iddle of bit interval8. It will not only result in
incorrect sa!ling but also !isaligned bit count i.e. a data bit can be !istaken for
sto bit if receiver0s clock is faster.
(. Synchronou! - 'arger blocks of bits are successfully trans!itted.4locks of data
are either treated as se6uence of bits or bytes. To revent ti!ing drift clocks at
two ends need to be synchroni9ed.This can done in two ways$
%. &rovide a searate clock line between receiver and trans!itter. O5
(. ;locking infor!ation is e!bedded in data signal i.e. bihase coding for
digital signals.
Still another level of synchroni9ation is re6uired so that receiver deter!ines
beginning or end of block of data. .ence each block begins with a start code and
ends with a sto code.These are in general sa!e known as flag that is uni6ue
se6uence of fi"ed no. of bits.In addition so!e control characters enco!ass data
within these flags. 'ata:control infor)ation is called a fra!e. Since any
arbitrary bit attern can be trans!itted there is no assurance that bit attern for
flag will not aear inside the fra!e thus destroying fra!e level synchroni9ation.
So to avoid this we use bit stuffing
$it Stuffin#: Suose our flag bits are 1%%%%%%1 7si" %0s8. So the trans!itter will
always insert an e"tra 1 bit after each occurrence of five %0s 7e"cet for flags8.
After detecting a starting flag the receiver !onitors the bit strea! . If attern of
five %0s aear, the si"th is e"a!ined and if it is 1 it isdeleted else if it is % and
ne"t is 1 the co!bination is acceted as a flag. Si!ilarly byte stuffing is used for
byte oriented trans!ission..ere we use an escae se6uence to refi" a byte
si!ilar to flag and ( escae se6uences if byte is itself a escae se6uence.
Mltiple'in#
#hen two co!!unicating nodes are connected through a !edia, it generally haens
that bandwidth of !edia is several ti!es greater than that of the co!!unicating nodes.
Transfer of a single signal at a ti!e is both slow and e"ensive. The whole caacity of the
link is not being utili9ed in this case. This link can be further e"loited by sending several
signals co!bined into one. This co!bining of signals into one is called !ultile"ing.
%. .re4uency 'i+i!ion ,ultiplexin# 0.',1: This is ossible in the case where
trans!ission !edia has a bandwidth than the re6uired bandwidth of signals to be
trans!itted. A nu!ber of signals can be trans!itted at the sa!e ti!e. :ach source
is allotted a fre6uency range in which it can transfer it0s signals, and a suitable
fre6uency ga is given between two ad>escent signals to avoid overlaing. This
is tye of !ultile"ing is co!!only seen in the cable T3 networks.
(. (i)e 'i+i!ion ,ultiplexin# 0(',1: This is ossible when data trans!ission
rate of the !edia is !uch higher than that of the data rate of the source. Aultile
signals can be trans!itted if each signal is allowed to be trans!itted for a definite
a!ount of ti!e. These ti!e slots are so s!all that all trans!issions aear to be in
arallel.
%. Synchronou! (',: Ti!e slots are reassigned and are fi"ed. :ach
source is given it0s ti!e slot at every turn due to it. This turn !ay be once
er cycle, or several turns er cycle ,if it has a high data transfer rate, or
!ay be once in a no. of cycles if it is slow. This slot is given even if the
source is not ready with data. So this slot is trans!itted e!ty.
(. A!ynchronou! (',: In this !ethod, slots are not fi"ed. They are allotted
dyna!ically deending on seed of sources, and whether they are ready
for trans!ission.
Network Topolo#ies
A network toology is the basic design of a co!uter network. It is very !uch like a !a
of a road. It details how key network co!onents such as nodes and links are
interconnected. A network0s toology is co!arable to the bluerints of a new ho!e in
which co!onents such as the electrical syste!, heating and air conditioning syste!, and
lu!bing are integrated into the overall design. Taken fro! the Breek work <Toos<
!eaning <&lace,< Toology, in relation to networking, describes the configuration of the
network= including the location of the workstations and wiring connections. 4asically it
rovides a definition of the co!onents of a 'ocal Area Network 7'AN8. A toology,
which is a attern of interconnections a!ong nodes, influences a network0s cost and
erfor!ance. There are three ri!ary tyes of network toologies which refer to the
hysical and logical layout of the Network cabling. They are$
%. Star (opolo#y: All devices connected with a Star setu co!!unicate through a
central .ub by cable seg!ents. Signals are trans!itted and received through the
.ub. It is the si!lest and the oldest and all the telehone switches are based on
this. In a star toology, each network device has a ho!e run of cabling back to a
network hub, giving each device a searate connection to the network. So, there
can be !ultile connections in arallel.
Ad+anta#e!
o Network ad!inistration and error detection is easier because roble! is
isolated to central node
o Networks runs even if one host fails
o :"ansion beco!es easier and scalability of the network increases
o Aore suited for larger networks
'i!ad+anta#e!
o 4roadcasting and !ulticasting is not easy because so!e e"tra
functionality needs to be rovided to the central hub
o If the central node fails, the whole network goes down= thus !aking the
switch so!e kind of a bottleneck
o Installation costs are high because each node needs to be connected to the
central switch
(. $u! (opolo#y: The si!lest and one of the !ost co!!on of all toologies, 4us
consists of a single cable, called a 4ackbone, that connects all workstations on the
network using a single line. All trans!issions !ust ass through each of the
connected devices to co!lete the desired re6uest. :ach workstation has its own
individual signal that identifies it and allows for the re6uested data to be returned
to the correct originator. In the 4us Network, !essages are sent in both directions
fro! a single oint and are read by the node 7co!uter or eriheral on the
network8 identified by the code with the !essage. Aost 'ocal Area Networks
7'ANs8 are 4us Networks because the network will continue to function even if
one co!uter is down. This toology works e6ually well for either eer to eer or
client server.
The urose of the ter!inators at either end of the network is to sto the signal
being reflected back.
Ad+anta#e!
o 4roadcasting and !ulticasting is !uch si!ler
o Network is redundant in the sense that failure of one node doesn0t effect
the network. The other art !ay still function roerly
o 'east e"ensive since less a!ount of cabling is re6uired and no network
switches are re6uired
o Bood for s!aller networks not re6uiring higher seeds
'i!ad+anta#e!
o Trouble shooting and error detection beco!es a roble! because,
logically, all nodes are e6ual
o 'ess secure because sniffing is easier
o 'i!ited in si9e and seed
*. *in# (opolo#y: All the nodes in a 5ing Network are connected in a closed circle
of cable. Aessages that are trans!itted travel around the ring until they reach the
co!uter that they are addressed to, the signal being refreshed by each node. In a
ring toology, the network signal is assed through each network card of each
device and assed on to the ne"t device. :ach device rocesses and retrans!its
the signal, so it is caable of suorting !any devices in a so!ewhat slow but
very orderly fashion. There is a very nice feature that everybody gets a chance to
send a acket and it is guaranteed that every node gets to send a acket in a finite
a!ount of ti!e.
Ad+anta#e!
o 4roadcasting and !ulticasting is si!le since you >ust need to send out
one !essage
o 'ess e"ensive since less cable footage is re6uired
o It is guaranteed that each host will be able to trans!it within a finite ti!e
interval
o 3ery orderly network where every device has access to the token and the
oortunity to trans!it
o &erfor!s better than a star network under heavy network load
'i!ad+anta#e!
o /ailure of one node brings the whole network down
o :rror detection and network ad!inistration beco!es difficult
o Aoves, adds and changes of devices can effect the network
o It is slower than star toology under nor!al load
Benerally, a 4CS architecture is referred over the other toologies - ofcourse, this is a
very sub>ective oinion and the final design deends on the re6uire!ents of the network
!ore than anything else. 'ately, !ost networks are shifting towards the STA5 toology.
Ideally we would like to design networks, which hysically rese!ble the STA5 toology,
but behave like 4CS or 5INB toology.
'ata Link Layer
)ata link layer can be characteri9ed by two tyes of layers$
%. Aediu! Access 'ayer 7AA'8
(. 'ogical 'ink 'ayer
Aloha Protocols
Hi!tory
The Aloha rotocol was designed as art of a ro>ect at the Cniversity of .awaii. It
rovided data trans!ission between co!uters on several of the .awaiian Islands using
radio trans!issions.
;o!!unications was tyically between re!ote stations and a central sited na!ed
Aenehune or vice versa.
All !essage to the Aenehune were sent using the sa!e fre6uency.
#hen it received a !essage intact, the Aenehune would broadcast an ack on a
distinct outgoing fre6uency.
The outgoing fre6uency was also used for !essages fro! the central site to
re!ote co!uters.
All stations listened for !essage on this second fre6uency.
%ure Aloha
&ure Aloha is an unslotted, fully-decentrali9ed rotocol. It is e"tre!ely si!le and trivial
to i!le!ent. The ground rule is - <when you want to talk, >ust talkO<. So, a node which
wants to trans!its, will go ahead and send the acket on its broadcast channel, with no
consideration whatsoever as to anybody else is trans!itting or not.
One serious drawback here is that, you dont know whether what you are sending has been
received roerly or not 7so as to say, <whether you0ve been heard and understoodP<8. To
resolve this, in &ure Aloha, when one node finishes seaking, it e"ects an
acknowledge!ent in a finite a!ount of ti!e - otherwise it si!ly retrans!its the data.
This sche!e works well in s!all networks where the load is not high. 4ut in large, load
intensive networks where !any nodes !ay want to trans!it at the sa!e ti!e, this sche!e
fails !iserably. This led to the develo!ent of Slotted Aloha.
Slotted Aloha
This is 6uite si!ilar to &ure Aloha, differing only in the way trans!issions take lace.
Instead of trans!itting right at de!and ti!e, the sender waits for so!e ti!e. This delay is
secified as follows - the ti!eline is divided into e6ual slots and then it is re6uired that
trans!ission should take lace only at slot boundaries. To be !ore recise, the slotted-
Aloha !akes the following assu!tions$
All fra!es consist of e"actly ' bits.
Ti!e is divided into slots of si9e '?5 seconds 7i.e., a slot e6uals the ti!e to
trans!it one fra!e8.
Nodes start to trans!it fra!es only at the beginnings of slots.
The nodes are synchroni9ed so that each node knows when the slots begin.
If two or !ore fra!es collide in a slot, then all the nodes detect the collision event
before the slot ends.
In this way, the nu!ber of collisions that can ossibly take lace is reduced by a huge
!argin. And hence, the erfor!ance beco!e !uch better co!ared to &ure Aloha.
collisions !ay only take lace with nodes that are ready to seak at the sa!e ti!e. 4ut
nevertheless, this is a substantial reduction.
Carrier Sense Mtiple Access Protocols
In both slotted and ure A'O.A, a node0s decision to trans!it is !ade indeendently of
the activity of the other nodes attached to the broadcast channel. In articular, a node
neither ays attention to whether another node haens to be trans!itting when it begins
to trans!it, nor stos trans!itting if another node begins to interfere with its
trans!ission. As hu!ans, we have hu!an rotocols that allow allows us to not only
behave with !ore civility, but also to decrease the a!ount of ti!e sent <colliding< with
each other in conversation and conse6uently increasing the a!ount of data we e"change
in our conversations. Secifically, there are two i!ortant rules for olite hu!an
conversation$
%. Li!ten before !peakin#: If so!eone else is seaking, wait until they are done. In
the networking world, this is ter!ed carrier sensing - a node listens to the channel
before trans!itting. If a fra!e fro! another node is currently being trans!itted
into the channel, a node then waits 7<backs off<8 a rando! a!ount of ti!e and
then again senses the channel. If the channel is sensed to be idle, the node then
begins fra!e trans!ission. Otherwise, the node waits another rando! a!ount of
ti!e and reeats this rocess.
(. If !o)eone el!e be#in! talkin# at the !a)e ti)e; !top talkin#< In the
networking world, this is ter!ed collision detection - a trans!itting node listens
to the channel while it is trans!itting. If it detects that another node is
trans!itting an interfering fra!e, it stos trans!itting and uses so!e rotocol to
deter!ine when it should ne"t atte!t to trans!it.
It is evident that the end-to-end channel roagation delay of a broadcast channel - the
ti!e it takes for a signal to roagate fro! one of the the channel to another - will lay a
crucial role in deter!ining its erfor!ance. The longer this roagation delay, the larger
the chance that a carrier-sensing node is not yet able to sense a trans!ission that has
already begun at another node in the network.
CS,A- Carrier Sen!e ,ultiple Acce!!
This is the si!lest version ;SAA rotocol as described above. It does not secify any
collision detection or handling. So collisions !ight and #I'' occur and clearly then, this
is not a very good rotocol for large, load intensive networks.
So, we need an i!rove!ent over ;SAA - this led to the develo!ent of ;SAA?;).
CS,A-C'- CS,A with Colli!ion 'etection
In this rotocol, while trans!itting the data, the sender si!ultaneously tries to receive it.
So, as soon as it detects a collission 7it doesn0t receive its own data8 it stos trans!itting.
Thereafter, the node waits for so!e ti!e interval before atte!ting to trans!it again.
Si!ly ut, =li!ten while you talk=. 4ut, how long should one wait for the carrier to be
freedP There are three sche!es to handle this$
%. >-%er!i!tent: In this sche!e, trans!ission roceeds i!!ediately if the carrier is
idle. .owever, if the carrier is busy, then sender continues to sense the carrier
until it beco!es idle. The !ain roble! here is that, if !ore than one trans!itters
are ready to send, a collision is BCA5ANT::)OO
(. Non-%er!i!tent: In this sche!e, the broadcast channel is not !onitored
continuously. The sender olls it at rando! ti!e intervals and trans!its whenever
the carrier is idle. This decreases the robability of collisions. 4ut, it is not
efficient in a low load situation, where nu!ber of collisions are anyway s!all.
The roble!s it entails are$
o If back-off ti!e is too long, the idle ti!e of carrier is wasted in so!e sense
o It !ay result in long access delays
*. p-%er!i!tent: :ven if a sender finds the carrier to be idle, it uses a robabilistic
distribution to deter!ine whether to trans!it or not. &ut si!ly, <toss a coin to
decide<. If the carrier is idle, then trans!ission takes lace with a robability
and the sender waits with a robability %-. This sche!e is a good trade off
between the Non-ersistent and %-ersistent sche!es. So, for low load situations,
is high 7e"a!le$ %-ersistent8= and for high load situations, !ay be lower.
;learly, the value of lays an i!ortant role in deter!ining the erfor!ance of
this rotocol. Also the sa!e is likely to rovide different erfor!ance at
different loads.
;SAA?;) doesn0t work in so!e wireless scenarios called =hidden node= roble!s.
;onsider a situation, where there are * nodes - A, 4 and ; co!!unicating with each
other using a wireless rotocol. Aorover, 4 can co!!unicate with both A and ;, but A
and ; lie outside each other0s range and hence can0t co!!unicate directly with each
other. Now, suose both A and ; want to co!!unicate with 4 si!ultaneously. They
both will sense the carrier to be idle and hence will begin trans!ission, and even if there
is a collision, neither A nor ; will ever detect it. 4 on the other hand will receive (
ackets at the sa!e ti!e and !ight not be able to understand either of the!. To get
around this roble!, a better version called ;SAA?;A was develoed, secially for
wireless alications.
CS,A with Colli!ion A+oidance
#e have observed that ;SAA?;) would break down in wireless networks because of
hidden node and e"osed nodes roble!s. #e will have a 6uick reca of these two
roble!s through e"a!les.
(idden Node Pro)lem
In the case of wireless network it is ossible that A is sending a !essage to 4, but ; is out
of its range and hence while <listening< on the network it will find the network to be free
and !ight try to send ackets to 4 at the sa!e ti!e as A. So, there will be a collision at
4. The roble! can be looked uon as if A and ; are hidden fro! each other. .ence it is
called the <hidden node roble!<.
$'posed Node Pro)lem
If ; is trans!itting a !essage to ) and 4 wants to trans!it a !essage to A, 4 will find
the network to be busy as 4 hears ; trnas!itting. :ven if 4 would have trans!itted to A,
it would not have been a roble! at A or ). ;SAA?;) would not allow it to trans!it
!essage to A, while the two trans!issions could have gone in arallel.
Addressin# hidden node pro)lem *CSMA+CA,
;onsider the figure above.Suose A wants to send a acket to 4. Then it will first send a
s!all acket to 4 called =*e4ue!t to Send= 0*(S1. In resonse, 4 sends a s!all acket
to A called =Clear to Send= 0C(S1. Only after A receives a ;TS, it trans!its the actual
data. Now, any of the nodes which can hear either ;TS or 5TS assu!e the network to be
busy. .ence even if so!e other node which is out of range of both A and 4 sends an 5TS
to ; 7which can hear at least one of the 5TS or ;TS between A and 48, ; would not send
a ;TS to it and hence the co!!unication would not be established between ; and ).
One issue that needs to be addressed is how long the rest of the nodes should wait before
they can trans!it data over the network. The answer is that the 5TS and ;TS would carry
so!e infor!ation about the si9e of the data that 4 intends to transfer. So, they can
calculate ti!e that would be re6uired for the trans!ission to be over and assu!e the
network to be free after that.Another interesting issue is what a node should do if it hears
5TS but not a corresonding ;TS. One ossibility is that it assu!es the reciient node
has not resonded and hence no trans!ission is going on, but there is a catch in this. It is
ossible that the node hearing 5TS is >ust on the boundary of the node sending ;TS.
.ence, it does hear ;TS but the signal is so deteriorated that it fails to recogni9e it as a
;TS. .ence to be on the safer side, a node will not start trans!ission if it hears either of
an 5TS or a ;TS.
The assu!tion !ade in this whole discussion is that if a node Q can send ackets to a
node R, it can also receive a acket fro! R, which is a fair enough assu!tion given the
fact that we are talking of a local network where standard instru!ents would be used. If
that is not the case additional co!le"ities would get introduced in the syste!.
Does CSMA+CD work ni-ersally in the wired networks .
The roble! of range is there in wired networks as well in the for! of deterioration of
signals. Nor!ally to counter this, we use reeaters, which can regenerate the original
signal fro! a deteriorated one. 4ut does that !ean that we can build as long networks as
we want with reeaters. The answer, unfortunately, is NOO The reason is the beyond a
certain length ;SAA?;) will break down.
The !echanis! of collision detection which ;SAA?;) follows is through listening
while talking. #hat this !eans is so long as a node is trans!itting the acket, it is
listening on the cable. If the data it listens to is different fro! the data it is trans!itting it
assu!es a collision. Once it has stoed trans!itting the acket, and has not detected
collision while trans!ission was going on, it assu!es that the trans!ission was
successful. The roble! arises when the distance between the two nodes is too large.
Suose A wants to trans!it so!e acket to 4 which is at a very large distance fro! 4.
)ata can travel on cable only at a finite seed 7usually (?*c, c being the seed of light8.
So, it is ossible that the acket has been trans!itted by A onto the cable but the first bit
of the acket has not yet reached 4. In that case, if a collision occurs, A would be
unaware of it occurring. Therefore there is roble! in too long a network.
'et us try to ara!etri9e the above roble!. Suose <t< is the ti!e taken for the node A
to trans!it the acket on the cable and <T< is the ti!e , the acket takes to reach fro! A
to 4. Suose trans!ission at A starts at ti!e t1. In the worst case the collision takes
lace >ust when the first acket is to reach 4. Say it is at t12T-e 7e being very s!all8.
Then the collision infor!ation will take T-e ti!e to roagate back to A. So, at t12(7T-e8
A should still be trans!itting. .ence, for the correct detection of collision 7ignoring e8
t / 0T
t increases with the nu!ber of bits to be transferred and decreases with the rate of transfer
7bits er second8. T increases with the distance between the nodes and decreases with the
seed of the signal 7usually (?*c8. #e need to either kee t large enough or T as s!all.
#e do not want to live with lower rate of bit transfer and hence slow networks. #e can
not do anything about the seed of the signal. So what we can rely on is the !ini!u!
si9e of the acket and the distance between the two nodes. Therefore, we fi" so!e
!ini!u! si9e of the acket and if the si9e is s!aller than that, we ut in so!e e"tra bits
to !ake it reach the !ini!u! si9e. Accordingly we fi" the !a"i!u! distance between
the nodes. .ere too, there is a tradeoff to be !ade. #e do not want the !ini!u! si9e of
the ackets to be too large since that wastes lots of resources on cable. At the sa!e ti!e
we do not want the distance between the nodes to be too s!all. Tyical !ini!u! acket
si9e is -+ bytes and the corresonding distance is (-, kilo!eters.
Colli!ion .ree %rotocol!
Although collisions do not occur with ;SAA?;) once a station has una!bigously sei9ed
the channel, they can still occur during the contention eriod. These collisions adversely
affect the efficiency of trans!ission. .ence so!e rotocols have been develoed which
are contention free.
!it1Map Method
In this !ethod, there N slots. If node 1 has a fra!e to send, it trans!it a % bit during the
first slot. No other node is allowed to trans!it during this eriod. Ne"t node % gets a
chance to trans!it % bit if it has so!ething to send, regardless of what node 1 had
trans!itted. This is done for all the nodes. In general node > !ay declare the fact that it
has a frs!e to send by inserting a % into slot >. .ence after all nodes have assed, each
node has co!lete knowledge of who wants to send a fra!e. Now they begin
trans!itting in nu!erical order. Since everyone knows who is trans!itting and when,
there could never be any collision.
The basic roble! with this rotocol is its inefficiency during low load. If a node has to
trans!it and no other node needs to do so, even then it has to wait for the bit!a to
finish. .ence the bit!a will be reeated over and over again if very few nodes want to
send wasting valuable bandwidth.
!inary Contdown
In this rotocol, a node which wants to signal that it has a fra!e to send does so by
writing its address into the header as a binary nu!ber. The arbitration is such that as soon
as a node sees that a higher bit osition that is 1 in its address has been overwritten with a
%, it gives u. The final result is the address of the node which is allowed to send. After
the node has trans!itted the whole rocess is reeated all over again. Biven below is an
e"a!le situation.
Node! Addre!!e!
A 11%1
4 1%1%
; %1%1
) %11%
----
%1%1
Node ; having higher riority gets to trans!it. The roble! with this rotocol is that the
nodes with higher address always wins. .ence this creates a riority which is highly
unfair and hence undesirable.
Li)ited Contention %rotocol!
4oth the tye of rotocols described above - ;ontention based and ;ontention - free has
their own roble!s. Cnder conditions of light load, contention is referable due to its low
delay. As the load increases, contention beco!es increasingly less attractive, because the
overload associated with channel arbitration beco!es greater. Sust the reverse is true for
contention - free rotocols. At low load, they have high delay, but as the load increases ,
the channel efficiency i!roves rather than getting worse as it does for contention
rotocols.
Obviously it would be better if one could co!bine the best roerties of the contention
and contention - free rotocols, that is, rotocol which used contention at low loads to
rovide low delay, but used a cotention-free techni6ue at high load to rovide good
channel efficiency. Such rotocols do e"ist and are called 'i!ited contention rotocols.
It is obvious that the robablity of so!e station a6uiring the channel could only be
increased by decreasing the a!ount of co!etition. The li!ited contention rotocols do
e"actly that. They first divide the stations u into 7 not necessarily dis>oint 8 grous. Only
the !e!bers of grou 1 are er!itted to co!ete for slot 1. The co!etition for a6uiring
the slot within a grou is contention based. If one of the !e!bers of that grou succeeds,
it a6uires the channel and trans!its a fra!e. If there is collision or no node of a articular
grou wants to send then the !e!bers of the ne"t grou co!ete for the ne"t slot. The
robablity of a articular node is set to a articular value 7 oti!u! 8.
Adapti-e Tree "alk Protocol
The following is the !ethod of adative tree rotocol. Initially all the nodes are allowed
to try to a6uire the channel. If it is able to a6uire the channel, it sends its fra!e. If there is
collision then the nodes are divided into two e6ual grous and only one of these grous
co!ete for slot %. If one of its !e!ber a6uires the channel then the ne"t slot is reserved
for the other grou. On the other hand, if there is a collision then that grou is again
subdivided and the sa!e rocess is followed. This can be better understood if the nodes
are thought of as being organised in a binary tree as shown in the following figure.
Aany i!rove!ents could be !ade to the algorith!. /or e"a!le, consider the case of
nodes B and . being the only ones wanting to trans!it. At slot % a collision will be
detected and so ( will be tried and it will be found to be idle. .ence it is ointless to
robe * and one should directly go to -,7.
I""" 8?@<A and "thernet
3ery oular 'AN standard.
:thernet and I::: I1(.* are distinct standards but as they are very si!ilar to one
another these words are used interchangeably.
A standard for a %-ersistent ;SAA?;) 'AN.
It covers the hysical layer and AA; sublayer rotocol.
$thernet Physical Layer
A ;o!arison of 3arious :thernet and I::: I1(.* &hysical-'ayer Secifications
Characteri!tic "thernet Balue I""" 8?@<A Balue!
>?$a!e7 >?$a!e@ >?$a!e(
)ata rate 7Abs8 %1 %1 %1 %1
Signaling !ethod 4aseband 4aseband 4aseband 4aseband
Aa"i!u! seg!ent length
7!8
,11 ,11 %I, %11
Aedia ,1-oh! coa"
7thick8
,1-oh! coa"
7thick8
,1-oh! coa"
7thin8
Cnshielded twisted-air
cable
Nodes?seg!ent %11 %11 *1 %1(+
Toology 4us 4us 4us Star
%14ase, !eans it oerates at %1 Abs, uses baseband signaling and can suort
seg!ents of u to ,11 !eters. The %14ase, cabling is oularly called the Thick
:thernet. 3a!ire tas are used for their connections where a in is carefully forced
halfway into the co-a"ial cable0s core as shown in the figure below. The %14ase( or Thin
:thernet bends easily and is connected using standard 4N; connectors to for! T
>unctions 7shown in the figure below8. In the %14ase-T sche!e a different kind of wiring
attern is followed in which all stations have a twisted-air cable running to a central hub
7see below8. The difference between the different hysical connections is shown below$
0a1 >?$a!e7 0b1>?$a!e@ 0c1>?$a!e-(
All I1(.* baseband syste!s use Aanchester encoding , which is a way for receivers to
una!biguously deter!ine the start, end or !iddle of each bit without reference to an
e"ternal clock. There is a restriction on the !ini!u! node sacing 7seg!ent length
between two nodes8 in %14ase, and %14ase( and that is (., !eter and 1., !eter
resectively. The reason is that if two nodes are closer than the secified li!it then there
will be very high current which !ay cause trouble in detection of signal at the receiver
end. ;onnections fro! station to cable of %14ase, 7i.e. Thick :thernet8 are generally
!ade using va!ire tas and to %14ase( 7i.e. Thin :thernet8 are !ade using industry
standard 4N; connectors to for! T >unctions. To allow larger networks, !ultile
seg!ents can be connected by reeaters as shown. A reeater is a hysical layer device. It
receives, a!lifies and retrans!its signals in either direction.
Note: To connect !ultile seg!ents, a!lifier is not used because a!lifier also
a!lifies the noise in the signal, whereas reeater regenerates signal after re!oving the
noise.
I$$$ 23045 6rame Strctre
%rea)ble
07 byte!1
Start of
.ra)e
'eli)iter
0> byte1
'e!t<
Addre!!
0@-9 byte!1
Source
Addre!!
0@-9 byte!1
Len#th
0@
byte!1
8?@<@
Header:'ata
069->7?? byte!1
.ra)e
Check!u)
06 byte!1
A brief description of each of the fields
%rea)ble ::ach fra!e starts with a rea!ble of 7 bytes, each byte containing the
bit attern %1%1%1%1. Aanchester encoding is e!loyed here and this enables the
receiver0s clock to synchroni9e with the sender0s and initialise itself.
Start of .ra)e 'eli)iter :This field containing a byte se6uence %1%1%1%%
denotes the start of the fra!e itself.
'e!t< Addre!! :The standard allows (-byte and --byte addresses. Note that the (-
byte addresses are always local addresses while the --byte ones can be local or
global.
2-Byte Address - Manually assigned address
Indi+idual0?1-2roup0>1
0> bit1
Addre!! of the )achine
0>7 bit!1

6-Byte Address - Every Ethernet card with globally unique address


Indi+idual0?1-2roup0>1
0> bit1
3ni+er!al0?1-Local0>1
0> bit1
Addre!! of the )achine
069 bit!1

,ultica!t : Sending to grou of stations. This is ensured by setting the first bit in
either (-byte?--byte addresses to %.
$roadca!t : Sending to all stations. This can be done by setting all bits in the
address field to %.All :thernet cards7Nodes8 are a !e!ber of this grou.
Source Addre!! :5efer to )est. Address. Sa!e holds true over here.
Len#th : The 'ength field tells how !any bytes are resent in the data field, fro!
a !ini!u! of 1 to a !a"i!u! of %,11. The )ata and adding together can be
fro! +-bytes to %,11 bytes as the valid fra!es !ust be at least -+ bytes long, thus
if data is less than +- bytes the a!ount of adding can be found out by length
field.
'ata :Actually this field can be slit u into two arts - )ata71-%,11 bytes8 and
&adding71-+- bytes8.
Reasons for having a minimum length frame :
%. To revent a station fro! co!leting the trans!ission of a short fra!e
before the first bit has even reached the far end of the cable, where it !ay
collide with another fra!e. Note that the trans!ission ti!e ought to be
greater than twice the roagation ti!e between two farthest nodes.
tran!)i!!ion ti)e for fra)e C @Dpropa#ation ti)e between two
farthe!t node!
(. #hen a transceiver detects a collision, it truncates the current fra!e,
which i!lies that stray bits and ieces of fra!es aear on the cable all
the ti!e. .ence to distinguish between valid fra!es fro! garbage, I1(.*
states that the !ini!u! length of valid fra!es ought to be -+ bytes 7fro!
)est. Address to /ra!e ;hecksu!8.
.ra)e Check!u) : It is a *(-bit hash code of the data. If so!e bits are
erroneously received by the destination 7due to noise on the cable8, the checksu!
co!uted by the destination wouldn0t !atch with the checksu! sent and therefore
the error will be detected. The checksu! algorith! is a cyclic redundancy
checksu! 7;5;8 kind. The checksu! includes the acket fro! )est. Address to
)ata field.
$thernet 6rame Strctre
%rea)ble
08 byte!1
'e!t< Addre!!
0@-9 byte!1
Source Addre!!
0@-9 byte!1
(ype
0@ byte!1
'ata
069->7?? byte!1
.ra)e Check!u)
06 byte!1
A brief description of the fields which differ from IEEE !2"#
%rea)ble :The Preamble and Start of Frame Delimiter are !erged into one in
:thernet standard. .owever, the contents of the first I bytes re!ains the sa!e in
both.
(ype :The length field of I::: I1(.* is relaced by Tye field, which denotes the
tye of acket being sent vi9. I&, A5&, 5A5&, etc. If the field indicates a value
less than %,11 bytes then it is length field of I1(.* else it is the tye field of
:thernet acket.
Trncated !inary $'ponential !ack off
In case of collision the node trans!itting backs off by a rando! nu!ber of slots , each
slot ti!e being e6ual to trans!ission ti!e of ,%( bits 7-+ 4yte- !ini!u! si9e of a
acket8 in the following fashion$
No of Colli!ion *ando) No of !lot!
%st 1-%
(nd 1-*
*rd 1-7
T T
T T
%1th 1-%1(*
---------------------------------------------
%%th 1-%1(*
%(th 1-%1(*
T T
%-th 1-%1(*
In general after i collisions a rando! nu!ber between 1-(Ki-% is chosen , and that nu!ber
of slots is skied. .owever, after %1 collisions have been reached the rando!i9ation
interval is fro9en at !a"i!u! of %1(* slots. After %- collisions the controller reorts
failure back to the co!uter.
71815 Rle
:ach version of I1(.* has a !a"i!u! cable length er seg!ent because long
roagation ti!e leads to difficulty in collision detection. To co!ensate for this the
trans!ission ti!e has to be increased which can be achieved by slowing down the
trans!ission rate or increasing the acket si9e, neither of which is desirable. .ence to
allow for large networks, !ultile cables are connected via repeater!. 4etween any two
nodes on an :thernet network, there can be at !ost five seg!ents, four reeaters and
three oulated seg!ents 7non-oulated seg!ents are those which do not have any
!achine connected between the two reeaters8. This is known as the 7-6-A *ule.
I""" 8?@<7: (oken *in# Network
Token 5ing is for!ed by the nodes connected in ring for!at as shown in the
diagra! below. The rincile used in the token ring network is that a token is
circulating in the ring and whichever node grabs that token will have right to
trans!it the data.
#henever a station wants to trans!it a fra!e it inverts a single bit of the *-byte
token which instantaneously changes it into a nor!al data acket. 4ecause there
is only one token, there can at!ost be one trans!ission at a ti!e.
Since the token rotates in the ring it is guarenteed that every node gets the token
with in so!e secified ti!e. So there is an uer bound on the ti!e of waiting to
grab the token so that starvation is avoided.
There is also an uer li!it of (,1 on the nu!ber of nodes in the network.
To distinguish the nor!al data ackets fro! token 7control acket8 a secial
se6uence is assigned to the token acket. #hen any node gets the token it first
sends the data it wants to send, then recirculates the token.
If a node trans!its the token and nobody wants to send the data the token co!es back to
the sender. If the first bit of the token reaches the sender before the trans!ission of the
last bit, then error situation araises. So to avoid this we should have$
propo#ation delay : tran!)i!!ion of n-bit! 0>-bit delay in each node 1 C tran!)i!!ion
of the token ti)e
A station !ay hold the token for the token-holding ti!e. which is %1 !s unless the
installation sets a different value. If there is enough ti!e left after the first fra!e has been
trans!itted to send !ore fra!es, then these fra!es !ay be sent as well. After all ending
fra!es have been trans!itted or the trans!ission fra!e would e"ceed the token-holding
ti!e, the station regenerates the *-byte token fra!e and uts it back on the ring.
Modes of Operation
%. Li!ten ,ode: In this !ode the node listens to the data and trans!its the data to
the ne"t node. In this !ode there is a one-bit delay associated with the
trans!ission.
(. (ran!)it ,ode: In this !ode the node >ust discards the any data and uts the
data onto the network.
*. $y-pa!! ,ode: In this !ode reached when the node is down. Any data is >ust
byassed. There is no one-bit delay in this !ode.
Token Rin# 9sin# Rin# Concentrator
One roble! with a ring network is that if the cable breaks so!ewhere, the ring dies.
This roble! is elegantly addressed by using a ring concentrator. A Token 5ing
concentrator si!ly changes the toology fro! a hysical ring to a star wired ring. 4ut
the network still re!ains a ring logically. &hysically, each station is connected to the ring
concentrator 7wire center8 by a cable containing at least two twisted airs, one for data to
the station and one for data fro! the station. The Token still circulates around the
network and is still controlled in the sa!e !anner, however, using a hub or a switch
greatly i!roves reliability because the hub can auto!atically byass any orts that are
disconnected or have a cabling fault. This is done by having byass relays inside the
concentrator that are energi9ed by current fro! the stations. If the ring breaks or station
goes down, loss of the drive current will release the relay and byass the station. The ring
can then continue oeration with the bad seg!ent byassed.
"ho shold remo-e the packet from the rin# .
There are * ossibilities-
%. (he !ource it!elf re)o+e! the packet after one full round in the rin#.
(. (he de!tination re)o+e! it after acceptin# it$ This has two otential roble!s.
/irstly, the solution won0t work for broadcast or !ulticast, and secondly, there
would be no way to acknowledge the sender about the receit of the acket.
*. Ha+e a !peciali/ed node only to di!card packet!$ This is a bad solution as the
seciali9ed node would know that the acket has been received by the destination
only when it receives the acket the second ti!e and by that ti!e the acket !ay
have actually !ade about one and half 7or al!ost two in the worst case8 rounds in
the ring.
Thus the first solution is adoted with the source itself re!oving the acket fro! the ring
after a full one round. #ith this sche!e, broadcasting and !ulticasting can be handled as
well as the destination can acknowledge the source about the receit of the acket 7or can
tell the source about so!e error8.
Token 6ormat
The token is the shortest fra!e trans!itted 7(+ bit8
AS4 7Aost Significant 4it8 is always trans!itted first - as oosed to :thernet
S) A; :)
S' E Startin# 'eli)iter 0> Octet1
AC E Acce!! Control 0> Octet1
"' E "ndin# 'eli)iter 0> Octet1
Startin# 'eli)iter .or)at:
S D O S D O O O
F E Code Biolation
& E Code Biolation
Acce!! Control .or)at:
& & & T A 5 5 5
(E(oken
T F 1 for Token
T F % for /ra!e
#hen a station with a /ra!e to trans!it detects a token which has a riority e6ual to or
less than the /ra!e to be trans!itted, it !ay change the token to a start-of-fra!e
se6uence and trans!it the /ra!e
% E %riority
&riority 4its indicate tokens riority, and therefore, which stations are allowed to use it.
Station can trans!it if its riority as at least as high as that of the token.
, E ,onitor
The !onitor bit is used to revent a token whose riority is greater than 1 or any fra!e
fro! continuously circulating on the ring. If an active !onitor detects a fra!e or a high
riority token with the !onitor bit e6ual to %, the fra!e or token is aborted. This bit shall
be trans!itted as 1 in all fra!e and tokens. The active !onitor insects and !odifies this
bit. All other stations shall reeat this bit as received.
* E *e!er+ed bit!
The reserved bits allow station with high riority /ra!es to re6uest that the ne"t token be
issued at the re6uested riority.
"ndin# 'eli)iter .or)at:
S D % S D % % :
F E Code Biolation
& E Code Biolation
I E Inter)ediate .ra)e $it
" E "rror 'etected $it
6rame 6ormat&
AS4 7Aost Significant 4it8 is always trans!itted first - as oosed to :thernet
S) A; /; )A SA )ATA ;5; :) /S
S'EStartin# 'eli)iter0> octet1
ACEAcce!! Control0> octet1
.C E .ra)e Control 0> Octet1
'A E 'e!tination Addre!! 0@ or 9 Octet!1
SA E Source Addre!! 0@ or 9 Octet!1
'A(A E Infor)ation ? or )ore octet! up to 6?@7
C*C E Check!u)06 Octet!1
"' E "ndin# 'eli)iter 0> Octet1
.SE.ra)e Statu!
Startin# 'eli)iter .or)at:
S D 1 S D 1 1 1
F E Code Biolation
& E Code Biolation
Acce!! Control .or)at:
& & & T A 5 5 5
(E(oken
T F 1 for Token,
T F % for /ra!e.
#hen a station with a /ra!e to trans!it detects a token which has a riority e6ual to or
less than the /ra!e to be trans!itted, it !ay change the token to a start-of-fra!e
se6uence and trans!it the /ra!e.
% E %riority
4its &riority 4its indicate tokens riority, and therefore, which stations are allowed to use
it. Station can trans!it if its riority as at least as high as that of the token.
, E ,onitor
The !onitor bit is used to revent a token whose riority is greater than 1 or any fra!e
fro! continuously circulating on the ring. if an active !onitor detects a fra!e or a high
riority token with the !onitor bit e6ual to %, the fra!e or token is aborted. This bit shall
be trans!itted as 1 in all fra!e and tokens. The active !onitor insects and !odifies this
bit. All other stations shall reeat this bit as received.
* E *e!er+ed bit! the reserved bits allow station with high riority /ra!es to re6uest
that the ne"t token be issued at the re6uested riority
.ra)e Control .or)at:
/ / ;ONT5O' 4ITS 7- 4ITS8
..E (ype of %acket-*e#ular data packet or ,AC layer packet
Control $it!E 3!ed if the packet i! for ,AC layer protocol it!elf
Source and 'e!tination Addre!! .or)at:
The addresses can be of ( bytes 7local address8 or - bytes 7global address8.
local addre!! for)at:
I?B 7% 4IT8 NO): A))5:SS 7%, 4ITS8
alternatively
I?B 7% 4IT8 5INB A))5:SS 77 4ITS8 NO): A))5:SS 7I 4ITS8
The first bit secifies individual or grou address.
uni+er!al 0#lobal1 addre!! for)at:
I?B 7% 4IT8 '?C 7% 4IT8 5INB A))5:SS 7%+ 4ITS8 NO): A))5:SS 7*( 4ITS8
The first bit secifies individual or grou address.
The second bit secifies local or global 7universal8 address.
local #roup addre!!e! 0>9 bit!1:
I?B 7% 4IT8 T?47% 4IT8 B5OC& A))5:SS 7%+ 4ITS8
The first bit secifies an individual or grou address.
The second bit secifies traditional or bit signature grou address.
(raditional 2roup Addre!!: (:"%+ grous can be defined.
$it Si#nature 2roup Addre!!: %+ grtous are defined. A host can be a !e!ber of none
or any nu!ber of the!. /or !ulticasting, those grou bits are set to which the acket
should go. /or broadcasting, all %+ bits are set. A host receives a acket only if it is a
!e!ber of a grou whose corresonding bit is set to %.
uni+er!al #roup addre!!e! 0>9 bit!1:
I?B 7% 4IT8 5INB NCA4:5 T?4 7% 4IT8 B5OC& A))5:SS 7%+ 4ITS8
The descrition is si!ilar to as above.
'ata .or)at:
No uer li!it on a!ount of data as such, but it is li!ited by the token holding ti!e.
Check!u):
The source co!utes and sets this value. )estination too calculates this value. If the two
are different, it indicates an error, otherwise the data !ay be correct.
.ra)e Statu!:
It contains the A and ; bits.
A bit !et to >: de!tination reco#ni/ed the packet<
C bit !et to >: de!tination accepted the packet<
This arrange!ent rovides an auto!atic acknowledge!ent for each fra!e. The A and ;
bits are resent twice in the /ra!e Status to increase reliability in as !uch as they are not
covered by the checksu!.
"ndin# 'eli)iter .or)at:
S D % S D % I :
F E Code Biolation
& E Code Biolation
I E Inter)ediate .ra)e $it
If this bit is set to %, it indicates that this acket is an inter!ediate art of a bigger acket,
the last acket would have this bit set to 1.
" E "rror 'etected $it
This bit is set if any interface detects an error.
This concludes our descrition of the token ring fra!e for!at.
(oken *in# Network 0Contd<<<1
Phase :itter Compensation &
In a token ring the source starts discarding all it0s reviously trans!itted bits as soon as
they circu!navigate the ring and reach the source. .ence, it0s not desirable that while a
token is being sent so!e bits of the token which have already been sent beco!e available
at the inco!ing end of the source. This behavior though is desirable in case of data
ackets which ought to be drained fro! the ring once they have gone around the ring. To
achieve the aforesaid behavior with resect to tokens, we would like the ring to hold at
least (+ bits at a ti!e. .ow do we ensure thisP
:ach node in a ring introduces a % bit delay. So, one aroach !ight be to set the
!ini!u! li!it on the nu!ber of nodes in a ring as (+. 4ut, this is not a viable otion.
The actual solution is as follows. #e have one node in the ring designated as
=)onitor=. The !onitor !aintains a (+ bits buffer with hel of which it introduces a (+
bit delay. The catch here is what if the clocks of nodes following the source are faster
than the sourceP In this case the (+ bit delay of the !onitor would be less than the (+ bit
delay desired by the host. To avoid this situation the !onitor !aintains * e"tra bits to
co!ensate for the faster bits. The * e"tra bits suffice even if bits are %1 H faster. This
co!ensation is called &hase Sitter ;o!ensation.
(andlin# mltiple priority frames
:ach node or acket has a riority level. #e don0t concern ourselves with how this
riority is decided. The first * bits of the Access ;ontrol byte in the token are for riority
and the last * are for reservation.

& & & T A 5 5 5
Initially the reservation bits are set to 111. #hen a node wants to trans!it a riority n
fra!e, it !ust wait until it can cature a token whose riority is less than or e6ual to n.
/urther!ore, when a data fra!e goes by, a station can try to reserve the ne"t token by
writing the riority of the fra!e it wants to send into the fra!e0s 5eservation bits.
.owever, if a higher riority has already been reserved there, the station cannot !ake a
reservation. #hen the current fra!e is finished, the ne"t token is generated at the riority
that has been reserved.
A slight roble! with the above reservation rocedure is that the reservation riority
kees on increasing. To solve this roble!, the station raising the riority re!e!bers the
reservation riority that it relaces and when it is done it reduces the riority to the
revious riority.
Note that in a token ring, low riority fra!es !ay starve.
Rin# Maintenance
:ach token ring has a !onitor that oversees the ring. A!ong the !onitor0s
resonsibilities are seeing that the token is not lost, taking action when the ring breaks,
cleaning the ring when garbled fra!es aear and watching out for orhan fra!es. An
orhan fra!e occurs when a station trans!its a short fra!e in it0s entirety onto a long
ring and then crashes or is owered down before the fra!e can be re!oved. If nothing is
done, the fra!e circulates indefinitely.
'etection of orphan fra)e!: The !onitor detects orhan fra!es by setting the
!onitor bit in the Access ;ontrol byte whenever it asses through. If an inco!ing
fra!e has this bit set, so!ething is wrong since the sa!e fra!e has assed the
!onitor twice. :vidently it was not re!oved by the source, so the !onitor drains
it.
Lo!t (oken!: The !onitor has a ti!er that is set to the longest ossible tokenless
interval $ when each node trans!its for the full token holding ti!e. If this ti!er
goes off, the !onitor drains the ring and issues a fresh token.
2arbled fra)e!: The !onitor can detect such fra!es by their invalid for!at or
checksu!, drain the ring and issue a fresh token.
The token ring control fra!es for !aintenance are$
Control
field
Name Meaning
11111111
)ulicate
address test
Test if two stations have the sa!e
address
111111%1 4eacon Csed to locate breaks in the ring
111111%% ;lai! token Atte!t to beco!e !onitor
11111%11 &urge 5einitiali9e the ring
11111%1%
Active !onitor
resent
Issued eriodically by the !onitor
11111%%1
Standby
!onitor resent
Announces the resence of otential
!onitors
The !onitor eriodically issues a !essage <Active Aonitor &resent< infor!ing all nodes
of its resence. #hen this !essage is not received for a secific ti!e interval, the nodes
detect a !onitor failure. :ach node that believes it can function as a !onitor broadcasts a
<Standby Aonitor &resent< !essage at regular intervals, indicating that it is ready to take
on the !onitor0s >ob. Any node that detects failure of a !onitor issues a <;lai!< token.
There are * ossible outco!es $
%. If the issuing node gets back its own clai! token, then it beco!es the !onitor.
(. If a acket different fro! a clai! token is received, aarently a wrong guess of
!onitor failure was !ade. In this case on receit of our own clai! token, we
discard it. Note that our clai! token !ay have been re!oved by so!e other node
which has detected this error.
*. If so!e other node has also issued a clai! token, then the node with the larger
address beco!es the !onitor.
In order to resolve errors of dulicate addresses, whenever a node co!es u it sends a
='uplicate Addre!! 'etection= !essage 7with the destination F source8 across the
network. If the address recogni9e bit has been set on receit of the !essage, the issuing
node reali9es a dulicate address and goes to standby !ode. A node infor!s other nodes
of re!oval of a acket fro! the ring through a =%ur#e= !essage. One !aintenance
function that the !onitor cannot handle is locating breaks in the ring. If there is no
activity detected in the ring 7e.g. /ailure of !onitor to issue the Acti+e ,onitor %re!ent
token...8 , the usual rocedures of sending a clai! token are followed. If the clai! token
itself is not received besides ackets of any other kind, the node then sends =$eacon!= at
regular intervals until a !essage is received indicating that the broken ring has been
reaired.
Other Rin# Networks
The roble! with the token ring syste! is that large rings cause large delays. It !ust be
!ade ossible for !ultile ackets to be in the ring si!ultaneously. The following ring
networks resolve this roble! to so!e e"tent $-
Slotted *in# :
In this syste!, the ring is slotted into a nu!ber of fi"ed si9e fra!es which are
continuously !oving around the ring. This !akes it necessary that there be enough
nu!ber of nodes 7large ring si9e8 to ensure that all the bits can stay on the ring at the
sa!e ti!e. The fra!e header contains infor!ation as to whether the slots are e!ty or
full. The usual disadvantages of overhead?wastage associated with fi"ed si9e fra!es are
resent.
*e#i!ter In!ertion *in#! :
This is an i!rove!ent over slotted ring architecture. The network interface consists of
two registers $ a shift register and an outut buffer. At startu, the inut ointer oints to
the right!ost bit osition in the inut shift register .#hen a bit arrives it is in the
right!ost e!ty osition 7the one indicated by the inut ointer8. After the node has
detected that the fra!e is not addressed to it, the bits are trans!itted one at ti!e 7by
shifting8. As new bits co!e in, they are inserted at the osition indicated by the ointer
and then the contents are shifted. Thus the ointer is not !oved. Once the shift register
has ushed out the last bit of a fra!e, it checks to see if it has an outut fra!e waiting. In
case yes, then it checks that if the nu!ber of e!ty slots in the shift register is at least
e6ual to the nu!ber of bits in the outut fra!e. After this the outut connection is
switched to this second register and after the register has e!tied its contents, the outut
line is switched back to the shift register. Thus, no single node can hog the bandwidth. In
a loaded syste!, a node can trans!it a k-bit fra!e only if it has saved u a k-bits of inter
fra!e gas.
Two !a>or disadvantages of this toology are co!licated hardware and difficulty in the
detection of start?end of ackets.
Contention *in#
The token ring has ri!arily two roble!s$
On light loads, huge overhead is incurred for token assing.
Nodes with low riority data !ay starve if there is always a node with high
riority data.
A contention ring atte!ts to address these roble!s. In a contention ring, if there is no
co!!unication in the ring for a while, a sender node will send its data i!!ediately,
followed by a token. If the token co!es back to the sender without any data acket in
between, the sender re!oves it fro! the ring. .owever under heavy load the behavior is
that of a nor!al token ring. In case a collision, each of the sending nodes will re!ove the
others0 data acket fro! the ring, back off for a rando! eriod of ti!e and then resend
their data.
I""" 8?@<6: (oken $u! Network
In this syste!, the nodes are hysically connected as a bus, but logically for! a ring with
tokens assed around to deter!ine the turns for sending. It has the robustness of the
I1(.* broadcast cable and the known worst case behavior of a ring. The structure of a
token bus network is as follows$
6rame Strctre
A I1(.+ fra!e has the following fields$
&rea!ble$ The &rea!ble is used to synchroni9e the receiver0s clock.
Starting )eli!iter 7S)8 and :nd )eli!iter 7:)8$ The Starting )eli!iter and
:nding )eli!iter fields are used to !ark fra!e boundaries. 4oth of the! contain
analog encoding of sy!bols other than % or 1 so that they cannot occur
accidentally in the user data. .ence no length field is needed.
/ra!e ;ontrol 7/;8$ This field is used to distinguish data fra!es fro! control
fra!es. /or data fra!es, it carries the fra!e0s riority as well as a bit which the
destination can set as an acknowledge!ent. /or control fra!es, the /ra!e ;ontrol
field is used to secify the fra!e tye. The allowed tyes include token assing
and various ring !aintenance fra!es.
)estination and Source Address$ The )estination and Source address fields !ay
be ( bytes 7for a local address8 or - bytes 7for a global address8.
)ata$ The )ata field carries the actual data and it !ay be I%I( bytes when ( byte
addresses are used and I%7+ bytes for - byte addresses.
;hecksu!$ A +-byte checksu! calculated for the data. Csed in error detection.
Rin# Maintenance&
,echani!):
#hen the first node on the token bus co!es u, it sends a Clai)Gtoken acket to
initiali9e the ring. If !ore than one station send this acket at the sa!e ti!e, there is a
collision. ;ollision is resolved by a contention !echanis!, in which the contending
nodes send rando! data for %, (, * and + units of ti!e deending on the first two bits of
their address. The node sending data for the longest ti!e wins. If two nodes have the
sa!e first two bits in their addresses, then contention is done again based on the ne"t two
bits of their address and so on.
After the ring is set u, new nodes which are owered u !ay wish to >oin the ring. /or
this a node sends SolicitG!ucce!!orG> ackets fro! ti!e to ti!e, inviting bids fro! new
nodes to >oin the ring. This acket contains the address of the current node and its current
successor, and asks for nodes in between these two addresses to rely. If !ore than one
nodes resond, there will be collision. The node then sends a *e!ol+eGcontention acket,
and the contention is resolved using a si!ilar !echanis! as described reviously. Thus at
a ti!e only one node gets to enter the ring. The last node in the ring will send a
SolicitG!ucce!!orG@ acket containing the addresses of it and its successor. This acket
asks nodes not having addresses in between these two addresses to resond.
A 6uestion arises that how fre6uently should a node send a Solicit@successor acketP If it
is sent too fre6uently, then overhead will be too high. Again if it is sent too rarely, nodes
will have to wait for a long ti!e before >oining the ring. If the channel is not busy, a node
will send a Solicit@successor acket after a fi"ed nu!ber of token rotations. This nu!ber
can be configured by the network ad!inistrator. .owever if there is heavy traffic in the
network, then a node would defer the sending of bids for successors to >oin in.
There !ay be roble!s in the logical ring due to sudden failure of a node. #hat haens
when a node goes down along with the tokenP After assing the token, a node, say node
A, listens to the channel to see if its successor either trans!its the token or asses a
fra!e. If neither haens, it resends a token. Still if nothing haens, A sends a
hoGfollow! acket, containing the address of the down node. The successor of the
down node, say node ;, will now resond with a SetG!ucce!!or acket, containing its
own address. This causes A to set its successor node to ;, and the logical ring is restored.
.owever, if two successive nodes go down suddenly, the ring will be dead and will have
to be built afresh, starting fro! a Clai)Gtoken acket.
#hen a node wants to shutdown nor!ally, it sends a SetG!ucce!!or acket to its
redecessor, na!ing its own successor. The ring then continues unbroken, and the node
goes out of the ring.
The various control fra!es used for ring !aintenance are shown below$
.ra)e Control .ield Na)e ,eanin#
11111111 ;lai!@token
;lai! token during ring
!aintenance
1111111% Solicit@successor@% Allow stations to enter the ring
111111%1 Solicit@successor@( Allow stations to enter the ring
111111%% #ho@follows 5ecover fro! lost token
11111%11 5esolve@contention
Csed when !ultile stations
want to enter
1111%111 Token &ass the token
1111%%11 Set@successor
Allow the stations leave the
ring
Priority Scheme&
Token bus suorts four distinct riority levels$ 1, (, + and -.
1 is the lowest riority level and - the highest. The following ti!es are defined by the
token bus$
T.T$ Token .olding Ti!e. A node holding the token can send riority - data for
a !a"i!u! of this a!ount of ti!e.
T5T@+$ Token 5otation Ti!e for class + data. This is the !a"i!u! ti!e a token
can take to circulate and still allow trans!ission of class + data.
T5T@( and T5T@1$ Si!ilar to T5T@+.
#hen a station receives data, it roceeds in the following !anner$
It trans!its riority - data for at !ost T.T ti!e, or as long as it has data.
Now if the ti!e for the token to co!e back to it is less than T5T@+, it will
trans!it riority + data, and for the a!ount of ti!e allowed by T5T@+. Therefore
the !a"i!u! ti!e for which it can send riority + data isF Actual T5T - T.T -
T5T@+
Si!ilarly for riority ( and riority 1 data.
This !echanis! ensures that riority - data is always sent, !aking the syste! suitable
for real ti!e data trans!ission. In fact this was one of the ri!ary ai!s in the design of
token bus.
'ata Link Layer
"hat is DLL*Data Link Layer,
The )ata 'ink 'ayer is the second layer in the OSI !odel, above the &hysical 'ayer,
which ensures that the error free data is transferred between the ad>acent nodes in the
network. It breaks the datagra!s assed down by above layers and convert the! into
fra!es ready for transfer. This is called /ra!ing. It rovides two !ain functionalities
5eliable data transfer service between two eer network layers
/low ;ontrol !echanis! which regulates the flow of fra!es such that data
congestion is not there at slow receivers due to fast senders.
"hat is 6ramin#.
Since the hysical layer !erely accets and trans!its a strea! of bits without any regard
to !eaning or structure, it is uto the data link layer to create and recogni9e fra!e
boundaries. This can be acco!lished by attaching secial bit atterns to the beginning
and end of the fra!e. If these bit atterns can accidentally occur in data, secial care !ust
be taken to !ake sure these atterns are not incorrectly interreted as fra!e deli!iters.
The four fra!ing !ethods that are widely used are
;haracter count
Starting and ending characters, with character stuffing
Starting and ending flags, with bit stuffing
&hysical layer coding violations
Character Count
This !ethod uses a field in the header to secify the nu!ber of characters in the fra!e.
#hen the data link layer at the destination sees the character count,it knows how !any
characters follow, and hence where the end of the fra!e is. The disadvantage is that if the
count is garbled by a trans!ission error, the destination will lose synchroni9ation and will
be unable to locate the start of the ne"t fra!e. So, this !ethod is rarely used.
Character !tuffin#
In the second !ethod, each fra!e starts with the AS;II character se6uence )': STQ
and ends with the se6uence )': :TQ.7where )': is )ata 'ink :scae, STQ is Start of
TeQt and :TQ is :nd of TeQt.8 This !ethod overco!es the drawbacks of the character
count !ethod. If the destination ever loses synchroni9ation, it only has to look for )':
STQ and )': :TQ characters. If however, binary data is being trans!itted then there
e"ists a ossibility of the characters )': STQ and )': :TQ occurring in the data. Since
this can interfere with the fra!ing, a techni6ue called character stuffing is used. The
sender0s data link layer inserts an AS;II )': character >ust before the )': character in
the data. The receiver0s data link layer re!oves this )': before this data is given to the
network layer. .owever character stuffing is closely associated with I-bit characters and
this is a !a>or hurdle in trans!itting arbitrary si9ed characters.
$it !tuffin#
The third !ethod allows data fra!es to contain an arbitrary nu!ber of bits and allows
character codes with an arbitrary nu!ber of bits er character. At the start and end of
each fra!e is a flag byte consisting of the secial bit attern 1%%%%%%1 . #henever the
sender0s data link layer encounters five consecutive %s in the data, it auto!atically stuffs a
9ero bit into the outgoing bit strea!. This techni6ue is called bit stuffing. #hen the
receiver sees five consecutive %s in the inco!ing data strea!, followed by a 9ero bit, it
auto!atically destuffs the 1 bit. The boundary between two fra!es can be deter!ined by
locating the flag attern.
%hy!ical layer codin# +iolation!
The final fra!ing !ethod is hysical layer coding violations and is alicable to
networks in which the encoding on the hysical !ediu! contains so!e redundancy. In
such cases nor!ally, a % bit is a high-low air and a 1 bit is a low-high air. The
co!binations of low-low and high-high which are not used for data !ay be used for
!arking fra!e boundaries.
$rror Control
The bit strea! trans!itted by the hysical layer is not guaranteed to be error free. The
data link layer is resonsible for error detection and correction. The !ost co!!on error
control !ethod is to co!ute and aend so!e for! of a checksu! to each outgoing
fra!e at the sender0s data link layer and to reco!ute the checksu! and verify it with the
received checksu! at the receiver0s side. If both of the! !atch, then the fra!e is
correctly received= else it is erroneous. The checksu!s !ay be of two tyes$
U :rror detecting $ 5eceiver can only detect the error in the fra!e and infor! the sender
about it. U :rror detecting and correcting $ The receiver can not only detect the error but
also correct it.
:"a!les of :rror )etecting !ethods$
%arity bit:
Si!le e"a!le of error detection techni6ue is arity bit. The arity bit is chosen
that the nu!ber of % bits in the code word is either even7 for even arity8 or odd
7for odd arity8. /or e"a!le when %1%%1%1% is trans!itted then for even arity
an % will be aended to the data and for odd arity a 1 will be aended. This
sche!e can detect only single bits. So if two or !ore bits are changed then that
can not be detected.
Lon#itudinal *edundancy Check!u):
'ongitudinal 5edundancy ;hecksu! is an error detecting sche!e which
overco!es the roble! of two erroneous bits. In this concetof arity bit is used
but with slightly !ore intelligence. #ith each byte we send one arity bit then
send one additional byte which have the arity corresonding to the each bit
osition of the sent bytes. So the arity bit is set in both hori9ontal and vertical
direction. If one bit get flied we can tell which row and colu!n have error then
we find the intersection of the two and deter!ine the erroneous bit. If ( bits are in
error and they are in the different colu!n and row then they can be detected. If the
error are in the sa!e colu!n then the row will differentiate and vice versa. &arity
can detect the only odd nu!ber of errors. If they are even and distributed in a
fashion that in all direction then '5; !ay not be able to find the error.
Cyclic *edundancy Check!u) 0C*C1:
#e have an n-bit !essage. The sender adds a k-bit /ra!e ;heck Se6uence 7/;S8
to this !essage before sending. The resulting 7n2k8 bit !essage is divisible by
so!e 7k2%8 bit nu!ber. The receiver divides the !essage 77n2k8-bit8 by the sa!e
7k2%8-bit nu!ber and if there is no re!ainder, assu!es that there was no error.
.ow do we choose this nu!berP
/or e"a!le, if kF%( then %111111111111 7%*-bit nu!ber8 can be chosen, but
this is a retty cray choice. 4ecause it will result in a 9ero re!ainder for all
7n2k8 bit !essages with the last %( bits 9ero. Thus, any bits fliing beyond the
last %( go undetected. If kF%(, and we take %%%111%111%%1 as the %*-bit nu!ber
7incidentally, in deci!al reresentation this turns out to be 7(*I8. This will be
unable to detect errors only if the corrut !essage and original !essage have a
difference of a !ultile of 7(*I. The robablilty of this is low, !uch lower than
the robability that anything beyond the last %(-bits flis. In ractice, this nu!ber
is chosen after analy9ing co!!on network trans!ission errors and then selecting
a nu!ber which is likely to detect these co!!on errors.
(ow to detect sorce errors.
In order ensure that the fra!es are delivered correctly, the receiver should infor! the
sender about inco!ing fra!es using ositive or negative acknowledge!ents. On the
sender0s side the receit of a ositive acknowledge!ent i!lies that the fra!e has arrived
at the destination safely while the receit of a negative acknowledge!ent !eans that an
error has occurred in the fra!e and it needs to be retrans!itted. .owever, this sche!e is
too si!listic because if a noise burst causes the fra!e to vanish co!letely, the receiver
will not resond at all and the sender would hang forever waiting for an
acknowledge!ent. To overco!e this drawback, ti!ers are introduced into the data link
layer. #hen the sender trans!its a fra!e it also si!ultaneously starts a ti!er. The ti!er is
set to go off after a interval long enough for the fra!e to reach the destination, be
rocessed there, and have the acknowledge!ent roogate back to the sender. If the
fra!e is received correctly the ositive acknowledg!ent arrives before the ti!er runs out
and so the ti!er is canceled. If however either the fra!e or the acknowledge!ent is lost
the ti!er will go off and the sender !ay retrans!it the fra!e. Since !ultile trans!ission
of fra!es can cause the receiver to accet the sa!e fra!e and ass it to the network layer
!ore than once, se6uence nu!bers are generally assigned to the outgoing fra!es.
The tyes of acknowledge!ents that are sent can be classified as follows$
;u!ulative acknowledge!ents$ A single acknowledge!ent infor!ing the sender
that all the fra!es uto a certain nu!ber have been received.
Selective acknowledge!ents$ Acknowledge!ent for a articular fra!e.
They !ay be also classified as$
Individual acknowledge!ents$ Individual acknowledge!ent for each fra!e.
Brou acknowledge!ents$ A bit-!a that secifies the acknowledge!ents of a
range of fra!e nu!bers.
6low Control
;onsider a situation in which the sender trans!its fra!es faster than the receiver can
accet the!. If the sender kees u!ing out fra!es at high rate, at so!e oint the
receiver will be co!letely swa!ed and will start losing so!e fra!es. This roble!
!ay be solved by introducing flow control. Aost flow control rotocols contain a
feedback !echanis! to infor! the sender when it should trans!it the ne"t fra!e.
,echani!)! .or .low Control:
Stop and ait %rotocol: This is the si!lest file control rotocol in which the
sender trans!its a fra!e and then waits for an acknowledge!ent, either ositive
or negative, fro! the receiver before roceeding. If a ositive acknowledge!ent
is received, the sender trans!its the ne"t acket= else it retrans!its the sa!e
fra!e. .owever, this rotocol has one !a>or flaw in it. If a acket or an
acknowledge!ent is co!letely destroyed in transit due to a noise burst, a
deadlock will occur because the sender cannot roceed until it receives an
acknowledge!ent. This roble! !ay be solved using ti!ers on the sender0s side.
#hen the fra!e is trans!itted, the ti!er is set. If there is no resonse fro! the
receiver within a certain ti!e interval, the ti!er goes off and the fra!e !ay be
retrans!itted.
Slidin# indow %rotocol!: Insite of the use of ti!ers, the sto and wait
rotocol still suffers fro! a few drawbacks. /irstly, if the receiver had the
caacity to accet !ore than one fra!e, its resources are being underutili9ed.
Secondly, if the receiver was busy and did not wish to receive any !ore ackets,
it !ay delay the acknowledge!ent. .owever, the ti!er on the sender0s side !ay
go off and cause an unnecessary retrans!ission. These drawbacks are overco!e
by the sliding window rotocols.
In sliding window rotocols the sender0s data link layer !aintains a 0sending
window0 which consists of a set of se6uence nu!bers corresonding to the fra!es
it is er!itted to send. Si!ilarly, the receiver !aintains a 0receiving window0
corresonding to the set of fra!es it is er!itted to accet. The window si9e is
deendent on the retrans!ission olicy and it !ay differ in values for the
receiver0s and the sender0s window. The se6uence nu!bers within the sender0s
window reresent the fra!es sent but as yet not acknowledged. #henever a new
acket arrives fro! the network layer, the uer edge of the window is advanced
by one. #hen an acknowledge!ent arrives fro! the receiver the lower edge is
advanced by one. The receiver0s window corresonds to the fra!es that the
receiver0s data link layer !ay accet. #hen a fra!e with se6uence nu!ber e6ual
to the lower edge of the window is received, it is assed to the network layer, an
acknowledge!ent is generated and the window is rotated by one. If however, a
fra!e falling outside the window is received, the receiver0s data link layer has two
otions. It !ay either discard this fra!e and all subse6uent fra!es until the
desired fra!e is received or it !ay accet these fra!es and buffer the! until the
aroriate fra!e is received and then ass the fra!es to the network layer in
se6uence.
In this si!le e"a!le, there is a +-byte sliding window. Aoving fro! left to
right, the window <slides< as bytes in the strea! are sent and acknowledged.
Aost sliding window rotocols also e!loy A5L 7 Auto!atic 5eeat reLuest 8
!echanis!. In A5L, the sender waits for a ositive acknowledge!ent before
roceeding to the ne"t fra!e. If no acknowledge!ent is received within a certain
ti!e interval it retrans!its the fra!e. A5L is of two tyes $
%. 2o $ack HnH: If a fra!e is lost or received in error, the receiver !ay
si!ly discard all subse6uent fra!es, sending no acknowledg!ents for the
discarded fra!es. In this case the receive window is of si9e %. Since no
acknowledge!ents are being received the sender0s window will fill u, the
sender will eventually ti!e out and retrans!it all the unacknowledged
fra!es in order starting fro! the da!aged or lost fra!e. The !a"i!u!
window si9e for this rotocol can be obtained as follows. Assu!e that the
window si9e of the sender is n. So the window will initially contain the
fra!es with se6uence nu!bers fro! 1 to 7w-%8. ;onsider that the sender
trans!its all these fra!es and the receiver0s data link layer receives all of
the! correctly. .owever, the sender0s data link layer does not receive any
acknowledge!ents as all of the! are lost. So the sender will retrans!it all
the fra!es after its ti!er goes off. .owever the receiver window has
already advanced to w. .ence to avoid overla , the su! of the two
windows should be less than the se6uence nu!ber sace.
w-> : > I Se4uence Nu)ber Space
i<e<; w I Se4uence Nu)ber Space
,axi)u) indow Si/e E Se4uence Nu)ber Space - >
(. Selecti+e *epeat:In this rotocol rather than discard all the subse6uent
fra!es following a da!aged or lost fra!e, the receiver0s data link layer
si!ly stores the! in buffers. #hen the sender does not receive an
acknowledge!ent for the first fra!e it0s ti!er goes off after a certain ti!e
interval and it retrans!its only the lost fra!e. Assu!ing error - free
trans!ission this ti!e, the sender0s data link layer will have a se6uence of
a !any correct fra!es which it can hand over to the network layer. Thus
there is less overhead in retrans!ission than in the case of Bo 4ack n
rotocol.
In case of selective reeat rotocol the window si9e !ay be calculated as
follows. Assu!e that the si9e of both the sender0s and the receiver0s
window is w. So initially both of the! contain the values 1 to 7w-%8.
;onsider that sender0s data link layer trans!its all the w fra!es, the
receiver0s data link layer receives the! correctly and sends
acknowledge!ents for each of the!. .owever, all the acknowledge!nets
are lost and the sender does not advance it0s window. The receiver window
at this oint contains the values w to 7(w-%8. To avoid overla when the
sender0s data link layer retrans!its, we !ust have the su! of these two
windows less than se6uence nu!ber sace. .ence, we get the condition
,axi)u) indow Si/e E Se4uence Nu)ber Space - @
Network Layer
"hat is Network Layer.
The network layer is concerned with getting ackets fro! the source all the way to the
destination. The ackets !ay re6uire to !ake !any hos at the inter!ediate routers while
reaching the destination. This is the lowest layer that deals with end to end trans!ission.
In order to achieve its goals, the network layer !ust know about the toology of the
co!!unication network. It !ust also take care to choose routes to avoid overloading of
so!e of the co!!unication lines while leaving others idle. The network layer-transort
layer interface fre6uently is the interface between the carrier and the custo!er, that is the
boundary of the subnet. The functions of this layer include $
%. 5outing - The rocess of transferring ackets received fro! the )ata 'ink 'ayer
of the source network to the )ata 'ink 'ayer of the correct destination network is
called routing. Involves decision !aking at each inter!ediate node on where to
send the acket ne"t so that it eventually reaches its destination. The node which
!akes this choice is called a router. /or routing we re6uire so!e !ode of
addressing which is recogni9ed by the Network 'ayer. This addressing is different
fro! the AA; layer addressing.
(. Inter-networking - The network layer is the sa!e across all hysical networks
7such as Token-5ing and :thernet8. Thus, if two hysically different networks
have to co!!unicate, the ackets that arrive at the )ata 'ink 'ayer of the node
which connects these two hysically different networks, would be stried of
their headers and assed to the Network 'ayer. The network layer would then
ass this data to the )ata 'ink 'ayer of the other hysical network..
*. ;ongestion ;ontrol - If the inco!ing rate of the ackets arriving at any router is
!ore than the outgoing rate, then congestion is said to occur. ;ongestion !ay be
caused by !any factors. If suddenly, ackets begin arriving on !any inut lines
and all need the sa!e outut line, then a 6ueue will build u. If there is
insufficient !e!ory to hold all of the!, ackets will be lost. 4ut even if routers
have an infinite a!ount of !e!ory, congestion gets worse, because by the ti!e
ackets reach to the front of the 6ueue, they have already ti!ed out 7reeatedly8,
and dulicates have been sent. All these ackets are dutifully forwarded to the
ne"t router, increasing the load all the way to the destination. Another reason for
congestion are slow rocessors. If the router0s ;&Cs are slow at erfor!ing the
bookkeeing tasks re6uired of the!, 6ueues can build u, even though there is
e"cess line caacity. Si!ilarly, low-bandwidth lines can also cause congestion.
#e will now look at these function one by one.
Addre!!in# Sche)e
I& addresses are of + bytes and consist of $
i8 The network address, followed by
ii8 The host address
The first art identifies a network on which the host resides and the second art identifies
the articular host on the given network. So!e nodes which have !ore than one interface
to a network !ust be assigned searate internet addresses for each interface. This !ulti-
layer addressing !akes it easier to find and deliver data to the destination. A fi"ed si9e
for each of these would lead to wastage or under-usage that is either there will be too
!any network addresses and few hosts in each 7which causes roble!s for routers who
route based on the network address8 or there will be very few network addresses and lots
of hosts 7which will be a waste for s!all network re6uire!ents8. Thus, we do away with
any notion of fi"ed si9es for the network and host addresses.
#e classify networks as follows$
%. Lar#e Network! : I-bit network address and (+-bit host address. There are
aro"i!ately %- !illion hosts er network and a !a"i!u! of %(- 7 (K7 - ( 8
;lass A networks can be defined. The calculation re6uires that ( be subtracted
because 1.1.1.1 is reserved for use as the default route and %(7.1.1.1 be reserved
for the loo back function. Aoreover each ;lass A network can suort a
!a"i!u! of %-,777,(%+ 7(K(+ - (8 hosts er network. The host calculation
re6uires that ( be subtracted because all 10s are reserved to identify the network
itself and all %s are reserved for broadcast addresses. The reserved nu!bers !ay
not be assigned to individual hosts.
(. ,ediu) Network! : %--bit network address and %--bit host address. There are
aro"i!ately -,111 hosts er network and a !a"i!u! of %-,*I+ 7(K%+8 ;lass 4
networks can be defined with u to 7(K%--(8 hosts er network.
*. S)all network! : (+-bit network address and I-bit host address. There are
aro"i!ately (,1 hosts er network.
Rou !ight think that 'arge and Aediu! networks are sort of a waste as few
cororations?organi9ations are large enough to have -,111 different hosts. 74y the way,
there are very few cororations in the world with even close to -,111 e!loyees, and
even in these cororations it is highly unlikely that each e!loyee has his?her own
co!uter connected to the network.8 #ell, if you think so, you0re right. This decision
see!s to have been a !istak
Addre!! Cla!!e!
The I& secifications divide addresses into the following classes $
;lass A - /or large networks
1 7 bits of the network address (+ bits of host address

;lass 4 - /or !ediu! networks
% 1 %+ bits of the network address %- bits of host address

;lass ; - /or s!all networks
% % 1 (% bits of the network address I bits of host address

;lass ) - /or !ulti-cast !essages 7 !ulti-cast to a <grou< of networks 8
% % % 1 (I bits for so!e sort of grou address

;lass : - ;urrently unused, reserved for otential uses in the future
% % % % (I bits

Internet Protocol
Secial Addresses $ There are so!e secial I& addresses $
%. 4roadcast Addresses They are of two tyes $
7i8 'i!ited 4roadcast $ It consists of all %0s, i.e., the address is (,,.(,,.(,,.(,, .
It is used only on the 'AN, and not for any e"ternal network.
7ii8 )irected 4roadcast $ It consists of the network nu!ber 2 all other bits as%0s. It
reaches the router corresonding to the network nu!ber, and fro! there it
broadcasts to all the nodes in the network. This !ethod is a !a>or security
roble!, and is not used any!ore. So now if we find that all the bits are % in the
host no. field, then the acket is si!ly droed. Therefore, now we can only do
broadcast in our own network using 'i!ited 4roadcast.
(. Network I) F 1
It !eans we are referring to this network and for local broadcast we !ake the host
I) 9ero.
*. .ost I) F 1
This is used to refer to the entire network in the routing table.
+. 'oo-back Address
.ere we have addresses of the tye %(7.".y.9 It goes down way uto the I& layer
and co!es back to the alication layer on the sa!e host. This is used to test
network alications before they are used co!!ercially.
Subnettin#
Sub netting !eans organi9ing hierarchies within the network by dividing the host I) as
er our network. /or e"a!le consider the network I) $ %,1.(J.".y
#e could organi9e the re!aining %- bits in any way, like $
+ bits - deart!ent
+ bits - 'AN
I bits - host
This gives so!e structure to the host I)s. This division is not visible to the outside world.
They still see >ust the network nu!ber, and host nu!ber 7as a whole8. The network will
have an internal routing table which stores infor!ation about which router to send an
address to. Now consider the case where we have $ I bits - subnet nu!ber, and I bits -
host nu!ber. :ach router on the network !ust know about all subnet nu!bers. This is
called the subnet !ask. #e ut the network nu!ber and subnet nu!ber bits as % and the
host bits as 1. Therefore, in this e"a!le the subnet !ask beco!es $ (,,.(,,.(,,.1 . The
hosts also need to know the subnet !ask when they send a acket. To find if two
addresses are on the sa!e subnet, we can AN) source address with subnet !ask, and
destination address with with subnet !ask, and see if the two results are the sa!e. The
basic reason for sub netting was avoiding broadcast. 4ut if at the lower level, our
switches are s!art enough to send directed !essages, then we do not need sub netting.
.owever, sub netting has so!e security related advantages.
Supernettin#
This is !oving towards class-less addressing. #e could say that the network nu!ber is
(% bits 7 for I class ; networks 8 or say that it is (+ bits and 7 nu!bers following that.
/or e"a!le $ a.b.c.d ? (% This !eans only look at the first (% bits as the network address.
Addre!!in# on II(& Network
If we do not have connection with the outside world directly then we could have &rivate
I& addresses 7 %7(.*% 8 which are not to be ublicised and routed to the outside world.
Switches will !ake sure that they do not broadcast ackets with such addressed to the
outside world. The basic reason for i!le!enting subnetting was to avoid broadcast. So
in our case we can have so!e subnets for security and other reasons although if the
switches could do the routing roerly, then we do not need subnets. In the IITD network
we have three subnets -;;, ;S: building are two subnets and the rest of the ca!us is
one subset
%acket Structure
3ersion
Nu!ber
7+ bits8
.eader
'ength
7+ bits8
Tye of
Service 7I
bits8
Total 'ength 7%- bits8
I) 7%- bits8
/lags
7*bits8
/lag Offset 7%* bits8
Ti!e To 'ive
7I bits8
&rotocol 7I
bits8
.eader ;hecksu! 7%-
bits8
Source 7*( bits8
)estination 7*( bits8
Otions
Version Number : The current version is 3ersion + 71%118.
%. Header Len#th : #e could have !ultile si9ed headers so we need this field.
.eader will always be a !ultile of +bytes and so we can have a !a"i!u! length
of the field as %,, so the !a"i!u! si9e of the header is -1 bytes 7 (1 bytes are
!andatory 8.
(. (ype Of Ser+ice 0(oS1 : This hels the router in taking the right routing
decisions. The structure is $
.ir!t three bit! : They secify the recedences i.e. the riority of the ackets.
Next three bit! :
o ) bit - ) stands for delay. If the ) bit is set to %, then this !eans that the
alication is delay sensitive, so we should try to route the acket with
!ini!u! delay.
o T bit - T stands for throughut. This tells us that this articular oeration is
throughut sensitive.
o 5 bit - 5 stands for reliability. This tells us that we should route this acket
through a !ore reliable network.
La!t two bit!: The last two bits are never used. Cnfortunately, no router in this
world looks at these bits and so no alication sets the! nowadays. The second
word is !eant for handling frag!entations. If a link cannot trans!it large ackets,
then we frag!ent the acket and ut sufficient infor!ation in the header for
recollection at the destination.
*. I' .ield : The source and I) field together will reresent the frag!ents of a
uni6ue acket. So each frag!ent will have a different I).
+. Off!et : It is a %* bit field that reresents where in the acket, the current
frag!ent starts. :ach bit reresents I bytes of the acket. So the acket si9e can
be at !ost -+ k4. :very frag!ent e"cet the last one !ust have its si9e in bytes as
a !ultile of I in order to ensure co!liance with this structure. The reason why
the osition of a frag!ent is given as an offset value instead of si!ly nu!bering
each acket is because refrag!entation !ay occur so!ewhere on the ath to the
other node. /rag!entation, though suorted by I&v+ is not encouraged. This is
because if even one frag!ent is lost the entire acket needs to be discarded. A
6uantity A.T.C 7Aa"i!u! Trans!ission Cnit8 is defined for each link in the
route. It is the si9e of the largest acket that can be handled by the link. The &ath-
A.T.C is then defined as the si9e of the largest acket that can be handled by the
ath. It is the s!allest of all the ATCs along the ath. Biven infor!ation about
the ath ATC we can send ackets with si9es s!aller than the ath ATC and thus
revent frag!entation. This will not co!letely revent it because routing tables
!ay change leading to a change in the ath.
,. .la#! :It has three bits -
o A bit $ If A is one, then there are !ore frag!ents on the way and if A is
1, then it is the last frag!ent
o )/ bit $ If this bit is sent to %, then we should not frag!ent such a acket.
o 5eserved bit $ This bit is not used.
5easse!bly can be done only at the destination and not at any inter!ediate node.
This is because we are considering )atagra! Service and so it is not guaranteed
that all the frag!ents of the acket will be sent thorough the node at which we
wish to do reasse!bly.
-. (otal Len#th : It includes the I& header and everything that co!es after it.
7. (i)e (o Li+e 0((L1 : Csing this field, we can set the ti!e within which the
acket should be delivered or else destroyed. It is strictly treated as the nu!ber of
hos. The acket should reach the destination in this nu!ber of hos. :very
router decreases the value as the acket goes through it and if this value beco!es
9ero at a articular router, it can be destroyed.
I. %rotocol : This secifies the !odule to which we should hand over the acket
7 C)& or T;& 8. It is the ne"t encasulated rotocol.
3alue &rotocol
1 &v- .o-by-.o Otion.
% I;A&, Internet ;ontrol Aessage &rotocol.
( IBA&, Internet Brou Aanage!ent &rotocol. 5BA&,
5outer-ort Brou Aanage!ent &rotocol.
* BB&, Bateway to Bateway &rotocol.
+ I& in I& encasulation.
, ST, Internet Strea! &rotocol.
- T;&, Trans!ission ;ontrol &rotocol.
7 C;', ;4T.
I :B&, :"terior Bateway &rotocol.
J IB5&.
%1 44N 5;; Aonitoring.
%% N3&, Network 3oice &rotocol.
%( &C&.
%* A5BCS.
%+ :A;ON, :!ission ;ontrol &rotocol.
%, QN:T, ;ross Net )ebugger.
%- ;haos.
%7 C)&, Cser )atagra! &rotocol.
%I TAu", Transort Aultile"ing &rotocol.
%J );N Aeasure!ent Subsyste!s.
-
-
(,,
J. Header Check!u) : This is the usual checksu! field used to detect errors. Since
the TT' field is changing at every router so the header checksu! 7 uto the
otions field 8 is checked and recalculated at every router.
%1. Source : It is the I& address of the source node
%%. 'e!tination : It is the I& address of the destination node.
%(. I% Option! : The otions field was created in order to allow features to be added
into I& as ti!e asses and re6uire!ents change. ;urrently , otions are secified
although not all routers suort the!. They are$
o Securtiy: It tells us how secret the infor!ation is. In theory a !ilitary
router !ight use this field to secify not to route through certain routers.
In ractice no routers suort this field.
o Source *outin#: It is used when we want the source to dictate how the
acket traverses the network. It is of ( tyes
-C Loo!e Source *ecord *outin# 0LS**1: It re6uires that the acket
traverse a list of secified routers, in the order secified but the acket
!ay ass though so!e other routers as well.
-C Strict Source *ecord *outin# 0SS**1: It re6uires that the acket
traverse only the set of secified routers and nothing else. If it is not
ossible, the acket is droed with an error !essage sent to the host.
The above is the for!at for SS55. /or 'S55 the code is %*%.
o *ecord *outin# :
In this the inter!ediate routers ut there I& addresses in the header, so that
the destination knows the entire ath of the acket. Sace for storing the
I& address is secified by the source itself. The ointer field oints to the
osition where the ne"t I& address has to be written. 'ength field gives the
nu!ber of bytes reserved by the source for writing the I& addresses. If the
sace rovided for storing the I& addresses of the routers visited, falls
short while storing these addresses, then the subse6uent routers do not
write their I& addresses.
o (i)e Sta)p *outin# :
It is si!ilar to record route otion e"cet that nodes also add their
ti!esta!s to the acket. The new fields in this otion are
-C .la#!: It can have the following values
1- :nter only ti!esta!.
%- The nodes should enter Ti!esta! as well as their I&.
* - The source secifies the I&s that should enter their ti!esta!.
A secial oint of interest is that only if the I& is the sa!e as that at
the ointer then the ti!e is entered. Thus if the source secifies I&%
and I&( but I&( is first in the ath then the field I&( is left e!ty,
even after having reached I&( but before reaching I&%.
-C O+erflow: It stores the nu!ber of nodes that were unable to add their
ti!esta!s to the acket. The !a"i!u! value is %,.
o .or)at of the type-code field
;oy 4it Tye of otion Otion Nu!ber.
Copy bit: It says whether the otion is to be coied to every
frag!ent or not. a value of % stands for coying and 1 stands for
not coying.
(ype: It is a ( bit field. ;urrently secified values are 1 and (. 1
!eans the otion is a control otion while ( !eans the otion is for
!easure!ent
Option Nu)ber: It is a , bit field which secifies the otion
nu!ber.
/or all otions a length field is ut in order that a router not fa!iliar with
the otion will know how !any bytes to ski. Thus every otion is of the
for!
o (LB: (ype-Len#th-Balue< This for!at is followed in not only in I& but in
nearly all !a>or rotocols.
Network Layer 0Continued<<<1
The network layer is concerned with getting ackets fro! the source all the way to the
destnation. The ackets !ay re6uire to !ake !any hos at the inter!ediate routers while
reaching the destination. This is the lowest layer that deals with end to end trans!ission.
In order to achieve its goals, the network later !ust know about the toology of the
co!!unication network. It !ust also take care to choose routes to avoid overloading of
so!e of the co!!unication lines while leaving others idle. The !ain functions
erfor!ed by the network layer are as follows$
5outing
;ongestion ;ontrol
Internetwokring
Rotin#
5outing is the rocess of forwarding of a acket in a network so that it reaches its
intended destination. The !ain goals of routing are$
%. Correctne!!: The routing should be done roerly and correctly so that the
ackets !ay reach their roer destination.
(. Si)plicity: The routing should be done in a si!le !anner so that the overhead is
as low as ossible. #ith increasing co!le"ity of the routing algorith!s the
overhead also increases.
*. *obu!tne!!: Once a !a>or network beco!es oerative, it !ay be e"ected to run
continuously for years without any failures. The algorith!s designed for routing
should be robust enough to handle hardware and software failures and should be
able to coe with changes in the toology and traffic without re6uiring all >obs in
all hosts to be aborted and the network rebooted every ti!e so!e router goes
down.
+. Stability: The routing algorith!s should be stable under all ossible
circu!stances.
,. .airne!!: :very node connected to the network should get a fair chance of
trans!itting their ackets. This is generally done on a first co!e first serve basis.
-. Opti)ality: The routing algorith!s should be oti!al in ter!s of throughut and
!ini!i9ing !ean acket delays. .ere there is a trade-off and one has to choose
deending on his suitability.
Classification of Rotin# Al#orithms
The routing algorith!s !ay be classified as follows$
%. Adapti+e *outin# Al#orith): These algorith!s change their routing decisions
to reflect changes in the toology and in traffic as well. These get their routing
infor!ation fro! ad>acent routers or fro! all routers. The oti!i9ation
ara!eters are the distance, nu!ber of hos and esti!ated transit ti!e. This can
be further classified as follows$
%. Centrali/ed: In this tye so!e central node in the network gets entire
infor!ation about the network toology, about the traffic and about other
nodes. This then trans!its this infor!ation to the resective routers. The
advantage of this is that only one node is re6uired to kee the infor!ation.
The disadvantage is that if the central node goes down the entire network
is down, i.e. single oint of failure.
(. I!olated: In this !ethod the node decides the routing without seeking
infor!ation fro! other nodes. The sending node does not know about the
status of a articular link. The disadvantage is that the acket !ay be send
through a congested route resulting in a delay. So!e e"a!les of this tye
of algorith! for routing are$
Hot %otato: #hen a acket co!es to a node, it tries to get rid of it
as fast as it can, by utting it on the shortest outut 6ueue without
regard to where that link leads. A variation of this algorith! is to
co!bine static routing with the hot otato algorith!. #hen a
acket arrives, the routing algorith! takes into account both the
static weights of the links and the 6ueue lengths.
$ackward Learnin#: In this !ethod the routing tables at each
node gets !odified by infor!ation fro! the inco!ing ackets. One
way to i!le!ent backward learning is to include the identity of
the source node in each acket, together with a ho counter that is
incre!ented on each ho. #hen a node receives a acket in a
articular line, it notes down the nu!ber of hos it has taken to
reach it fro! the source node. If the revious value of ho count
stored in the node is better than the current one then nothing is
done but if the current value is better then the value is udated for
future use. The roble! with this is that when the best route goes
down then it cannot recall the second best route to a articular
node. .ence all the nodes have to forget the stored infor!ations
eriodically and start all over again.
*. 'i!tributed: In this the node receives infor!ation fro! its neighbouring
nodes and then takes the decision about which way to send the acket. The
disadvantage is that if in between the the interval it receives infor!ation
and sends the aket so!ething changes then the acket !ay be delayed.
(. Non-Adapti+e *outin# Al#orith): These algorith!s do not base their routing
decisions on !easure!ents and esti!ates of the current traffic and toology.
Instead the route to be taken in going fro! one node to the other is co!uted in
advance, off-line, and downloaded to the routers when the network is booted. This
is also known as static routing. This can be further classified as$
%. .loodin#: /looding adats the techni6ue in which every inco!ing acket
is sent on every outgoing line e"cet the one on which it arrived. One
roble! with this !ethod is that ackets !ay go in a loo. As a result of
this a node !ay receive several coies of a articular acket which is
undesirable. So!e techni6ues adated to overco!e these roble!s are as
follows$
Se4uence Nu)ber!: :very acket is given a se6uence nu!ber.
#hen a node receives the acket it sees its source address and
se6uence nu!ber. If the node finds that it has sent the sa!e acket
earlier then it will not trans!it the acket and will >ust discard it.
Hop Count: :very acket has a ho count associated with it. This
is decre!ented7or incre!ented8 by one by each node which sees it.
#hen the ho count beco!es 9ero7or a !a"i!u! ossible value8
the acket is droed.
Spannin# (ree: The acket is sent only on those links that lead to
the destination by constructing a sanning tree routed at the source.
This avoids loos in trans!ission but is ossible only when all the
inter!ediate nodes have knowledge of the network toology.
/looding is not ractical for general kinds of alications. 4ut in cases
where high degree of robustness is desired such as in !ilitary alications,
flooding is of great hel.
(. *ando) alk: In this !ethod a acket is sent by the node to one of its
neighbours rando!ly. This algorith! is highly robust. #hen the network
is highly interconnected, this algorith! has the roerty of !aking
e"cellent use of alternative routes. It is usually i!le!ented by sending
the acket onto the least 6ueued link.
Delta Rotin#
)elta routing is a hybrid of the centrali9ed and isolated routing algorith!s. .ere each
node co!utes the cost of each line 7i.e so!e functions of the delay, 6ueue length,
utili9ation, bandwidth etc8 and eriodically sends a acket to the central node giving it
these values which then co!utes the k best aths fro! node i to node J. 'et CiJ> be the
cost of the best i-J ath, CiJ@ the cost of the ne"t best ath and so on.If CiJn - CiJ> I
delta, 7CiJn - cost of nHth best i-J ath, delta is so!e constant8 then ath n is regarded
e6uivalent to the best i-J ath since their cost differ by so little. #hen delta -C ? this
algorith! beco!es centrali9ed routing and when delta -C infinity all the aths beco!e
e6uivalent.
Mltipath Rotin#
In the above algorith!s it has been assu!ed that there is a single best ath between any
air of nodes and that all traffic between the! should use it. In !any networks however
there are several aths between airs of nodes that are al!ost e6ually good. So!eti!es in
order to i!rove the erfor!ance !ultile aths between single air of nodes are used.
This techni6ue is called !ultiath routing or bifurcated routing. In this each node
!aintains a table with one row for each ossible destination node. A row gives the best,
second best, third best, etc outgoing line for that destination, together with a relative
weight. 4efore forwarding a acket, the node generates a rando! nu!ber and then
chooses a!ong the alternatives, using the weights as robabilities. The tables are worked
out !anually and loaded into the nodes before the network is brought u and not changed
thereafter.
(ierarchical Rotin#
In this !ethod of routing the nodes are divided into regions based on hierarchy. A
articular node can co!!unicate with nodes at the sa!e hierarchial level or the nodes at
a lower level and directly under it. .ere, the ath fro! any source to a destination is fi"ed
and is e"actly one if the heirarchy is a tree.
*outin# Al#orith)!
Non1(ierarchical Rotin#
In this tye of routing, interconnected networks are viewed as a single network, where
bridges, routers and gateways are >ust additional nodes.
:very node kees infor!ation about every other node in the network
In case of adative routing, the routing calculations are done and udated for all
the nodes.
The above two are also the disadvantages of non-hierarchical routing, since the table
si9es and the routing calculations beco!e too large as the networks get bigger. So this
tye of routing is feasible only for s!all networks.
(ierarchical Rotin#
This is essentially a 0)ivide and ;on6uer0 strategy. The network is divided into different
regions and a router for a articular region knows only about its own do!ain and other
routers. Thus, the network is viewed at two levels$
%. The Sub-network level, where each node in a region has infor!ation about its
eers in the sa!e region and about the region0s interface with other regions.
)ifferent regions !ay have different 0local0 routing algorith!s. :ach local
algorith! handles the traffic between nodes of the sa!e region and also directs
the outgoing ackets to the aroriate interface.
(. The Network 'evel, where each region is considered as a single node connected
to its interface nodes. The routing algorith!s at this level handle the routing of
ackets between two interface nodes, and is isolated fro! intra-regional transfer.
Networks can be organi9ed in hierarchies of !any levels= e.g. local networks of a city at
one level, the cities of a country at a level above it, and finally the network of all nations.
In .ierarchical routing, the interfaces need to store infor!ation about$
All nodes in its region which are at one level below it.
Its eer interfaces.
At least one interface at a level above it, for outgoing ackages.
Advantages of .ierarchical 5outing $
S!aller si9es of routing tables.
Substantially lesser calculations and udates of routing tables.
)isadvantage $
Once the hierarchy is i!osed on the network, it is followed and ossibility of
direct aths is ignored. This !ay lead to sub oti!al routing.
Sorce Rotin#
Source routing is si!ilar in concet to virtual circuit routing. It is i!le!ented as under$
Initially, a ath between nodes wishing to co!!unicate is found out, either by
flooding or by any other suitable !ethod.
This route is then secified in the header of each acket routed between these two
nodes. A route !ay also be secified artially, or in ter!s of so!e inter!ediate
hos.
Advantages$
4ridges do not need to looku their routing tables since the ath is already
secified in the acket itself.
The throughut of the bridges is higher, and this !ay lead to better utili9ation of
bandwidth, once a route is established.
)isadvantages$
:stablishing the route at first needs an e"ensive search !ethod like flooding.
To coe u with dyna!ic relocation of nodes in a network, fre6uent udates of
tables are re6uired, else all ackets would be sent in wrong direction. This too is
e"ensive.
Policy !ased Rotin#
In this tye of routing, certain restrictions are ut on the tye of ackets acceted and
sent. e.g.. The IIT- D router !ay decide to handle traffic ertaining to its deart!ents
only, and re>ect ackets fro! other routes. This kind of routing is used for links with very
low caacity or for security uroses.
Shortest Path Rotin#
.ere, the central 6uestion dealt with is 0.ow to deter!ine the oti!al ath for routing P0
3arious algorith!s are used to deter!ine the oti!al routes with resect to so!e
redeter!ined criteria. A network is reresented as a grah, with its ter!inals as nodes
and the links as edges. A 0length0 is associated with each edge, which reresents the cost
of using the link for trans!ission. 'ower the cost, !ore suitable is the link. The cost is
deter!ined deending uon the criteria to be oti!i9ed. So!e of the i!ortant ways of
deter!ining the cost are$
,ini)u) nu)ber of hop!: If each link is given a unit cost, the shortest ath is
the one with !ini!u! nu!ber of hos. Such a route is easily obtained by a
breadth first search !ethod. This is easy to i!le!ent but ignores load, link
caacity etc.
(ran!)i!!ion and %ropa#ation 'elay!: If the cost is fi"ed as a function of
trans!ission and roagation delays, it will reflect the link caacities and the
geograhical distances. .owever these costs are essentially static and do not
consider the varying load conditions.
Kueuin# 'elay!: If the cost of a link is deter!ined through its 6ueuing delays, it
takes care of the varying load conditions, but not of the roagation delays.
Ideally, the cost ara!eter should consider all the above !entioned factors, and it should
be udated eriodically to reflect the changes in the loading conditions. .owever, if the
routes are changed according to the load, the load changes again. This feedback effect
between routing and load can lead to undesirable oscillations and sudden swings.
Rotin# Al#orithms
As !entioned above, the shortest aths are calculated using suitable algorith!s on the
grah reresentations of the networks. 'et the network be reresented by grah B 7 3,
: 8 and let the nu!ber of nodes be 0N0. /or all the algorith!s discussed below, the costs
associated with the links are assu!ed to be ositive. A node has 9ero cost w.r.t itself.
/urther, all the links are assu!ed to be sy!!etric, i.e. if d
i,>
F cost of link fro! node i
to node >, then d
i,>
F d
>,i
. The grah is assu!ed to be co!lete. If there e"ists no edge
between two nodes, then a link of infinite cost is assu!ed. The algorith!s given below
find costs of the aths fro! all nodes to a articular node= the roble! is e6uivalent to
finding the cost of aths fro! a source to all destinations.
!ellman16ord Al#orithm
This algorith! iterates on the nu!ber of edges in a ath to obtain the shortest ath. Since
the nu!ber of hos ossible is li!ited 7cycles are i!licitly not allowed8, the algorith!
ter!inates giving the shortest ath.
Notation:
d
i,>
F 'ength of ath between nodes i and >, indicating the cost of the link.
h F Nu!ber of hos.
)M i,hN F Shortest ath length fro! node i to node %, with uto 0h0 hos.
)M %,hN F 1 for all h .

Al#orith) :

Initial condition $ )M i, 1N F infinity, for all i 7 i OF % 8
Iteration $ )Mi, h2%N F !in

V d
i,>
2 )M>,hN W over all values of > .
Ter!ination $ The algorith! ter!inates when
)Mi, hN F ) M i, h2%N for all i .
%rinciple:
/or 9ero hos, the !ini!u! length ath has length of infinity, for every node. /or one
ho the shortest-ath length associated with a node is e6ual to the length of the edge
between that node and node %. .ereafter, we incre!ent the nu!ber of hos allowed,
7fro! h to h2% 8 and find out whether a shorter ath e"ists through each of the other
nodes. If it e"ists, say through node 0>0, then its length !ust be the su! of the lengths
between these two nodes 7i.e. d
i,>
8 and the shortest ath between > and % obtainable in
uto h aths. If such a ath doesn0t e"ist, then the ath length re!ains the sa!e. The
algorith! is guaranteed to ter!inate, since there are ut!ost N nodes, and so N-% aths. It
has ti!e co!le"ity of O 7 N
*
8 .
Di;kstra<s Al#orithm
Notation:
)
i
F 'ength of shortest ath fro! node 0i0 to node %.
d
i,>
F 'ength of ath between nodes i and > .
Al#orith)
:ach node > is labeled with )>, which is an esti!ate of cost of ath fro! node > to node
%. Initially, let the esti!ates be infinity, indicating that nothing is known about the aths.
#e now iterate on the length of aths, each ti!e revising our esti!ate to lower values, as
we obtain the!. Actually, we divide the nodes into two grous = the first one, called set &
contains the nodes whose shortest distances have been found, and the other L containing
all the re!aining nodes. Initially & contains only the node %. At each ste, we select the
node that has !ini!u! cost ath to node %. This node is transferred to set &. At the first
ste, this corresonds to shifting the node closest to % in &. Its !ini!u! cost to node % is
now known. At the ne"t ste, select the ne"t closest node fro! set L and udate the
labels corresonding to each node using $
'
J
E )in L '
J
; '
i
: d
J;i
M
/inally, after N-% iterations, the shortest aths for all nodes are known, and the algorith!
ter!inates.

%rinciple
'et the closest node to % at so!e ste be i. Then i is shifted to &. Now, for each node > ,
the closest ath to % either asses through i or it doesn0t. In the first case )> re!ains the
sa!e. In the second case, the revised esti!ate of )
>
is the su! )
i
2 d
i,>
. So we take the
!ini!u! of these two cases and udate )
>
accordingly. As each of the nodes get
transferred to set &, the esti!ates get closer to the lowest ossible value. #hen a node is
transferred, its shortest ath length is known. So finally all the nodes are in & and the )
>
0s
reresent the !ini!u! costs. The algorith! is guaranteed to ter!inate in N-% iterations
and its co!le"ity is O7 N
(
8.
The 6loyd "arshall Al#orithm
This algorith! iterates on the set of nodes that can be used as inter!ediate nodes on
aths. This set grows fro! a single node 7 say node % 8 at start to finally all the nodes of
the grah. At each iteration, we find the shortest ath using given set of nodes as
inter!ediate nodes, so that finally all the shortest aths are obtained.
Notation
)
i,>
MnN F 'ength of shortest ath between the nodes i and > using only the nodes
%,(,....n as inter!ediate nodes.
Initial Condition
)i,>M1N F d
i,>
for all nodes i,> .
Al#orith)
Initially, n F 1. At each iteration, add ne"t node to n. i.e. /or n F %,(, .....N-% ,
)i,>Mn 2 %N F !in V )
i,>
MnN , )
i,n2%
MnN 2 )
n2%,>
MnN W
%rinciple
Suose the shortest ath between i and > using nodes %,(,...n is known. Now, if node n2%
is allowed to be an inter!ediate node, then the shortest ath under new conditions either
asses through node n2% or it doesn0t. If it does not ass through the node n2%, then
)
i,>
Mn2%N is sa!e as )
i,>
MnN . :lse, we find the cost of the new route, which is obtained
fro! the su!, )
i,n2%
MnN 2 )
n2%,>
MnN. So we take the !ini!u! of these two cases at each
ste. After adding all the nodes to the set of inter!ediate nodes, we obtain the shortest
aths between all airs of nodes together. The co!le"ity of /loyd-#arshall algorith!
is O 7 N
*
8.
It is observed that all the three algorith!s !entioned above give co!arable
erfor!ance, deending uon the e"act toology of the network.
A*%;*A*%;IC,% %rotocol!
Address Resoltion Protocol
If a !achine talks to another !achine in the sa!e network, it re6uires its hysical or
AA; address. 4ut ,since the alication has given the destination0s I& address it re6uires
so!e !echanis! to bind the I& address with its AA; address.This is done through
Address 5esolution rotocol 7A5&8.I& address of the destination node is broadcast and
the destination node infor!s the source of its AA; address.
%. Assu!e broadcast nature of 'AN
(. 4roadcast I& address of the destination
*. )estination relies it with its AA; address.
+. Source !aintains a cache of I& and AA; address bindings
4ut this !eans that every ti!e !achine A wants to send ackets to !achine 4, A has to
send an A5& acket to resolve the AA; address of 4 and hence this will increase the
traffic load too !uch, so to reduce the co!!unication cost co!uters that use A5&
!aintains a cache of recently ac6uired I&@to@AA; address bindings, i.e. they dont have
to use A5& reeatedly. A5& 5efine!ents Several refine!ents of A5& are ossible$ #hen
!achine A wants to send ackets to !acine 4, it is ossible that !achine 4 is going to
send ackets to !achine A in the near future.So to avoid A5& for !achine 4, A should
ut its I&@to@AA; address binding in the secial acket while re6uesting for the AA;
address of 4. Since A broadcasts its initial re6uest for the AA; address of 4, every
!achine on the network should e"tract and store in its cache the I&@to@AA; address
binding of A #hen a new !achine aears on the network 7e.g. when an oerating
syste! reboots8 it can broadcast its I&@to@AA; address binding so that all other
!achines can store it in their caches. This will eli!inate a lot of A5& ackets by all other
!achines, when they want to co!!unicate with this new !achine.
:"a!le dislaying the use of Address 5esolution &rotocol$
;onsider a scenario where a co!uter tries to contact so!e re!ote !achine using ing
rogra!, assu!ing that there has been no e"change of I& datagra!s reviously between
the two !achines and therefore ar acket !ust be sent to identify the AA; address of
the re!ote !achine.
The ar re6uest !essage 7who is A.A.A.A tell 4.4.4.4 where the two are I& addresses8 is
broadcast on the local area network with an :thernet rotocol tye 1"I1-. The acket is
discarded by all the !achines e"cet the target !achine which resonds with an ar
resonse !essage 7A.A.A.A is hh$hh$hh$hh$hh$hh where hh$hh$hh$hh$hh$hh is the
:thernet source address8. This acket is unicast to the !achine with I& address 4.4.4.4.
Since the ar re6uest !essage included the hardware address 7:thernet source address8 of
the re6uesting co!uter, target !achine doesn0t re6uire another ar !essage to figure it
out.
Re-erse Address Resoltion Protocol
5A5& is a rotocol by which a hysical !achine in a local area network can re6uest to
learn its I& address fro! a gateway server0s Address 5esolution &rotocol table or cache.
This is needed since the !achine !ay not have er!anently attacded disk where it can
store its I& address er!anently. A network ad!inistrator creates a table in a local area
network0s gateway router that !as the hysical !achine 7or Aediu! Access ;ontrol -
AA;8 addresses to corresonding Internet &rotocol addresses. #hen a new !achine is
set u, its 5A5& client rogra! re6uests fro! the 5A5& server on the router to be sent
its I& address. Assu!ing that an entry has been set u in the router table, the 5A5& server
will return the I& address to the !achine which can store it for future use.
)etailed Aechanis!
4oth the !achine that issues the re6uest and the server that resonds use hysical
network addresses during their brief co!!unication. Csually, the re6uester does not
know the hysical address. So, the re6uest is broadcasted to all the !achines on the
network. Now, the re6uester !ust identify istelf uni6uely to the server. /or this either
;&C serial nu!ber or the !achine0s hysical network address can be used. 4ut using the
hysical address as a uni6ue id has two advantages.
These addresses are always available and do not have to be bound into bootstra
code.
4ecause the identifying infor!ation deends on the network and not on the ;&C
vendor, all !achines on a given network will suly uni6ue identifiers.
*e4ue!t:
'ike an A5& !essage, a 5A5& !essage is sent fro! one !achine to the another
encasulated in the data ortion of a network fra!e. An ethernet fra!e carrying a 5A5&
re6uest has the usual rea!le, :thernet source and destination addresses, and acket tye
fields in front of the fra!e. The fra!e conatins the value I1*, 7base %-8 to identify the
contents of the fra!e as a 5A5& !essage. The data ortion of the fra!e contains the (I-
octet 5A5& !essage. The sender braodcasts a 5A5& re6uest that secifies itself as both
the sender and target !achine, and sulies its hysical network address in the target
hardware address field. All !achines on the network receive the re6uest, but only those
authorised to suly the 5A5& services rocess the re6uest and send a rely, such
!achines are known infor!ally as 5A5& servers. /or 5A5& to succeed, the network
!ust contain at least one 5A5& server.
*eply:
Servers answers re6uest by filling in the target rotocol address field, changing the
!essage tye fro! re6uest to rely, and sending the rely back directly to the !achine
!aking the re6uest.
(i)in# *A*% (ran!action!
Since 5A5& uses the hysical network directly, no other rotocol software will ti!e the
resonse or retrans!it the re6uest. 5A5& software !ust handle these tasks. So!e
workstations that rely on 5A5& to boot, choose to retry indefinitely until the receive a
resonse. Other i!le!entations announce failure after only a few tries to avoid flooding
the network with unnecessary broadcast.
,ulitple *A*% Ser+er!
Advantage$ Aore reliability. )iadvantage$ Overloading !ay result when all servers
resond. So, to get away with disadvantage we have ri!ary and secondary servers. :ach
!achine that !akes 5A5& re6uest is assigned a ri!ary server. Nor!ally, the ri!ary
server resonds but if it fails, then re6uester !ay ti!e out and rebroadcast the
re6uest.#henever a secondary server receives a second coy of the re6uest within a short
ti!e of the first, it resonds. 4ut, still there !ight be a roble! that all secondary servers
resond, thus overloading the network. So, the solution adoted is to avoid having all
secondary servers trans!it resonses si!ultaneously. :ach secondary server that receives
the re6uest co!utes a rando! delay and then sends a resonse.
'rawback! of *A*%
Since it oerates at low level, it re6uires direct addresss to the network which
!akes it difficult for an alication rogra!!er to build a server.
It doesn0t fully utili9es the caability of a network like ethernet which is enforced
to send a !ini!u! acket si9e since the rely fro! the server contains only one
s!all iece of infor!ation, the *(-bit internet address.
5A5& is for!ally described in 5/;J1*.
ICMP
This rotocol discusses a !echanis! that gateways and hosts use to co!!unicate control
or error infor!ation.The Internet rotocol rovides unreliable,connectionless datagra!
service,and that a datagra! travels fro! gateway to gateway until it reaches one that can
deliver it directly to its final destination. If a gateway cannot route or deliver a
datagra!,or if the gateway detects an unusual condition, like network congestion, that
affects its ability to forward the datagra!, it needs to instruct the original source to take
action to avoid or correct the roble!. The Internet ;ontrol Aessage &rotocol allows
gateways to send error or control !essages to other gateways or hosts=I;A& rovides
co!!unication between the Internet &rotocol software on one !achine and the Internet
&rotocol software on another. This is a secial urose !essage !echanis! added by the
designers to the T;&?I& rotocols. This is to allow gateways in an internet to reort errors
or rovide infor!ation about une"ecter circu!stances. The I& rotocol itself contains
nothing to hel the sender test connectivity or learn about failures.
"rror *eportin# +! "rror Correction
I;A& only reorts error conditions to the original source= the source !ust relate errors to
individual alication rogra!s and take action to correct roble!s. It rovides a way for
gateway to reort the error It does not fully secify the action to be taken for each
ossible error. I;A& is restricted to co!!unicate with the original source but not
inter!ediate sources.
IC,% ,e!!a#e 'eli+ery
I;A& !essages travel across the internet in the data ortion of an I& datagra!,which
itself travels across the internet in the data ortion of an I& datagra!,which itself travels
across each hysical network in the data ortion of a fra!e.)atagra!s carryin I;A&
!essages are routed e"actly like datagra!s carrying infor!ation for users=there is no
additional reliability or riority.An e"cetion is !ade to the error handling rocedures if
an I& datagra! carrying an I;A& !essages are not generated for errors that result fro!
datagra!s carrying I;A& error !essages.
IC,% ,e!!a#e .or)at
It has three fields=an I-bit integer !essage TR&: field that identifies the !essage,an I-bit
;O): field that rovides further infor!ation about the !essage tye,and a %--bit
;.:;DSCA field7I;A& uses the sa!e additive checksu! algorith! as I&,but the I;A&
checksu! only covers the I;A& !essage8.In addition , I;A& !essages that reort errors
always include the header and first -+ data bits of the datagra! causing the roble!. The
I;A& TR&: field defines the !eaning of the !essage as well as its for!at.
(he (ype! include :
(N%" .I"L' IC,% ,"SSA2" (N%"
1 :;.O 5:&'R
* ):STINATION CN5:A;.A4':
+ SOC5;: LC:N;.
, 5:)I5:;T7;.ANB: A 5OCT:8
I :;.O 5:LC:ST
%% TIA: :Q;::):) /O5 A )ATAB5AA
%( &A5AA:T:5 &5O4':A ON A )ATAB5AA
%* TIA:STAA& 5:LC:ST
%+ TIA:STAA& 5:&'R
%, IN/O5AATION 5:LC:ST7O4SO':T:8
%- IN/O5AATION 5:&'R7O4SO':T:8
%7 A))5:SS AASD 5:LC:ST
%I A))5:SS AASD 5:&'R T:STINB ):STINATION
*eachabilty and Statu! :
T;&?I& rotocols rovide facilities to hel network !anagers or users identify network
roble!s.One of the !ost fre6uently used debugging tools invokes the I;A& echo
re6uest and echo rely !essages.A host or gateway sends an I;A& echo re6uest !essage
to a secified destination.Any !achine that receives an echo re6uest for!ulates an echo
rely and returns to the original sender.The re6uest contains an otional data area= the
rely contains a coy of the data sent in the re6uest.The echo re6uest and associated rely
can be used to test whether a destination is reachable and resonding.4ecause both the
re6uest and rely travel in I& datagra!s,successful receit of a rely verifies that !a>or
ieces of the transort syste! work.
%.% $ I& software on the source !ust route the datagra!
(.( $ Inter!ediate gateways between the source and destination !ust be oerating and
!ust route datagra! correctly.
*.* $ The destination !achine !ust be running , and both I;A& and I& software !ust be
working.
+.+ $ 5outes in gateways along the return ath !ust be correct.
"cho *e4ue!t and *eply
The field listed O&TIONA' )ATA is a variable length field that contains data to be
returned to the sender.An echo rely always returns e"actly the sa!e data as was received
in the re6uest./ields I):NTI/I:5 and S:LC:N;: NCA4:5 are used by the sender to
!atch relies to re6uest.The value of the TR&: field secifies whether the !essage is a
re6uest7I8 or a rely718.
*eport! of 3nreachable 'e!tination!
The ;ode field in a destination unreachable !essage contains an integer that further
describes th roble!.&ossible values are $
CO'" BAL3" ,"ANIN2
1 N:T#O5D CN5:A;.A4':
% .OST CN5:A;.A4':
( &5OTO;O' CN5:A;.A4':
* &O5T CN5:A;.A4':
+ /5ABA:NTATION N::):) AN) )/ S:T
, SOC5;: 5OOT /AI':)
- ):STINATION N:T#O5D CNDNO#N
7 ):STINATION .OST CNDNO#N
I SOC5;: .OST ISO'AT:)
J ;OAACNI;ATION #IT. ):STINATION N:T#O5D
A)AINIST5ATI3:'R &5O.I4IT:)
%1 ;OAACNI;ATION #TT. ):STINATION .OST
A)AINIST5ATI3:'R &5O.I4IT:)
%% N:T#O5D CN5:A;.A4': /O5 TR&: O/ S:53I;:
%( .OST CN5:A;.A4': /O5 TR&: O/ S:53I;:
#henever an error revents a gateway fro! routing or delivering a datagra!, the
gateway sends a destination unreachable !essage back to the source and then dros the
datagra!.Network unreachable errors usually i!ly roting failures = host unreachable
errors i!ly delivery failures.4ecause the !essage contains a short refi" of the
datagra! that caused the roble!, the source will know e"actly which address is
unreachable. )estinations !ay be unreachable because hardware is te!orarily out of
service, because the sender secified a none"istent destination address, or because the
gateway does not have a route to the destination network. Although gateways send
destination unreachable !essages if they cannot route or deliver datagra!s, not all such
errors can be detected.If the datagra! contains the source route otion with an incorrect
route, it !ay trigger a source route failure !essage.If a gateway needs to frag!ent
adatagra! but the <don0t frag!ent< bit is set, the gateway sends a frag!entation needed
!essage back to the source.
Con#e!tion and 'ata#ra) .low Control :
Bateways cannot reserve !e!ory or co!!unication resources in advance of receiving
datagra!s because I& is connectionless. The result is, gateways can overrun with traffic, a
condition known as congestion.;ongestion arises due to two reasons $
%. A high seed co!uter !ay be able to generate traffic faster than a network can
transfer it .
(. If !any co!uters su!ultaneously need to send datagra!s through a single
gateway , the gateway can e"erience congestion, even though no single source
causes the roble!.
#hen datagra!s arrive too 6uickly for a host or a gateway to rocess, it en6ueues the!
in !e!ory te!orarily.If the traffic continues, the host or gateway eventually e"hausts
!enory ans !ust discard additional datagra!s that arrive. A !achine uses I;A& source
6uench !essages to releive congestion. A source 6uench !essage is a re6uest for the
source to reduce its current rate of datagra! trans!ission.
There is no I;A& !essages to reverse the effect of a source 6uench.
Source Kuench :
Source 6uench !essages have a field that contains a datagra! refi" in addition to the
usual I;A& TR&:,;O):,;.:;DSCA fields.;ongested gateways send one source
6uench !essage each ti!e they discard a datagra!= the datagra! refi" identifies the
datagra! that was droed.
*oute Chan#e *e4ue!t! .ro) 2ateway! :
Internet routing tables are initiali9ed by hosts fro! a configuration file at syste! startu,
and syste! ad!inistrators seldo! !ake routing changes during nor!al
oerations.Bateways e"change routing infor!ation eriodically to acco!adate network
changes and kee their routes u-to-date.The general rule is , Bateways are assu!ed to
know correct routes= host begin wint !ini!al routing infor!ation and learn new routes
fro! gateways. The BAT:#AR INT:5N:T A))5:SS field contains the address of a
gateway that the host is to use to reach the destination !entioned in the datagra! header.
The INT:5N:T .:A):5 field contains I& header lus the ne"t -+ bits of the datagra!
that triggered the !essage.The ;O): field of an I;A& redirect !essage further secifies
how to interret the destination address, based on values assigned as follows $
;ode 3alue Aeaning
1 5:)I5:;T )ATAB5AAS /O5 T.: N:T
% 5:)I5:;T )ATAB5AAS /O5 T.: .OST
( 5:)I5:;T )ATAB5AAS /O5 T.: TR&: O/ S:53I;: AN)
N:T
* 5:)I5:;T )ATAB5AAS /O5 T.: TR&: O/ S:53I;: AN)
.OST
Bateways only send I;A& redirect re6uests to hosts and not to other gateways.
'etectin# Circular or "xce!!i+ely Lon# *oute! :
Internet gateways co!ute a ne"t ho using local tables, errors in routing tables can
roduce a routing cycle for so!e destination. A routing cycle can consist of two gateways
that each route a datagra! for a articular destination to other, or it can consist of several
gateways.To revent datagra!s fro! circling forever in a T;&?I& internet, each I&
datagra! contains a ti!e-to-live counter , so!eti!es called a ho count. A gateway
decre!ents the ti!e-to-live counter whenever it rocesses the datagra! and discards the
datagra! when the count reaches 9ero. #henever a gateway discards a datagra! because
its ho count has reached 9ero or because a ti!eout occured while waiting for frag!ents
of a datagra! ,it sends an I;A& ti!e e"ceeded !essage back to the datagra!0s source, A
gateway sends this !essage whenever a datagra! is discarded because the ti!e-to-live
field in the datagra! header has reached 9ero or because its reasse!bly ti!er e"ired
while waiting for frag!ents.
The code field e"lains the nature of the ti!eout $
;ode 3alue Aeaning
1 TIA:-TO-'I3: ;OCNT :Q;::):)
% /5ABA:NT 5:ASS:A4'R TIA: :Q;::):)
/rag!ent reasse!bly refers to the task of collecting all the frag!ents fro! a datagra!.
*eprtin# Other %roble)! :
#hen a gateway or host finds roble!s with a datagra! not covered by revious I;A&
error !essages it sends a ara!eter roble! !essage to the original source.To !ake the
!essage una!bigous, the sender uses the &OINT:5 field in the !essage header to
identify the octet in the datagra! that caused the roble!. ;ode % is used to reort that a
re6uired otion is !issing= the &OINT:5 field is not used for code %.
Clock Synchroni/ation nd (ran!)it the e!ti)ation :
I;A& !essages are used to obtain the ti!e fro! another !achine.A re6uesting !achine
sends an I;A& ti!esta! re6uest !essage to another !achine, asking that the second
!achine return its current value of the ti!e of day. The receiving !achine returns a
ti!esta! rely back to the !achine !aking the re6uest. T;&?I& rotocol suite includes
several rotocols that can be used to synchroni9e clocks. This is one of the si!lest
techni6ues used by T;&?I&. The TR&: field idintifies the !essage as a re6uest 7%* 8 or a
rely 7 %+ 8= the I):NTI/I:5 and S:LC:N;: NCA4:5 fields are used by the source
to associate relies with re6uests.The O5IBINAT: TIA:STAA& filed is filled in by the
original sendet >ust before the acket is trans!itted, the 5:;:I3: TIA:STAA& field is
filled i!!ediately uon receit of a re6uest, and the T5ANSAIT TIA:STAA& field is
filled i!!ediately before the rely is trans!itted. .osts use the three ti!esta! fields to
co!ute esti!ates of the delay ti!e between the! and to synchroni9e their clock.A host
can co!ute the total ti!e re6uired for a re6uest to travel to a destination, be transfor!ed
into a rely, and return. In ractice, accurate esti!ation of round-tri delay can be
difficult and substantially restirct the utility of I;A& ti!estan !essages.To obtain an
accurate esti!ate to round tri delay one !ust take !any !easure!ents and average
the!.
Obtainin# a Subnet ,a!k:
Subnet addressing is used by the hosts to e"tract so!e bits in the hostid ortion of their I&
address to identify a hysical network.To articiate in subnet addressing, hosts need to
know which bits of the *(-bit internet address corresond to the hysical network and
which corresond to host identifiers. The infor!ation needed to interret the address is
reresented in a *(-bit 6uatity called the subnet !ask. To learn the subnet !ask used for
the local network, a !achine can send an address !ask re6uest !essage to a gateway and
receive an address !ask rely. The TR&: field in an address !ask !essage secifies
whether the !essage is a re6uest 7 %7 8 or a rely 7 %I 8. A rely contains the nework0s
subnet address !ask in the A))5:SS AASD field.The I):NTI/I:5 and S:LC:N;:
NCA4:5 fields allow a !achine to associate relies with re6uests.
(ran!port Layer %rotocol
"hat is TCP.
T;& was secifically designed to rovide a reliable end to end byte strea! over an
unreliable internetwork. :ach !achine suorting T;& has a T;& transort entity either a
user rocess or art of the kernel that !anages T;& strea!s and interface to I& layer. A
T;& entity accets user data strea!s fro! local rocesses, breaks the! u into ieces not
e"ceeding -+D4 and sends each iece as a searate I& datagra!. ;lient Server
!echanis! is not necessary for T;& to behave roerly.
The I& layer gives no guarantee that datagra! will be delivered roerly, so it is u to
T;& to ti!eout and retrans!it, if needed. )ulicate, lost and out of se6uence ackets are
handled using the se6uence nu!ber, acknowledge!ents, retrans!ission, ti!ers, etc to
rovide a reliable service. ;onnection is a !ust for this service.4it errors are taken care
of by the ;5; checksu!. One difference fro! usual se6uence nu!bering is that each
byte is given a nu!ber instead of each acket. This is done so that at the ti!e of
trans!ission in case of loss, data of !any s!all ackets can be co!bined together to get
a larger acket, and hence s!aller overhead.
T;& connection is a duplex onnetion. That !eans there is no difference between two
sides once the connection is established.
(C% Connection e!tabli!h)ent
The <three-way handshake< is the rocedure used to establish a connection. This
rocedure nor!ally is initiated by one T;& and resonded to by another T;&. The
rocedure also works if two T;& si!ultaneously initiate the rocedure. #hen
si!ultaneous atte!t occurs, each T;& receives a <SRN< seg!ent which carries no
acknowledg!ent after it has sent a <SRN<. Of course, the arrival of an old dulicate
<SRN< seg!ent can otentially !ake it aear, to the reciient, that a si!ultaneous
connection initiation is in rogress. &roer use of <reset< seg!ents can disa!biguate
these cases.
The three-way handshake reduces the ossibility of false connections. It is the
i!le!entation of a trade-off between !e!ory and !essages to rovide infor!ation for
this checking.
The si!lest three-way handshake is shown in figure below. The figures should be
interreted in the following way. :ach line is nu!bered for reference uroses. 5ight
arrows 7--G8 indicate dearture of a T;& seg!ent fro! T;& A to T;& 4, or arrival of a
seg!ent at 4 fro! A. 'eft arrows 7X--8, indicate the reverse. :llisis 7...8 indicates a
seg!ent which is still in the network 7delayed8. T;& states reresent the state A/T:5 the
dearture or arrival of the seg!ent 7whose contents are shown in the center of each line8.
Seg!ent contents are shown in abbreviated for!, with se6uence nu!ber, control flags,
and A;D field. Other fields such as window, addresses, lengths, and te"t have been left
out in the interest of clarity.
TCP A TCP B
1. CLOSED LISTEN
2. SYN-SENT --> <SEQ=100><CTL=SYN> --> SYN-RECEIVED
3. ESTABLISHED <-- <SEQ=300><ACK=101><CTL=SYN,ACK> <-- SYN-RECEIVED
4. ESTABLISHED --> <SEQ=101><ACK=301><CTL=ACK> --> ESTABLISHED
. ESTABLISHED --> <SEQ=101><ACK=301><CTL=ACK><DATA> --> ESTABLISHED
B!"#$ 3-%!& H!'(")!*+ ,o- Co''+$.#o' S&'$)-o'#"!.#o'
In line ( of above figure, T;& A begins by sending a SRN seg!ent indicating that it will
use se6uence nu!bers starting with se6uence nu!ber %11. In line *, T;& 4 sends a SRN
and acknowledges the SRN it received fro! T;& A. Note that the acknowledg!ent field
indicates T;& 4 is now e"ecting to hear se6uence %1%, acknowledging the SRN which
occuied se6uence %11.
At line +, T;& A resonds with an e!ty seg!ent containing an A;D for T;& 40s SRN=
and in line ,, T;& A sends so!e data. Note that the se6uence nu!ber of the seg!ent in
line , is the sa!e as in line + because the A;D does not occuy se6uence nu!ber sace
7if it did, we would wind u A;Ding A;D0sO8.
Si!ultaneous initiation is only slightly !ore co!le", as is shown in figure below. :ach
T;& cycles fro! ;'OS:) to SRN-S:NT to SRN-5:;:I3:) to :STA4'IS.:).
TCP A TCP B
1. CLOSED CLOSED
2. SYN-SENT --> <SEQ=100><CTL=SYN> ...
3. SYN-RECEIVED <-- <SEQ=300><CTL=SYN> <-- SYN-SENT
4. ... <SEQ=100><CTL=SYN> --> SYN-RECEIVED
. SYN-RECEIVED --> <SEQ=100><ACK=301><CTL=SYN,ACK> ...
/. ESTABLISHED <-- <SEQ=300><ACK=101><CTL=SYN,ACK> <-- SYN-RECEIVED
0. ... <SEQ=101><ACK=301><CTL=ACK> --> ESTABLISHED
S#123.!'+o2" Co''+$.#o' S&'$)-o'#"!.#o'
Kue!tion: #hy is three-way handshake neededP #hat is the roble! if we send only
two ackets and consider the connection establishedP #hat will be the roble! fro!
alication0s oint of viewP #ill the ackets be delivered to the wrong alicationP
&roble! regarding (-way handshake
The only real roble! with a (-way handshake is that dulicate ackets fro! a revious
connection7 which has been closed8 between the two nodes !ight still be floating on the
network. After a SRN has been sent to the resonder, it !ight receive a dulicate acket
of a revious connection and it would regard it as a acket fro! the current connection
which would be undesirable.
Again soofing is another issue of concern if a two way handshake is used.Suose there
is a node ; which sends connection re6uest to 4 saying that it is A.Now 4 sends an A;D
to A which it re>ects Y asks 4 to close connection.4eteween these two events ; can send
a lot of ackets which will be delievered to the alication..
The first two figures show how a three way handshake deals with roble!s of
dulicate?delayed connection re6uests and dulicate?delayed connection
acknowledge!ents in the network.The third figure highlights the roble! of soofing
associated with a two way handshake.
So)e Con+ention!
%. The A;D contains 0"2%0 if the se6uence nu!ber received is 0"0.
(. If 0ISN0 is the se6uence nu!ber of the connection acket then %st data acket has the
se6 nu!ber 0ISN2%0
*. Se6 nu!bers are *( bit.They are byte se6 nu!ber7every byte has a se6 nu!ber8.#ith a
acket %st se6 nu!ber and length of the acket is sent.
+. Acknowlege!ents are cu!!ulative.
,. Acknowledge!ents have a se6 nu!ber of their own but with a length 1.So the ne"t
data acket have the se6 nu!ber sa!e as A;D.
Connection "!tabli!h
The sender sends a SRN acket with ser6uence nu!vber say 0"0.
The receiver on receiving SRN acket resonds with SRN acket with se6uence
nu!ber 0y0 and A;D with se6 nu!ber 0"2%0
On receiving both SRN and A;D acket, the sender resonds with A;D acket
with se6 nu!ber 0y2%0
The receiver when receives A;D acket, initiates the connection.
Connection *elea!e
The initiator sends a /IN with the current se6uence and acknowledge!ent
nu!ber.
The resonder on receiving this infor!s the alication rogra! that it will
receive no !ore data and sends an acknowledge!ent of the acket. The
connection is now closed fro! one side.
Now the resonder will follow si!ilar stes to close the connection fro! its side.
Once this is done the connection will be fully closed.
(ran!port Layer %rotocol 0continued1
T;& connection is a dule" connection. That !eans there is no difference between two
sides once the connection is established.
Salient .eature! of (C%
%i##ybackin# of acknowled)ent!:The A;D for the last received acket need
not be sent as a new acket, but gets a free ride on the ne"t outgoing data
fra!e7using the A;D field in the fra!e header8. The techni6ue is te!orarily
delaying outgoing A;Ds so that they can be hooked on the ne"t outgoing data
fra!e is known as iggybacking. 4ut A;D can0t be delayed for a long ti!e if
receiver7of the acket to be acknowledged8 does not have any data to send.
.low and con#e!tion control:T;& takes care of flow control by ensuring that
both ends have enough resources and both can handle the seed of data transfer of
each other so that none of the! gets overloaded with data. The ter! congestion
control is used in al!ost the sa!e conte"t e"cet that resources and seed of each
router is also taken care of. The !ain concern is network resources in the latter
case.
,ultiplexin# - 'e)ultiplexin#: Aany alication can be sending?receiving data
at the sa!e ti!e. )ata fro! all of the! has to be !ultile"ed together. On
receiving so!e data fro! lower layer, T;& has to decide which alication is the
reciient. This is called de!ultile"ing. T;& uses the concet of ort nu!ber to
do this.
TCP se#ment header&
"xplanation of header field!:
Source and de!tination port :These fields identify the local endoint of the
connection. :ach host !ay decide for itself how to allocate its own orts starting
at %1(+. The source and destination socket nu!bers together identify the
connection.
Se4uence and AC& nu)ber : This field is used to give a se6uence nu!ber to
each and every byte transferred. This has an advantage over giving the se6uence
nu!bers to every acket because data of !any s!all ackets can be co!bined
into one at the ti!e of retrans!ission, if needed. The A;D signifies the ne"t byte
e"ected fro! the source and not the last byte received. The A;Ds are cu!ulative
instead of selective.Se6uence nu!ber sace is as large as *(-bit although %7 bits
would have been enough if the ackets were delivered in order. If ackets reach in
order, then according to the following for!ula$
7sender0s window si9e8 2 7receiver0s window si9e8 X 7se6uence nu!ber sace8
the se6uence nu!ber sace should be %7-bits. 4ut ackets !ay take different
routes and reach out of order. So, we need a larger se6uence nu!ber sace. And
for oti!isation, this is *(-bits.
Header len#th :This field tells how !any *(-bit words are contained in the T;&
header. This is needed because the otions field is of variable length.
.la#! : There are si" one-bit flags.
%. 3*2 : This bit indicates whether the urgent ointer field in this acket is
being used.
(. AC& :This bit is set to indicate the A;D nu!ber field in this acket is
valid.
*. %SH : This bit indicates &CS.ed data. The receiver is re6uested to deliver
the data to the alication uon arrival and not buffer it until a full buffer
has been received.
+. *S( : This flag is used to reset a connection that has beco!e confused
due to a host crash or so!e other reason.It is also used to re>ect an invalid
seg!ent or refuse an atte!t to oen a connection. This causes an abrut
end to the connection, if it e"isted.
,. SNN : This bit is used to establish connections. The connection
re6uest7%st acket in *-way handshake8 has SRNF% and A;DF1. The
connection rely 7(nd acket in *-way handshake8 has SRNF% and
A;DF%.
-. .IN : This bit is used to release a connection. It secifies that the sender
has no !ore fresh data to trans!it. .owever, it will retrans!it any lost or
delayed acket. Also, it will continue to receive data fro! other side.
Since SRN and /IN ackets have to be acknowledged, they !ust have a
se6uence nu!ber even if they do not contain any data.
indow Si/e : /low control in T;& is handled using a variable-si9e sliding
window. The #indow Si9e field tells how !any bytes !ay be sent starting at the
byte acknowledged. Sender can send the bytes with se6uence nu!ber between
7A;DU8 to 7A;DU 2 window si9e - %8 A window si9e of 9ero is legal and says that
the bytes u to and including A;DU -% have been received, but the receiver would
like no !ore data for the !o!ent. &er!ission to send can be granted later by
sending a seg!ent with the sa!e A;D nu!ber and a non9ero #indow Si9e field.
Check!u) : This is rovided for e"tre!e reliability. It checksu!s the header, the
data, and the concetual seudoheader. The seudoheader contains the *(-bit I&
address of the source and destination !achines, the rotocol nu!ber for T;&7-8,
and the byte count for the T;& seg!ent 7including the header8.Including the
seudoheader in T;& checksu! co!utation hels detect !isdelivered ackets,
but doing so violates the rotocol hierarchy since the I& addresses in it belong to
the I& layer, not the T;& layer.
3r#ent %ointer : Indicates a byte offset fro! the current se6uence nu!ber at
which urgent data are to be found. Crgent data continues till the end of the
seg!ent. This is not used in ractice. The sa!e effect can be had by using two
T;& connections, one for transferring urgent data.
Option! : &rovides a way to add e"tra facilities not covered by the regular header.
eg,
o Aa"i!u! T;& ayload that sender is willing to handle. The !a"i!u!
si9e of seg!ent is called ASS 7Aa"i!u! Seg!ent Si9e8. At the ti!e of
handshake, both arties infor! each other about their caacity. Aini!u!
of the two is honoured. This infor!ation is sent in the otions of the SRN
ackets of the three way handshake.
o #indow scale otion can be used to increase the window si9e. It can be
secified by telling the receiver that the window si9e should be interreted
by shifting it left by secified nu!ber of bits. This header otion allows
window si9e u to (*1.
'ata : This can be of variable si9e. T;& knows its si9e by looking at the
I& si9e header.
Topics to )e Discssed relatin# TCP
%. ,axi)u) Se#)ent Si/e : It refers to the !a"i!u! si9e of seg!ent 7 ASS 8 that
is accetable to both ends of the connection. T;& negotiates for ASS using
O&TION field. In Internet environ!ent ASS is to be selected oti!ally. An
arbitrarily s!all seg!ent si9e will result in oor bandwith utili9ation since )ata to
Overhead ratio re!ains low. On the other hand e"tre!ely large seg!ent si9e will
necessitate large I& )atagra!s which re6uire frag!entation. As there are finite
chances of a frag!ent getting lost, seg!ent si9e above <frag!entation threshold <
decrease the Throughut. Theoretically an oti!u! seg!ent si9e is the si9e that
results in largest I& )atagra!, which do not re6uire frag!entation anywhere
enroute fro! source to destination. .owever it is very difficult to find such an
oti!u! seg!et si9e. In syste! 3 a si!le techni6ue is used to identify ASS. If
.% and .( are on the sa!e network use ASSF%1(+. If on different networks then
ASSF,111.
(. .low Control : T;& uses Sliding #indow !echanis! at octet level. The window
si9e can be variable over ti!e. This is achieved by utili9ing the concet of
<#indow Advertise!ent< based on $
%. $uffer a+ailabilty at the recei+er
(. Network condition! 0 traffic load etc<1
In the for!er case receiver varies its window si9e deending uon the sace
available in its buffers. The window is referred as 5:;:I3: #IN)O#
75ecv@#in8. #hen receiver buffer begin to fill it advertises a s!all 5ecv@#in so
that the sender does0nt send !ore data than it can accet. If all buffers are full
receiver sends a <Eero< si9e advertise!ent. It stos all trans!ission. #hen buffers
beco!e available receiver advertises a Non Eero widow to resu!e retrans!ission.
The sender also eriodically robes the <Eero< window to avoid any deadlock if
the Non Eero #indow advertise!ent fro! receiver is lost. The 3ariable si9e
5ecv@#in rovides efficient end to end flow control.
The second case arises when so!e inter!ediate node 7 e.g. a router 8 controls the
source to reduce trans!ission rate. .ere another window referred as
;OB:STION #IN)O# 7;@#in8 is utili9ed. Advertise!ent of ;@#in hels to
check and avoid congestion.
*. Con#e!tion Control : ;ongestion is a condition of severe delay caused by an
overload of datagra!s at any inter!ediate node on the Internet. If unchecked it
!ay feed on itself and finally the node !ay start droing arriving
datagra!s.This can further aggravate congestion in the network resulting in
congestion collase. T;& uses two techni6ues to check congestion.
%. Slow Start : At the ti!e of start of a connection no infor!ation about
network conditios is available. A 5ecv@#in si9e can be agreed uon
however ;@#in si9e is not known. Any arbitrary ;@#in si9e can not be
used because it !ay lead to congestion. T;& acts as if the window si9e is
e6ual to the !ini!u! of 7 5ecv@#in Y ;@#in8. So following algorith!
is used.
%. 5ecv@#inFQ
(. S:T ;@#inF%
*. for every A;D received ;@#in22
(. ,ultiplicati+e decrea!e : This sche!e is used when congestion is
encountered 7 ie. when a seg!ent is lost 8. It works as follows. 5educe the
congestion window by half if a seg!ent is lost and e"onentially backoff
the ti!er 7 double it 8 for the seg!ents within the reduced window. If the
ne"t seg!ent also gets lost continue the above rocess. /or successive
losses this sche!e reduces traffic into the connection e"onentially thus
allowing the inter!ediate nodes to clear their 6ueues. Once congestion
ends S'O# STA5T is used to scale u the trans!ission.
+. Con#e!tion A+oidance : This rocedure is used at the onset of congestion to
!ini!i9e its effect on the network. #hen trans!ission is to be scaled u it should
be done in such a way that it does0nt lead to congestion again. /ollowing
algorith! is used .
%. At loss of a seg!ent S:T ;@#inF%
(. S:T S'O# STA5T T.5:S.O') 7SST8 F Send@#in ? (
*. Send seg!ent
+. If A;D 5eceived, ;@#in22 till ;@#in XF SST
,. else for each A;D ;@#in 2F % ? ;@#in
,. (i)e out and *etran!)i!!ion : /ollowing two sche!es are used $
>< .a!t *etran!)it
@< .a!t *eco+ery
#hen a source sends a seg!ent T;& sets a ti!er. If this value is set too low it will
result in !any unnecessary trerans!issions. If set too high it results in wastage of
banwidth and hence lower throughut. In /ast 5etrans!it sche!e the ti!er value
is set fairly higher than the 5TT. The sender can therefore detect seg!ent loss
before the ti!er e"ires. This sche!e resu!es that the sender will get reeated
A;D for a lost acket.
-. *ound (rip (i)e 0*((1 : In Internet environ!ent the seg!ents !ay travel
across different inter!ediate networks and through !ultile routers. The networks
and routers !ay have different delays, which !ay vary over ti!e. The 5TT
therefore is also variable. It !akes difficult to set ti!ers. T;& allows varying
ti!ers by using an adative retrans!ission algorith!. It works as follows.
%. Note the ti!e 7t%8 when a seg!ent is sent and the ti!e 7t(8 when its A;D
is received.
(. ;o!ute 5TT7sa!le8 F 7t ( - t % 8
*. Again ;o!ute 5TT7new8 for ne"t seg!ent.
+. ;o!ute Average 5TT by weighted average of old and new values of 5TT
,. 5TT7est8 F a Z5TT7old8 2 7%-a8 Z 5TT 7new8 where 1 X a X %
A high value of 0a0 !akes the esti!ated 5TT insensitive to changes that
last for a short ti!e and 5TT relies on the history of the network. A low
value !akes it sensitive to current state of the network. A tyical value of
0a0 is 1.7,
-. ;o!ute Ti!e Out F b Z 5TT7est8 where bG %
A low value of 0b0 will ensure 6uick detection of a acket loss. Any s!all
delay will however cause unnecessary retrans!ission. A tyical value of
0b0 is ket at .(
(ran!port Layer %rotocol- I)ple)entation I!!ue!
In this class we discussed about the T;& fro! the i!le!entation oint of view and
addressed various issues like state diagra! and other details which T;& Standard does
not define but suorted by co!!ercial i!le!entations.
State Dia#ram
The state diagra! aroach to view the T;& connection establish!ent and closing
si!lifies the design of T;& i!le!entation. The idea is to reresent the T;& connection
state, which rogresses fro! one state to other as various !essages are e"changed. To
si!lify the !atter, we considered two state diagra!s, vi9., for T;& connection
establish!ent and T;& connection closing.
/ig % shows the state diagra! for the T;& connection establish!ent and associated table
briefly e"lains each state.
T;& ;onnection establish!ent
The table gives brief descrition of each state of the above diagra!.
State )escrition Table %.
'isten
5eresents the state when waiting for connection re6uest fro! any
re!ote host and ort. This secifically alies to a Server.
/ro! this state, the server can close the service or actively oen a
connection by sending SRN.

Syn-Sent
5eresents waiting for a !atching for a connection re6uest after
having sent a connection re6uest. This alies to both server and
client side. :ven though server is considered as the one with
assive oen, it can also send a SRN acket actively.

Syn@5cvd
5eresents waiting for a confir!ation connection re6uest
acknowledg!ent after having both received and sent connection
re6uest.

:stab
5eresents an oen connection. )ata transfer can take lace fro!
this oint onwards.


After the connection has been established, two end-oints will e"change useful
infor!ation and ter!inate the connection. /ig. ( shows the state diagra! for ter!inating
an active connection.

/ig (. T;& ;onnection ter!ination



State )escrition Table (
/IN-#AIT-%
5eresents connection ter!ination re6uest fro! the re!ote T;&
eer, or an acknowledg!ent of the connection ter!ination re6uest
reviously sent.
This state is entered when server issues close call.
/IN-#AIT-(
5eresents waiting for a connection ter!ination re6uest fro! the
re!ote T;&.

;'OSINB
5eresents connection ter!ination re6uest acknowledg!ent fro!
the re!ote T;&.

TIA:@#AIT
This reresents waiting ti!e enough for the ackets to reach their
destination. This waiting ti!e is usually + !in.

;'OS:@#AIT 5eresents a state when the server receives a /IN fro! the re!ote
T;& , sends A;D and issues close call sending /IN

'AST@A;D
5eresents waiting for an A;D for the reviously sent /IN-A;D to
the re!ote T;&

;'OS:
5eresents a closed T;& connection having received all the A;Ds


Other implementation details
Kuite (i)e
It !ight haen that a host currently in co!!unication crashes and reboots. At startu
ti!e, all the data structures and ti!ers will be reset to an initial value. To !ake sure that
earlier connection ackets are gracefully re>ected, the local host is not allowed to !ake
any new connection for a s!all eriod at startu. This ti!e will be set in accordance with
reboot ti!e of the oerating syste!.
Initial Se4uence nu)ber :
Initial se6uence nu!ber used in the T;& co!!unication will be initiali9ed at boot ti!e
rando!ly, rather than to 1. This is to ensure that ackets fro! old connection should not
interfere with a new connection. So the reco!!ended !ethod is to
Initiali9e the ISN at boot ti!e by a rando! nu!ber
/or every ,11 !s, incre!ent ISN by -+D
#ith every SRN received, incre!ent ISN by -+D
,axi)u) *e4ue!t backlo# at !er+er
As we have seen in Cni" Networking rogra!!ing, listen!sd"n#" sets a !a"i!u! to the
nu!ber of re6uests to be obliged by the server at any ti!e. So if there are already n
re6uests for connection, and n2% re6uest co!es, two things can be done.
)ro the acket silently
Ask the eer to send the re6uest later.
The first otion is reco!!ended here because, the assu!tion is that this 6ueue for
re6uest is a coincident and so!e ti!e later, the server should be free to rocess the new
re6uest. .ence if we dro the acket, the client will go through the ti!e-out and
retrans!ission and server will be free to rocess it.
Also, Standard T;& does not define any strategy?otion of knowing who re6uested the
connection. Only Solaris (.( suorts this otion.
'elayed Acknowled#)ent
T;& will iggyback the acknowledg!ent with its data. 4ut if the eer does not have the
any data to send at that !o!ent, the acknowledg!ent should not be delayed too long.
.ence a ti!er for (11 !s will be used. At every (11 !s, T;& will check for any
acknowledg!ent to be sent and send the! as individual ackets.
S)all packet!
T;& i!le!entation discourages s!all ackets. :secially if a revious relatively large
acket has been sent and no acknowledg!ent has been received so far, then this s!all
acket will be stored in the buffer until the situation i!roves.
4ut there are so!e alications for which delayed data is worse than bad data. /or
e"a!le, in telnet" each key stroke will be rocessed by the server and hence no delay
should be introduced. As we have seen in Cni" Networking rogra!!ing, otions for the
socket can be set as NO@):'AR, so that s!all ackets are not discouraged.
IC,% Source Kuench
#e have seen in I;A& that I;A& Source Luench !essage will be send for the eer to
slow down. So!e i!le!entations discard this !essage, but few set the current window
!i/e to %.
4ut this is not a very good idea.
*etran!)i!!ion (i)eout
In so!e i!le!entation 7:.g.. 'inu"8, 5TO F 5TT 2 + Z delay variance is used to instead
of constant (.
Also instead of calculating 5TT7est8 fro! the scratch, cache will be used to store the
history fro! which new values are calculated as discussed in the revious classes.
Standard values for Aa"i!u! Seg!ent 'ife 7AS'8 will be between 1., to ( !inutes
and Ti!e wait state F f7AS'8
&eep Ali+e (i)e
Another i!ortant ti!er in T;& is kee alive ti!er. It is basically used by a T;& eer to
check whether the other end is u or down. It eriodically checks this connection. If the
other end did not resond, then that connection will be closed.
%er!i!t (i)er
As we saw in T;& window !anage!ent, when source sends one full window of ackets,
it will set its window si9e to 1 and e"ects an A;D fro! re!ote T;& to increase its
window si9e. Suose such an A;D has been sent and is lost. .ence source will have
current window si9e F 1 and cannot send Y destination is e"ecting ne"t byte. To avoid
such a deadlock, a &ersist Ti!er will be used. #hen this ti!er goes off, the source will
send the last one byte again. So we hoe that situation has i!roved and an A;D to
increase the current window si9e will be received.
3nix Socket %ro#ra))in#
Client Ser-er Architectre
In the client server architecture, a !achine7refered as client8 !akes a re6uest to connect
to another !achine 7called as server8 for roviding so!e service. The services running on
the server run on known orts7alication identifiers8 and the client needs to know the
address of the server !achine and this ort in order to connect to the server. On the other
hand, the server does not need to know about the address or the ort of the client at the
ti!e of connection initiation. The first acket which the client sends as a re6uest to the
server contains these infor!ations about the client which are further used by the server to
send any infor!ation. ;lient acts as the active device which !akes the first !ove to
establish the connection whereas the server assively waits for such re6uests fro! so!e
client.
Illu!tration of Client Ser+er ,odel
"hat is a Socket .
In uni", whenever there is a need for inter rocess co!!unication within the sa!e
!achine, we use !echanis! like signals or ies7na!ed or unna!ed8. Si!ilarly, when
we desire a co!!unication between two alications ossibly running on different
!achines, we need !ocket!. Sockets are treated as another entry in the uni" oen file
table. So all the syste! calls which can be used for any IO in uni" can be used on socket.
The server and client alications use various syste! calls to conenct which use the basic
construct called !ocket. A socket is one end of the co!!unication channel between two
alications running on different !achines.
Stes followed by client to establish the connection$
%. ;reate a socket
(. ;onnect the socket to the address of the server
*. Send?5eceive data
+. ;lose the socket
Stes followed by server to establish the connection$
%. ;reate a socket
(. 4ind the socket to the ort nu!ber known to all clients
*. 'isten for the connection re6uest
+. Accet connection re6uest
,. Send?5eceive data
!asic data strctres sed in Socket pro#rammin#
Socket 'e!criptor: A si!le file descritor in Cni".
int
Socket Addre!!: This construct holds the infor!ation for socket address
".-2$. "o$*!((-" 4
2'"#5'+( ")o-. "!6,!1#3&7 88 !((-+"" ,!1#3&, A96::: o-
P96:::
$)!- "!6(!.!;14<7 88 14 =&.+" o, >-o.o$o3 !((-+""
?7
A/ stands for Address /a!ily and &/ stands for &rotocol /a!ily. In !ost !odern
i!le!entations only the A/ is being used. The various kinds of A/ are as follows$
N!1+ P2->o"+
A96@NIA, A96LOCAL Lo$!3 $o112'#$!.#o'
A96INET IPB4 I'.+-'+. >-o.o$o3"
A96INET/ IPB/ I'.+-'+. >-o.o$o3"
A96IPA IPA - NoB+33 >-o.o$o3"
A96NETLINK K+-'+3 2"+- #'.+-,!$+ (+B#$+
A96A2 IT@-T A.2 8 ISO-C20C >-o.o$o3
A96AA2 A1!.+2- -!(#o AA.2 >-o.o$o3
A96ATDPVC A$$+"" .o -!E ATD PVC"
A96APPLETALK A>>3+.!3*
A96PACKET LoE 3+B+3 >!$*+. #'.+-,!$+
In all the sa!le rogra!s given below, we will be using A/@IN:T.
!truct !ockaddrGin: This construct holds the infor!ation about the address fa!ily, ort
nu!ber, Internet address,and the si9e of the struct sockaddr.
".-2$. "o$*!((-6#' 4
")o-. #'. "#'6,!1#3&7 88 A((-+"" ,!1#3&
2'"#5'+( ")o-. #'. "#'6>o-.7 88 Po-. '21=+-
".-2$. #'6!((- "#'6!((-7 88 I'.+-'+. !((-+""
2'"#5'+( $)!- "#'6F+-o;C<7 88 S!1+ "#F+ !" ".-2$. "o$*!((-
?7
So!e syste!s 7like "I1I-8 are 'ittle :ndian i-e. least signficant byte is stored in the
higher address, whereas in 4ig endian syste!s !ost significant byte is stored in the
higher address. ;onsider a situation where a 'ittle :ndian syste! wants to co!!unicate
with a 4ig :ndian one, if there is no standard for data reresentation then the data sent by
one !achine is !isinterreted by the other. So standard has been defined for the data
reresentation in the network 7called Network 4yte Order8 which is the 4ig :ndian. The
syste! calls that hel us to convert a short?long fro! .ost 4yte order to Network 4yte
Order and viceversa are
htons78 -- <.ost to Network Short<
htonl78 -- <.ost to Network 'ong<
ntohs78 -- <Network to .ost Short<
ntohl78 -- <Network to .ost 'ong<
IP addresses
Assu!ing that we are dealing with I&v+ addresses, the address is a *(bit integer.
5e!e!bering a *( bit nu!ber is not convenient for hu!ans. So, the address is written as
a set of four integers seerated by dots, where each integer is a reresentation of I bits.
The reresentation is like a.b.c.d, where a is the reresentation of the !ost significant
byte. The syste! call which converts this reresentation into Network 4yte Order is$
#'. #'+.6!.o'G$o'". $)!- H$>, ".-2$. #'6!((- H#'>I7
inetGaton01 converts the Internet host address p fro! the standard nu!bers-and-dots
notation into binary data and stores it in the structure that inp oints to. inet@aton returns
non9ero if the address is valid, 9ero if not.
/or e"a!le, if we want to initiali9e the sockaddr@in construct by the I& address and
desired ort nu!ber, it is done as follows$
".-2$. "o$*!((-6#' "o$*!((-7
"o$*!((-."#'6,!1#3& = A96INET7
"o$*!((-."#'6>o-. = ).o'"G21I7
#'+.6!.o'GJ102.2/.110.1/CJ, KG"o$*!((-."#'6!((-II7
1+1"+.GKG"o$*!((-."#'6F+-oI, LM0L, CI7

Socket System Call
A socket is created using the syste! call$
#'. "o$*+.G (o1!#' , .&>+ , >-o.o$o3I7
This syste! call returns a Socket )escritor 7like file descritor8 which is an integer
value. )etails about the Argu!ents$
%. 'o)ain: It secifies the co!!unication do!ain. It takes one of the redefined
values described under the rotocol fa!ily and address fa!ily above in this
lecture.
(. (ype: It secifies the se!antics of co!!unication , or the tye of service that is
desired . It takes the following values$
o SO;D@ST5:AA $ Strea! Socket
o SO;D@)B5AA $ )atagra! Socket
o SO;D@5A# $ 5aw Socket
o SO;D@S:L&A;D:T $ Se6uenced &acket Socket
o SO;D@5)A $ 5eliably )elivered Aessage &acket
*. %rotocol: This ara!eter identifies the rotocol the socket is suosed to use .
So!e values are as follows$
o I&&5OTO@T;& $ /or T;& 7SO;D@ST5:AA8
o I&&5OTO@C)& $ /or C)& 7SO;D@)5AA8
Since we have only one rotocol for each kind of socket, it does not !atter if we
do not define any rotocol at all. So for si!licity, we can ut <1< 79ero8 in the
rotocol field.
!ind System Call
The syste! call bind associates an address to a socket descritor created by socket.
#'. =#'( G #'. "o$*,( , ".-2$. "o$*!((- H1&!((- , #'. !((-3+' I7
The second ara!eter myaddr secifies a ointer to a redefined address of the socket.Its
structure is a general address structure so that the bind syste! call can be used by both
Cni" do!ain and Internet do!ain sockets.
Other System Calls and their 6nctions
'IST:N $ Annou!ce willingness to accet connections = give 6ueue si9e.
A;;:&T $ 4lock the caller until a co!!wction atte!t arrives.
;ONN:;T $ Actively atte!t to establish a connection.
S:N) $ Send so!e data over the connection.
5:;I:3: $ 5ecieve s!e data fro! the connection.
;'OS: $ 5elease the connection.
3nix Socket %ro#ra))in# 0Contd<<1
Client1Ser-er Commnication O-er-iew
The analogy given below is often very useful in understanding !any such networking
concets. The analogy is of a nu!ber of eole in a roo! co!!unicating with each other
by way of talking. In a tyical scenario, if A has to talk to 4, then he would call out the
na!e of 4 and only if 4 was listening would he resond. In case 4 resonds, then one
can say that a connection has been established. .enceforth until both of the! desire to
co!!unicate, they can carry out their conversation.
A ;lient-Server architecture generally e!loyed in networks is also very si!ilar in
concet. :ach !achine can act as a client or a server.
Ser+er: It is nor!ally defined which rovides so!e sevices to the client rogra!s.
.owever, we will have a deeer look at the concet of a <service< in this resect later.
The !ost i!ortant feature of a server is that it is a assive entiry, one that listens for
re6uest fro! the clients.
Client: It is the active entity of the architecture, one that generated this re6uest to connect
to a articular ort nu!ber on a articular server
;o!!unication takes the for! of the client rocess sending a !essage over the network
to the server rocess. The client rocess then waits for a rely !essage. #hen the server
rocess gets the re6uest, it erfor!s the re6uested work and sends back a rely.The server
that the client will try to connect to should be u and running before the client can be
e"ecuted. In !ost of the cases, the servers runs continuously as a dae!on.
There is a general !isconcetion that servers necessarily rovide so!e service and is
therefore called a server. /or e"a!le an e-!ail client rovides as !uch service as an
!ail server does. Actually the ter! service is not very well defined. So it would be better
not to refer to the ter! at all. In fact servers can be rogra!!ed to do ractically
anything that a nor!al alication can do. In brief, a server is >ust an entity that
listens?waits for re6uests.
To send a re6uest, the client needs to know the address of the server as well as the ort
nu!ber which has to be sulied to establish a connection. One otion is to !ake the
server choose a rando! nu!ber as a ort nu!ber, which will be so!ehow conveyed to
the client. Subse6uently the client will use this ort nu!ber to send re6uests. This !ethod
has severe li!itations as such infor!ation has to be co!!unicated offline, the network
connection not yet being established. A better otion would be to ensure that the server
runs on the sa!e ort nu!ber always and the client already has knowledge as to which
ort rovides which service. Such a standardi9ation already e"ists. The ort nu!bers 1-
%1(* are reserved for the use of the sueruser only. The list of the services and the orts
can be found in the file ?etc?services.
Connection Oriented -s Connectionless Commnication
Connection Oriented Co))unication
Analogous to the telehone network.The sender re6uests for a co!!unication 7dial the
nu!ber8, the receiver gets an indication 7the hone ring8 the receiver accets the
connection 7icks u the hone8 and the sender receives the acknowledg!ent 7the ring
stos8. The connection is established through a dedicated link rovided for the
co!!unication. This tye of co!!unication is characteri9ed by a high level of reliability
in ter!s of the nu!ber and the se6uence of bytes.
Connectionle!! Co))unication
Analogous to the ostal service. &ackets7letters8 are sent at a ti!e to a articular
destination. /or greater reliability, the receiver !ay send an acknowledge!ent 7a receit
for the registered letters8.
4ased on this two tyes of co!!unication, two kinds of sockets are used$
!trea) !ocket!: used for connection-oriented co!!unication, when reliability in
connection is desired.
data#ra) !ocket!: used for connectionless co!!unication, when reliability is
not as !uch as an issue co!ared to the cost of roviding that reliability. /or eg.
strea!ing audio?video is always send over such sockets so as to di!inish network
traffic.
Se4uence of Sy!te) Call! for Connection Oriented co))unication
The tyical set of syste! calls on both the !achines in a connection-oriented setu is
shown in /igure below.
The se6uence of syste! calls that have to be !ade in order to setu a connection is given
below.
%. The so$et syste! call is used to obtain a socket descritor on both the client and
the server. 4oth these calls need not be synchronous or related in the ti!e at
which they are called.The synosis is given below$

UincludeXsys?tyes.hG
UincludeXsys?socket.hG
int socket7int do!ain, int tye, int rotocol8=

(.
*. 4oth the client and the server 0bind0 to a articular ort on their !achines using
the bind syste! call. This function has to be called only after a socket has been
created and has to be assed the socket descritor returned by the so$et call.
Again this binding on both the !achines need not be in any articular order.
Aoreover the binding rocedure on the client is entirely otional. The bind
syste! call re6uires the address fa!ily, the ort nu!ber and the I& address. The
address fa!ily is known to be A/@IN:T, the I& address of the client is already
known to the oerating syste!. All that re!ains is the ort nu!ber. Of course the
rogra!!er can secify which ort to bind to, but this is not necessary. The
binding can be done on a rando! ort as well and still everything would work
fine. The way to !ake this haen is not to call bind at all. Alternatively bind can
be called with the ort nu!ber set to 1. This tells the oerating syste! to assign a
rando! ort nu!ber to this socket. This way whenever the rogra! tries to
connect to a re!ote !achine through this socket, the oerating syste! binds this
socket to a rando! local ort. This rocedure as !entioned above is not
alicable to a server, which has to listen at a standard redeter!ined ort.

+. The ne"t call has to be listen to be !ade on the server. The synosis of the listen
call is given below.

UincludeXsys?socket.hG
int listen7int skfd, int backlog8=
,. s$fd is the socket descritor of the socket on which the !achine should start
listening.
ba$log is the !a"i!u! length of the 6ueue for acceting re6uests.
-. The onnet syste! call signifies that the server is willing to accet connections
and thereby start co!!unicating.
7. Actually what haens is that in the T;& suite, there are certain !essages that are
sent to and fro and certain initiali9ations have to be erfor!ed. So!e finite
a!ount of ti!e is re6uired to setu the resources and allocate !e!ory for
whatever data structures that will be needed. In this ti!e if another re6uest arrives
at the sa!e ort, it has to wait in a 6ueue. Now this 6ueue cannot be arbitrarily
large. After the 6ueue reaches a articular si9e li!it no !ore re6uests are
acceted by the oerating syste!. This si9e li!it is recisely the ba$log
argu!ent in the listen call and is so!ething that the rogra!!er can set. Today0s
rocessors are retty seedy in their co!utations and !e!ory allocations. So
under nor!al circu!stances the length of the 6ueue never e"ceeds ( or *. Thus a
ba$log value of (-* would be fine, though the value tyically used is around
,.Note that this call is different fro! the concet of <arallel< connections.The
established connections are not counted in n. So, we !ay have %11 arallel
connection running at a ti!e when nF,.
I.
J. The onnet function is then called on the client with three argu!ents, na!ely the
socket descritor, the re!ote server address and the length of the address data
structure. The synosis of the function is as follows$

UincludeXsys?socket.hG
UincludeXnetinet?in.hG ?Z only for A/@IN:T , or the IN:T )o!ain Z?

int connect7int skfd, struct sockaddrZ addr, int addrlen8=
This function initiates a connection on a socket.
s$fd is the sa!e old socket descritor.
addr is again the sa!e kind of structure as used in the bind syste! call. Aore
often than not, we will be creating a structure of the tye so$addr%in instead of
so$addr and filling it with aroriate data. Sust while sending the ointer to that
structure to the onnet or even the bind syste! call, we cast it into a ointer to a
so$addr structure. The reason for doing all this is that the so$addr%in is !ore
convenient to use in case of IN:T do!ain alications. addr basically contains
the ort nu!ber and I& address of the server which the local !achine wants to
connect to. This call nor!ally block! until either the connection is established or
is re>ected.
addrlen is the length of the socket address structure, the ointer to which is the
second argu!ent.

%1. The re6uest generated by this onnet call is rocessed by the re!ote server and is
laced in an oerating syste! buffer, waiting to be handed over to the alication
which will be calling the aept function. The aept call is the !echanis! by
which the networking rogra! on the server receives that re6uests that have been
acceted by the oerating syste!. This synosis of the aept syste! call is given
below.

UincludeXsys?socket.hG

int accet7int skfd, struct sockaddrZ addr, int addrlen8=
s$fd is the socket descritor of the socket on which the !achine had erfor!ed a
listen call and now desires to accet a re6uest on that socket.
addr is the address structure that will be filled in by the oerating syste! by the
ort nu!ber and I& address of the client which has !ade this re6uest. This
so$addr ointer can be tye-casted to a so$addr%in ointer for subse6uent
oerations on it.
addrlen is again the length of the socket address structure, the ointer to which is
the second argu!ent.
This function aept e"tracts aconnection on the buffer of ending connections in
the syste!, creates a new socket with the sa!e roerties as skfd, and returns a
new file descritor for the socket.
In fact, such an architecture has been critici9ed to the e"tent that the alications
do not have a say on what connections the oerating syste! should accet. The
syste! accets all re6uests irresective of which I&, ort nu!ber they are co!ing
fro! and which alication they are for. All such ackets are rocessed and sent
to the resective alications, and it is then that the alication can decide what to
do with that re6uest.
The aept call is a blocking syste! call. In case there are re6uests resent in the
syste! buffer, they will be returned and in case there aren0t any, the call si!ly
blocks until one arrives.
This new socket is !ade on the sa!e ort that is listening to new connections. It
!ight sound a bit weird, but it is erfectly valid and the new connection !ade is
indeed a uni6ue connection. /or!ally the definition of a onnetion is
connection: defined as a +-tule $ 7'ocal I&, 'ocal ort, /oreign I&, /oreign ort8
/or each connection at least one of these has to be uni6ue. Therefore !ultile
connections on one ort of the server, actually are different.

%%. /inally when both onnet and aept return the connection has been established.

%(. The socket descritors that are with the server and the client can now be used
identically as a nor!al I?O descritor. 4oth the read and the &rite calls can be
erfor!ed on this socket descritor. The lose call can be erfor!ed on this
descritor to close the connection. Aan ages on any CNIQ tye syste! will
furnish further details about these generic I?O calls.

%*. 3ariants of read and &rite also e"ist, which were secifically designed for
networking alications. These are rev and send.

UincludeXsys?socket.hG

int recv7int skfd, void Zbuf, int buflen, int flags8=
int send7int skfd, void Zbuf, int buflen, int flags8=
:"cet for the flags argu!ent the rest is identical to the argu!ents of the read and
&rite calls. &ossible values for the flags are$

used for maro for the flag omment
rev ,S2G%""&
look at the !essage in the buffer but do
not consider it read
send ,S2G'ON(G*O3("
send !essage only if the destination is
on the sa!e network, i.e. directly
connected to the local !achine.
rev Y
send
,S2GOO$
used for transferring data out of
se6uence, when so!e bytes in a strea!
!ight be !ore i!ortant than others.
%+. To close a articular connection the shutdo&n call can also be used to achieve
greater fle"ibility.

UincludeXsys?socket.hG

int shutdown7int skfd, int how8=
s$fd is the socket descritor of the socket which needs to be closed.
ho& can be one of the following$

SH3(G*'
o
r
1sto all read oerations on this socket, but continue writing
SH3(G*
o
r
%sto all write oerations on this socket, but kee receiving data
SH3(G*'*
o
r
(sa!e as close
A ort can be reused only if it has been closed co!letely.
3nix Socket %ro#ra))in# 0Contd<<1
Se4uence of Sy!te) Call! for Connectionle!! Co))unication
The tyical set of syste! calls on both the !achines in a connectionless setu is shown in
/igure below.
The !ocket and bind syste! calls are called in the sa!e way as in the connection-
oriented case. Again the bind call is otional at the client side.
The connect function is not called in a connectionless co!!unication with the
sane intention as above. Instead, if we call a connect78 in this case, then we are
si!ly secifying a articular server address to which we have to send, and fro!
which we have to receive the )atagra!s
:very ti!e a acket has to be sent over a socket, the re!ote address has to be
!entioned. This is because there is no concet of a connection that can re!e!ber
which re!ote !achine to send that acket to.
The calls !endto and rec+fro) are used to send datagra! ackets. The synoses
of both are given below.
int sendto7int skfd, void Zbuf, int buflen, int flags, struct sockaddrZ to, int tolen8=
int recvfro!7int skfd, void Zbuf, int buflen, int flags, struct sockaddrZ fro!, int
fro!len8=
!endto sends a datagra! acket containing the data resent in buf addressed to
the address resent in the !ockaddr structure, to.
rec+fro) fills in the buf structure with the data received fro! a datagra! acket
and the !ockaddr structure, fro! with the address of the client fro! which the
acket was received.
4oth these calls block until a acket is sent in case of !endto and a acket is
received in case of rec+fro). In the strict sense though !endto is not blocking as
the acket is sent out in !ost cases and !endto returns i!!ediately.
Suose if the rogra! desires to co!!unicate only to one articular !achine
and !ake the oerating syste! discard ackets fro! all other !achines, it can use
the connect call to secify the address of the !achine with which it will
e"clusively co!!unicate. All subse6uent calls do not re6uire the address field to
be given. It will be understood that the re!ote address is the one secified in
connect called earlier.
Socket Options and Settin#s
There are various otions which can be set for a socket and there are !ultile ways to set
otions that affect a socket.
Of these, !et!ockopt01 syste! call is the one secifically designed for this urose. Also,
we can retrieve the otion which are currently set for a socket by !eans of #et!ockopt01
syste! call.
int setsoc$opt%int soc$et& int level& int option'name& const void (option'value&
soc$len't option'len)*
The socket argu!ent !ust refer to an oen socket descritor. The level secifies who in
the syste! is to interret the otion$ the general socket code, the T;&?I& code, or the
QNS code. This function sets the otion secified by the otion@na!e, at the rotocol
level secified by the level, to the value ointed to by the otion@value for the socket
associated with the file descritor secified by the socket. The level argu!ent secifies
the rotocol level at which the otion resides. To set otions at the socket level, we need
to secify the level argu!ent as SOLGSOC&"(. To set otions at other levels, we need
to suly the aroriate rotocol nu!ber for the rotocol controlling the otion. The
otion@na!e secifies a single otion to set. The otion@na!e and any secified otions
are assed uninterreted to the aroriate rotocol !odule for interretations. The list of
otions available at the socket level 0SOLGSOC&"(1 are$
SOG'"$32
Turns on recording of debugging infor!ation. This otion enables or disables debugging
in the underlying rotocol !odules. This otion takes an int value. This is a boolean
otion.
SOG$*OA'CAS(
&er!its sending of broadcast !essages, if this is suorted by the rotocol. This otion
takes an int value. This is a boolean otion.
SOG*"3S"A''*
Secifies that the rules used in validating addresses sulied to bind78 should allow reuse
of local addresses, if this is suorted by the rotocol. This otion takes an int value. This
is a boolean otion.
SOG&""%ALIB"
Dees connections active by enabling the eriodic trans!ission of !essages, if this is
suorted by the rotocol. This otion takes an int value. If the connected socket fails to
resond to these !essages, the connection is broken and rocesses writing to that socket
are notified with a SIB&I&: signal. This is a boolean otion.
SOGLIN2"*
'ingers on a close78 if data is resent. This otion controls the action taken when unsent
!essages 6ueue on a socket and close78 is erfor!ed. If SO@'INB:5 is set, the syste!
blocks the rocess during close78 until it can trans!it the data or until the ti!e e"ires. If
SO@'INB:5 is not secified, and close78 is issued, the syste! handles the call in a way
that allows the rocess to continue as 6uickly as ossible. This otion takes a linger
structure, as defined in the Xsys?socket.hG header, to secify the state of the otion and
linger interval.
SOGOO$INLIN"
'eaves received out-of-band data 7data !arked urgent8 in line. This otion takes an int
value. This is a boolean otion.
SOGSN'$3.
Sets send buffer si9e. This otion takes an int value.
SOG*CB$3.
Sets receive buffer si9e. This otion takes an int value.
SOG'ON(*O3("
5e6uests that outgoing !essages byass the standard routing facilities. The destination
!ust be on a directly-connected network, and !essages are directed to the aroriate
network interface according to the destination address. The effect, if any, of this otion
deends on what rotocol is in use. This otion takes an int value. This is a boolean
otion.
SOG*CBLOA(
Sets the !ini!u! nu!ber of bytes to rocess for socket inut oerations. The default
value for SO@5;3'O#AT is %. If SO@5;3'O#AT is set to a larger value, blocking
receive calls nor!ally wait until they have received the s!aller of the low water !ark
value or the re6uested a!ount. 7They !ay return less than the low water !ark if an error
occurs, a signal is caught, or the tye of data ne"t in the receive 6ueue is different than
that returned, e.g. out of band data8. This otion takes an int value. Note that not all
i!le!entations allow this otion to be set.
SOG*CB(I,"O
Sets the ti!eout value that secifies the !a"i!u! a!ount of ti!e an inut function waits
until it co!letes. It accets a ti!eval structure with the nu!ber of seconds and
!icroseconds secifying the li!it on how long to wait for an inut oeration to co!lete.
If a receive oeration has blocked for this !uch ti!e without receiving additional data, it
returns with a artial count or errno set to M:ABAINN or M:#OC')4'O;DN if no data
were received. The default for this otion is 9ero, which indicates that a receive oeration
will not ti!e out. This otion takes a ti!eval structure. Note that not all i!le!entations
allow this otion to be set.
SOGSN'LOA(
Sets the !ini!u! nu!ber of bytes to rocess for socket outut oerations. Non-blocking
outut oerations will rocess no data if flow control does not allow the s!aller of the
send low water !ark value or the entire re6uest to be rocessed. This otion takes an int
value. Note that not all i!le!entations allow this otion to be set.
SOGSN'(I,"O
Sets the ti!eout value secifying the a!ount of ti!e that an outut function blocks
because flow control revents data fro! being sent. If a send oeration has blocked for
this ti!e, it returns with a artial count or with errno set to M:ABAINN ore
M:#OC')4'O;DN if no data were sent. The default for this otion is 9ero, which
indicates that a send oeration will not ti!e out. This otion stores a ti!eval structure.
Note that not all i!le!entations allow this otion to be set.
/or boolean otions, 1 indicates that the otion is disabled and % indicates that the otion
is enabled.Otions at other rotocol levels vary in for!at and na!e.
So!e of the otions available for the I%G%*O(OG(C% socket are$
(C%G,AOS"2
5eturns the !a"i!u! seg!ent si9e in use for the socket.The tyical value for a +*.4S)
socket using an :thernet is %1(+ bytes.
(C%GNO'"LAN
#hen T;& is being used for a re!ote login,there will be !any s!all data ackets sent
fro! the client0s syste! to the server.:ach acket can contain a single character that the
user enters which is sent to the server for echoing and rocessing.It !ight be desirable to
reduce the nu!ber of such s!all ackets by co!bining a nu!ber of the! into one big
acket.4ut this causes a delay between the tying of a character by the user and its
aearance on its !onitor.This is certainly not so!ething the user will areciate. /or
such services it is desirable that the client0s ackets be sent as soon as they are ready.The
(C%GNO'"LAN otion is used for these clients to defeat the buffering algorith!, and
allow the client0s T;& to send s!all ackets as soon as ossible.
int getsoc$opt%int soc$et& int level& int option'name& void (option'value& soc$len't
(option'len)*
This function retrieves the value for the otion secified by the otion@na!e argu!ent
for the socket. If the si9e of the otion value is greater than otion@len, the value stored in
the ob>ect ointed to by the otion@value will be silently truncated. Otherwise, the ob>ect
ointed to by the otion@len will be !odified to indicate the actual length of the value.
The level secifies the rotocol level at which the otion resides. To retrieve otions at
the socket level, we need to secify the level argu!ent as SOLGSOC&"(< To retrieve
otions at other levels, we need to suly the aroriate rotocol nu!ber for the
rotocol controlling the otion. The socket in use !ay re6uire the rocess to have
aroriate rivileges to use the #et!ockopt01 function. The list of otions for
otion@na!e is the sa!e as those available for !et!ockopt01 syste! call.
Ser-ers
Nor!ally a client rocess is started on the sa!e syste! or on another syste! that is
connected to the server0s syste! with a network. ;lient rocesses are often initiated by
the interactive user entering a co!!and to a ti!e-sharing syste!. The client rocess
sends a re6uest across the network to the server re6uesting service of so!e for!. In this
way, nor!ally a server handles only one client at a ti!e. If !ultile client connections
arrive at about the sa!e ti!e, the kernel 6ueues the! uto so!e li!it, and returns the!
to accet function one at a ti!e. 4ut if the server takes !ore ti!e to service each client
7say a few seconds or !inutes8, we would need so!e way to overla the service of one
client with another client. Aultile re6uests can be handled in two ways. In fact servers
are classified on the basis of the way they handle !ultile re6uests.
%. Iterati+e Ser+er!: #hen a client0s re6uest can be handled by the server in a
known, finite a!ount of ti!e, the server rocess handles the re6uest itself. These
servers handles one client at a ti!e by iterating between the!.
(. Concurrent Ser+er!: These servers handle !ultile clients at the sa!e ti!e.
A!ong the various aroaches that are available to handle these !ultile clients,
si!lest aroach is to call the CNIQ fork syste! call , creating a child rocess
for each client. #hen a connection is established, accet returns, the server calls
fork, and then the child rocess services the client and the arent rocess waits for
another connection. The arent closes the connected socket since the child
handles this new client.
Internet Sperser-er *inetd,
Servers !ust kee running at all ti!es. .owever, all the servers are not working all this
ti!e but !erely waiting for a re6uest fro! a client. To avoid this waste of resources, a
single server is run which waits on all the ort nu!bers. This Internet suer server is
called inetd in CNIQ. It is referred to as the [[Internet Suer-Server00 because it !anages
connections for several dae!ons. &rogra!s that rovide network service are co!!only
known as dae!ons. inetd serves as a !anaging server for other dae!ons. #hen a
connection is received by inetd; it deter!ines which dae!on the connection is destined
for, sawns the articular dae!on and delegates the socket to it. 5unning one instance of
inetd reduces the overall syste! load as co!ared to running each dae!on individually
in stand-alone !ode. This dae!on rovides two features -
>< It allows a single rocess 0inetd1 to be waiting to service !ultile connection re6uests,
instead of one rocess for each otential service. This reduces the total nu!ber of
rocesses in the syste!.
@< It si!lifies the writing of the server rocesses to handle the re6uests, since !any of
the start-u details are handled by inetd<
The inetd rocess uses fork and e"ec syste! calls to invoke the actual server rocess.The
only way the server can obtain the identity of the client is by calling the #etpeerna)e
syste! call.
int getpeername%int soc$fd& struct soc$addr (peer& int (addrlen)*
2etpeerna)e returns the na!e of the eer connected to socket so$fd. The addrlen
ara!eter should be initialised to indicate the a!ount of sace ointed to by eer . On
return it contains the actual si9e of the na!e returned 7in bytes8. The na!e is truncated if
the buffer rovided is too s!all.
A si!ilar syste! call is #et!ockna)e< 2et!ockna)e returns the current na!e for the
secified socket. The addrlen ara!eter should be initiali9ed to indicate the a!ount of
sace ointed to by na!e. On return it contains the actual si9e of the na!e returned 7in
bytes8.
int getsoc$name%int soc$fd& struct soc$addr (name& int (addrlen)*
/ollowing illustrates the stes erfor!ed by inetd
.owever, the inetd rocess has its own disadvantages. The code of a server is to be
coied fro! the disk to !e!ory each ti!e it is e"eced, and this is e"ensive. So, if there
is an alication which is called fre6uently, like e-!ail server, the above !entioned
aroach 7using inetd8 is not reco!!ended.
(opic! in (C%
TCP Con#estion Control
If the receiver advertises a large window-si9e , larger than what the network en route can
handle , then there will invariably be acket losses. So there will be re-trans!issions as
well . .owever , the sender cannot send all the ackets for which A;D has not been
received because this way it will be causing even !ore congestion in the network.
Aoreover , the sender at this oint of ti!e cannot be sure about how !any ackets have
actually been lost . It !ight be that this is the only one that has been lost , and so!e
following it have actually been received and buffered by the receiver. In that case , the
sender will have unnecessarily sent a nu!ber of ackets.
So the re-trans!ission of the ackets also follows slow-start !echanis!. .owever , we
do indeed need to kee an uer bound on the si9e of the ackets as it increases in slow
start, to revent it fro! increasing unbounded and causing congestion. This ca is ut at
half the value of the seg!ent si9e at which acket loss started.
Con#e!tion indow
#e have already seen one bound on the si9e of the seg!ents sent by the receiver-na!ely ,
the receiver window that the receiver advertises . .owever there could be a bottleneck
created by so!e inter!ediate network that is getting clogged u. The net effect is that
>ust having the receiver window is not enough. There should be so!e bound relating to
the congestion of the network ath - congestion window catures e"actly this bound.
Si!ilar to receiver window, we have another window , the ;ongestion #indow , and the
!a"i!u! si9e of the seg!ents sent are bounded by the !ini!u! of the si9es of the two
windows. :.g. If the receiver says <send ID< 7si9e of the receiver window 8 , but the
sender knows that bursts of !ore than +D 7si9e of congestion window 8 clog the network
u, then it sends +D. On the other hand , if the congestion window was of si9e *(D , then
the sender would send seg!ents of !a"i!u! si9e ID.
How do we calculate-)ana#e the Con#e!tion indow P
The si9e of the congestion window is initiali9ed to %./or every A;D received , it is
incre!ented by %. Another field that we !aintain is threshold which is e6ual to half the
si9e of the congestion window. #henever a acket loss takes lace, the congestion
window is set to %.Then we kee increasing the congestion window by % on every A;D
received till we reach the threshold value. Thereafter, we incre!ent the congestion
window si9e by % after every round tri ti!e.
Notice that T;& always tries to kee the flow rate slightly below the !a"i!u! value. So
if the network traffic fluctuates slightly, then a lot of ackets !ight be lost. &acket losses
cause a terrible loss in throughut.
In all these sche!es, we have been assu!ing that any acket loss occurs only due to
network congestion. #hat haens if so!e acket loss occurs not due to so!e congestion
but due to so!e rando! factorsP
#hen a acket is lost, the congestion window si9e is set to %. Then when we retrans!it
the acket, if we receive a cu!ulative A;D for a lot of subse6uent ackets, we can
assu!e that the acket loss was not due to congestion, but because of so!e rando!
factors. So we give u slow start and straightaway set the si9e of ;ongestion #indow to
the threshold value.
Silly indow Syndro)e
This haens when the alication sulying data to the sender does do in large chunks,
but the alication taking data fro! receiver 7robably an interactive alication8 does it
in very s!all chunks, say % byte at a ti!e. The sender kees advertising windows of si9e
% byte each as the alication consu!es the bytes one at a ti!e.
ClarkH! Solution to thi! proble)
#e try to revent the sender fro! advertising very s!all windows. The sender should try
to wait until it has accu!ulated enough sace in the window to send a full seg!ent or
half the receiver0s buffer si9e, which it can esti!ate fro! the attern of window udates
that it received in the ast.
Another proble): #hat if the sa!e behavior is shown by an interactive alication at
the sender0s end P That is , what if the sender kees sending in seg!ents of very s!all
si9eP
Na#leH! al#orith)
when data co!es to the sender one byte at a ti!e , send the first byte and buffer all the
re!aining bytes till the outstanding byte is acknowledged. Then send all the buffered
characters in one seg!ent and start buffering again till they are acknowledged. It can hel
reduce the bandwidth usage for e"a!le when the user is tying 6uickly into a telnet
connection and the network is slow .
%er!i!tent (i)er
;onsider the following deadlock situation . The receiver sends an A;D with 1 si9ed
window, telling the sender to wait. 'ater it send an A;D with non-9ero window, but this
A;D acket gets lost. Then both the receiver and the sender will be waiting for each
other to do so!ething. So we kee another ti!er. #hen this ti!er goes off, the sender
trans!its a robe acket to the sender with an A;D nu!ber that is old. The receiver
resonds with an A;D with udated window si9e and trans!ission resu!es.
Now we look at the solution of the last two roble!s ,na!ely %roble) of *ando)
Lo!!e! and Se4uence Nu)ber rap Around.
Pro)lem of Random Losses
.ow do we know if a loss is a congestion related loss or rando! loss PIf our window si9e
is very large then we cannot say that one acket loss is rando! loss.So we need to have
so!e !echanis! to find what ackets are lost. ;u!ulative Acknowledge!ent is not a
good idea for this.
Solution!
Selecti+e Acknowled#e)ent
#e need a selective acknowledge!ent but that creates a roble! in T;& because we use
byte se6uence nu!bers .So what we we do is that we send the se6uence nu!ber and the
length. #e !ay have to send a large nu!ber of such Selective Acknowledge!ents which
will increase the overhead So whenever we get out of se6uence ackets we send the
infor!ation a few ti!e not in all the ackets anyway. So we cannot rely on Selective
Acknowledge!ent anyway. If we have *( bit se6uence nu!ber and *( bit length,then
already we will have too !uch of overhead .One roosal is to use %- bit length field. If
we have very s!all gas then we will think that rando! losses are there and we need to
fill the! .If large gas are there we assu!e that congestion is there and we need to slow
down.
(C% (i)e!ta)p! Option
T;& is a sy!!etric rotocol, allowing data to be sent at any ti!e in either direction, and
therefore ti!esta! echoing !ay occur in either direction. /or si!licity and sy!!etry,
we secify that ti!esta!s always be sent and echoed in both directions. /or efficiency,
we co!bine the ti!esta! and ti!esta! rely fields into a single T;& Ti!esta!s
Otion.
Dind$ I
'ength$ %1 bytes
2-------2-------2---------------------2---------------------2
TDindFI T %1 T TS 3alue T TS :cho 5ely T
2-------2-------2---------------------2---------------------2
% % + + 7length in bytes8
The Ti!esta!s otion carries two four-byte ti!esta! fields. The Ti!esta! 3alue
field 7TSval8 contains the current value of the ti!esta! clock of the T;& sending the
otion. The Ti!esta! :cho 5ely field 7TSecr8 is only valid if the AC& bit is set in the
T;& header= if it is valid, it echos a ti!es- ta! value that was sent by the re!ote (C% in
the TSval field of a Ti!esta!s otion. #hen TSecr is not valid, its value !ust be 9ero.
The TSecr value will generally be the ti!e sta! for the last in-se6uence acket received.
:"a!le$
Se6uence of acket send $ % 7t%8 ( 7t(8 * 7t*8 + 7t+8 ,
7t,8 - 7t-8
se6uence of ackets received$ % ( + *
, -
ti!e sta! coied in AC&: t% t( t*
PA"S& Protect A#ainst "rapped Se%ence Nm)ers
&A#S oerates within a single T;& connection, using state that is saved in the
connection control block. &A#S uses the sa!e T;& Ti!esta!s otion as the 5TTA
!echanis! described earlier, and assu!es that every received T;& seg!ent 7including
data and A;D seg!ents8 contains a ti!esta! S"2<(S+al whose values are !onotone
non-decreasing in ti!e. The basic idea is that a seg!ent can be discarded as an old
dulicate if it is received with a ti!esta! S"2<(S+al less than so!e ti!esta! recently
received on this connection.
In both the &A#S and the 5TTA !echanis!, the <ti!esta!s< are *(- bit unsigned
integers in a !odular *(-bit sace. Thus, <less than< is defined the sa!e way it is for T;&
se6uence nu!bers, and the sa!e i!le!entation techni6ues aly. If s and t are
ti!esta! values, s X t if 1 X 7t - s8 X (ZZ*%, co!uted in unsigned *(-bit arith!etic.
The choice of inco!ing ti!esta!s to be saved for this co!arison !ust guarantee a
value that is !onotone increasing. /or e"a!le, we !ight save the ti!esta! fro! the
seg!ent that last advanced the left edge of the receive window, i.e., the !ost recent in-
se6uence seg!ent. Instead, we choose the value (S<*ecent for the 5TTA !echanis!,
since using a co!!on value for both &A#S and 5TTA si!lifies the i!le!entation of
both. (S<*ecent differs fro! the ti!esta! fro! the last in-se6uence seg!ent only in
the case of delayed A;Ds, and therefore by less than one window. :ither choice will
therefore rotect against se6uence nu!ber wra-around.
5TTA was secified in a sy!!etrical !anner, so that TSval ti!esta!s are carried in
both data and A;D seg!ents and are echoed in TSecr fields carried in returning A;D or
data seg!ents. &A#S sub!its all inco!ing seg!ents to the sa!e test, and therefore
rotects against dulicate A;D seg!ents as well as data seg!ents. 7An alternative un-
sy!!etric algorith! would rotect against old dulicate A;Ds$ the sender of data would
re>ect inco!ing A;D seg!ents whose TSecr values were less than the TSecr saved fro!
the last seg!ent whose A;D field advanced the left edge of the send window. This
algorith! was dee!ed to lack econo!y of !echanis! and sy!!etry.8
TSval ti!esta!s sent on VSRNW and VSRN,A;DW seg!ents are used to initiali9e
&A#S. &A#S rotects against old dulicate non-SRN seg!ents, and dulicate SRN
seg!ents received while there is a synchroni9ed connection. )ulicate VSRNW and
VSRN,A;DW seg!ents received when there is no connection will be discarded by the
nor!al *-way handshake and se6uence nu!ber checks of T;&.
(eader Prediction
As we want to know that fro! which T;& connection this acket belongs. So for each
new acket we have to !atch the header of each acket to the database that will take a lot
of ti!e so what we do is we first co!are this header with the header of last received
acket and on an average this will reduce the work. Assu!ing that this acket is fro! the
sa!e T;& connection fro! where we have got the last one 7locality rincial8.
3'% 03!er 'ata#ra) %rotocol1
C)& -- like its cousin the Trans!ission ;ontrol &rotocol 7T;&8 -- sits directly on to of
the base Internet &rotocol 7I&8. In general, C)& i!le!ents a fairly <lightweight< layer
above the Internet &rotocol. It see!s at first site that si!ilar service is rovided by both
C)& and I&, na!ely transfer of data.4ut we need C)& for !ultile"ing?de!ultile"ing
of addresses.
C)&0s !ain urose is to abstract network traffic in the for! of datagra!s. A datagra!
co!rises one single <unit< of binary data= the first eight 7I8 bytes of a datagra! contain
the header infor!ation and the re!aining bytes contain the data itself.
C)& .eaders
The C)& header consists of four 7+8 fields of two bytes each$

Source &ort )estination &ort
length checksu!
source ort nu!ber
destination ort nu!ber
datagra! si9e
checksu!

C)& ort nu!bers allow different alications to !aintain their own <channels< for data=
both C)& and T;& use this !echanis! to suort !ultile alications sending and
receiving data concurrently. The sending alication 7that could be a client or a server8
sends C)& datagra!s through the source ort, and the reciient of the acket accets this
datagra! through the destination ort. So!e alications use static ort nu!bers that are
reserved for or registered to the alication. Other alications use dyna!ic
7unregistered8 ort nu!bers. 4ecause the C)& ort headers are two bytes long, valid ort
nu!bers range fro! 1 to -,,*,= by convention, values above +J%,% reresent dyna!ic
orts.
The datagra! si9e is a si!le count of the nu!ber of bytes contained in the header and
data sections . 4ecause the header length is a fi"ed si9e, this field essentially refers to the
length of the variable-si9ed data ortion 7so!eti!es called the ayload8. The !a"i!u!
si9e of a datagra! varies deending on the oerating environ!ent. #ith a two-byte si9e
field, the theoretical !a"i!u! si9e is -,,*, bytes. .owever, so!e i!le!entations of
C)& restrict the datagra! to a s!aller nu!ber -- so!eti!es as low as I%J( bytes.
C)& checksu!s work as a safety feature. The checksu! value reresents an encoding of
the datagra! data that is calculated first by the sender and later by the receiver. Should an
individual datagra! be ta!ered with 7due to a hacker8 or get corruted during
trans!ission 7due to line noise, for e"a!le8, the calculations of the sender and receiver
will not !atch, and the C)& rotocol will detect this error. The algorith! is not fool-
roof, but it is effective in !any cases. In C)&, check su!!ing is otional -- turning it
off s6uee9es a little e"tra erfor!ance fro! the syste! -- as oosed to T;& where
checksu!s are !andatory. It should be re!e!bered that check su!!ing is otional only
for the sender, not the receiver. If the sender has used checksu! then it is !andatory for
the receiver to do so.
Csage of the ;hecksu! in C)& is otional. In case the sender does not use it, it sets the
checksu! field to all 10s. Now if the sender co!utes the checksu! then the reciient
!ust also co!ute the checksu! an set the field accordingly. If the checksu! is
calculated and turns out to be all %0s then the sender sends all %0s instead of all 10s. This is
since in the algorith! for checksu! co!utation used by C)&, a checksu! of all %0s if
e6uivalent to a checksu! of all 10s. Now the checksu! field is una!biguous for the
reciient, if it is all 10s then checksu! has not been used, in any other case the checksu!
has to be co!uted.
'NS 0'o)ain Na)e Ser+ice1
The internet ri!arily uses I& addresses for locating nodes. .owever, its hu!anly not
ossible for us to kee track of the !any i!ortant nodes as nu!bers. Alhabetical
na!es as we see would be !ore convenient to re!e!ber than the nu!bers as we are
!ore fa!iliar with words. .ence, in the chaotic organi9ation of nu!bers 7I& addresses8
we would be !uch relieved if we can use fa!iliar sounding na!es for nodes on the
network.
There is also another !otivation for )NS. All the related infor!ation about a articular
network 7generally !aintained by an organi9ation, fir! or university8 should be available
at one lace. The organi9ation should have co!lete control over what it includes in its
network and how does it <organi9e< its network. Aeanwhile, all this infor!ation should
be available transarently to the outside world.
;oncetually, the internet is divide into several hundred to level do!ains where each
do!ain covers !any hosts. :ach do!ain is artitioned in subdo!ains which !ay be
further artitioned into subsubdo!ains and so on... So the do!ain sace is artitioned in
a tree like structure as shown below. It should be noted that this tree hierarchy has
nothing in co!!on with the I& address hierarchy or organi9ation.
The internet uses a hierarchical tree structure of )o!ain Na!e Servers for I& address
resolution of a host na!e.
The to level do!ains are either generic or na!es of countries. eg of generic to level
do!ains are .edu .!il .gov .org .net .co! .int etc. /or countries we have one entry for
each country as defined in ISO*%--. eg. .in 7India8 .uk 7Cnited Dingdo!8.
The leaf nodes of this tree are target !achines. Obviously we would have to ensure that
the na!es in a row in a subdo!ain are uni6ue. The !a" length of any na!e between two
dots can be -* characters. The absolute address should not be !ore than (,, characters.
)o!ain na!es are case insensitive. Also in a na!e only letters, digits and hyhen are
allowed. /or eg. www.iitk.ac.in is a do!ain na!e corresonding to a !achine na!ed
www under the subsubdo!ain iitk.ac.in.
*e!ource *ecord!:
:very do!ain whether it is a single host or a to level do!ain can have a set of resource
records associated with it. #henever a resolver 7this will be e"lained later8 gives the
do!ain na!e to )NS it gets the resource record associated with it. So )NS can be
looked uon as a service which !as do!ain na!es to resource records. :ach resource
record has five fields and looks as below$

)o!ain Na!e ;lass Tye Ti!e to 'ive 3alue
)o!ain na!e$ the do!ain to which this record alies.
;lass$ set to IN for internet infor!ation. /or other infor!ation other codes !ay be
secified.
Tye$ tells what kind of record it is.
Ti!e to live$ Cer 'i!it on the ti!e to reach the destination
3alue$ can be an I& address, a string or a nu!ber deending on the record tye.
'NS 0Contd<<<1
Resorce Record
A *e!ource *ecord 7558 has the following$
owner which is the do!ain na!e where the 55 is found.
type which is an encoded %- bit value that secifies the tye of the resource in
this resource record. It can be one of the following$
o A a host address
o CNA," identifies the canonical na!e of an alias
o HIN.O identifies the ;&C and OS used by a host
o ,O identifies a !ail e"change for the do!ain.
o NS the authoritative na!e server for the do!ain
o %(* a ointer to another art of the do!ain na!e sace
o SOA identifies the start of a 9one of authority class which is an encoded
%- bit value which identifies a rotocol fa!ily or instance of a rotocol.
cla!! One of$ IN the Internet syste! or CH the ;haos syste!
((L which is the ti!e to live of the 55. This field is a *( bit integer in units of
seconds, an is ri!arily used by resolvers when they cache 55s. The TT'
describes how long a 55 can be cached before it should be discarded.
*'A(A )ata in this field deends on the values of the tye and class of the 55
and a descrition for each is as follows$
o for A$ /or the IN class, a *( bit I& address /or the ;. class, a do!ain
na!e followed by a %- bit octal ;haos address.
o for ;NAA:$ a do!ain na!e.
o for AQ$ a %- bit reference value 7lower is better8 followed by a host
na!e willing to act as a !ail e"change for the owner do!ain.
o for NS$ a host na!e.
o for &T5$ a do!ain na!e.
o for SOA$ several fields.
Note: #hile short TT's can be used to !ini!i9e caching, and a 9ero TT' rohibits
caching, the realities of Internet erfor!ance suggest that these ti!es should be on the
order of days for the tyical host. If a change can be anticiated, the TT' can be reduced
rior to the change to !ini!i9e inconsistency during the change, and then increased back
to its for!er value following the change. The data in the 5)ATA section of 55s is
carried as a co!bination of binary strings and do!ain na!es. The do!ain na!es are
fre6uently used as <ointers< to other data in the )NS.
Aliases and Cannonical Names
So!e servers tyically have !ultile na!es for convenience. /or e"a!le www.iitk.ac.in
Y ya!una.iitk.ernet.in identify the sa!e server. In addition !ultile !ailbo"es !ight be
rovided by so!e organi9ations. Aost of these syste!s have a notion that one of the
e6uivalent set of na!es is the canonical or ri!ary na!e and all others are aliases.
#hen a na!e server fails to find a desired 55 in the resource set associated with the
do!ain na!e, it checks to see if the resource set consists of a ;NAA: record with a
!atching class. If so, the na!e server includes the ;NAA: record in the resonse and
restarts the 6uery at the do!ain na!e secified in the data field of the ;NAA: record.
Name Ser-ers
Na!e servers are the reositories of infor!ation that !ake u the do!ain database. The
database is divided u into sections called 9ones, which are distributed a!ong the na!e
servers. Na!e servers can answer 6ueries in a si!le !anner= the resonse can always be
generated using only local data, and either contains the answer to the 6uestion or a
referral to other na!e servers <closer< to the desired infor!ation. The way that the na!e
server answers the 6uery deends uon whether it is oerating in recursive !ode or
iterative !ode$
The si!lest !ode for the server is non-recursive, since it can answer 6ueries
using only local infor!ation$ the resonse contains an error, the answer, or a
referral to so!e other server <closer< to the answer. All na!e servers !ust
i!le!ent non-recursive 6ueries.
The si!lest !ode for the lient is recursive, since in this !ode the na!e server
acts in the role of a resolver and returns either an error or the answer, but never
referrals. This service is otional in a na!e server, and the na!e server !ay also
choose to restrict the clients which can use recursive !ode.
*ecur!i+e Kuery +! Iterati+e Kuery
If the server is suosed to answer a recursive 6uesry then the resonse is either the
reource record data or a error code. A server oerating in this !ode will never return the
na!e of any forwarding na!e server but will contact the aroiate na!e server itself
and try to get the infor!ation.
In iterative !ode, on the other hand, if the server does not have the infor!ation re6uested
locally then it return the address of so!e na!e server who !ight have the infor!ation
about the 6uery. It is then the resonsibility of the contacting alication to contact the
ne"t na!e server to resolve its 6uery and do this iteratively until gets an answer or and
error.
Relati-e Names
In lace of giving full )NS na!es like cu(.cse.iitk.ac.in or bhaskar.cc.iitk.ac.in one can
give >ust cu( or bhaskar.This can be used by the server side as well as the client side.4ut
for this one has to !anually secify these e"tensions in the database of the servers
holding the resource records.
$OO(%
The 4OOT& uses C)&?I&. It is run when the !achine boots. The rotocol allows diskless
!achines to discover their I& address and the address of the server host. Additionally
na!e of the file to be loaded fro! !e!ory and e"ecuted is also sulied to the !achine.
This rotocol is an i!rove!ent over 5A5& which has the follwing li!itations$
%. Networks which do not have a broadcast !ethod can0t suort 5A5& as it uses
the broadcast !ethod of the AA; layer underneath the I& layer.
(. 5A5& is heavily deendent on the AA; rotocol.
*. 5A5& >ust sulies the I& address corresonding to a AA; address It doesn0t
suort resond with any !ore data.
+. 5A5& uses the co!uter hardware0s address to identify the !achine and hence
cannot be used in networks that dyna!ically assign hardware addresses.
$-ents in !OOTP
%. The ;lient broadcasts its AA; address 7or other uni6ue hardware identity
nu!ber8 asking for hel in booting.
(. The 4OOT& Server resonds with the data that secifies how the ;lient should be
configured 7re-configured for the secific client8
Note: 4OOT& doesn0t use the AA; layer broadcast but uses C)&?I&.
Confi#ration Information
The i!ortant infor!ations rovided are$
I& address
I& address of the default router for that articular subnet
Subnet !ask
I& addresses of the ri!ary and secondary na!eservers
Additionaly it !ay also rovide$
Ti!e offset fro! BAT
The I& address of a ti!e server
The I& address of a boot server
The na!e of a boot file 7e.g. boot i!age for Q ter!inals8
The I& do!ain na!e for the client
4ut the roble! with 4OOT& is that it again can0t be used for the dyna!ic I&0s as in
5A5& servers./or getting dyna!ic I&0s we use ).;&.
'HC% 0'yna)ic Ho!t Confi#uration %rotocol1
).;& 7)yna!ic .ost ;onfiguration &rotocol8 is a rotocol that lets network
ad!inistrators !anage centrally and auto!ate the assign!ent of Internet &rotocol 7I&8
addresses in an organi9ation0s network. If a !achine uses Internet0s set of rotocol
7T;&?I&8, each !achine that can connect to the Internet needs a uni6ue I& address. #hen
an organi9ation sets u its co!uter users with a connection to the Internet, an I& address
!ust be assigned to each !achine. #ithout ).;&, the I& address !ust be entered
!anually at each co!uter and, if co!uters !ove to another location in another art of
the network, a new I& address !ust be entered. ).;& lets a network ad!inistrator
suervise and distribute I& addresses fro! a central oint and auto!atically sends a new
I& address when a co!uter is lugged into a different lace in the network.
IP Address Allocation Mechanism
).;& suorts three !echanis!s for I& address allocation.
Auto)atic allocation: ).;& assigns a er!anent I& address to a host.
'yna)ic allocation: ).;& assigns an I& address to a host for a li!ited eriod of
ti!e 7or until the host e"licitly relin6uishes the address8.
,anual allocation: .ost0s I& address is assigned by the network ad!inistrator,
and ).;& is used si!ly to convey the assigned address to the host. A articular
network will use one or !ore of these !echanis!s, deending on the olicies of
the network ad!inistrator.
Messa#es 9sed )y D(CP
'HC% 'i!co+er - ;lient broadcast to locate available servers. It is assu!ed
atleast one of the servers will have resources to fulfill the re6uest.7 !ay include
additional ointers to secific services re6uired eg. articular subnet, !ini!u!
ti!e li!it etc 8.
'HC% Offer - Server to client in resonse to ).;& )iscover with offer of
configration ara!eters.
'HC% *e4ue!t - ;lient broadcast to servers re6uesting offered ara!eters fro!
one server and i!licitly declining offers fro! all others.7 also i!ortant in case
of lease renewal if the alloted ti!e is about to e"ire 8.
'HC% 'ecline - ;lient to server indicating configration ara!eters invalid.
'HC% *elea!e - ;lient to server relin6uishing network address and cancelling
current lease.7 in case of a graceful shut down ).;& server is sent a ).;&
5elease by the host !achine8.
'HC% Ack - Server to client with configration ara!eters, including co!!itted
Network address.
'HC% Nack - Server to client refusing re6uest for configratin ara!eters 7eg.
re6uested network address already allocated8.
Timers 9sed
Note that lease ti!e is the ti!e secified by the server for which the services have been
rovided to the client.
Lea!e *enewal (i)er - #hen this ti!er e"ires !achine will ask the server for
!ore ti!e sending a ).;& 5e6uest.
Lea!e *ebindin# (i)er - #henever this ti!er e"ires, we have not been
receiving any resonse fro! the server and so we can assu!e the server is down.
Thus send a ).;& 5e6uest to all the servers using I& 4roadcast facility. This is
only oint of difference between 'ease renewal and rebinding.
Lea!e "xpiry (i)er - #henever this ti!er e"ires, the syste! will have to start
crashing as the host does not have a valid I& address in the network.

Timer Confi#ration Policy
The ti!ers have this usual setting which can be configured deending uon the usage
attern of the network. An e"a!le setting has been discussed below.
'ease 5enewal F ,1 H 'ease ti!e
'ease 5ebinding F I7., H 'ease ti!e
'ease :"iry F %11 H 'ease ti!e
*outin# in Internet
The Ori#in of Internet
The resonse of Internet to the issue of choosing routing tables with co!lete?ar tail
infor!ation is shown by the following architecture. There are a few nodes having
co!lete routing infor!ation and a large nu!ber of nodes with artial infor!ation. The
nodes with co!lete infor!ation, called core gateways, are well connected by a
4ackbone Network. These nodes talk to each other to kee the!selves udated. The non-
core gateways are connected to the core gateways. 7.istorically, this architecture co!es
fro! the A5&AN:T.8
The original internet was structured around a backbone of A5&AN:T with several core
gateways connected to it .These core gateways connected so!e 'ocal Area Networks
7'ANs8 to the rest of the network. These core gateways talked to the!selves and
e"changed routing infor!ation0s. :very core gateway contained co!lete infor!ation
about all ossible destinations.
(ow do yo do rotin# .
The usual I& routing algorith! e!loys an internet routing table 7so!e ti!es called an I&
routing table8 on each !achine that Stores the infor!ation about the ossible
destinations, and how to reach the!.
'efault *oute!
This techni6ue used to hide infor!ation and kee routing table si9e s!all consolidates
!ultile entries into a default case. If no route aears in the routing table, the routing
routine sends the data gra! to the default router.
)efault routing is esecially useful when a site has a s!all set of local addresses and only
one connection to the rest of the internet.
Ho!t-Specific *oute!
Aost I& routing software allows er-host routes to be secified as a secial case. .aving
er-host routes gives the local network ad!inistrator !ore control over network use,
er!its testing, and can also be used to control access for security uroses. when
debugging network connections or routing tables, the ability to secify a secial route to
one individual !achine turns out to be esecially useful.
Internet with (wo $ackbone!
As long as there was >ust one single router connecting A5&AN:T with NS/N:T there
was no roble!. The core gateways of A5&AN:T had infor!ation about all destinations
and the routers inside NS/N:T contained infor!ation about local destinations and used a
default route to send all non-NS/N:T traffic to between NS/N:T and A5&AN:T as
both of the! used different !atrices to !easure costs. the core gateways through the
router between A5&AN:T and NS/N:T. .owever as !ultile connections were !ade
between the two backbones, roble!s arise. #hich route should a acket fro! net% to
net( takeP Should it be *> or *@ or *A or *6 or *7P /or this so!e e"change of routing
infor!ation between the two backbones was necessary. 4ut, this was again a roble! as
how should we co!are infor!ation.
=ateway1To1=ateway Protocol *==P,
This was the rotocol used by the core-routers to e"change routing infor!ation a!ong
the!selves. This is based on +istance ,ector Algorithm and uses nu!ber of hos as the
distance !etric. This is a very oor !etric as this does not take into account the load on
the links and whether a link is slow or fast. A rovision is !ade to !anually incre!ent
the ho count in case a link is articularly slow.A rotocol based on Shortest &ath /irst
Algorith! , known as S%*"A' ,was also used for the sa!e urose.
Added Co)plexity (o (he Architecture ,odel
As the nu!ber of networks and routers increased, to reduce the load on the core gateways
because of the enor!ous a!ount of calculations, routing was done with so!e core
gateways keeing co!lete infor!ation and the non-core gateways keeing artial
infor!ation.
In thisarchitecture, B
%
,B
(
,B
*
are all core gateways and B
+
and B
,
are non-core gateways.
#e !ust have a !echanis! for so!eone to tell B
(
that it is connected to net( , net* and
net+ , besides net%. Only B
,
can tell this to B
(
and so we !ust rovide for a !echanis!
for B
(
to talk to B
,
. A concet of one backbone with core gateways connected to
'utonomous Systems was develoed. An 'utonomous system is a grou of networks
controlled by a single ad!inistrative authority. 5outers within an autono!ous syste! are
free to choose their own !echanis!s for discovering , roagating ,validating , and
checking the consistency of routes. :ach autono!ous syste! !ust agree to advertise
network reachability infor!ation to other autono!ous syste!s. :ach advertise!ent
roagates through a core router. The assu!tion !ade is that !ost of the routers in the
autono!ous syste! have co!lete infor!ation about the autono!ous syste!. One such
router will be assigned the task of talking to the core gateway.
Interior =ateway Protocols *I=P,
IB& is a tye of rotocols used by the routers in an autono!ous syste! to e"change
network reachability and routing infor!ation. So!e of IB&s are given below.
*outin# Infor)ation %rotocol 0*I%1
This is one of the !ost widely used IB&. It was develoed at 4erkeley. This is also known
by the na!e of the rogra! that i!le!ents it, routed .This i!le!ents )istance 3ector
algorith!./eatures of 5I&$
5I& uses a ho count !etric to !easure the distance to a destination. To
co!ensate for differences in technologies, !any 5I& i!le!entations allow
!anagers to configure artificially high ho counts when advertising connections
to slow networks. All routinfg udates are broadcast. This allows all hosts on the
network to know about the routes.
To revent routes fro! oscillating between two or !ore e6ual cost aths, 5I&
secifies that e"isting routes should be retained until a new route has strictly
lower cost. Since 5I& does not e"licitly detect routing loos, 5I& !ust either
assu!e articiants can be trusted 7being art of one autono!ous syste!8 or take
recautions to revent such loos.
To revent instabilities, 5I& !ust use a low value for the !a"i!u! ossible
distance.5I& uses %- as the !a"i!u! ho count. This restricts the !a"i!u!
network dia!eter of the syste! to %-.
To solve the slow convergence roble! arising due to slow roagation of routing
infor!ation, 5I& uses .old )own. If a articular link is down , any new
infor!ation about that link is not acceted till so!e ti!e. This is because the
router !ust wait till the infor!ation aboutthe link being down roagates to
another router before acceting infor!ation fro! that router about that down link.
5I& runs on to of T;&?I&. 5I& allows addresses to be of a !a"i!u! si9e of %+
4ytes. The )istance varies fro! % to %- 7where %- is used to signify infinity8. 5I&
address 1.1.1.1 denotes a default route. There is no e"licit si9e of the 5I&
!essage and any nu!ber of routes can be adverti9ed.
The !essage for!at is as shown$
OS%.0Open Shorte!t %ath .ir!t 1
This is an Interior Bateway &rotocol designed by the Internet :ngineering Task /orce
7 I:T/ 8. This algorith! scales better than the vector distance algorith!s. This &rotocol
tackles several goals$
OS&/ includes tye of service7ToS8 routing. So, you can install!ultile routers to
a given destination, one for each tye of service. #hen routing a datagra!, a
router running OS&/ uses both the destination address and tye of service fields
in the I& .eader to choose a route.
OS&/ rovides load balancing. If there are !ultile routes to a given destination
at the sa!e cost, OS&/ distributes traffic over all the routes e6ually.
OS&/ allows for creation of A5:A .I:5A5;.I:S. This !akes the growth of
the network easier and !akes the network at a site easier to !anage. :ach area is
self contained, so, !ultile grous within a site can cooerate in the use of OS&/
for routing.
OS&/ rotocol secifies that all e"changes between the routers be authenticated.
OS&/ allows variety of authentication sche!es, and even allows one area to
choose a different sche!e fro! the other areas.
To acco!odate !ulti-access networks like ethernet, OS&/ allows every !ulti-
access network to have a designated router7 designated gateway8.
To er!it !a"i!u! fle"ibility, OS&/ allows the descrition of a virtual network
toology that abstracts away fro! details of hysical connections.
OS&/ also allows for routers to e"change routing infor!ation learned fro! other
sites. The !essage for!at distinguishes between infor!ation ac6uired fro!
e"ternal sources and infor!ation ac6uired fro! routers interior to the site, so
there is no a!biguity about the source or reliability of routes.
It hastoo !uch overhead of sending 'S&s but is gradually beco!ing oular.
"xterior 2ateway %rotocol 0"2%1
If two routers belonging to two different autono!ous syste!s e"change routing
infor!ation ,the rotocol used is called :B& . :B& consists of$
Ac4ui!ition *e4ue!t: A router sends a re6uest to another neighbour router saying
0I want to talk0.
Ac4ui!ition Confir): This is a ositive rely to the Ac6uisition re6uest.
Ac4ui!ition *efu!e: This is a negative resonse to the Ac6uisition re6uest.
Cea!e *e4ue!t: This re6uests ter!ination of neighbour relationshi.
Cea!e Confir): This is a confir!ation resonse to the ;ease 5e6uest.
Hello : This is used to find if the neighbour router is u or down.This re6uests
router to resond if alive.
I Heard Nou: This is a resonse to the .ello !essage confir!ing that the router
is alive. 4ecause it is ossible for .ello or I .eard Rou !essages to be lost in
transit, :B& uses a k-out-of-n rule to deter!ine whether a network is down.At
least k of the last n !essages !ust fail for the router to declare its neighbour
down.
%oll *e4ue!t: This is a re6uest for network routing udate.
*outin# 3pdate: This conveys routing infor!ation about reachable networks to
its :B& neighbour. The routing infor!ation is the distance vector of the reachable
networks.
"rror: This is a resonse to an incorrect !essage.
:B& is used only to find network reachability and not for differentiating between good
and bad routes. #e can only use distance !etric to declare a route lausible and not for
co!aring it with so!e other route 7unless the two route for! art of a sa!e autono!ous
syste!8. Since there cannot be two different routes to the sa!e network, :B& restricts
the toology of any internet to a tree structure in which a core syste! for!s the root.
There are no loos a!ong other autono!ous syste!s connected to it. This leads to
several roble!s$
Cniverasal connectivity fails if the core gateway syste! fails.
:B& can advertise only one ath to a given network.
:B& does not suort load sharing on routers between arbitrary autono!ous
syste!s.
Aultile backbone networks with !ultile connections between the! cannot be
handled by :B&.
$order 2ateway %rotocol0$2%1
4B& is a distance-vector rotocol used to co!!unicate between different ASes. Instead
of !aintaining >ust the cost to each destination,each 4B& router kees track of the e"act
ath used.Si!ilarly,instead of eriodically giving each neighbour its esti!ated cost to
each destination, each 4B& router tells its neighbours the ath it is using.:very 4B&
router contains a !odule that e"a!ines routes to a given destination and scores the!
returning a nu!ber for destination to each route. Any route violating a olicy constraint
auto!atically gets a score of infinity. The router adats a route with shortest distance.The
scoring function is not a art of the 4B& rotocol and can be any function that the syste!
!anagers want.4B& easily solves the count to infinity roble! that lagues other
distance-vector algorith!s as whole ath is known.
*outin# 0Continued1
Shortest Path Al#orithm
%. )i>ktstra0s Algorith!$
At the end each node will be labeled 7see Figure()8 with its distance fro! source node
along the best known ath. Initially, no aths are known, so all nodes are labeled with
infinity. As the algorith! roceeds and aths are found, the labels !ay change reflecting
better aths. Initially, all labels are tentative. #hen it is discovered that a label reresents
the shortest ossible ath fro! the source to that node, it is !ade er!anent and never
changed thereafter.
'ook at the weighted undirected grah of Figure()!a#, where the weights reresent, for
e"a!le, distance. #e want to find shortest ath fro! A to ). #e start by !aking node A
as er!anent, indicated by a filled in circle. Then we e"a!ine each of the nodes ad>acent
to A 7the working node8, relabeling each one with the distance to A. #henever a node is
relabeled, we also label it with the node fro! which the robe was !ade so that we can
construct the final ath later. .aving e"a!ined each of the nodes ad>acent to A, we
e"a!ine all the tentatively labeled nodes in the whole grah and !ake the one with the
s!allest label er!anent, as shown in Figure()!b#( This one beco!es new working node.
#e now start at 4, and e"a!ine all nodes ad>acent to it. If the su! of the label on 4 and
the distance fro! 4 to the node being considered is less than the label on the node, we
have a shorter ath, so the node is relabeled. After all the nodes ad>acent to the working
node have been insected and the tentative labels changed if ossible, the entire grah is
searched for the tentatively labeled node with the s!allest value. This node is !ade
er!anent and beco!es the working node for the ne"t round. The Figure( ) shows the
first five stes of the algorith!.

Note$ )i>kstra0s Algorith! is alicable only when cost of all the nodes is non-negative.
(. 4ell!an /ord0s Algorith!$
#e look at the distributed version which works on the re!ise that the infor!ation about
far away nodes can be had fro! the ad>oining links.
The algorith! works as follows.
o ;o!ute the link costs fro! the starting node to every directly connected
node .
o Select the cheaest links for every node 7if there is !ore than one8 .
o /or every directly connected node, co!ute the link costs for all these
nodes.
o Select the cheaest route for any node .
5eeat until all nodes have been rocessed.
:very node should have the infor!ation about it0s i!!ediate neighbors and over a eriod
of ti!e we will have infor!ation about other nodes. #ithin n units of ti!e , where n is
the dia!eter of the network, every node will have the co!lete infor!ation. #e do not
need to be synchroni9ed i.e. do not need to e"change infor!ation at the sa!e ti!e.
5outing algorith!s based on )i>kstra0s algorith! are called 'ink State Algorith!s.
)istance 3ector &rotocols are based on distributed 4ell!an0s algorith!. In the for!er we
are sending little infor!ation to !any nodes while in the latter we send huge infor!ation
to few neighbors.

-ount-to-Infinity problem.


Suose the link between A and : is down events !ay occur are$
7%8 / tells A that it has a ath to : with cost -
7(8 A sets cost to : to be %%, and advertise to / again
7*8 / sets the cost to : to be %-, and advertise to A again
This cycle will continue and the cost to : goes to infinity. The core of the roble! is that
when Q tells R that it has a ath so!ewhere ,R has no way to know whether it itself is on
the ath.
)uring this rocess of counting to infinity, ackets fro! A or / destined to : are likely
to loo back and forth between A and /, causing congestion for other ackets.

"xa)ple to illu!trate bad *outin# %rotocol :
)esign of a bad routing rotocol can lead to highly undesirable results. ;onsider the
following scenario to understand this. #e are having %- nodes logically connected in a
ring as shown in /igure%.


:ach node sends one unit of data in unit ti!e e"cet one node L which sends e 71XeX%8
unit of data in unit ti!e. #e consider cost of the link as the traffic in that link. #e
consider & as the only receiver in the ring. Now Ideally we !ust have nodes left of the
diagonal &L sending data clockwise and that on the right of the &L counterclockwise as
shown in /igure (. #e !ay assu!e that L sends data counterclockwise. Assu!e that this
ideal distribution was achieved at so!e ti!e. Now we can see that cost of links to the left
of &L are resectively %,(,* ..,7 while that on the right of &L are e,%2e,(2e ..,72e.
Therefore when we reconsider the shortest ath the node i!!ediately to the right of L
will see traffic (I to the left while (I27e to the right and therefore will start sending data
clockwise and sa!e is true for L also. This will heavily change the traffic on the network.
Now the traffic load will shift to the left of &L and ne"t reconsideration will !ake a lot of
nodes fro! left of &L send data counterclockwise. This !ay kee oscillating and will
cost a lot to the network. To revent these two stes can be taken $
%. Assign a !ini!u! cost to each link.
(. )o not change the route until you get a significant advantage.
*e)ote %rocedure Call
Data Con-ersion
There is a ossibility of having co!uters of different architectures in the sa!e network.
/or e.g. we !ay have ):; or Intel !achines 7 which use 'ittle-endian reresentation8
connected with I4A or Aotorola &;s 7which use 4ig-endian reresentation8 . Now a
!essage fro! an Intel !achine, sent in 'ittle-endian order, !ay be interreted by an I4A
!achine in 4ig-endian for!at. This will obviously give erroneous results. So we !ust
have so!e strategy to convert data fro! one !achine0s native for!at to the other one0s or,
to so!e standard network for!at.
A+ailable ,ethod! :
Abstract /ynta0 1otation %A/1"2) . This is the notation develoed by the ISO, to
describe the data structures used in co!!unication, in a fle"ible yet standard
enough way. The basic idea is to define all the data structure tyes 7 i.e., data
tyes8 needed by each alication in ASN.% and ackage the! together in a
)odule. #hen an alication wants to trans!it a data structure, it can ass the
data structure to the resentation layer, along with the ASN.% na!e of the data
structure. Csing the ASN.% definition as a guide, the resentation layer then
knows what the tyes and si9es of the fields are, and thus know how to encode
the! for trans!ission 7 *xpliit +yping8. It can be i!le!ented with Asy!!etric
or Sy!!etric data conversion.
E0ternal +ata 3epresentation %4+3) . This is i!le!ented using Sy!!etric
data reresentation. Q)5 is the standard reresentation used for data traversing
the network. Q)5 rovides reresentations for !ost of the structures that a ;-
rogra! can secify. .owever the encodings contain only data ite!s and not
infor!ation about their tyes. Thus, client and servers using Q)5 !ust agree on
the e"act for!at of !essages that they will e"change 7 ,mpliit +yping 8.
The chief advantage lies in fle"ibility$ neither the server nor the client need to
understand the architecture of the other. 4ut, co!utational overhead is the !ain
disadvantage. Nevertheless, it si!lifies rogra!!ing, reduces errors, increases
interoerability a!ong rogra!s and !akes easier network !anage!ent and
debugging.
+he -uffer Paradigm : Q)5 uses a buffer aradig! which re6uires a rogra! to
allocate a buffer large enough to hold the e"ternal reresentation of a !essage and
to add ite!s 7i.e., fields8 one at a ti!e. Thus a co!lete !essage is created in
Q)5 for!at.
Remote Procedre Call *RPC,
5&; co!es under the Alication-Oriented )esign, where the client-server
co!!unication is in the for! of &rocedure ;alls. #e call the !achine !aking the
rocedure call as lient and the !achine e"ecuting the called rocedure as server. /or
every rocedure being called there !ust e"ist a iece of code which knows which
!achine to contact for that rocedure. Such a iece of code is called a Stub. On the client
side, for every rocedure being called we need a uni6ue stub. .owever, the stub on the
server side can be !ore general= only one stub can be used to handle !ore than one
rocedures 7see figure 8. Also, two calls to the sa!e rocedure can be !ade using the
sa!e stub.
Now let us see how a tyical re!ote rocedure call gets e"ecuted $-
%. ;lient rogra! calls the stub rocedure linked within its own address sace. It is a
nor!al local call.
(. The client stub then collects the ara!eters and acks the! into a !essage
7Parameter Marshalling8. The !essage is then given to the transort layer for
trans!ission.
*. The transort entity >ust attaches a header to the !essage and uts it out on the
network without further ado.
+. #hen the !essage arrives at the server the transort entity there asses it tot the
server stub, which un!arshalls the ara!eters.
,. The server stub then calls the server rocedure, assing the ara!eters in the
standard way.
-. After it has co!leted its work, the server rocedure returns, the sa!e way as any
other rocedure returns when it is finished. A result !ay also be returned.
7. The server stub then !arshalls the result into a !essage and hands it off at the
transort interface.
I. The rely gets back to the client !achine.
J. The transort entity hands the result to the client stub.
%1. /inally, the client stub returns to its caller, the client rocedure, along-with the
value returned by the server in ste -.
This whole !echanis! is used to give the client rocedure the illusion that it is !aking a
direct call to a distant server rocedure. To the e"tent the illusion e"ceeds, the !echanis!
is said to be tran!parent. 4ut the transarency fails in parameter passing. &assing any
data 7 or data structure8 by value is OD, but assing ara!eter 0by reference0 causes
roble!s. This is because the ointer in 6uestion here, oints to an address in the address
sace of the client rocess, and this address sace is not shared by the server rocess. So
the server will try to search the address ointed to by this assed ointer, in its own
address sace. This address !ay not have the value sa!e as that on the client side, or it
!ay not lie in the server rocess0 address sace, or such an address !ay not even e"ist in
the server address sace.
One solution to this can be Copy-in Copy-out. #hat we ass is the value of the ointer,
instead of the ointer itself. A local ointer, ointing to this value is created on the server
side 7Copy.in8. #hen the server rocedure returns, the !odified 0value0 is returned, and is
coied back to the address fro! where it was taken 7Copy.out8. 4ut this is
disadvantageous when the ointer involved oint to huge data structures. Also this
aroach is not foolroof. ;onsider the following e"a!le 7 ;-code8 $
The rocedure 0!yfunction780 resides on the server !achine. If the rogra! e"ecutes on a
single !achine then we !ust e"ect the outut to be 0+0. 4ut when run in the client-server
!odel we get 0*0. #hy P 4ecause 0", and 0y0 oint to different !e!ory locations with the
sa!e value. :ach then incre!ents its own coy and the incre!ented value is returned.
Thus 0*0 is assed back and not 0+0.
Aany 5&; syste!s finesse the whole roble! by rohibiting the use of reference
ara!eters, ointers, function or rocedure ara!eters on re!ote calls 7Copy-in8. This
!akes the i!le!entation easier, but breaks down the transarency.
%rotocol : Another key i!le!entation issue is the rotocol to be used - T;& or C)&. If
T;& is used then there !ay be roble! in case of network breakdown. No roble!
occurs if the breakdown haens before client sends its re6uest 7client will be notified of
this8, or after the re6uest is sent and the rely is not received 7 ti!e-out will occur8. In
case the breakdown occurs >ust after the server has sent the rely, then it won0t be able to
figure out whether its resonse has reached the client or not. This could be devastating for
bank servers, which need to !ake sure that their rely has in fact reached to the client
7 robably an ATA !achine8. So C)& is generally referred over T;&, in !aking re!ote
rocedure calls.
Ide)potent Operation!:
If the server crashes, in the !iddle of the co!utation of a rocedure on behalf of a
client, then what !ust the client doP Suose it again sends its re6uest, when the server
co!es u. So so!e art of the rocedure will be re-co!uted. It !ay have instructions
whose reeated e"ecution !ay give different results each ti!e. If the side effect of
!ultile e"ecution of the rocedure is e"actly the sa!e as that of one e"ecution, then we
call such rocedures as Ide)potent %rocedure!. In general, such oerations are called
Ide)potent Operation!.
/or e.g. consider ATA banking. If I send a re6uest to withdraw 5s. (11 fro! !y account
and so!e how the re6uest is e"ecuted twice, then in the two transactions of 0withdrawing
5s. (110 will be shown, whereas, I will get only 5s. (11. Thus 0withdrawing is a non-
ide!otent oeration. Now consider the case when I send a re6uest to 0check !y
balance0. No !atter how !any ti!es is this re6uest e"ecuted, there will arise no
inconsistency. This is an ide!otent oeration.
Se)antic! of *%C :
If all oerations could be cast into an ide!otent for!, then ti!e-out and retrans!ission
will work. 4ut unfortunately, so!e oerations are inherently non-ide!otent 7e.g.,
transferring !oney fro! one bank account to another 8. So the e"act se!antics of 5&;
syste!s were categori9ed as follows$
*xatly one : .ere every call is carried out 0e"actly once0, no !ore no less. 4ut
this goal is unachievable as after a server crash it is i!ossible to tell that a
articular oeration was carried out or not.
't most one : when this for! is used control always returns to the caller. If
everything had gone right, then the oeration will have been erfor!ed e"actly
once. 4ut, if a server crash is detected, retrans!ission is not atte!ted, and
further recovery is left u to the client.
't least one : .ere the client stub kees trying over and over, until it gets a
roer rely. #hen the caller gets control back it knows that the oeration has
been erfor!ed one or !ore ti!es. This is ideal for ide!otent oerations, but
fails for non-ide!otent ones.
/ast of many : This a version of 0At least once0, where the client stub uses a
different transaction identifier in each retrans!ission. Now the result returned is
guaranteed to be the result of the final oeration, not the earlier ones. So it will be
ossible for the client stub to tell which rely belongs to which re6uest and thus
filter out all but the last one.
S9N RPC Model
The basic idea behind Sun 5&; was to i!le!ent N/S 7Network /ile Syste!8. Sun 5&;
e"tends the re!ote rocedure call !odel by defining a re!ote e"ecution enviro!ent. It
defines a remote program at the server side as the basic unit of software that e"ecutes on
a re!ote !achine. :ach re!ote rogra! consists of one or !ore re!ote rocedures and
global data. The global data is static data and all the rocedures inside a re!ote rogra!
share access to its global data. The figure below illustrates the concetual organi9ation of
three re!ote rocedures in a single re!ote rogra!.
Sun 5&; allows both T;& and C)& for co!!unication between re!ote rocedures and
rogra!s calling the!. It uses the at least once se!antic i.e., the re!ote rocedure is
e"ecuted at least once. It uses coy-in !ethod of ara!eter assing but does not suort
coy-out style. It uses Q)5 for data reresentation. It does not handle orhans7which are
servers whose corresonding clients have died8. Thus if a client gives a re6uest to a
server for e"ecution of a re!ote rocedure and eventually dies before acceting the
results, the server does not know who! to rely. It also uses a tool called rpcgen to
generate stubs auto!atically.
'et us suose that a client 7say client%8 wants to e"ecute rocedure &%7in the figure
above8. Another client 7say client(8 wants to e"ecute rocedure &(7in the figure above8.
Since both &% and &( access co!!on global variables they !ust be e"ecuted in a
!utually e"clusive !anner. Thus in view of this Sun 5&; rovides !utual e"clusion by
default i.e. no two rocedures in a rogra! can be active at the sa!e ti!e. This
introduces so!e a!ount of delay in the e"ecution of rocedures, but !utual e"clusion is
a !ore funda!ental and i!ortant thing to rovide, without it the results !ay go wrong.
Thus we see that anything which can be a threat to alication rogra!!ers, is rovided
by SCN 5&;.
(ow A Client In-okes A Procedre On Another (ost
The re!ote rocedure is a art of a rogra! e"ecuting in a re!ote host. Thus we would
have to roerly locate the host, the rogra! in it, and the rocedure in the rogra!.
:ach host can be secified by a uni6ue *(-bit integer. SCN 5&; standard secifies that
each re!ote rogra! e"ecuting on a co!uter !ust be assigned a uni6ue *(-bit integer
that the caller uses to identify it. /urther!ore, Sun 5&; assigns a *(-bit integer identifier
for each re!ote rocedure inside a given re!ote rogra!. The rocedures are nu!bered
se6uentially$ %, (, ...., N. To hel ensure that rogra! nu!bers defined by searate
organi9ations do not conflict, Sun 5&; has divided the set of rogra! nu!bers into eight
grous.
Thus it see!s sufficient that if we are able to locate the host, the rogra! in the host, and
the rocedure in the rogra!, we would be able to uni6uely locate the re!ote rocedure
which is to be e"ecuted.
Accommodatin# Mltiple >ersions Of A Remote Pro#ram
Suose so!ebody wants to change the version of a re!ote rocedure in a re!ote
rogra!. Then as er the identification !ethod described above, he or she would have to
!ake sure that the newer version is co!atible with the older one. This is a bottleneck on
the server side. Sun 5&; rovides a solution to this roble!. In addition to a rogra!
nu!ber, Sun 5&; includes a *(-bit integer version number for each re!ote rogra!.
Csually, the first version of a rogra! is assigned version %. 'ater versions each receive a
uni6ue version nu!ber.
3ersion nu!bers rovide the ability to change the details of a re!ote rocedure call
without obtaining a new rogra! nu!ber. Now, the newer client and the older client are
dis>oint, and no co!atibility is re6uired between the two. #hen no re6uest co!es for
the older version for a retty long ti!e, it is deleted. Thus, in ractice, each 5&; !essage
identifies the intended reciient on a given co!uter by a trile$
7rogra! nu!ber, version nu!ber, rocedure nu!ber8
Thus it is ossible to !igrate fro! one version of a re!ote rocedure to another
gracefully and to test a new version of the server while an old version of the server
continues to oerate.
Mappin# A Remote Pro#ram To A Protocol Port
At the botto! of every co!!unication in the 5&; !odel there are transort rotocols
like C)& and T;&. Thus every co!!unication takes lace with the hel of sockets. Now,
how does the client know to which ort to connect to the serverP This is a real roble!
when we see that we cannot have a standard that a articular rogra! on a articular host
should co!!unicate through a articular ort. 4ecause the rogra! nu!ber is *( bit and
we can have (
*(
rogra!s whereas both T;& and C)& uses %- bit ort nu!bers to
identify co!!unication endoints. Thus 5&; rogra!s can otentially outnu!ber
rotocol orts. Thus it is i!ossible to !a 5&; rogra! nu!bers onto rotocol orts
directly. Aore i!ortant, because 5&; rogra!s cannot all be assigned a uni6ue rotocol
ort, rogra!!ers cannot use a sche!e that deends on well-known rotocol ort
assign!ents. Thus, at any given ti!e, a single co!uter e"ecutes only a s!all nu!ber of
re!ote rogra!s. As long as the ort assign!ents are te!orary, each 5&; rogra! can
obtain a rotocol ort nu!ber and use it for co!!unication.
If an 5&; rogra! does not use a reserved, well-known rotocol ort, clients cannot
contact it directly. 4ecause, when the server 7re!ote rogra!8 begins e"ecution, it asks
the oerating syste! to allocate an unused rotocol ort nu!ber. The server uses the
newly allocated rotocol ort for all co!!unication. The syste! !ay choose a different
rotocol ort nu!ber each ti!e the server begins7i.e., the server !ay have a different ort
assigned each ti!e the syste! boots8.
The client 7the rogra! that issues the re!ote rocedure call8 knows the !achine address
and 5&; rogra! nu!ber for the re!ote rogra! it wishes to contact. .owever, because
the 5&; rogra! 7server8 only obtains a rotocol ort after it begins e"ecution, the client
cannot know which rotocol ort the server obtained. Thus, the client cannot contact the
re!ote rogra! directly.
Dynamic Port Mappin#
To solve the ort identification roble!, a client !ust be able to !a fro! an 5&;
rogra! and a !achine address to the rotocol ort that the server obtained on the
destination !achine when it started. The !aing !ust be dyna!ic because it can change
if the !achine reboots or if the 5&; rogra! starts e"ecution again.
To allow clients to contact re!ote rogra!s, the Sun 5&; !echanis! includes a
dyna!ic !aing service. The 5&; ort !aing !echanis! uses a server to !aintain a
s!all database of ort !aings on each !achine. This 5&; server waits on a articular
ort nu!ber 7%%%8 and it receives the re6uests for all re!ote rocedure calls.
#henever a re!ote rogra! 7i.e., a server8 begins e"ecution, it allocates a local ort that
it will use for co!!unication. The re!ote rogra! then contacts the server on its local
!achine for registration and adds a air of integers to the database$
75&; rogra! nu!ber, rotocol ort nu!ber8
Once an 5&; rogra! has registered itself, callers on other !achines can find its
rotocol ort by sending a re6uest to the server. To contact a re!ote rogra!, a caller
!ust know the address of the !achine on which the re!ote rogra! e"ecutes as well as
the 5&; rogra! nu!ber assigned to the rogra!. The caller first contacts the server on
the target !achine, and sends an 5&; rogra! nu!ber. The server returns the rotocol
ort nu!ber that the secified rogra! is currently using. This server is called the 35-
port mapper or si!ly the port mapper. A caller can always reach the ort !aer
because it co!!unicates using the well known rotocol ort, %%%. Once a caller knows
the rotocol ort nu!ber the target rogra! is using, it can contact the re!ote rogra!
rogra! directly.
RPC Pro#rammin#
5&; &rogra!!ing can be thought in !ultile levels. At one e"tre!e, the user writing the
alication rogra! uses the 5&; library. .e?she need not have to worry about the
co!!unication through the network. At the other end there are the low level details about
network co!!unication. To e"ecute a re!ote rocedure the client would have to go
through a lot of overhead e.g., calling Q)5 for for!atting of data, utting it in outut
buffer, connecting to ort !aer and subse6uently connecting to the ort through which
the re!ote rocedure would co!!unicate etc. The 35- library contains rocedures that
rovide al!ost everything re6uired to !ake a re!ote rocedure call. The library contains
rocedures for !arshaling and un!arshaling of the argu!ents and the results
resectively. )ifferent Q)5 routines are available to change the for!at of data to Q)5
fro! native, and fro! Q)5 to native for!at. 4ut still a lot of overhead re!ains to
roerly call the library routines. To !ini!i9e the overhead faced by the alication
rogra!!er to call a re!ote rocedure a tool na!ed rpcgen is devised which generates
client and server stubs. The stubs are generated auto!atically, thus they have loose
fle"ibility e.g., the ti!eout ti!e, the nu!ber of retrans!issions are fi"ed. The rogra!
secification file is given as inut and both the server and client stubs are auto!atically
generated by rcgen. The secification file should have a ." e"tension attatched to it. It
contains the following infor!ation$-
constant declarations ,
global data 7if any8,
infor!ation about all re!ote rocedures ie.
rocedure argu!ent tye ,
return tye .

*e)ote %rocedure Call 0Contd<<<1
#e now look at the different ways of writing 5&; rogra!s. There are three levels at
which 5&; rogra!s can be written$
%. On one e"tre!e we can use so!e standard alications or rogra!s rovided by
sun-5&;. /or e"a!le, one can use the library function int rnusers 7char
Z!achinena!e 8 for finding nu!ber of users logged onto a re!ote syste!.
(. On the other hand we can use 5&; runti!e library $ This has the !a"i!u!
fle"ibility and efficiency. It has various functions like oening a connection,
connecting to a ort-!aer and other low level functions. Csing this we can
write our own stubs. This is however relatively difficult to use.
*. The best aroach is to use 5&;gen $ 5&;gen stands for 5&; generator. It
generates client and server stubs. There are several details that cannot be easily
controlled 7for e"a!le, the nu!ber of retries in case of ti!eout8. 5&;gen takes
as inut a secification file which has a list of the rocedures and argu!ents. It
creates the client stub and server stub.
"ritin# the Confi#ration 6ile
If we use RPCgen, then our work is essentially reduced to writing a secification file.
This file has the rocedure na!es, argu!ent tyes, return tyes etc. .ere we show a
si!le 5&; secification file 7 sec." 8 for rinting a !essage on so!e other !achine $

program M*SS'0*PR10 2
version M*SS'0*V*RS 2
int PR,N+M*SS'0* ! string # 3 )4
5 3 )4
5 3 664

#e will have to do so!e changes on the server as well as client side. The server rogra!
7 !sg@roc.c 8 will look like this $

7inlude 8stdio(h9
7inulde 8rp:rp(h9
7inlude ;msg(h;
int <printmessage%)! msg #
har <<msg4
2
( ( ( ( (
( ( ( ( (
5

On the client side the rogra! 7 client.c 8 will look like
7inlude 8stdio(h9
7inulde 8rp:rp(h9
7inlude ;msg(h;
main! int arg" har <argv=>#
2
lient <)4
int <result4
har <server 3 argv=)>4
har <message 3 argv=?>4
if !! ) 3 lnt%reate! server" M*SS'0*PR10" M*SS'0*V*RS" ;tp; ## 33
N@//
2
:: error
5
result 3 printmessage%)! Amessage" )#4
( ( ( ( (
5
After creating the secification file we give the co!!and \rcgen sec." 7 where
sec." is the na!e of the secification file 8. The following files actions are taken and the
files sec.h, sec@svc.c, sec@clnt.c get created $
Once we have these files we write
\cc !sg@roc.c sec@svc.c
\cc client.c sec@clnt.c

%. #hen we start the server rogra! it creates a socket and binds any local ort to it. It
then calls sv%register" to register the rogra! nu!ber and version. This function contacts
the ort !aer to register itself.
(. #hen the client rogra! is started it calls lnt%reate. This call secifies the na!e of
the re!ote syste!, the rogra! nu!ber, version nu!ber, and the rotocol. This functions
contacts the ort !aer and finds the ort for the server 7 Sun 5&; suorts both T;&
and C)&8.
*. The client now calls a re!ote rocedure defined in the client stub. This stub sends the
datagra!?acket to the server, using the ort nu!ber obtained in ste two. The client
waits for a resonse trans!itting the re6uests a fi"ed nu!ber of ti!es in case of a
ti!eout. This datagra!?acket is received by the server stub associated with the server
rogra!. The server stub e"ecutes the called rocedure. #hen the function returns to the
server stub it takes the return value, converts it to the Q)5 for!at and trans!its it back
to the client. The client stub receives the resonse, converts it as re6uired and returns to
the client rogra!
Athentication
5&; defines several ossible for!s of authentication, including a si!le authentication
sche!e that relies on CNIQ and a !ore co!le" sche!e that uses the +ata Encryption
/tandard %+E/).
Authentication rotocols can be of the following tyes$
N3LL Authentication - In this case, no authentication is done. Neither the client
cares about its identity nor the server cares who the client is. :"a!le is a ti!e
server.
3NIO Style Authentication - Cni" authentication relies on the client !achine to
suly its hostna!e and the userid of the user !aking the re6uest. The client also
secifies its local ti!e as a ti!esta! which can be used to se6uence re6uests.
The client also sends the !ain nu!eric grou identifier of the grou of which the
user is a !e!ber and also the grou identifiers of all the grous of which the user
is a !e!ber. 4ased on this infor!ation, the server decides whether the client will
be given er!ission to e"ecute the rocedure re6uested. This is a very weak for!
of security as the user and grou identifiers are the sa!e as CI) and BI) in the
client0s own !achine, and anyone can send these infor!ation and see the data.
This for! of authentication is used in N/S.
'ata "ncryption Standard 0'"S1 - .ere the client gives a assword which is
sent to the server in encryted for!. :ncrytion is done based on keys which are
known only to the client and the server. This is indeed a owerful !ethod of
authentication.
SHO*( - This !ethod is used for short for! of authentication in !essages after
the first one. The client is authenticated only once during the initial handshake
and a handle is given to the client. In future the client co!!unicates with the
server using the handle. It is difficult for another user to break in. This is not an
entirely new style of authentication, and it can be used with any for! of
authentication.
'i!tributed Application!
#e can use any of the following two aroaches in designing a distributed alication.
Co))unication-Oriented 'e!i#n: 4egin with the co!!unication rotocol.
)esign a !essage for!at and synta". )esign the client and server co!onents by
secifying how each reacts to in-co!ing !essages and how each generates
outgoing !eassages.
Application-Oriented 'e!i#n: 4egin with the alication. )esign a conventional
alication rogra! to solve the roble!. 4uild and test a working version of the
conventional rogra! into two or !ore ieces, and add co!!unication rotocols
that allow each iece to e"ecute on a searate co!uter.
Semantics of Applications
Nor)al Application: A !ain rogra! which !ay call rocedures defined within
the rogra! 7roc A in this case8. On return fro! this rocedure the rogra!
continues. This rocedure 7roc A8 !ay itself call other rocedures 7roc 4 in this
case8. 5efer to the figure below$
'i!tributed Application: A client rogra! e"ecuting on a !achine % !ay call a
rocedure 7roc A8 which is defined and run on another !achine 7 we say server
for !achine % is !achine (8 uon return fro! the call the rogra! on !achine %
continues. The server rogra! on !achine ( !ay in turn act as a client and call
rocedures on another !achine* 7now !achine * is a server for !achine (8. 5efer
to the figure below$
Passin# Ar#ments in Distri)ted Pro#rams
%roble): Inco)patibility in ar#u)ent !tora#e
/or e"a!le, so!e !achines !ay use 7 bit for storing characters while so!e others
!ight use I bit, so!e !achines !ay use 4ig-endian reresentation while others !ight
use S!all-endian reresentation.
%o!!ible Solution!
One solution !ay be to find out the architecture of receiving end, convert the data
to be sent to that architectue and then send the data. .owever, this will lead to
following roble!s$
%. It is not easy to find out the architecture of a !achine.
(. If I change the architecture of !y !achine then this infor!ation has to be
conveyed to the client.
Another solution is to have a standard for!at for networks. This !ay lead to
inefficiency in the case when the two co!!unicating !achines have the sa!e
architecture beacuse in this case the conversion is unnecessary.
?DR *$'ternal Data Representation,
Q)5 was the solution adoted by SCN 5&;. 5&; was !ainly the outco!e of the need
for distributed filesyste!s7N/S8.
$uffer %aradi#)
The rogra! allocates a buffer large enough to hold the e"ternal reresentation of a
!essage and adds ite!s one at a ti!e. The library routine invoked to allocate sace for
the buffer is "dr@!e!@create . After allocating sace we !ay aend data to this buffer
using various conversion library routines like "dr@int 7"dr@int coverts an integer to it0s
e"ternal reresentaion and aends it to the buffer8 to convert native ob>ects to e"ternal
reresentaion and then aend to the buffer. After all the data to be assed has been
converted and aended we send the buffer.
ASN<>
/irst add the infor!ation related to the the data being sent to the buffer and then aend
the data to the buffer. /or e"a!le, to send a character followed by an integer 7if the
sending !achine uses one byte for char and two bytes for integers8 we send the
infor!ation as - one byte char, two byte integer ...
The routines for encoding and decoding are the sa!e, deending on the tye of the buffer
which !ay be 7secified at the ti!e fo allocating sace for the buffer8 Q)5@:N;O): or
Q)5@):;O): encoding or decoding are erfor!ed resectively.
/or the routine "dr@int7"drs, Yi8
If the allocation was done as "dr@!e!@create7"drs, buf, 4C/SIE:,
Q)5@:N;O):8 then the value obtained by converting i to its e"ternal
reresentation would be aended to the buffer.
If the allocation was done as "dr@!e!@create7"drs, buf, 4C/SIE:,
Q)5@):;O):8 then an integer will be e"tracted , decoded , and the value will
be stored in the variable i.
There are routines 7like "dr@stdin@create8 to write?read fro! sockets and file descritors.
Application!
6TP
Biven a reliable end-to-end trasort rotocol like T;&, /ile Transfer !ight see! trivial.
4ut, the details authori9ation, reresentation a!ong heterogeneous !achines !ake the
rotocol co!le".
/T& offers !any facilities $
Interactive Access $ Aost i!le!entations rovide an interactive interface that
allows hu!ans to easily interact with re!ote servers.
/or!at 7reresentation8 secification $ /T& allows the client to secify the tye
and for!at of stored data.
Authentication ;ontrol $ /T& re6uires client to authori9e the!selves by sending a
login na!e and assword to the server before re6uesting file transfers.
/T& &rocess Aodel
/T& allows concurrent accesses by nultile clients. ;lients use T;& to connect to the
server. A !aster server awaits connections and creates a slave rocess to handleeach
connection. Cnlike !ost servers, the slave rocess does not erfor! all the necessary
co!utation. Instead the slave accets and handles the control connection fro! the client,
but uses an additinal rocess to handle a searate data transfer connection. The control
connection carries the co!!and that tells the server which file to transfer.
)ata transfer connections and the data transfer rocesses that use the! can be created
dyna!ically when needed, but the control connection ersists throughout a session. Once
the control connection disaears, the session is ter!inated and the software at both ends
ter!inates all data transfer rocesses.
In addition toassing user co!!ands to the server, /T& uses the control connection to
allow client and server rocesses to coordinate their use of dyna!ically assigned T;&
rotocol orts and the creation of data transfer rocesses that use those orts.
%roxy co))and! - allows one to coy files fro! any !achine to any other arbitrary
!achine ie. the !achine the files are being coied to need not be the client but any other
!achine.
So!eti!es so!e !pecial proce!!in# can be done which is not art of the rotocol. eg. if
a re6uest for coying a file is !ade by issuing co!!and 0get file@A.g90 and the 9ied
file does not e"ist but the file file@A does , then the file is auto!atically 9ied and sent.
;onsider what haens when the connection break! durin# a .(% !e!!ion. Two things
!ay haen, certain /T& servers !ay again restart fro! the beginning and whatever
ortion of the file had been coied is overwritten. Other /T& servers !ay ask the client
how !uch it has already read and it si!ly continues fro! that oint.
T6TP
T/T& stands for Trivial /ile Transfer &rotocol. Aany alications do not need the full
functionality of /T& nor can they afford the co!le"ity. T/T& rovides an ine"ensive
!echanis! that does not need co!le" interactions between the client and the server.
T/T& restricts oerations to si!le file transfer and does not rovide authentication.
)iskless devices have T/T& encoded in read-only !e!ory75OA8 and use it to obtain an
initial !e!ory i!age when the !achine is owered on. The advantage of using T/T& is
that it allows bootstraing code to use the sa!e underlying T;&?I& rotocols. that the
oerating syste! uses once it begins e"ecution. Thus it is ossible for a co!uter to
bootstra fro! a server on another hysical network. T/T& does not have a reliable
strea! transort service. It runs on to of C)& or any other unreliable acket delivery
syste! using ti!eout and retrans!ission to ensure that data arrives. The sending side
trans!its a file in fi"ed si9e blocks and awaits acknowledge!ents for each block before
sending the ne"t.
Rles for T6TP
The first acket sent re6uests file transfer and establishes connection between server and
client. Other secifications are file na!e and whether it is to be transferred to client or to
the server. 4locks of the file are nu!bered starting fro! % and each data acket has a
header that secifies the nu!ber of blocks it carries and each acknowledge!ent contains
the nu!ber of the block being acknowledged. A block of less than ,%( bytes signals end
of file. There can be five tyes of T/T& ackets . The initial acket !ust use oeration
codes % or ( secifying either a read re6uest or a write re6uest and also the filena!e.
Once the read re6uest or write re6uest has been !ade the server uses the I& address and
C)& ort nu!ber of the client to identify subse6uent oerations.Thus data or ack !sgs
do not contain filena!e. The final !essage tye is used to reort errors.
T/T& suorts sy!!etric retrans!ission. :ach side has a ti!eout and retrans!ission.If
the side sending data ti!es out, then it retrans!its the last data block. If the receiving side
ti!es out it retrans!its the last acknowledge!ent. This ensures that transfer will not fail
after a single acket loss.
&roble! caused by sy!!etric retrans!ission - SorcererH! Apprentice $u#
#hen an ack for a data acket is delayed but not lost then the sender retrans!its the sa!e
data acket which the receiver acknowledges. Thus both the acks eventually arrives at the
sender and the sender now trans!its the ne"t data acket once corresonding to each ack.
Therefore a retrans!ission of all the subse6uent ackets are triggered . 4asically the
receiver will acknowledge both coies of this acket and send two acks which causes the
sender in turn to send two coies of the ne"t acket.. The cycle continues with each
acket being trans!itted twice.
T/T& suorts !ultile file tyes >ust like /T& ie. binary and ascii data. T/T& !ay also
be integrated with e!ail . #hen the file tye is of tye !ail then the /I':NAA: field is
to be considered as the na!e of the !ailbo" and instead of writing the !ail to a new file
it should be aended to it. .owever this i!le!entation is not co!!only used .
Now we look at another very co!!on alication :AAI'
$MAIL *electronic mail 1 SMTP @ MIM$ @ $SMTP ,
:!ail is the !ost widely used alication service which is used by co!uter users. It
differs fro! other uses of the networks as network rotocols send ackets directly to
destinations using ti!eout and retrans!ission for individual seg!ents if no ack returns.
.owever in the case of e!ail the syste! !ust rovide for instances when the re!ote
!achine or the network connection has failed and take so!e secial action.:!ail
alications involve two asects -
Cser-agent7 ine, el! etc.8
Transfer agent7 send!ail dae!on etc.8
#hen an e!ail is sent it is the !ail transfer agent 7ATA8 of the source that contacts the
ATA of the destination. The rotocol used by the ATA 0s on the source and destination
side is called SAT&. SAT& stands for Si)ple ,ail (ran!fer %rotocol<. There are so!e
rotocols that co!e between the user agent and the ATA eg. &O&,IAA& which are
discussed later.
Mail =ateways 1
Aail gateways are also called !ail relays, !ail bridges and in such syste!s the senders
!achine does not contact the receiver0s !achine directly but sends !ail across one or
!ore inter!ediate !achines that forward it on. These inter)ediate )achine! are called
!ail gateways.Aail gateways are introduce unreliablity.Once the sender sends to first
inter!ediate !?c then it discards its local coy. So failure at an inter!ediate !achine
!ay result in !essage loss without infor!ing the sender or the receiver. Aail gateways
also introduce delays. Neither the sender nor the receiver can deter!ine how long the
delay will last or where it has been delayed.
.owever !ail gateways have an advantage roviding interoerability ie. they rovide
connections a!ong standard T;&?I& !ail syste!s and other !ail syste!s as well as
between T;&?I& internets and networks that do not suort Internet rotocols. So when
there is a change in rotocol then the !ail gateway hels in translating the !ail !essage
fro! one rotocol to another since it will be designed to understand both. .
SIMPL$ MAIL TRANS6$R PROTOCOL*SMTP,
T;&?I& rotocol suite secifies a standard for the e"change of !ail between !achines. It
was derived fro! the 7AT& 8 Aail Transfer &rotocol. it deals with how the nderlying !ail
delivery syste! asses !essages across a link fro! one.!achine to another. The !ail is
enclosed in what is called an en+elope . The enveiloe contains the To and /ro! fields
and these are followed by the !ail . The !ail consists of two arts na!ely the .eader
and the )ata.
The .eader has the To and /ro! fields. If .eaders are defined by us they should start
with Q. The standard headers do not start with Q.
In SAT& data ortion can contain only rintable AS;II characters The old !ethod of
sending a binary file was to send it in uuencoded for! but there was no way to
distinguish between the !any tyes of binary files ossible eg. .tar , .g9 , .dvi etc.
MIM$*Mltiprpose Internet Mail $'tension,
This alllows the trans!ission of Non AS;II data througfh e!ail, AIA: allows arbitrary
data to be encoded in AS;II and sent in a standard e!ail !essage. :ach AIA: !essage
includes infor!ation that tells the reciient the tye of data and the tye of encoding
used.and this infor!ation alongwith the AIA: version resides in the AIA: header.
Tyical AIA: header looks like -
MIME-,ersion. 2"!
-ontent-+escription.
-ontent-Id.
-ontent-6ype. image7gif
-ontent-6ransfer-Encoding. base68

;ontent )escirtion $ contains the file na!e of the file that is being sent. ;ontent
-Tye $ is an i!ortant field that secifies the data for!at ie. tells what kind of data is
being sent. It contains two identifiers a content tye and a subtye searated by a slash.
for e.g. i!age?gif
There are 7 ;ontent Tyes -
%. te"t
(. i!age
*. video
+. audio
,. alication
-. !ultiart
7. !essage
;ontent tye - ,e!!a#e
It suorts * subtyes na!ely
%. 5/;I(( - the old !ail !essage for!at
(. &artial- !eans that ordinary !essage is >ust a art and the receiver should wait for
all the arts before utting it in the !ailbo".
*. e"ternal@body - destination ATA will fetch file fro! re!ote site.
;ontent Tye - ,ultipart
Aultile !essages which !ay have different content tyes can be sent together. It
suorts + subtyes na!ely
%. !i"ed -'ook at each art indeendently
(. alternative - The sa!e !essage is sent in !ultile tyes and for!ats and the
receiver !ay choose to read the !essage in any for! he wishes.
*. arallel -The different arts of the !essage have to be read in arallel. ie.audio ,
video and te"t need to be read in a synchronised fashion
+. digest -There are !ultile 5/; !essages in !ail. The addresses of the receivers
are in the for! of a !ailing list. Although file header is long it revents cluttering
of !ail bo".
PRO!L$MS "IT( SMTP
%. There is no convenient way to send nonrintable characters
(. There is no way to know if one has received !ail or not or has read it or not.
*. So!eone else can send a !ail on !y behalf.
So a better rotocol was roosed - "S,(%:SAT& stands for :"tended Si!le Aail
Transfer &rotocol. It is co!atible with SAT&. Sust as the first acket sent in SAT& is
.:'O si!ilarly in :SAT& the first acket is called :.:'O. If the receiver suorts
:SAT& then it will answer to this :.:'O acket by sending what data tye and what
kind of encoding it suorts. :ven a SAT& based receiver can rely to it. Also if there is
an error !essage or there is no answer then the sender uses SAT&.
D$LI>$RA PROTOCOLS
The delivery rotocols deter!ine how the !ail is transferred by the !ail transfer agent
to the user agent which rovides an interface for reading !ails.
(here are A kind!
>< %O%A 0%o!t Office %rotocol1 .ere the !ail erson accesses the !ail bo" fro!
say a &; and the !ail gets accu!ulated on a server. So in &O&* the !ail
is downloaded to the &; at a ti!e interval which can be secified by the
user. &O&* is used when the !ail is always read fro! the sa!e !achine,
so it hels to download the !ail to it in advance.
@<I,A%0Inter)ediate ,ail Acce!! %rotocol1 .ere the user !ay access the !ail bo"
on the server fro! different !achines so there is no oint in downloading
the !ail before hand. Instead when the !ail has to be read one has to log
on to the server. 7IAA& thus rovides authentication8 The !ailbo" on the
server can be looked uon as a relational databa!e<
A<',S%0'i!tributi+e ,ail Sy!te) %rotocol1 There are !ultile !ailbo"es on
different
servers. To read the !ail I connect to the! fro! ti!e to ti!e and whenever I
do so the !ail will be downloaded. #hen a rely is sent then it will ut the
!essage in a 6ueue. Thus )AS& is like a p!eudo ,(A<

$nsrin# Network Secrity
%. .ow to ensure that nobody else reads your !ailP
(. .ow to be sure that the !ail has not been seen by so!eone else in your na!eP
*. Integrity ie. !ail has not been ta!ered with
+. Non-5eudiability- !eans once I send a !ail I cannot deny it, and this fact can be
roved to a third erson
,. Authentication
Mechanisms *P=P B P$M,
&B& 7&retty Bood &rivacy8 - It uses so!e crytograhy algorith! to cryt the !essages.
Sy))etric %2%- The key used for encrytion and decrytion is the sa!e.
A!y))etric %2% - The key used for encrytion and decrytion is different.Deys co!e
in airs - ublic 7known to all8 and rivate. which everybody has. Csually encrytion is
done using ublic key so that the rivate key is used for decrytion by the receiver only
for who! the !essage is !eant.
:g. of Sy!!etric &B& is ):S, I):A
:g. of Asy!!etric &B& is 5SA
Sy!!etric is usually faster In asy!!etric &B& there is a roble! of key distribution. A
hash function is alied on every !essage so that no two !essages hash to the sa!e
value. Now the hash function is encryted . If the hash function of source and destination
!atches then No ta!ering. If the key for encrytion is rivate then not everybody can
generate the !essage although anyone can read it . So this sche!e lack! pri+acy tackles
the other security issues.
%", Q SN,%
P$M*Pri-acy $nhanced Mail,
This is a I:T/ standard , a result of a grou working for a long ti!e. The basic idea is
have rivacy by virtue of hierarchial authentication. A receiver trusts the !essage of the
sender when it i acco!anied by a certificate fro! his trusted authority. These
authoratative certificates are distributed fro! a grou called Internet &olicy 5egistration
Authority 7I&5A8 and &olicy ;ertificate Authority 7&;A8. These trusted authority
actually certifies the ublic key sent by senders. The !ode of oeration is as follows $
One difference with &B& is that it doesn0t suort co!ression.
SNMP*Simple Network Mana#ement Protocol,
A large network can often get into various kinds of trouble due to routers 7droing too
!any ackets8, hosts7 going down8 etc. One has to kee track of all these occurence and
adat to such situations. A rotocol has been defined . Cnder this sche!e all entities in
the network belong to + class $
%. Aanaged Nodes
(. Aanage!ent Stations
*. Aanage!ent Infor!ation 7called Ob>ect8
+. A !anage!ent rotocol
The !anaged nodes can be hosts,routers,bridges,rinters or any other device caable of
co!!unicating status infor!ation to others. To be !anaged directly by SNA& , a node
!ust be caable of running a! SNA& !anage!ent rocess, called SNA& agent.
Network !anage!ent is done by !anage!ent stations by e"changing infor!ation with
the nodes. These are basically general urose co!uters running secial !anage!ent
software.
The !anage!ent stations olls the stations eriodically . Since SNA& uses unreliable
service of C)& the olling is essential to kee in touch with the nodes. Often the nodes
sends a tra !essage indiacting that it is going to go down. The !anage!ent stations
then eriodically checks 7with an increased fre6uaency8 . This tye of olling is called
tra directed olling. Often a grou of nodes are reresented by a single node which
co!!unicate with the !anage!enet stations. This tye of node is called ro"y agent.
The ro"y agent can also server as a security arrange!ent.
All the variables in these sche!e are called Ob>ects. :ach variable can be referenced by a
secific addressing sche!e adoted by this syste!. The entire collection of all ob>ects is
called Aanage!ent Infor!ation 4ase 7AI48. The adrressing is hierarchial as seen in the
icture.
Internet is adressed as %.*.-%. All the ob>ects under this do!ain has this string at the
beginning. The infor!ations are e"changed in a standard and vendor-neutral way . All the
data are reresented in Abstract Synta" Notation % 7ASN.%8. It is si!ilar to Q)5 as in
5&; but it have widely different reresentation sche!e. A art of it actually adoted in
SNA& and !odified to for! Structure Of Infor!ation 4ase. The &rotocol secifies
various kinds of !essages that can be e"changed between the !anaged nodes and the
!anage!ent station.
,e!!a#e 'e!cription
%. Bet@5e6uest 5e6uest the value for a variable
(. Bet@5esonse 5eturns the value of the variable asked for
*. Bet@Ne"t@5e6uest 5e6uest a variable ne"t to the revious one
+. Set@5e6uest Set the value of an Ob>ect.
,. Tra Agent to !anager Tra reort
-. Bet@bulk@re6uest 5e6uest a set of variable of sa!e tye
7. Infor!@5e6uest :"change of AI4 a!ong Aanage!ent stations

The last two otions has been actually added in the SNA&v(. The fourth otion need
so!e kind of authentication fro! the !anage!ent station.
Addre!!in# "xa)ple :
/ollowing is an :"a!le of the kind of address one can refer to when fetching a value
in the table $-
7(18 I&-Addr-Table F Se6uence of I&Addr-:ntry 7%8
I&Addr:ntry F S:LC:N;: V
I&A)):NT5RA))5 $ I&A))5 7%8
Inde" $ integer 7(8
Net!ask $ I&Addr 7*8 W
So when accessing the net!ask of so!e I&-entity the variable na!e wld be $
)(B(C()(?(D(?E .)(B($ey.value
.ere since I-address the uni6ue key to inde" any !e!ber of the array the address can
be like $-
)(B(C()(?(D(?E()(B()?F()E(?(B
.irewall!
Introdction
This lecture discusses about security !echanis!s in the Internet na!ely /irewall . In
brief, It0s a configuration of routers and networks laced between an organi9ation0s
internal internet and a connection to an e"ternal internet to rovide security. In other
words, /irewall is a !echanis! to rovide li!ited access to !achines either fro! the
outside world to internal internet or fro! internal world to outside world. 4y, roviding
these security !echanis!s, we are increasing the rocessing ti!e before one can access a
!achine. So, there is a trade-off between security and ease of use. A firewall artitions an
internet into two regions, referred to infor!ally as the inside and outside.
@@
T T @@@@@@@@@ /irewall
@@@@@@@@@@@@@@@@@@@@@@ T T @@@@@@@@@@@@@@@@@@@@
T T T T T T
T T T T T T
T 5est of Internet T@@@@@@@@ T T@@@@@ T Intranet T
T T T T T T
T@@@@@@@@@@@@@@@@@@@@@ T T T T@@@@@@@@@@@@@@@@@@@T
T@T
Outside Inside

Security 'ases
3ulnerable Services - N/S $ A user should not be allowed to e"ort certain files
to the outside world and fro! the outside world also, so!eone should not be
allowed to e"ort our files.
5outing based attacks $ So!e kind of I;A& !essage should not be allowed to
enter !y network. e.g.. Source routing and change route I;A&0s.
;ontrolled access to our syste!s $ e.g.. Aail server and web ages should be
accessible fro! outside but our individual &;0s should not be accessible fro! the
outside world.
Authentication $ :ncrytion can be used between hosts on different networks.
:nhanced &rivacy $ So!e alications should be blocked. e.g.. finger ...
&INB Y SRN attack $ Since these !essages are send very fre6uently, therefore
you won0t be able to do anything e"cet rely to these !essages. So, I should not
allow these !essages to enter !y network.
So. whatever I rovide for !y security is called /irewall. It is a !echanis! and not
>ust a hardware or software.

6irewall Mechanisms
%. Network &olicy $ .ere, we take into consideration, what services are allowed for
outside and inside users and the services which are allowed can have additional
restrictions. e.g.. I !ight be allowed to download things fro! the net but not uload i.e..
so!e outside users cannot download the things fro! our net. So!e e"cetional cases
!ight be there which have to be handled searately. And if so!e new alication co!es
u then , we choose an aroriate network olicy.
(. Authentication !echanis! $ An alication can be designed which ask for a assword
for authentication.
*. &acket /iltering $ 5outer have infor!ation about so!e articular ackets which should
not be allowed.
+. Alication gateways $ or ro"y servers.

Certain %roble)! with .irewall
%. ;o!lacency $ There are lots of attacks on the firewall fro! internal users and
therefore, it0s li!itations should be understood.
(. :ncasulated ackets $ An encasulated acket is an I& acket within another I&
acket. If we ask the router to dro encasulated ackets then, it will dro the !ulticast
ackets also.
*. Throughut $So, in order to check which ackets are allowed and which are not, we are
doing so!e rocessing which can be an overhead and thus affects throughut.

Athentication&
#e can use the following !echanis!s$
One ti!e asswords $ asswords are used only once and then it changes. 4ut only
the user and the !achine knows the changing asswords.
assword aging $ Cser are forced to change asswords after so!e ti!e on regular
intervals.
s!art cards $ swie through the &;.
bio!etrics $ eyes or finger rints are used.

Packet 6ilterin# &
Ter!s associated$
Source I& address
)estination I& address
Source ort U
)estination ort U
rotocol
interface
Aany co!!ercial routers offer a !echanis! that aug!ents nor!al routing and
er!its a !anager to further control acket rocessing. Infor!ally called a pa$et filter"
the !echanis! re6uires the !anager to secify how the router should disose of each
datagra!. /or e"a!le, the !anager !ight choose to filter 7i.e.. block8 all datagra!s that
co!e fro! a articular source or those used by a articular alication, while choosing to
route other datagra!s to their destination.
The ter! pa$et filter arises because the filtering !echanis! does not kee a record
of interaction or a history of revious datagra!s. Instead, the filter considers each
datagra!s searately. #hen a datagra! first arrives, the router asses the datagra!
through its acket filter before erfor!ing any other rocessing. If the filter re>ects the
datagra!, the router dros it i!!ediately.
/or e"a!le, nor!ally I won0t allow T/T&, oenwin, 5&;, rlogin, rsh ackets to ass
through the router whether fro! inside or outside and router >ust discard these ackets.
4ut I !ight ut so!e restrictions on telnet, ft, htt, and s!t ackets in order to ass
through the router and therefore so!e rocessing is to be done before discarding or
allowing these ackets.
4ecause T;&?I& does not dictate a standard for acket filters, each router vendor is free
to choose the caabilities of their acket filter as well as the interface the !anager uses to
configure the filter. So!e routers er!it a !anager to configure searate filter actions
for each interface, while others have a single configuration for all interfaces. Csually,
when secifying datagra!s that the filter should block, a !anager can list any
co!bination of source I& address, destination I& address, rotocol, source rotocol ort
nu!ber, and destination rotocol ort nu!ber.
So, these filtering rules !ay beco!e !ore tricky with co!le" network olicies.

Since, /iltering rules are based on ort nu!bers, there is a roble! with 5&;
alications. /irst, the nu!ber of well-known orts is large and growing. Thus, a
!anager would need to udate such a list continually because a si!le error of o!ission
could leave the firewall vulnerable. Second, !uch of the traffic on an internet does not
travel to or fro! a well-known ort. In addition to rogra!!ers who can choose ort
nu!bers for their rivate client-server alications, services like Remote Proedure Call
!RPC# assigns ort dyna!ically. Third, listing orts of well-known services leaves the
firewall vulnerable to tunneling, a techni6ue in which one datagra! is te!orarily
encasulated in another for transfer across art of an internet.

Relay Software *pro'ies, &
I can run !ultile ro"y on sa!e !achine. They !ay detect !isuse by keeing loos.
/or e"a!le, so!e !achine give login to &h.).. students. So, in this case it0s better to
kee ro"y servers than to give login on those !achines. 4ut the disadvantage with this is
that there are two connections for each rocess.
@@@@@@@@@ @@@@@@@@@@
T T T T
T Cser T@@@@@@@@@@@@@@@T &ro"y T@@@@@@@@@@@ Outside
T @@@@@@@@T %. T@@@@@@@@@ T (.


>arios 6irewall Considerations
%. &acket /iltering /irewall
This is the si!lest design and it is considered when the network is s!all and user don0t
run !any Intranet alications.
@@@@@@@@@@
T T
Intranet @@@@@@@@@@T 5outer T@@@@@@@@@@ Internet
T@@@@@@@@ @ T
T
T
/ilter
(. )ual ho!e gateway
This gives least a!ount of fle"ibility. Instead of router, we have alication gateways.
@@@@@@@@@@@@@@
T Alication T
Inside @@@@@@@@ @ T level T@@@@@@@@@@@ Outside
T gateway T
T@@@@@@@@@@@@ T
ro"y

*. Sreened host /irewall
It0s the co!bination of the above two sche!es. So!e alications are allowed
uninterruted while so!e have to be screened. /or any reasonable si9e network, Screened
host firewall can get loaded.
@@@@@@@@@ @@@@@@@@@@@
T T T T
Inside @@@@@@@@@T 5outer % T@@@@@@@@@@@@@@@@@@@@@@@ T 5outer ( T@@@@@@
Outside
T@@@@@@@@@T T T@@@@@@@@@@ T
@@@@T@@@@@@
T T
T &ro"y T
T@@@@@@@@@@T
The roble! with this is that there is only one ro"y and thus, it !ay get overloaded.
Therefore, to reduce load, we can use !ultile screened host firewalls. And this is what
nor!ally used.
@@@@@@@@@ @@@@@@@@@@
T T T T
Inside @@@@@ T 5outer % T@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ T 5outer ( T
@@@@@Outside
T@@@@@@@@@T T T@@@@@@@@@@ T
@@@@T@@@@
T T
T &ro"y % T &ro"y( .......
T@@@@@@@@ T


Modem pool
Cser can dial and oen only a ter!inal server but he has to give a assword. 4ut
T:'N:T and /T& client does not understand ro"y. Therefore, eole co!e out with
+ransparent proxy which !eans that I have so!e !e!ory which kees track of whether
this acket was allowed earlier or not and therefore, I need not check this ti!e. ;lient
does not know that there is so!ebody who is checking !y authentication.
So, transarent ro"y is used only for checking the I& ackets whereas ro"y is used
when !any I& addresses are not available.
%ri+ate I% 7&I& address8
It is an e"tension of transarent ro"y. .ere we also change the I& address 7source
address8 to one of the allocated I& address and send it. So, the client does not know that
the I& address has been changed, only the ro"y server knows it. The !achine that
changes the I& address is Net&or$ address translator !NAT8 . NAT also changes other
things like ;5;, T;& header checksu! 7 this is calculated using seudo I& header8. NAT
can also change the ort nu!ber.
e.g.. &ort address translation
@@@@@@@@@@@@
Q -------T T
T NAT T
R -------T@@@@@@@@@@@ T
Q
%
, &
%
----G B
%
, &
a
7I& address, ort U8
Q% , &( ----G B% , &b
R , &* ----G B%, &c
I !ay not like to have global I& address because then, anybody can contact !e insite of
these security !easures. So, I work with &rivate I&. In that case, there has to be a one-to-
one !aing between rivate I& and global I&.
irele!! Network!
Introdction
As the need of co!!unication beca!e !ore and !ore de!anding, new technologies in
the field of networks develoed. One of the! is the use of wireless networks. It is the
trans!ission of data fro! source to destination without the use of wires as the hysical
!edia.
"hy to se "ireless.
Three reasons !ay be stated for the over-growing use of wireless networks across the
world$
%. They are ubi6uitous networks. As the do not re6uire !essy wires as a !ediu! of
co!!unication, they can be used to connect far-off laces.
(. They are cheaer than wired networks secially in the case of long-distance
co!!unication.
*. They are retty effective and fast, esecially with the !odern advance!ents in
this field.
Some Terms and Technolo#ies&
A(,-A!ynchronou! (ran!fer ,ode:
ATA is a connection-oriented switching technology. It was built to suort IS)N
7Integrated Services )igital Network8. IS)N re6uired high seed cables for both its
narrow band 7-+ Dbs8 and broad band 7%,, Abs8 trans!ission. There were two
technologies available for trans!itting data-
%. Circuit Switchin#: In this technology, when a user !akes a call, the resources are
reserved for hi!. The advantage of this technology is that it revents collisions
a!ong various users. 4ut the disadvantage is that it leads to inefficient utili9ation
of bandwidth-- if the user fails to send data or if the trans!ission seed is faster
than the seed of sending data. then !ost of the bandwidth is wasted.
(. %acket Switchin#: In this technology, resources are never reserved for any
articular user. The advantage of this technology is that it leads to efficient
utili9ation of bandwidth i.e. the channel is never free until Y unless there are no
users, 4ut the disadvantage is that it causes !any collision.
ATA was built as a co!bination of the best features of these two. Also ATA rovides
LoS 7Luality of Service8 based on the following riority attern$
%. C$*-Con!tant $it *ate: Sobs that can tolerate no delay are assigned the ;45
riority. These >obs are rovided sa!e nu!ber of bits every fra!e.. /or
e"a!le, viewing a video reel definitely re6uires so!e blocks in every fra!e.
(. B$*-Bariable $it *ate: Sobs that !ay roduce different si9ed ackets at
different ti!es are assigned 345 riority. They are rovided with a variable
nu!ber of bits varying between a !a"i!u! and a !ini!u! in different fra!es.
e.g.. a docu!ent !ay be co!ressed differently by different !achines.
Trans!itting it will be a variable trans!ission.
*. A$*-A+ailable $it *ate: This is the sa!e as 345 e"cet that it has only the
!ini!u! fi"ed. If there are no ;45 or 345 >obs left, it can use the entire fra!e,
+. 3$*-3na+ailable $it *ate: These >obs are the least riority >obs. The network
does not ro!ise anything but si!ly tries its best to trans!it it.
LAN-irele!! LAN
This is currently being used as dictated by the standards of I::: I1(.%%. It can be
installed at the !ediu! access layer and the data trans!ission can occur using a
converter to reach the wired 'AN network.7 I::: I1(."8

A(,-irele!! A(,
It is the wireless version of ATA. It rovides LoS. It is not yet available in !arket.
because installing it will re6uire the si!ultaneous installation of ATA infrastructure. It is
currently being tested thoroughly.
Couplin# of Network!:
The alternatives are$
%. #'AN 'AN
(. #ATA 'AN
*. #'AN ATA
+. #ATA ATA

%. #'AN-'AN is the si!lest of the above. According to the I::: standards, the
I::: I1(.%% 7#'AN8 can be used with I::: I1(." 7'AN8 as follows$
(. #'AN-ATA- NOT /:ASI4':.
*. #ATA-'AN- NOT /:ASI4': because #ATA re6uires an infrastructure of the
tye ATA
+. #ATA-ATA-this is also a si!le sche!e because #ATA can run on ATA.
Isses in-ol-ed in "ireless Networks
Co!t and Speed: As it is being considered as an alternative to wired networks, it
should be faster and cheaer.
Kuality of (ran!)i!!ion: It gives a higher 4:5 74it :rror 5ate8. The 4:5 is
greater than %1
--.
This is caused because trans!ission 6uality deends highly on
the hysical !edia including landscae, weather etc.
*ayLei#h .adin#: The data has to travel the distance through a !ediu! like air.
Several rays of the sa!e strea! cause 5ayleigh fading due to interference. This
causes oor trans!ission.
,ultipath %ropa#ation: Si!ilarly, due to !ultiath roagation, the signal
received at the destination !ay be garbled.
Hand-Off!: If hand-offs are used i.e., he"agonal cells each having a base station
and !any !obile ter!inals, two Aobile ter!inals that are far enough can use the
sa!e bandwidth. This reuse of bandwidth is helful.
'yna)ic %hy!ical Characteri!tic!: The ter!inal !ay be !obile and constantly
!oving. Thus the distance between the base station and any active ter!inal !ay
be constantly changing. This has to be taken into account while designing.
%ractical I)ple)entation$ The ractical i!le!entation of any wireless
network re6uires ;SAA?;) for roer trans!ission. The range of any ter!inal is
fi"ed. So, there !ay be two ter!inals that are out of range of each other. These
are called .I)):N T:5AINA'S. ;ollisions !ay be caused due to si!ultaneous
sending of data fro! any two hidden ter!inals. The .I)):N T:5AINA'
&5O4':A should be overco!e with the hel of 4ase Station.
.,obility and Network (opolo#ie!: #ireless networks should be effective
enough to overco!e the roble!s caused by the toology of the area and the
!obility of the ter!inals
.re4uency Allocation: Licen!ed Q 3nlicen!ed: /or licensed networks,
er!ission has to be taken fro! the authorities that grant you a fi"ed bandwidth
which is not used by anybody else while unlicensed networking does not re6uire
any such er!issions. It >ust rovides with so!e unlicensed bands which can be
used by anybody. Cnlicensed bands !ay thus, cause collisions.
Capture "ffect: If there are !ore than one ter!inals re6uiring the attention of the
4ase Station, the one nearer to the base station !ay cature it. This unfair access
to the base station should be revented.
%ower *e4uire)ent! and $attery: This roble! arises for the Aobile Ter!inals
that run battery or cells. Auch dissiation of ower is caused when switching
fro! receiving !ode to sending !ode and vice versa.
Hu)an Safety: Not all bandwidths can be used . Also, the intensity should not be
very high as it !ay lead to several co!lications in hu!an body e.g.. cataract.
"ireless Physical Media
In the wireless hysical !edia, three technologies are used$
%. (ran!)i!!ion at Infrared fre4uency: This is easier to build and set-u. It is
!ainly used for indoor uroses because the bea! has to be focussed and can0t
cross oa6ue !edia like walls etc.
(. (ran!)i!!ion throu#h ,icrowa+e: This is referred as it re6uires low ower
consu!tion. 7the bandwidth is fi"ed8 4ut the basic roble! is that it re6uires
'ine-of-Sight. Also, it re6uires license.
*. (ran!)i!!ion at *adio .re4uency: This is the one that is !ost fa!iliar to us.
The bandwidth is retty large.
Inte#rity and Secrity of the si#nal
Spread Spectru): To reduce the effect of noise signals, the bandwidth of the signal is
increased tre!endously. This is costly but assures better trans!ission. This is called
S&5:A)-S&:;T5CA. This is used in two ways$
.HSS 0.re4uency hoppin# !pread !pectru)1$ The entire acket is not sent at
the sa!e bandwidth. Say, it is sent at fre6uency range A for ti!e T%, fre6uency
range 4 for ti!e T(, A for T%, 4 for T( and so on. The receiver also knows this
se6uence and so, looks at A for ti!e T%, then at 4 for ti!e T( and so on. Thus this
sort of understanding between the sender and receiver revents the signal fro!
being co!letely garbled .
'SSS 0'irect Se4uence Spread Spectru)1: This involves sending of coded
data instead of the actual data. This code is known to the destination only which
can deciher the data now.
The roble! still left undealt is that of bursty errors. If there is lot of traffic, interference
!ay hinder the 4ase Station fro! receiving data for a burst of ti!e. This is called
=$ur!ty "rror!=<
Such roble! are looked at by ,AC-Aediu! Access ;ontrol.
M$DI9M ACC$SS CONTROL
To control the traffic, various techni6ues are used. AA; fulfills the following
re6uire!ents$
%. KoS *e4uire)ent!: It rovides Luality of Service according to the riority of
>obs.
(. "rror Control: :rror handling is done using so!e codes.
*. .ra)e Si/e: To trans!it !a"i!u! data, we want the fra!e-si9e to be !a"i!u!
but at the sa!e ti!e, large fra!e-si9e highly increases the robability of errors.
So, AA; rovides a tradeoff between the above two factors deter!ining the si9e
of the fra!e.
+. Secure (ran!)i!!ion: The data !eant for a articular receiver is secured fro!
others.
,. *ea!onable (ran!)i!!ion: If the nu!ber of users increases, each should get
reasonable service. AA; revents unfair access to channel.
-. "fficient utili/ation of %ower: If a trans!itter is always on, it is continuously
using ower even if there is no data on the channel for it. This is reduced by
sending the trans!itter to <slee !ode< whenever the battery is going down. In
this !ode, the trans!itter is unable to receive any data.
Architectre for "ireless Network
There are two tyes of architecture ossible$
>< A'-HOC N"(O*&
@< IN.*AS(*3C(3*" N"(O*&
The Ad-.oc network can be set u anyti!e. It does not re6uire a 4ase Station. It is
generally used for indoor uroses.
The Infrastructure network involves 4ase Station and Aobile Ter!inals. It rovides
ulink facility 7 link fro! AT to 4S8 and downlink facility 7link fro! 4S to AT8.
T($ MAC PROTOCOL
This rotocol decides how to assign data slots to different users. The various olicies it
uses are$
>< .ixed A!!i#n)ent %olicy
@< *ando) A!!i#n)ent %olicy
A< Centrally Controlled %olicy
6< 'i!tributed Controlled %olicy
7< Hybrid Controlled %olicy
.ixed A!!i#n)ent %olicy:
In this olicy, each ter!inal is assigned so!e sort of data slot to seak. It causes a fi"ed
delay. It is done in * ways$
%. (',A 0(I," 'IBISION ,3L(I%L" ACC"SS1 : :ach user is given a fi"ed
ti!e to seak., after which the chance goes to another user. This cycle continues
indefinitely.
(. .',A 0.*"K3"NCN 'IBISION ,3L(I%L" ACC"SS1: :ach user is given
a fi"ed bandwidth in which he can seak at all
ti!es.
*. C',A 0CO'IBISION ,3L(I%L" ACC"SS1: :ach user is given different
fre6uencies at different ti!es. This ensures that each user gets a fair a!ount of
channel each ti!e.
Also, so!eti!es, statistical !ultile access is used in which a slot is assigned to a user
only if it has data to send.

*ando) A!!i#n)ent %olicy
In this olicy, contention slots are rovided to all the users. &roble! !ay arise if the
nu!ber of users increase drastically. The nu!ber of contention slots should be variable.
This !ay cause so!e li!iting of data slots but is necessary to revent the derail!ent of
the service .

Centrally Controlled %olicy:
This is used in an infrastructure architecture. It involves the articiation of a 4ase
Station which !ay assign slots and riorities7;N45,345 etc.8 to all the users.

'i!tributed Controlled %olicy:
This is used in Ad-.oc architecture. The control is a!ong the ter!inals which decide
a!ong the!selves about who is going to seak first.

Hybrid Controlled %olicy:
This co!bines the best features of centrally controlled and distributed controlled olicies.

CINDS O6 MAC PROTOCOLS&
There are two kinds of Aac rotocols$
%. .'' 0.re4uency 'i+i!ion 'uplex1 This rovides two searate bandwidths for
ulink and downlink trans!ission. This leads to inefficient utili9ation of
bandwidth as there is !ore traffic on downlink than ulink
(. ('' 0(i)e 'i+i!ion 'uplex1 This rovides an adotive boundary between the
ulink and downlink fre6uency which deends on the what is being used at that
articular ti!e. It works as follows$
Any !obile ter!inal can be in * states $ e!ty state, re6uest state and ready-to-trans!it
state.
%. ulink-AT% sends a rando!-access re6uest to 4S to co!!unicate with AT(
(. downlink$ 4S sends a b-bit access id to AT(
*. ulink$ AT% sends the acket
+. downlink$ 4S sends the acket to AT(
The T)) is !ore in use now-a-days.
Network Security
)ata on the network is analogous to ossessions of a erson. It has to be ket secure fro!
others with !alicious intent. This intent ranges fro! bringing down servers on the
network to using eole0s rivate infor!ation like credit card nu!bers to sabotage of
!a>or organi9ations with a resence on a network. To secure data, one has to ensure that
it !akes sense only to those for who! it is !eant. This is the case for data transactions
where we want to revent eavesdroers fro! listening to and stealing data. Other
asects of security involve rotecting user data on a co!uter by roviding assword
restricted access to the data and !aybe so!e resources so that only authori9ed eole get
to use these, and identifying !iscreants and thwarting their atte!ts to cause da!age to
the network a!ong other things.
The various issues in Network security are as follows $
%. Authentication: #e have to check that the erson who has re6uested for
so!ething or has sent an e-!ail is indeed allowed to do so. In this rocess we will
also look at how the erson authenticates his identity to a re!ote !achine.
(. Inte#rity: #e have to check that the !essage which we have received is indeed
the !essage which was sent. .ere ;5; will not be enough because so!ebody
!ay deliberately change the data. Nobody along the route should be able to
change the data.
*. Confidentiality: Nobody should be able to read the data on the way so we need
:ncrytion
+. Non-repudiation: Once we sent a !essage, there should be no way that we can
deny sending it and we have to accet that we had sent it.
,. Authori/ation: This refers to the kind of service which is allowed for a articular
client. :ven though a user is authenticated we !ay decide not to authori9e hi! to
use a articular service.
/or authentication, if two ersons know a secret then we >ust need to rove that no third
erson could have generated the !essage. 4ut for Non-reudiation we need to rove that
even the sender could not have generated the !essage. So authentication is easier than
Non-reudiation. To ensure all this, we take the hel of crytograhy. #e can have two
kinds of encrytion $
%. Sy))etric &ey "ncryption: There is a single key which is shared between the
two users and the sa!e key is used for encryting and decryting the !essage.
(. %ublic &ey "ncryption: There are two keys with each user $ a ublic key and a
rivate key. The ublic key of a user is known to all but the rivate key is not
known to anyone e"cet the owner of the key. If a user encryts a !essage in his
rivate key then it can be decryted by anyone by using the sender0s ublic key.
To send a !essage securely, we encryt the !essage in the ublic key of the
receiver which can only be decryted by the user with his rivate key.
Sy!!etric key encrytion is !uch faster and efficient in ter!s of erfor!ance. 4ut it
does not give us Non-reudiation. And there is a roble! of how do the two sides agree
on the key to be used assu!ing that the channel is insecure 7 others !ay snoo on our
acket 8. In sy!!etric key e"change, we need so!e a!ount of ublic key encrytion for
authentication. .owever, in ublic key encrytion, we can send the ublic key in lain
te"t and so key e"change is trivial. 4ut this does not authenticate anybody. So along with
the ublic key, there needs to be a certificate. .ence we would need a ublic key
infrastructure to distribute such certificates in the world.
Cey $'chan#e in Symmetric Cey Schemes
#e will first look at the case where we can use ublic key encrytion for this key
e"change. . The sender first encryts the !essage using the sy!!etric key. Then the
sender encryts the sy!!etric key first using it0s rivate key and then using the receiver0s
ublic key. So we are doing the encrytion twice. If we send the certificate also along
with this then we have authentication also. So what we finally send looks like this $
E $ ;ertificate
sender
2 &ublic
reciever
7 &rivate
sender
7 :
k
8 8 2 :
k
7 A 8
.ere :
k
stands for the sy!!etric key and :
k
7 A 8 for the !essage which has been
encryted in this sy!!etric key.
.owever this still does not ensure integrity. The reason is that if there is so!e change in
the !iddle ele!ent, then we will not get the correct key and hence the !essage which we
decryt will be >unk. So we need so!ething si!ilar to ;5; but slightly !ore
co!licated. This is because so!ebody !ight change the ;5; and the !essage
consistently. This function is called )igital Signature.
Di#ital Si#natres
Suose A has to send a !essage to 4. A co!utes a hash function of the !essage and
then sends this after encryting it using its own rivate key. This constitutes the signature
roduced by A. 4 can now decryt it, reco!ute the hash function of the !essage it has
received and co!are the two. Obviously, we would need the hash functions to be such
that the robability of two !essages hashing to the sa!e value is e"tre!ely low. Also, it
should be difficult to co!ute a !essage with the sa!e hash function as another given
!essage. Otherwise any intruder could relace the !essage with another that has the
sa!e hash value and leave the signatures intact leading to loss of integrity. So the
!essage along with the digital signature looks like this $
E 2 &rivate
sender
7 .ash 7 A 8 8
Di#ital Certificates
In addition to using the ublic key we would like to have a guarantee of talking to a
known erson. #e assu!e that there is an entity who is entrusted by everyone and whose
ublic key is known to everybody. This entity gives a certificate to the sender having the
sender0s na!e, so!e other infor!ation and the sender0s ublic key. This whole
infor!ation is encryted in the rivate key of this trusted entity. A erson can decryt this
!essage using the ublic key of the trusted authority. 4ut how can we be sure that the
ublic key of the authority is correct P In this resect )igital signatures are like I-;ards.
'et us ask ourselves the 6uestion $ .ow safe are we with I-;ardsP ;onsider a situation
where you go to the bank and need to rove your identity. I-;ard is used as a roof of
your identity. It contains your signature. .ow does the bank know you did not !ake the
I-;ard yourselvesP It needs so!e roof of that and in the case of I-;ards they contain a
counter signature by the director for the urose. Now how does the bank know the
signature I clai! to be of the director indeed belongs to hi!P &robably the director will
also have an I-;ard with a counter signature of a higher authority. Thus we will get a
chain of signing authorities. Thus in addition to signing we need to rove that the
signatures are genuine and for that urose we would robably use !ultile I-;ards each
carrying a higher level of signature-counter signature air.
So in order to di!tribute the public key of thi! authority
we u!e certificate! of hi#her authority and !o on< (hu!
we #et a tree !tructure where the each node need! the
certificate! of all node! abo+e it on the path to the root
in order to be tru!ted< $ut at !o)e le+el in the tree the
public key need! to be known to e+erybody and !hould
be tru!ted by e+erybody too<
Network Security0Contd<<<1
Cey $'chan#e in Symmetric Cey Schemes *contd4,
In this lecture we will look at key e"change in sy!!etric key sche!es where ublic key
encrytion cannot be used. So the encrytion using ublic and rivate keys is not
ossible. #e will see that in this scenario how do we e"change the sy!!etric key. The
two eole who are co!!unicating do not want others to understand what they are
talking about. So they would use a language which others ossibly do not understand. 4ut
they have to decide uon a co!!on language. /or this the language has to be encryted
in so!e key which will be so!ehow known to the other erson.
Dey e"change in sy!!etric key sche!es is a tricky business because anyone snooing
on the e"change can get hold of the key if we are not careful and since there is no ublic-
rivate key arrange!ent here, he can obtain full control over the co!!unication. There
are various aroaches to the foolroof e"change of keys in these sche!es. #e look at
one aroach which is as follows$-
Diffie 1 (ellman Cey $'chan#e
A and 4 are two ersons wishing to co!!unicate. 4oth of the! generate a rando!
nu!ber each, say " and y resectively. There is a function f which has no inverse. Now A
sends f7"8 to 4 and 4 sends f7y8 to A. So now A knows " and f7y8 and 4 knows y and
f7"8. There is another function g such that g7", f7y88 F g7y, f7"88. The key used by A is
g7", f7y88 and that used by 4 is g7y, f7"88. 4oth are actually sa!e. The i!le!entation of
this aroach is described below $
%. A has two large ri!e nu!bers n and #. There are other conditions also that these
nu!bers !ust satisfy.
(. A sends n; # and #
x
)od n to 4 in a !essage. 4 evaluates 7#
x
)od n1
y
to be used
as the key.
*. 4 sends #
y
)od n to A. A evaluates 0#
y
)od n1
x
to be used as the key. So now
both arties have the co!!on nu!ber #
xy
)od n. This is the sy!!etric 7secret
co!!unication8 key used by both A and 4 now.
This works because though the other eole know n; #; #
x
)od n; #
y
)od n but still they
cannot evaluate the key because they do not know either " or y.
,an in the ,iddle Attack
.owever there is a security roble! even then. Though this syste! cannot be broken but
it can be byassed. The situation which we are referring to is called the )an-in-the-
)iddle attack. #e assu!e that there is a guy ; in between A and 4. ; has the ability to
cature ackets and create new ackets. #hen A sends n; # and #
x
)od n; ; catures
the! and sends n; # and #
/
)od n to 4. On receiving this 4 sends n; # and #
y
)od n but
again ; catures these and sends n; # and #
/
)od n to A. So A will use the key 0#
/
)od
n1
x
and 4 will use the key 0#
/
)od n1
y
. 4oth these keys are known to ; and so when a
acket co!es fro! A, ; decryts it using A0s key and encryts it in it0s own key and then
sends it to 4. Again when a acket co!es fro! 4, it does a si!ilar thing before sending
the acket to A. So effectively there are two keys - one oerating between A and ; and
the other between ; and 4.
There !ust be so!e solution to this roble!. The solution can be such so that we !ay
not be able to co!!unicate further 7 because our keys are different 8 but atleast we can
revent ; fro! looking at the data. #e have to do so!ething so that ; cannot encryt or
decryt the data. #e use a olicy that A only sends half a acket at a ti!e. ; cannot
decryt half a acket and so it is stuck. A sends the other half only when it receives a
half-acket fro! 4. ; has two otions when it receives half a acket $
%. It does not send the acket to 4 at all and du!s it. In this case 4 will anyway
co!e to know that there is so!e roble! and so it will not send it0s half-acket.
(. It forwards the half-acket as it is to 4. Now when 4 sends it0s half-acket, A
sends the re!aining half. #hen 4 decryts this entire acket it sees that the data
is >unk and so it co!es to know that there is so!e roble! in co!!unication.
.ere we have assu!ed that there is so!e alication level understanding between A and
4 like the ort nu!ber. If A sends a acket at ort nu!ber (, and receives a acket at
ort nu!ber *,, then it will co!e to know that there is so!e roble!. At the very least
we have ensured that ; cannot read the ackets though it can block the co!!unication.
There is another !uch si!ler !ethod of e"changing keys which we now discuss $
Cey Distri)tion Center
There is a central trusted node called the Dey )istribution ;enter 7 D); 8. :very node
has a key which is shared between it and the D);. Since no one else knows A0s secret
key 7&
A
8 D); is sure that the !essage it received has co!e fro! A. #e show the
i!le!entation through this diagra! $
#hen A wants to co!!unicate with 4, it sends a !essage encryted in it0s key to
the D);. The D); then sends a co!!on key to both A and 4 encryted in their
resective keys. A and 4 can co!!unicate safely using this key. There is a
roble! with this i!le!entation also. It is rone to replay attack. The !essages
are in encryted for! and hence would not !ake sense to an intruder but they
!ay be relayed to the listener again and again with the listener believing that the
!essages are fro! the correct source. To revent this, we can use$
(i)e!ta)p!: which however don0t generally work because of the offset in
ti!e between !achines. Synchroni9ation over the network beco!es a
roble!.
Nonce nu)ber!: which are like ticket nu!bers. 4 accets a !essage only
if it has not seen this nonce nu!ber before.
Network Security0Contd<<<1
Cey Distri)tion Centre*Recap4,
There is a central trusted node called the Dey )istribution ;enter 7 D); 8. :very node
has a key which is shared between it and the D);. Since no one else knows node A0s
secret key D
A
, D); is sure that the !essage it received has co!e fro! A. #hen A wants
to co!!unicate with 4 it could do two things$
%. A sends a !essage encryted in it0s key D
A
to the D);. The D); then sends a
co!!on key D
S
to both A and 4 encryted in their resective keys D
A
and

D
4
. A
and 4 can co!!unicate safely using this key.
(. Otherwise A sends a key D
S
to D); saying that it wants to talk to 4 encryted in
the key D
A.
D); send a !essage to 4 saying that A wants to co!!unicate with
you using D
S.

There is a roble! with this i!le!entation. It is rone to replay attack. The !essages
are in encryted for! and hence would not !ake sense to an intruder but they !ay be
relayed to the listener again and again with the listener believing that the !essages are
fro! the correct source. #hen A send a !essage D
A
7A8, ; can send the sa!e !essage to
4 by using the I& address of A. A solution to be used is to use the key only once. If 4
sends the first !essage D
A
7A,D
S
8 also along with D7s,A8, then again we !ay have
trouble. In case this haens, 4 should accet ackets only with higher se6uence
nu!bers.
To revent this, we can use$
(i)e!ta)p! which however don0t generally work because of the offset in ti!e
between !achines. Synchroni9ation over the network beco!es a roble!.
Nonce nu)ber! which are like ticket nu!bers. 4 accets a !essage only if it has
not seen this nonce nu!ber before.
In general, (-way handshakes are always rone to attacks. So we now look at an another
rotocol.
Needham1Schroeder Athentication Protocol
This is like a bug-fi" to the D); sche!e to eli!inate relay attacks. A *-way handshake
7using nonce nu!bers8 very si!ilar to the ubi6uitous T;& *-way handshake is used
between co!!unicating arties. A sends a rando! nu!ber 5
A
to D);. D); send back a
ticket to A which has the co!!on key to be used.

5
A
, 5
4
and 5
A(
are nonce nu!bers. 5
A
is used by A to co!!unicate with the
D);. On getting the aroriate rely fro! the D);, A starts co!!unicating
with 4, whence another nonce nu!ber 5
A(
is used. The first three !essages tell 4
that the !essage has co!e fro! D); and it has authenticated A. The second last
!essage authenticates 4. The rely fro! 4 contains 5
4
, which is a nonce nu!ber
generated by 4. The last !essage authenticates A. The last two !essages also
re!ove the ossibility of relay attack.
.owever, the roble! with this sche!e is that if so!ehow an intruder gets to
know the key D
S
7 !aybe a year later 8, then he can relay the entire thing
7 rovided he had stored the ackets 8. One ossible solution can be that the ticket
contains a ti!e sta!. #e could also ut a condition that A and 4 should change
the key every !onth or so. To i!rove uon the rotocol, 4 should also involve
D); for authentication. #e look at one ossible i!rove!ent here. which is a
different rotocol.
Otway1Rees Cey $'chan#e Protocol
.ere a connection is initiated first. This is followed by key generation. This
ensures greater security. 4 sends the !essage sent by A to the D); and the D);
verifies that A, 4, 5 in the two !essages are sa!e and 5
A
and 5
4
have not been
used for so!e ti!e now. It then sends a co!!on key to both A and 4.
In real life all rotocols will have ti!e-sta!s. This is because we cannot
re!e!ber all rando! nu!bers generated in the ast. #e ignore ackets with
higher ti!e sta!s than so!e li!it. So we only need to re!e!ber nonces for this
li!it. 'ooking at these rotocols, we can say that designing of rotocols is !ore
of an art than science. If there is so !uch roble! in agreeing on a key then
should we not use the sa!e key for a long ti!e. The key can be !anually tyed
using a telehone or sent through so!e other !edia.
Challen#e 1 Response Protocol
Suose nodes A and 4 have a shared key D
A4
which was so!ehow re-decided
between the!. ;an we have a secure co!!unication between A and 4 P #e !ust
have so!e kind of a three way handshake to avoid relay attack So, we need to
have so!e interaction before we start sending the data. A hallenges 4 by sending
it a rando! nu!ber 5
A
and e"ects an encryted rely using the re-decided key
D
A4
. 4 then hallenges A by sending it a rando! nu!ber 5
4
and e"ects an
encryted rely using the re-decided key D
A4.
A 4
%. A, 5
A
-------------G
(. X--------D
A4
75
A
8, 5
4
*. D
A4
75
4
8----------G
Cnfortunately this sche!e is so si!le that this will not work. This rotocol
works on the assu!tion that there is a uni6ue connection between A and 4. If
!ultile connections are ossible, then this rotocol fails. In relay attack, we
could reeat the !essage D
A4
7A8 if we can so!ehow convince 4 that I a! A.
.ere, a node ; need not know the shared key to co!!unicate with 4. To identify
itself as A, ; >ust needs to send D
A4
75
4%
8 as the resonse to the challenge-value
5
4%
given by 4 in the first connection. ; can re!arkably get this value through the
second connection by asking 4 itself to rovide the resonse to its own challenge.
Thus, ; can verify itself and start co!!unicating freely with 4.
Thus, relay of !essages beco!es ossible using the second connection. Any
encrytion desired, can be obtained by sending the value as 5
4(
in the second
connection, and obtaining its encryted value fro! 4 itself.
A 4
%
st
;onnection$ A, 5
A
-------------G
X----------D
A4
75
A
8, 5
4%
(
nd
;onnection$ A, 5
4%
------------G
X--------- D
A4
75
4%
8, 5
4(
%
st
;onnection$ D
A4
75
4%
8---------G
;an we have a si!le solution aart fro! ti!e-sta! P #e could send D
A4
75
A,
5
4
8
in the second !essage instead of D
A4
75
A
8 and 5
A.
It !ay hel if we kee two
different keys for different directions. So we share two keys one fro! A to 4 and
the other fro! 4 to A. If we use only one key, then we could use different nu!ber
saces 7 like even and odd8 for the two directions. Then A would not be able to
send 5
4
. So basically we are trying to look at the traffic in two directions as two
different traffics. This articular tye of attack is called reflection attack.
7 1 way handshake
#e should tell the sender that the erson who initiates the connection should
authenticate hi!self first. So we look at another rotocol. .ere we are using a ,-
way handshake but it is secure. #hen we co!bine the !essages, then we are
changing the order of authentication which is leading to roble!s. 4asically
D
A4
75
4
8 should be sent before D
A4
75
A
8. If we have a node ; in the !iddle, then ;
can ose as 4 and talk to A. So ; can do relay attack by sending !essages which
it had started so!e ti!e ago.
A 4
%. A------------------G
(. X-----------------5
4
*. D
A4
75
4
8----------G
+. 5
A
----------------G
,. X----------D
A4
75
A
8
/ig$ ,-way handshake in ;hallenge-5esonse &rotocol
On initiating a connection 4 challenges A by sending it a rando! nu!ber 5
4
and
e"ects an encryted rely using the re-decided key D
A4.
#hen A sends back
D
A4
75
4
8, 4 beco!es sure that it is talking to the correct A, since only A knows the
shared key. Now A challenges 4 by sending it a rando! nu!ber 5
A
, and e"ects
an encryted rely using the re-decided key D
A4.
#hen 4 sends back D
A4
75
A
8, A
beco!es sure that it is talking to the correct 4, since only 4 knows the shared
key.
.owever in this case also, if we have a node ; in the !iddle, then ; can ose as
4 and talk to A. So ; can do relay attack by sending !essages which it had
stored so!e ti!e ago OO
&erbero!
Derberos was created by Aassachusetts Institute of Technology as a solution to !any
network security roble!s. It is being used in the AIT ca!us for reliability. The basic
features of Derberos !ay be ut as$
It uses sy!!etric keys.
:very user has a assword 7 key fro! it to the Authentication Server 8
:very alication server has a assword.
The asswords are ket only in the Derberos )atabase.
The Servers are all hysically secure.7No unauthori9ed user has access to the!.8
The user gives the assword only once.
The assword is not sent over the network in lain te"t or encryted for!.
The user re6uires a ticket for each access.
A diagra!!atic reresentation of the interfaces involved in Derberos !ay be ut as$
The e"changes of infor!ation between the want of transaction by a Cser with the
alication server and the ti!e that they actually start e"changing data !ay be ut as$
%. Client to the Authentication Ser+er0AS1: The following data in lain te"t for!
are sent$
o Cserna!e.
o Ticket Branting Server7TBS8 na!e.
o A nonce id 0n0.
(. 5esonse fro! the Authentication Ser+er0AS1 to the Client: The following data
in encryted for! with the key shared between the AS and the ;lient is sent$
o The TBS session key.
o The Ticket Branting Ticket. This contains the following data encryted
with the TBS assword and can be decryted by the TBS only.
Cserna!e.
The TBS na!e.
The #ork Station address.
The TBS session key.
o The nonce id 0n0.
*. Client to the (icket 2rantin# Ser+er: This contains the following data
o The Ticket Branting ticket.
o Authenticator.
o The Alication Server.
o The nonce id 0n0
+. (icket 2rantin# Ser+er to the Client: The following data encryted by the TBS
session key is sent$
o The new session key.
o Nonce id 0n0
o Ticket for the alication server- The ticket contains the following data
encryted by the alication servers0 key$
Cserna!e
Server na!e
The #orkstation address
The new session key.
After these e"changes the identity of the user is confir!ed and the nor!al e"change of
data in encryted for! using the new session key can take lace. The current version of
Derberos being develoed is Derberos 3,.
Types of Tickets
%. *enewable (icket!: :ach ticket has a ti!er bound , beyond that no
authentication e"change can take lace . Alications !ay desire to hold tickets
which can be valid for long eriods of ti!e. .owever, this can e"ose their secret
session key to otential theft for e6ually long eriods, and those stolen keys
would be valid until the e"iration ti!e of the ticket7s8. Si!ly using short-lived
tickets and obtaining new ones eriodically would re6uire the client to have long-
ter! access to its secret key, an even greater risk. 5enewable tickets can be used
to !itigate the conse6uences of theft.
(. %o!t 'ated (icket!: Alications !ay occasionally need to obtain tickets for use
!uch later, e.g., a batch sub!ission syste! would need tickets to be valid at the
ti!e the batch >ob is serviced. .owever, it is dangerous to hold valid tickets in a
batch 6ueue, since they will be on-line longer and !ore rone to theft. &ostdated
tickets rovide a way to obtain these tickets fro! the AS at >ob sub!ission ti!e,
but to leave the! <dor!ant< until they are activated and validated by a further
re6uest of the AS. Again this is for additional security.
*. %roxiable (icket!: At ti!es it !ay be necessary for a rincial to allow a service
to erfor! an oeration on its behalf. The service !ust be able to take on the
identity of the client, but only for a articular urose. A rincial can allow a
service to take on the rincial0s identity for a articular urose by granting it a
ro"y. This ticket allows a client to ass a ro"y to a server to erfor! a re!ote
re6uest on its behalf, e.g., a rint service client can give the rint server a ro"y to
access the client0s files on a articular file server in order to satisfy a rint re6uest.
+. .orwardable (icket!: Authentication forwarding is an instance of the ro"y case
where the service is granted co!lete use of the client0s identity. An e"a!le
where it !ight be used is when a user logs in to a re!ote syste! and wants
authentication to work ro! that syste! as if the login were local.
Time Stamps&
Authentication: This is the ti!e when i first authenticated !yself .
Start: This is the ti!e when valid eriod starts.
"nd: This is the ti!e when valid eriod ends.
*enewal ti)e: This is the ti!e when ticket is renewed.
Current ti)e: This ti!e is for additional security. This stos using old ackets.
.ere we need to synchroni9e all clocks.
Cross Realm Athentication
The Derberos rotocol is designed to oerate across organi9ational boundaries. A client in
one organi9ation can be authenticated to a server in another. :ach organi9ation wishing to
run a Derberos server establishes its own <real!<. The na!e of the real! in which a
client is registered is art of the client0s na!e, and can be used by the end-service to
decide whether to honor a re6uest.
4y establishing <inter-real!< keys, the ad!inistrators of two real!s can allow a client
authenticated in the local real! to use its authentication re!otely 7Of course, with
aroriate er!ission the client could arrange registration of a searately-na!ed
rincial in a re!ote real!, and engage in nor!al e"changes with that real!0s services.
.owever, for even s!all nu!bers of clients this beco!es cu!berso!e, and !ore
auto!atic !ethods as described here are necessary8. The e"change of inter-real! keys 7a
searate key !ay be used for each direction8 registers the ticket-granting service of each
real! as a rincial in the other real!. A client is then able to obtain a ticket-granting
ticket for the re!ote real!0s ticket- granting service fro! its local real!. #hen that
ticket-granting ticket is used, the re!ote ticket-granting service uses the inter- real! key
7which usually differs fro! its own nor!al TBS key8 to decryt the ticket-granting ticket,
and is thus certain that it was issued by the client0s own TBS. Tickets issued by the
re!ote ticket- granting service will indicate to the end-service that the client was
authenticated fro! another real!.
Limitations of Cer)eros
%a!!word 2ue!!in#: Anyone can get all rivileges by cracking assword.
'enial-of-Ser+ice Attack: This !ay arise due to kee sending re6uest to invalid
ticket.
Synchroni/ation of Clock: This is the !ost significant li!itation to the kerberos.
%ublic &ey Authentication %rotocol
Autual authentication can be done using ublic key authentication. To start with let us
assu!e A and 4 want to establish a session and then use secret key crytograhy on that
session. The urose of this initial e"change is authenticate each other and agree on a
secret shared session key.
Setup
A sends a re6uest to AS for getting 40s ublic key. Si!ilarly 4 is trying to get the A0s
ublic key. AS sends ublic key of 4 and na!e of 4 in encryted for! using AS0s rivate
key.
Hand!hake
#hether it ca!e fro! A or fro! so!eone else., but he lays along and sends A back a
!essage containing A0s n%, his own rando! nu!ber n( and a roosed session key, Ds.
#hen A gets this !essage, he decryts it using his rivate key. .e sees n% in it, and
hence gets sure that 4 actually got the !essage. The !essage !ust have co!e fro! 4,
since none else can deter!ine n%. A agrees to the session by sending back !essage. #hen
4 sees n( encryted with the session key he >ust generated, he knows A got !essage and
verified n%.
Di#ital Si#natres
The authenticity of !any legal, financial and other docu!ents is deter!ined by the
resence or absence of an authori9ed handwritten signature. The roble! of devising a
relace!ent for handwritten signatures is a difficult one. 4asically, what is needed is a
syste! bu which one arty can send a assigned !essage to other arty in such a way that$
%. The receiver can verify the clai!ed identity of sender
(. The sender cannot later reudiate the contents of the !essage.
*. The receiver cannot ossibly have concocted the !essage hi!self
Messa#e Di#est
One criticis! of signature !ethods is that they often coule two distinct functions $
authentication and secrecy. Often, authentication is needed but secrecy is not. Since
crytograhy is slow, it is fre6uently desirable to be able to send signed lainte"t
docu!ents.One sche!e, known as A:SSAB: )IB:ST, is based on the idea of a one-
way hash function that takes an arbitrarily long iece of lainte"t and fro! it co!utes a
fi"ed length bit string. This hash function has three i!ortant roerties$
%. Biven , it is easy to co!ute A)7&8.
(. Biven A)7&8, it is effectively i!ossible to find &.
*. No one can generate two !essages that have the sa!e !essage digest.
Main Steps in Athentication
Sender co!utes checksu! of !essage and sends it to AS.
AS returns signature block. Signature block consists of na!e and checksu! of
!essage in encryted for! using AS0s sy!!etric key.
5eciient sends signature block to AS.
AS decryt signature.
o verifies sender0s na!e.
o sends checksu! back to reciient.
5eciient verifies checksu!.
Network .ile Sy!te) 0N.S1
Network /ile Syste! 7 N/S 8 is a distributed file syste! 7 )/S 8 develoed by Sun
Aicrosyste!s. This allows directory structures to be sread over the net- worked
co!uting syste!s.
A )/S is a file syste! whose clients, servers and storage devices are dis- ersed a!ong
the !achines of distributed syste!. A file syste! rovides a set of file oerations like
read, write, oen, close, delete etc. which for!s the file services. The clients are rovided
with these file services. The basic features of )/S are !ultilicity and autono!y of
clients and servers.
N/S follows the directory structure al!ost sa!e as that in non-N/S syste! but there are
so!e differences between the! with resect to$
Na!ing
&ath Na!es
Se!antics
Namin#
Na!ing is a !aing between logical and hysical ob>ects. /or e"a!le, users refers to a
file by a te"tual na!e, but it is !aed to disk blocks. There are two notions regarding
na!e !aing used in )/S.
Location (ran!parency: The na!e of a file does not give any hint of file0s
hysical storage location.
Location Independence: The na!e of a file does not need to be changed when
file0s hysical storage location changes.
A location indeendent na!ing sche!e is basically a dyna!ic !aing. N/S does not
suort location indeendency.
There are three !a>or na!ing sche!es used in )/S. In the si!lest aroach, files are
na!ed by so!e co!bination of !achine or host na!e and the ath na!e. This na!ing
sche!e is neither location indeendent nor location transarent. This !ay be used in
server side. Second aroach is to attach or !ount the re!ote directories to the local
directories. This gives an aearance of a coherent directory. This sche!e is used by
N/S. :arly N/S allowed only reviously !ounted re!ote directories. 4ut with the
advent of auto!ount , re!ote directories are !ounted on de!and based on the table of
!ount oints and file structure na!es. This has other advantages like the file-!ount table
si9e is !uch s!aller and for each !ount oint, we can secify !any servers. The third
aroach of na!ing is to use na!e sace which is identical to all !achines. In ractice,
there are !any secial files that !ake this aroach difficult to i!le!ent.
Montin#
The !ount rotocol is used to establish the initial logical connection between a server
and a client. A !ount oeration includes the na!e of the re!ote directory to be !ounted
and the na!e of the server !achine storing it. The server !aintains an e"ort list which
secifies local file syste! that it e"orts for !ounting along with the er!itted !achine
na!es. Cni" uses ?etc?e"orts for this urose. Since, the list has a !a"i!u! length,
N/S is li!ited in scalabilty. Any directory within an e"orted file syste! can be !ounted
re!otely on a !achine. #hen the server receives a !ount re6uest, it returns a file handle
to the client. /ile handle is basically a data-structure of length *( bytes. It serves as the
key for further access to files within the !ounted syste!. In Cni" ter!, the file handle
consists of a file syste! identifier that is stored in suer block and an inode nu!ber to
identify the e"act !ounted directory within the e"orted file syste!. In N/S, one new
field is added in inode that is called the generic nu!ber.
Aount can be is of three tyes -
%. Soft )ount: A ti!e bound is there.
(. Hard )ount: No ti!e bound.
*. Auto)ount: Aount oeration done on de!and.
N6S Protocol and Remote Operations
The N/S rotocol rovides a set of 5&;s for re!ote oerations like lookup; create;
rena)e; #etattr; !etattr; read; write; re)o+e; )kdir etc. The rocedures can be
invoked only after a file handle for the re!otely !ounted directory has been esta-
blished. N/S servers are stateless servers. A stateless file server avoids to kee state
infor!ations by !aking each re6uest self-contained. That is, each re6uest iden- tifies the
file and the osition of the file in full. So, the server needs not to store file ointer.
Aoreover, it needs not to establish or ter!inate a connection by oening a file or closing
a file, reectively. /or reading a directory, N/S does not use any file ointer, it uses a
)a#ic cookie.
:"cet the oening and closing a file, there is al!ost one-to-one !aing between Cni"
syste! calls for file oerations and the N/S rotocol 5&;s. A re!ote file oeration can
be translated directly to the corresonding 5&;. Though concetu- ally, N/S adheres to
the re!ote service aradig!, in ractice, it uses buffering and caching. /ile blocks and
attributes are fetched by 5&;s and cached locally. /uture re!ote oerations use the
cached data, sub>ect to consistency constraints.
Since, N/S runs on 5&; and 5&; runs on C)&?I& which is unreliable, oerations should
be ide!otent.
Cache 9pdate Policy
The olicy used to write !odified data blocks to the server0s !aster coy has critical
effect on the syste! erfor!ance and reliability. The si!lest olicy is to write throu#h
the disk as soon as they are laced on any cache. It0s advantageous because it ensures the
reliability but it gives oor erfor!ance. In server site this olicy is often followed.
Another olicy is delayed write. It does not ensure reliability. ;lient sites can use this
olicy. Another olicy is write-on-clo!e. It is a variation of delayed write. This is used by
Andrews /ile Syste! 7A/S8.
In N/S, clients use delayed write. 4ut they don0t free delayed written block until the
server confir!s that the data have been written on disk. So, here, Cni" se!antics are not
reserved. N/S does not handle client crash recovery like Cni". Since, servers in N/S are
stateless, there is no need to handle server crash recovery also.
Time Skew
4ecause of differences of ti!e at server and client, this roble! occures. This !ay lead
to roble!s in erfor!ing so!e oerations like < !ake <.
Performance Isses
To increase the reliability and syste! erfor!ance, the following things are generally
done.
%. ;ache, file blocks and directory infor!ations are !aintained.
(. All attributes of file ? directory are cached. These stay * sec. for files and *1 sec.
for directory.
*. /or large caches, bigger block si9e 7 ID 8 is benificial.
This is a brief descrition of N/S version (. N/S version * has already been co!e out
and this new version is an enhance!ent of the revious version. It re!oves !any of the
difficulties and drawbacks of N/S (.
Andrew! .ile Sy!te) 0A.S1
A/S is a distributed file syste!, with scalability as a !a>or goal. Its efficiency can be
attributed to the following ractical assu!tions 7as also seen in CNIQ file syste!8$
/iles are s!all 7i.e. entire file can be cached8
/re6uency of reads !uch !ore than those of writes
Se6uential access co!!on
/iles are not shared 7i.e. read and written by only one user8
Shared files are usually not written
)isk sace is lentiful
A/S distinguishes between client !achines 7workstations8 and dedicated server
!achines. ;aching files in the client side cache reduces co!utation at the server side,
thus enhancing erfor!ance. .owever, the roble! of sharing files arises. To solve this,
all clients with coies of a file being !odified by another client are not infor!ed the
!o!ent the client !akes changes. That client thus udates its coy, and the changes are
reflected in the distributed file syste! only after the client closes the file. 3arious ter!s
related to this concet in A/S are$
hole .ile Ser+in#$ The entire file is transferred in one go, li!ited only by the
!a"i!u! si9e C)&?I& suorts
hole .ile Cachin#$ The entire file is cached in the local !achine cache,
reducing file-oen latency, and fre6uent read?write re6uests to the server
rite On Clo!e$ #rites are roagated to the server side coy only when the
client closes the local coy of the file
In A/S, the server kees track of which files are oened by which clients 7as was not in
the case of N/S8. In other words, A/S has !tateful !er+er!, whereas N/S has !tatele!!
!er+er!. Another difference between the two file syste!s is that A/S rovides location
independence 7the hysical storage location of the file can be changed, without having to
change the ath of the file, etc.8 as well as location tran!parency 7the file na!e does not
hint at its hysical storage location8. 4ut as was seen in the last lecture, N/S rovides
only location transarency. Stateful servers in A/S allow the server to infor! all clients
with oen files about any udates !ade to that file by another client, through what is
known as a callback. ;allbacks to all clients with a coy of that file is ensured as a
callback pro)i!e is issued by the server to a client when it re6uests for a coy of a file.
The key software co!onents in A/S are$
Bice$ The server side rocess that resides on to of the uni" kernel, roviding
shared file services to each client
Benu!$ The client side cache !anager which acts as an interface between the
alication rogra! and the 3ice
All the files in A/S are distributed a!ong the servers. The set of files in one server is
referred to as a +olu)e. In case a re6uest can not be satisfied fro! this set of files, the
vice server infor!s the client where it can find the re6uired file.
The basic file oerations can be described !ore co!letely as$
Oen a file$ 3enus tras alication generated file oen syste! calls, and checks
whether it can be serviced locally 7i.e. a coy of the file already e"ists in the
cache8 before re6uesting 3ice for it. It then returns a file descritor to the calling
alication. 3ice, along with a coy of the file, transfers a callback ro!ise, when
3enus re6uests for a file.
5ead and #rite$ 5eads?#rites are done fro!?to the cached coy.
;lose a file$ 3enus tras file close syste! calls and closes the cached coy of the
file. If the file had been udated, it infor!s the 3ice server which then relaces its
coy with the udated one, as well as issues callbacks to all clients holding
callback ro!ises on this file. On receiving a callback, the client discards its coy,
and works on this fresh coy.
The server wishes to !aintain its states at all ti!es, so that no infor!ation is lost due to
crashes. This is ensured by the 3ice which writes the states to the disk. #hen the server
co!es u again, it also infor!s all the servers about its crash, so that infor!ation about
udates !ay be assed to it.
A client !ay issue an oen i!!ediately after it issued a close 7this !ay haen if it has
recovered fro! a crash very 6uickly8. It will wish to work on the sa!e coy. /or this
reason, 3enus waits a while 7deending on the cache caacity8 before discarding coies
of closed files. In case the alication had not udated the coy before it closed it, it !ay
continue to work on the sa!e coy. .owever, if the coy had been udated, and the client
issued a file oen after a certain ti!e interval 7say *1 seconds8, it will have to ask the
server the last !odification ti!e, and accordingly, re6uest for a new coy. /or this, the
clocks will have to be synchroni9ed.

Potrebbero piacerti anche