7/24/2019 CS6411 Network Lab Manual
1/345
THIRUMALAI ENGINEERING
COLLEGE
KILAMBI,
KANCHIPURAM-631551
DEPARTMENT OF COMPUTER SCIENCE ANDENGINEERING
Networ! L"#or"tor$
%CS 6&11'
NAME ( )))))))))))))))))))))))))))))))))
7/24/2019 CS6411 Network Lab Manual
2/345
REG* NUMBER ( )))))))))))))))))))))))))))))))))
SEMESTER ( )))))))))))))))))))))))))))))))))
+EAR ( )))))))))))))))))))))))))))))))))))
7/24/2019 CS6411 Network Lab Manual
3/345
THIRUMALAI
ENGINEERING
COLLEGE
KILAMBI,
KANCHIPURAM-
631551
DEPARTMENT OF COMPUTER SCIENCE ANDENGINEERING
BONAFIDE CERTIFICATE
This is to certify that this is a
bonafide work done by
Mr./Miss.______________________________
Reg.No._____________________
7/24/2019 CS6411 Network Lab Manual
4/345
For the CS 6&11 - Networ! L"#or"tor$ as a
part of B*E*, Co.ter S/0e/e "12
E1301eer013 course in T40r.,"5"0 E1301eer013
Co55e3e, Kanchipuram during the year of !""#!".
The Record is found to be comp$eted and satisfactory.
He"2 o t4e De"rtet
St"7 I-C4"re
%ubmitted for the &ractica$ '(amination he$d on))))))))))))))))
Iter" E8"0er
E8ter" E8"0er
7/24/2019 CS6411 Network Lab Manual
5/345
E9*NO(1%"' Ieet"t0o o S020:02owProto/o
AIM(
To write a )a*a program to perform s$iding window protoco$
ALGORITHM(
".%tart the program.
.+et the frame sie from the user
-.To create the frame based on the
user reuest. .To send frames toser*er from the c$ient side.
0.1f your frames reach the ser*er it wi$$ send 23K signa$ to c$ient
otherwise it wi$$ send N23K signa$ toc$ient.
4.%top the program
Pror" (
imp
ort
)a*a.
net.5
6
imp
ort
)a*a.
io.56
imp
ort
)a*a.
rmi.56
p
u
b
$
i
7/24/2019 CS6411 Network Lab Manual
6/345
c
c
$
as
s
s
$
i
d
s
en
d
e
r
7
pub$ic static
*oidmain8%tring
a9:;throws
'(ception
7
%er*er%ocket serdo
7
7/24/2019 CS6411 Network Lab Manual
7/345
p
7/24/2019 CS6411 Network Lab Manual
8/345
pri
nt
$n8
sbuff9
sp
tr:;
6
sptr6
G
sws#
7/24/2019 CS6411 Network Lab Manual
9/345
%ystem.out.print$n8@ for @DanoD@ frames@;6 swsD
7/24/2019 CS6411 Network Lab Manual
10/345
s
@
;
;
6
s
.
c
$
o
s
e8
;
6
G
G
RECEI;ER PROGRAM
import )a*a.net.56 import )a*a.io.56 c$ass s$idrecei*er7
pub$ic static
*oid
main8%tring
a9:;throws
'(ception
7
%ocket s6 %tring rbuf9::6 %tring ch6%ystem.out.print$n8;6 do
7
7/24/2019 CS6411 Network Lab Manual
11/345
nf
7/24/2019 CS6411 Network Lab Manual
12/345
f
o
r
8
i
%ender8;7Gpub$
ic*o
id
7/24/2019 CS6411 Network Lab Manual
21/345
ru
n8
;7
try7IufferedReader brout
7/24/2019 CS6411 Network Lab Manual
22/345
packet
6
%ystem.out.print$n8@2$$datasent.
e(iting.@;6 Gcatch8'(ceptione;7Gfina$$y7
try7in.c$os
7/24/2019 CS6411 Network Lab Manual
27/345
e8;6
out.c$ose8;6
sender.c
$ose8;6
Gc
atch8'
(c
7/24/2019 CS6411 Network Lab Manual
28/345
ept
io
ne
;7G
GGpu
b$ic
static*oidmai
n8%trin
gargs
9:;7%enders.3$ose the ser*er socket.
O.%top.
C0et
".3reate a c$ient socket and connect it to the ser*ers port number.
.Retrie*e its own 1& address using bui$t#in function.
-.%end its address to the ser*er.
.=isp$ay the date P time sent by the ser*er.
0.3$ose the input and output streams.
4.3$ose the c$ient socket.
. %top.
PROGRAM(
D"teC0e
7/24/2019 CS6411 Network Lab Manual
43/345
t*?"
>"A
impo
rt
)a*
a.net.
5
6
im
port)
a*a.io
.5
7/24/2019 CS6411 Network Lab Manual
44/345
6
c$
ass
datec
$i
ent
7
pub$ic
st
atic*oid
main8%tri
ngargs9:;
7
7/24/2019 CS6411 Network Lab Manual
45/345
%ocket soc6=a
ta
1np
ut%tre
am
dis
6%tri
n
gsda
te6&ri
nt%tream
7/24/2019 CS6411 Network Lab Manual
46/345
ps6
t
ry7
1net2ddress
ia
7/24/2019 CS6411 Network Lab Manual
47/345
dis
7/24/2019 CS6411 Network Lab Manual
48/345
G
G
D"teSer>er*?">"(import)a
*a.net.56
import)a*a.io.56
i
7/24/2019 CS6411 Network Lab Manual
49/345
mport
)a*a.uti$.56
c$assdateser*er
7
pu
b$icst
7/24/2019 CS6411 Network Lab Manual
50/345
atic
*o
idm
ain8%tr
in
garg
s9:;7
%
e
r*er%
ocket
ss6
%
oc
7/24/2019 CS6411 Network Lab Manual
51/345
ket
s
6&rint%tream ps6
=ata1n
put
%tr
eamdi
s6
%tr
ingin
e
t6try7s
s!!
;6whi
$
e8tru
e;7s
7/24/2019 CS6411 Network Lab Manual
53/345
ps.print$n8d;6
dis
7/24/2019 CS6411 Network Lab Manual
54/345
G
G
G
OUTPUT(
CLIENTSIDE(3AE&rogram Fi$esESa*aE)dk".0.!Ebin)a*ac datec$ient.)a*aNoteA datec$ient.)a*a uses or o*errides a deprecated 2&1.NoteA Recompi$e with #deprecation for detai$s.3AE&rogram Fi$esESa*aE)dk".0.!Ebin)a*a datec$ientTH' date in the ser*er isA%atMar "O "-A!"A"4
+MTD!0A-! !!>3AE&rogramFi$esESa*aE)dk".0.!Ebin
SER;ERSIDE(3AE&rogram Fi$esESa*aE)dk".0.!Ebin)a*ac dateser*er.)a*aNoteA dateser*er.)a*a uses or o*errides a deprecated 2&1.NoteA Recompi$e with #deprecation for detai$s.3AE&rogram Fi$esESa*aE)dk".0.!Ebin)a*a dateser*erTH' 3B1'NT %%T'M 2==R'%% 1% Acom"/"O."4>."."
7/24/2019 CS6411 Network Lab Manual
55/345
E9*NO(3 :r0te " /o2e !0."t0 ARP
7/24/2019 CS6411 Network Lab Manual
56/345
A0(
To write a )a*a program for simu$ating 2R& protoco$s using T3&
ALGORITHM(
C0et
1* %tart the program=* sing socket connection is estab$ished between c$ient and ser*er.3* +et the 1& address to be con*erted into M23 address.&* %end this 1& address to ser*er.5* %er*er returns the M23 address to c$ient.
Ser>er
". %tart the program. 2ccept the socket which is created by the c$ient.-. %er*er maintains the tab$e in which 1& and corresponding M23addresses are stored.. Read the 1& address which is send by the c$ient.0. Map the 1& address with its M23 address and return the M23 address toc$ient.
Pror"
C0et(
i
m
p
o
r
t
)a
*
a
.
i
o
7/24/2019 CS6411 Network Lab Manual
57/345
.
5
6
i
m
p
o
r
t
)
a
*
a
.
n
e
t
.
5
6
i
m
p
o
r
t
)a
*
a
.
u
t
7/24/2019 CS6411 Network Lab Manual
58/345
i
$
.
5
6c$ass 3$ientarp
7
p
u
b
$i
c
s
ta
ti
c
*
o
i
d
m
ai
n
8
%
tr
i
n
g
ar
g
s
9
:
7/24/2019 CS6411 Network Lab Manual
59/345
;
7
tr
y
7
IufferedReader in
7/24/2019 CS6411 Network Lab Manual
60/345
=ata1nput%tream din
7/24/2019 CS6411 Network Lab Manual
61/345
%
t
r
i
n
g
s
t
r
er
". %tart the program.. %er*er maintains the tab$e in which 1& and corresponding M23addresses are stored.-. Read the M23 address which is send by the c$ient.. Map the 1& address with its M23 address and return the 1& address to
c$ient.
C0et(
i
m
p
o
r
t
)
a
*
a
.
i
7/24/2019 CS6411 Network Lab Manual
75/345
o
.
5
6
i
m
p
o
r
t
)
a*
a
.
n
e
t
.
5
6
i
m
p
o
r
t
)a
*
a
.
u
t
7/24/2019 CS6411 Network Lab Manual
76/345
i
$
.
5
6
c
$
a
s
s
3
$i
e
n
t
r
a
r
p
"
7
p
u
b
$i
c
s
t
a
ti
c
*
o
i
7/24/2019 CS6411 Network Lab Manual
77/345
d
m
a
i
n8
%
tr
i
n
g
a
r
gs
9
:
;
7
t
r
y
7
=atagram%ocket c$ient
7/24/2019 CS6411 Network Lab Manual
78/345
%tring str
7/24/2019 CS6411 Network Lab Manual
79/345
c$ient.recei*e8recei*er;6%tring s
7/24/2019 CS6411 Network Lab Manual
80/345
.
o
u
t
.p
r
i
n
t
$
n
8
e;
6
G
G
G
Ser>er(
i
m
p
o
r
t
)
a
*
a
.
i
7/24/2019 CS6411 Network Lab Manual
81/345
o
.
5
6
i
m
p
o
r
t
)
a
*
a
.
n
e
t
.
5
6
i
m
p
o
r
t
)
a
*
a
.
u
7/24/2019 CS6411 Network Lab Manual
82/345
t
i
$
.
5
6
c
$
a
s
s
%
e
r
*
e
r
r
a
r
p"
7
p
u
b
$i
c
s
t
a
ti
c
7/24/2019 CS6411 Network Lab Manual
83/345
*
o
i
d
ma
i
n
8
%
tr
i
n
ga
r
g
s
9
:
;
7
tr
y
7
=atagram%ocket
ser*er
7/24/2019 CS6411 Network Lab Manual
84/345
gth;6
ser*er.recei*e8recei*er;6
%tring
str
7/24/2019 CS6411 Network Lab Manual
85/345
!@,@
"40.
"40.
O."
@G6
%tri
ng
mac9:A22A3
@,@>2A
I3A'-A
F2@G6
for8int
i
iDD;
7/24/2019 CS6411 Network Lab Manual
86/345
7i
f
8
s
.
e
u
a$
s
8
m
a
c
9
i
:;
;
7
sendbyte
7/24/2019 CS6411 Network Lab Manual
87/345
bre
ak
6
G
G
c
a
t
c
h
8
'
(
c
e
p
t
i
o
n
e
;
7
%
y
s
t
e
m
.
o
7/24/2019 CS6411 Network Lab Manual
88/345
u
t
.
p
ri
n
t
$
n
8
e
;
6
G
G
G
O.t.t(
1
A
E
e
(
)a
*
a
%
e
7/24/2019 CS6411 Network Lab Manual
89/345
r
*
e
r
ra
r
p
"
1
AE
e
(
)
a
*
a
3
$
i
e
n
t
r
a
rp
"
'
nt
7/24/2019 CS6411 Network Lab Manual
90/345
er
th
e&
hysica
$
addr
ess
8
M
23;A
42A!>A
22A3
The Bogica$ 2ddress is81&;A "40."40.>!.>!
7/24/2019 CS6411 Network Lab Manual
91/345
E9-NO* &%"'* :r0te " /o2e !0."t0 PING/o"2
A0(
To Jrite the )a*a program for simu$ating ping command
Aor0t4%tep "A start the program.%tep A 1nc$ude necessary package in )a*a.%tep -A To create a process ob)ectp to imp$ement the pingcommand. %tep A dec$are oneIufferedReader stream c$assob)ect.%tep 0A +et thedetai$s of theser*er
0."A $ength of the 1& address.0.A time reuired to get the detai$s.0.-A send packets , recei*e packets and $ost packets.
0.Aminimum
,ma(imumand a*eragetimes. %tep 4Aprint theresu$ts.%tep A%top the program.
Pror"(
im
por
t)a*
7/24/2019 CS6411 Network Lab Manual
92/345
a.i
o.
56
impor
t
)a*a
.net.5
6
c$a
sspin
gser*e
r
7/24/2019 CS6411 Network Lab Manual
93/345
7
pub
$icstatic*oidm
ain8%tringarg
s9:;7tr
y
7
%tring str6%ystem.out.print8@'nter the 1&2ddress to be &ingA @;6IufferedReaderbuf"
7/24/2019 CS6411 Network Lab Manual
94/345
w1nput%treamReader8%ystem.in;;6%tring ip
7/24/2019 CS6411 Network Lab Manual
95/345
H.e(e
c8@ping@D
ip;6
1nput
%treamin.!."
&inging "O."4>.!."A with bytes of data .!.""Abytes
1& in binary is!""!!"!!!""!"""!"!!"!""!!!!!"!"! 'nter the
number of addressesA Numb
erof
bitsreuiredforadd
ress< -The
subnetmas
k is
Bast
a
ddres
siser*?">"
import )a*a.net.56import )a*a.io.56pu
b$icc
$ass
'%e
7/24/2019 CS6411 Network Lab Manual
157/345
r*e
r
7
p
ub$icst
ati
c*oi
dmain8
%
tringa
rgs9:;
7%er*er%
7/24/2019 CS6411 Network Lab Manual
158/345
ocket
se
r3AE&rogramFi$esESa*aE)dk".0.!Ebin)a*ac'%er*er.)a*a NoteA'%er*er.)a*a usesor o*errides adeprecated 2&1.NoteA Recompi$ewith #deprecationfor detai$s.
3AE&rogramFi$esESa*aE)dk".0.!Ebin)a*a '%er*er3AE&rogramFi$esESa*aE)dk".0.!EbinC0et
7/24/2019 CS6411 Network Lab Manual
172/345
3AE&rogramFi$esESa*aE)dk".0.!Ebin)a*ac'3$ient.)a*aNoteA '3$ient.)a*a
uses or o*errides adeprecated 2&1.NoteA Recompi$ewith #deprecationfor detai$s.3AE&rogramFi$esESa*aE)dk".0.!Ebin)a*a '3$ient3$ientAHai %er*er
%
er*er
AHai
%
er*er
3$ie
ntAHe$$o
%er*
7/24/2019 CS6411 Network Lab Manual
173/345
erA
He
$$o
3$ie
nt
Aend
%er*erAend
3$ientA
ds%ocket 3$osed
7/24/2019 CS6411 Network Lab Manual
174/345
B*C4"t
7/24/2019 CS6411 Network Lab Manual
175/345
A0:r0te " Pror" /0et -!er>er
"0/"t0o or /4"t .!0 UDPSo/et!Pror"UDP!er>er*?">"im
port)
a*a.io
.56
i
mport
)a*a.n
e
7/24/2019 CS6411 Network Lab Manual
176/345
t.5
6
c$
ass=
&s
er*e
r
7pub$ic static =atagram%ocket ds6pub$ic static byte buffer9:
7/24/2019 CS6411 Network Lab Manual
177/345
8;,!,p.getBength8;;6%ystem.out.print
$n8@3$ientA@ Dps(;6
%ystem.out.
print$n8@%er*erA@;6
%t
ringstr
7/24/2019 CS6411 Network Lab Manual
178/345
er
i
mp
o
r
t
)
a
*
a
.
i
o
.
5
6
i
mp
o
r
t
)
a
*
a.
n
e
t
.
5
7/24/2019 CS6411 Network Lab Manual
198/345
7/24/2019 CS6411 Network Lab Manual
199/345
$
e
7 p
ub$
icsta
tic
*oi
d
ma
in8
%tr
ing
args9:
;
7
T
r
y
7%er*er%ocket
ob)
7/24/2019 CS6411 Network Lab Manual
200/345
Iuffere
dReade
r
b
7/24/2019 CS6411 Network Lab Manual
201/345
tem
.o
ut.
print$
n8
s;6
d
o
u
t
.
w
r
i
t
e
I
y
t
e
s
8
s
D
U
E
n
U
7/24/2019 CS6411 Network Lab Manual
202/345
;
6
Gf.c$ose8;6dout.writeIytes8@#"En@;6
G G
catch8'(ception e;
7 %ystem.out.print$n8e;6G
G
G
7/24/2019 CS6411 Network Lab Manual
203/345
O.t.t
Fi$e content3
o
m
p
u
t
e
r
ne
t
w
o
r
k
s
)
h
f
c
g
s
a
u
f
)bsda*a
)
b
*
u
e
s
7/24/2019 CS6411 Network Lab Manual
204/345
a
g
*
c
$
i
e
n
t
'nt
er
thef
i$e
na
meA
s
am
p$e.
t(t
!er>er
7/24/2019 CS6411 Network Lab Manual
205/345
3om
pu
ter
netwo
rk
s
)
hfcgsa
u
f
)bsda*a
)b*uesag*
/0et
'nter
then
ew
7/24/2019 CS6411 Network Lab Manual
206/345
fi$
e
nam
eA
ne
t.
t(t
3omput
ernet
works
)hfc
gsa
7/24/2019 CS6411 Network Lab Manual
207/345
uf
)bsda*a
)b*uesag*
=estination fi$e
3o
mputer
n
etwo
rks
)h
fcgs
auf
)bsda*a)b*uesag*
7/24/2019 CS6411 Network Lab Manual
208/345
E9-NO * A0/"t0o! .!0 TCP "2 UDPSo/et! 0e DNS, SNMP "2 F0e
Tr"!er
A0
To write a )a*a program for =N% app$ication
Aor0t4
".%tart the program.
.+et the frame sie from the user-.To create the frame based on the user reuest..To send frames to ser*er from the c$ient side.
0.1f your frames reach the ser*er it wi$$ send23K signa$ to c$ient otherwise it wi$$ sendN23K signa$ to c$ient.4.%top the program
Pror"
e
r
7/24/2019 CS6411 Network Lab Manual
209/345
U
2
2
!
!
e
r
>
e
r
*)
a*aim
port
)a*a.io
.56
import
7/24/2019 CS6411 Network Lab Manual
210/345
)a*
a.
net
.56
p
u
b
$
ic
c
$
a
s
s
ud
p
d
n
s
s
e
r
*e
r
7
7/24/2019 CS6411 Network Lab Manual
211/345
pri*ate static
int
inde(?f8%trin
g9: array,
%tring str;7
str < str.trim8;6
f
o
r
8
i
nt
i
!.!4.">@,
@!O.>0.">."O@,@>!."4>.O."!@,
@4O.4-.">O."4@G6 %ystem.out.print$n8@&ress 3tr$
D 3 to ]uit@;6
whi$e 8true;
7/24/2019 CS6411 Network Lab Manual
214/345
7
=atagram%ocket
ser*ersocket
7/24/2019 CS6411 Network Lab Manual
215/345
!
.
"
4
>
.
O
.
"
!
)
a*
a
u
d
p
7/24/2019 CS6411 Network Lab Manual
231/345
d
n
s
c
$
i
e
n
t
'
n
t
e
r
t
h
e
h
o
s
t
n
a
m
e
A
y
o
u
tu
b
e
.
c
o
7/24/2019 CS6411 Network Lab Manual
232/345
m
1
&
2
d
d
r
e
s
s
A
Ho
s
t
N
o
t
F
o
u
n
d
7/24/2019 CS6411 Network Lab Manual
233/345
B*SNMP
A0To wr0te " ?">" ror" or SNMP "0/"t0o ror"
Aor0t4
".%tart the program..+et the frame sie from the user
-.To create the frame based on the user reuest..To send frames to ser*er from the c$ient side.
0.1f your frames reach the ser*er it wi$$ send
23K signa$ to c$ient otherwise it wi$$ sendN23K signa$ to c$ient.4.%top the program
Pror"import )a*a.io.1?'(ception6
importorg.sn
mp).3o
mmunity
Targ
et6importorg.s
7/24/2019 CS6411 Network Lab Manual
234/345
nmp
).&=
6i
m
p
o
r
t
o
r
g
.
s
n
m
p
)
.
%
n
m
p
6
i
m
p
o
r
t
o
r
g
.
s
7/24/2019 CS6411 Network Lab Manual
235/345
n
m
p
)
.T
a
r
g
e
t
6import org.snmp).TransportMapping6
impo
rtorg.s
nmp
).e*e
nt.Re
spons
e'*e
nt6
impo
rt
org.snmp
).mp.
%nmp
3onst
ants6
impo
rt
org.s
nmp
).smi.2ddr
ess6
im
po
rt
or
7/24/2019 CS6411 Network Lab Manual
236/345
g.s
n
m
p
).s
mi.+
en
eri
c2
dd
res
s6
im
po
rtor
g.s
n
m
p
).s
mi
.?
1=
6import org.snmp).smi.?ctet%tring6
import org.snmp).smi.Variab$eIinding6
import org.snmp).transport.=efau$tdpTransportMapping6
pub$ic c$ass %NM&Manager 7
%nmp snmp < nu$$6
%tring address < nu$$6
53onstructor
5
^paramadd
5/
7/24/2019 CS6411 Network Lab Manual
237/345
p
u
b
$
i
c
%
N
M
&
M
a
n
a
g
e
r
8
%
t
r
i
n
g
a
d
d
;
7
address < add6
7/24/2019 CS6411 Network Lab Manual
238/345
pub$ic static *oid main8%tring9: args; throws 1?'(ception 7
/55
5 &ort "4" is used for Read and ?ther operations
5
&ort
"4
is
used
for
the
trap
gene
ratio
n 5/
%NM&Manager c$ient < new
%NM&Manager8@udpA".!.!."/"4
"@;6 c$ient.start8;6
/55
5?1= # .".-.4."..".".".!
7/24/2019 CS6411 Network Lab Manual
239/345
TransportMapping transport er
i
mp
o
r
t
)
a
*
a
.
i
o
.
5
6
i
mp
o
r
t
)
a
*
a.
n
e
t
.
5
7/24/2019 CS6411 Network Lab Manual
254/345
6
i
m
p
o
r
t
)
a
*
a
.
u
t
i
$
.
5
6
c
$
a
s
s
%
e
r
*
e
r
f
i
7/24/2019 CS6411 Network Lab Manual
255/345
$
e
7 p
ub$
icsta
tic
*oi
d
ma
in8
%tr
ing
args9:
;
7
T
r
y
7%er*er%ocket
ob)
7/24/2019 CS6411 Network Lab Manual
256/345
e
a
d
e
r
f
er>
7/24/2019 CS6411 Network Lab Manual
268/345
0ew
Ns
programmingA 2
]uick start
3ase study 1A
2 simp$eJire$essnetwork
3ase study 11A3reate a newagent in Ns
N! o>er>0ew
Ns %tatus
&eriodica$
re$ease 8ns#.4, Feb
!!-; &$atformsupport
FreeI%=, Binu(, %o$aris, Jindows and Mac
N! ./t0o"0t0e!Routing,Transportation, Trafficsources,]ueuingdiscip$ines,
]o%
:0ree!!
2dhocrouting,mobi$e 1&,senso
r#M23Tracing,*isua$iation
7/24/2019 CS6411 Network Lab Manual
269/345
and*ariousuti$itie
N%8Network%imu$ators;
Most of the commercia$ simu$ators are +1 dri*en,
whi$e some network simu$ators are 3B1 dri*en. The network
mode$ / configuration describes the state of the network
8nodes,routers, switches, $inks; and the e*ents 8data
transmissions, packet error etc.;. 2n important output ofsimu$ations are the trace fi$es. Trace fi$es $og e*ery packet,
e*ery e*ent that occurred in the simu$ation and are used for
ana$ysis. Network simu$ators can a$so pro*ide other too$s to
faci$itate *isua$ ana$ysis of trends and potentia$ troub$e spots.
Most network simu$ators use discrete e*entsimu$ation, in which a $ist of pending @e*ents@ is stored, andthose e*ents are processed in order, with some e*entstriggering future e*ents_ such as the e*ent of the arri*a$ ofa packet at one node triggering the e*ent of the arri*a$ ofthat packet at a downstream node.
%imu$ation of networks is a *ery comp$e( task. Fore(amp$e, if congestion is high, then estimation of the
a*erage occupancy is cha$$enging because of high *ariance.To estimate the $ike$ihood of a buffer o*erf$ow in anetwork, the time reuired for an accurate answer can bee(treme$y $arge. %pecia$ied techniues such as @contro$
*ariates@ and @importance samp$ing@ ha*e been de*e$oped tospeed simu$ation.
7/24/2019 CS6411 Network Lab Manual
270/345
E8"e! o etwor !0."tor!There are many both free/open#source and
proprietary network simu$ators. '(amp$es of
notab$e network simu$ation software are, ordered after howoften they are mentioned in researchpapersA
". ns 8open source;. ?&N'T 8proprietary software;
-.Net%im 8proprietary software;
U!e! o etwor !0."tor!
Network simu$ators ser*e a *ariety of needs. 3ompared to
the cost and time in*o$*ed in settingup an entire test bed containing mu$tip$e networkedcomputers, routers and data $inks, networksimu$ators are re$ati*e$y fast and ine(pensi*e. They a$$owengineers, researchers to test scenariosthat might be particu$ar$y difficu$t or e(pensi*e to emu$ate
using rea$ hardware # for instance,
simu$ating a scenario with se*era$ nodes or e(perimenting
with a new protoco$ in the network.
Network simu$ators are particu$ar$y usefu$ in a$$owing
researchers to test new networking
protoco$s or changes to e(isting protoco$s in a contro$$edand reproducib$e en*ironment. 2
typica$ network simu$ator encompasses a wide range ofnetworking techno$ogies and can he$p theusers to bui$d comp$e( networks from basic bui$ding b$ockssuch as a *ariety of nodes and $inks.Jith the he$p of simu$ators, one can design hierarchica$networks using *arious types of nodes$ike computers, hubs, bridges, routers, switches, $inks, mobi$eunits etc.
Various types of Jide 2rea Network 8J2N; techno$ogies
$ike T3&, 2TM, 1& etc. and Boca$ 2rea Network 8B2N;techno$ogies $ike 'thernet, token rings etc., can a$$ be
simu$ated with a typica$ simu$ator and the user can test,ana$ye *arious standard resu$ts apart from de*ising someno*e$ protoco$ or strategy for routing etc. Networksimu$ators are a$so wide$y used to simu$ate batt$efie$dnetworks in Network#centric warfare
7/24/2019 CS6411 Network Lab Manual
271/345
There are a wide *ariety of network simu$ators, rangingfrom the *ery simp$e to the *ery comp$e(. Minima$$y, anetwork simu$ator must enab$e a user to represent a network
topo$ogy, specifying the nodes on the network, the $inks
between those nodes and the traffic between the nodes. Morecomp$icated systems may a$$ow the user to specifye*erything about the protoco$s used to hand$e traffic in anetwork. +raphica$ app$ications a$$ow users to easi$y*isua$ie the workings of their simu$ated en*ironment. Te(t#
based app$ications may pro*ide a $ess intuiti*e interface, butmay permit more ad*anced forms of customiation.
P"/et o!!
occurs when one or morepacketsof data tra*e$$ing across acomputer networkfai$ to reachtheirdestination. &acket $oss is distinguished as one of the three
main error types encountered indigita$ communications6 the other two being bit errorandspurious packets caused due to noise.
&ackets can be $ost in a network because they may bedropped when a ueue in the network nodeo*erf$ows. The amount of packet $oss during the steadystate is another important property of acongestion contro$ scheme. The $arger the *a$ue of packet$oss, the more difficu$t it is fortransport$ayer protoco$s to maintain high bandwidths, thesensiti*ity to $oss of indi*idua$ packets,as we$$ as to freuency and patterns of $oss among $onger
packet seuences is strong$y dependenton the app$ication itse$f.
7/24/2019 CS6411 Network Lab Manual
272/345
T4ro.4.t
This is the main performance measure characteristic, and most
wide$y used.1ncommunicationnetworks, such as'thernetorpacket radio, throughputornetwork throughputis
the a*erage rate of successfu$message de$i*ery o*er a
communication channe$. The throughput is usua$$y measured
inbitsper second 8bit/s orbps;, andsometimes indata
packetsper second or data packets pertime s$otThis measure
how soon the recei*er is ab$e to get a certain amount of data
send by the sender. 1t is determined as the ratio of the tota$
data recei*ed to the end to end de$ay. Throughput is an
important factor which direct$y impacts the network
performance
De"$
=e$ay is the time e$apsed whi$e a packet tra*e$s from one
point e.g., source premise or network
ingress to destination premise or network degrees. The $arger
the *a$ueof de$ay, the more difficu$t
it is for transport $ayer protoco$s to maintain highbandwidths.
Je wi$$ ca$cu$ate end to end de$ay
.e.e Let42 ueuing system in networks can be described as
packets arri*ing for ser*ice, waiting for ser*ice if it is notimmediate, and if ha*ing waited for ser*ice, $ea*ingthesystem after being ser*ed. Thus ueue $ength is *eryimportant characteristic to determine that how we$$ theacti*e ueue management of the congestion contro$a$gorithm has been working.
7/24/2019 CS6411 Network Lab Manual
273/345
11* Peror " /"!e !t.2$ "#o.t t4e 207eretro.t0 "or0t4! to !ee/t t4e
7/24/2019 CS6411 Network Lab Manual
274/345
etwor "t4 w0t4 0t! ot0. "2e/oo0/" 2.r0 2"t" tr"!er*
0* L0 St"te ro.t0
A0(To study the $ink state routing
L0 St"te ro.t0
Routing is the process of se$ecting best paths in a network. 1n
the past, the term routing was a$so used to mean forwarding
network traffic among networks. Howe*er this $atter
function is much better described as simp$y forwarding.
Routing is performed for many kinds of networks,inc$uding the te$ephone network 8circuit switching;,
e$ectronic data networks 8such as the 1nternet;, and
transportation networks. This artic$e is concerned
primari$y with routing in e$ectronic data networks using
packet switching techno$ogy.
1n packet switching networks, routing directs packet
forwarding 8the transit of $ogica$$y addressed
network packets from their source toward their u$timate
destination; through intermediate nodes.1ntermediate nodes are typica$$y network hardware de*ices
such as routers, bridges, gateways,
firewa$$s, or switches. +enera$#purpose computers can a$so
forward packets and perform routing,
though they are not specia$ied hardware and may suffer
from $imited performance. The routing
process usua$$y directs forwarding on the basis of routing
tab$es which maintain a record of the
routes to *arious network destinations. Thus, constructing
routing tab$es, which are he$d in therouterUs memory, is *ery important for efficient routing. Most
routing a$gorithms use on$y one
network path at a time. Mu$tipath routing techniues enab$e
the use of mu$tip$e a$ternati*e paths.
7/24/2019 CS6411 Network Lab Manual
275/345
1n case of o*er$apping/eua$ routes, the fo$$owing e$ementsare considered in order to decide which routes get insta$$edinto the routing tab$e 8sorted by priority;A
". Pre8-Le3t4A where $onger subnet masks are
preferred 8independent of whether it iswithin a routing protoco$ or o*er different routing
protoco$;
. Metr0/A where a $ower metric/cost is preferred 8on$y*a$id within one and the same routing
protoco$;
-. A200!tr"t0>e 20!t"/eA where a $ower distanceis preferred 8on$y *a$id between different
routing protoco$s;
Routing, in a more narrow sense of the term, is often
contrasted with bridging in its assumption that network
addresses are structured and that simi$ar addresses imp$y
pro(imity within the network. %tructured addresses a$$ow a
sing$e routing tab$e entry to represent the route to a group of
de*ices. 1n $arge networks, structured addressing 8routing, in
the narrow sense; outperforms unstructured addressing
8bridging;. Routing has become the dominant form of
addressing on the 1nternet. Iridging is sti$$ wide$y used
within $oca$ied en*ironments.
7/24/2019 CS6411 Network Lab Manual
276/345
00* Foo20
F5oo203 s a simp$e routing a$gorithm in which e*ery
incoming packet is sent through e*eryoutgoing $ink e(cept the one it arri*ed on.F$ooding is used
in bridging and in systems such as
senet and peer#to#peer fi$e sharing and as part of some
routing protoco$s, inc$uding ?%&F,
=VMR&, and those used in ad#hoc wire$ess networks.There
are genera$$y two types of f$ooding
a*ai$ab$e, ncontro$$ed F$ooding and 3ontro$$ed
F$ooding.ncontro$$ed F$ooding is the fata$ $aw
of f$ooding. 2$$ nodes ha*e neighbours and route packets
indefinite$y. More than two neighbourscreates a broadcast storm.
3ontro$$ed F$ooding has its own two a$gorithms to make it
re$iab$e, %N3F 8%euence Number
3ontro$$ed F$ooding; and R&F 8Re*erse &ath F$ooding;. 1n
%N3F, the node attaches its own
address and seuence number to the packet, since e*ery
node has a memory of addresses and
seuence numbers. 1f it recei*es a packet in memory, it
drops it immediate$y whi$e in R&F, thenode wi$$ on$y send the packet forward. 1f it is recei*ed from
the ne(t node, it sends it back to the
sender.
Aor0t4
There are se*era$ *ariants of f$ooding a$gorithm. Most work rough$y asfo$$owsA
".
'ach node acts as both a transmitter and a recei*er.
. 'ach node tries to forward e*ery message to e*ery oneof its neighbours e(cept the source
node.
This resu$ts in e*ery message e*entua$$y being de$i*ered to a$$ reachab$eparts of the network.
7/24/2019 CS6411 Network Lab Manual
277/345
2$gorithms may need to be more comp$e( than this, since, in
some case, precautions ha*e to be taken to a*oid wasted
dup$icate de$i*eries and infinite $oops, and to a$$ow messages
to e*entua$$y e(pire from the system. 2 *ariant of f$ooding
ca$$ed !ee/t0>e oo20partia$$y addresses these issues
by on$y sending packets to routers in the same direction. 1n
se$ecti*e f$ooding the routers donUt send e*ery incoming
packet on e*ery $ine but on$y on those $ines which are
going appro(imate$y in the right direction.
A2>"t"e!
f a packet can be de$i*ered, it wi$$ 8probab$y mu$tip$e times;.
shortest path.atura$$y uti$ies e*ery path through the network, it
wi$$ a$so use the
G This a$gorithm is *ery simp$e to imp$ement.
7/24/2019 CS6411 Network Lab Manual
278/345
D0!"2>"t"e!
F$ooding can be cost$y in terms of wasted bandwidth. Jhi$e amessage may on$y ha*e
one destination it has to be sent to e*ery host. 1n the caseof a ping f$oor a denia$ of ser*ice attack, it can be harmfu$to the re$iabi$ity of a computer network.
Messages can become dup$icated in the network further
increasing the $oad on thenetworks bandwidth as we$$s reuiring an increase in
processing comp$e(ity todisregard dup$icate messages.
=up$icate packets may circu$ate fore*er, un$ess certain precautions are takenA
se a hop count or a time to $i*e count and inc$ude it witheach packet. This *a$ue shou$d
take into account number of nodes that a packet may ha*eto pass through on the way
to its destination.
Ha*e each node keep track of e*ery packet seen and on$y forward each packet once
'nforce a network topo$ogy without $oops
000 * D0!t"/e >e/tor
1n computer communication theory re$ating to packet#switched
networks, a 20!t"/e->e/tor ro.t03 roto/o5 is one of the two ma)or c$asses
of routing protoco$s, the other ma)or
c$ass being the $ink#state protoco$. =istance#*ector routing
protoco$s use the Ie$$man#Ford
a$gorithm, Ford#Fu$kerson a$gorithm, or =2B F%M 8in the
case of 3isco %ystemsUs protoco$s;
to ca$cu$ate paths.
2 distance#*ector routing protoco$ reuires that a router
informs its neighbors of topo$ogy changes periodica$$y.3ompared to $ink#state protoco$s, which reuire a router to
inform a$$ the nodes in a network of topo$ogy changes,
distance#*ector routing protoco$s ha*e $ess
computationa$ comp$e(ity and message o*erhead.
7/24/2019 CS6411 Network Lab Manual
279/345
The term 20!t"/e >e/tor refers to the fact that theprotoco$ manipu$ates >e/tor! 8arrays; of distances toother nodes in the network. The *ector distance
a$gorithm was the origina$ 2R&2N'T routing a$gorithm
and was a$so used in the internet under the name of R1&
8Routing 1nformation &rotoco$;.
'(amp$es of distance#*ector routing protoco$s inc$ude R1&*" and R1&*and 1+R&.
Met4o2
Routers using distance#*ector protoco$ do not ha*eknow$edge of the entire path to a destination. 1nstead they usetwo methodsA
". =irection in which router or e(it interface a packet shou$d beforwarded.
. =istance from its destination
=istance#*ector protoco$s are based on ca$cu$ating thedirection and distance to any $ink in anetwork. @=irection@ usua$$y means the ne(t hop addressand the e(it interface. @=istance@ is a
7/24/2019 CS6411 Network Lab Manual
280/345
measure of the cost to reach a certain node. The $east cost route
between any two nodes is the route with minimum distance. 'achnode maintains a *ector 8tab$e; of minimum distance to e*ery node.
The cost of reaching a destination is ca$cu$ated using *arious route
metrics. R1& uses the hop count of the destination whereas 1+R& takes
into account other information such as node de$ay and a*ai$ab$e
bandwidth.
pdates are performed periodica$$y in a distance#*ector protoco$ where
a$$ or part of a routerUs routing tab$e is sent to a$$ its neighbors that are
configured to use the same distance#*ector routing protoco$. R1&
supports cross#p$atform distance *ector routing whereas 1+R& is a3isco %ystems proprietary distance *ector routing protoco$. ?nce a
router has this information it is ab$e to amend its own routing tab$e to
ref$ect the changes and then inform its neighbors of the changes.
This process has been described as `routing by rumor because
routers are re$ying on the information they recei*e from other routers
and cannot determine if the information is actua$$y *a$id and true.
There are a number of features which can be used to he$p with
instabi$ity and inaccurate routing information.
'+& and I+& are not pure distance#*ector routing protoco$s because adistance#*ector protoco$ ca$cu$ates routes based on$y on $ink costs
whereas in I+&, for e(amp$e, the $oca$ route preference *a$ue takes
priority o*er the $ink cost.
Co.t-to-00t$ ro#e
The Ie$$man#Ford a$gorithm does not pre*ent routing $oops from
happening and suffers from the /o.t-
to-00t$ ro#5e. The core of the count#to#infinity prob$em
is that if 2 te$$s I that it has a pathsomewhere, there is no way for I to know if the path has I as a part
of it. To see the prob$em c$ear$y,
imagine a subnet connected $ike 2#I#3#=#'#F, and $et the metric
between the routers be @number of
)umps@. Now suppose that 2 is taken off$ine. 1n the *ector#update#
process I notices that the route to 2,
7/24/2019 CS6411 Network Lab Manual
281/345
which was distance ", is down # I does not recei*e the *ector update
from 2. The prob$em is, I a$so gets
an update from 3, and 3 is sti$$ not aware of the fact that 2 is down #
so it te$$s I that 2 is on$y two )umps
from 3 83 to I to 2;, which is fa$se. This s$ow$y propagates through
the network unti$ it reaches infinity
8in which case the a$gorithm corrects itse$f, due to the re$a(ation
property of Ie$$man#Ford;.
E8*o*11 UNICAST ROUTING PROTOCOL
2imATo write a ns program for imp$ementing unicast routing protoco$.
7/24/2019 CS6411 Network Lab Manual
282/345
2$gorithmA
%tep "A start the program.
%tep A dec$are the g$oba$*ariab$es ns for creating a newsimu$ator. %tep -A set the co$orfor packets.
%tep A open the network animator fi$e inthe name of fi$e in the write mode. %tep0A open the trace fi$e in the name of fi$e "in the write mode.
%tep 4A set the unicast routing protoco$ totransfer the packets in network. %tep Acreate the reuired no of nodes.%tep >A create the dup$e(#$ink between the nodes inc$uding thede$ay time,bandwidth and dropping
ueue mechanism.%tep OA gi*e the position for the $inks between the nodes.%tep "!A set a tcp reno connection for source node.%tep ""A set the destination node using tcp sink.%tep "A setup a ftp connection o*er the tcp connection.
%tep "-A down the connection
between any nodes at a particu$artime. %tep "A reconnect thedowned connection at aparticu$ar time.%tep "0A define the finishprocedure.%tep "4A in the definition of the finish proceduredec$are the g$oba$ *ariab$es ns,fi$e",fi$e. %tep "Ac$ose the trace fi$e and namefi$e and e(ecute thenetwork animation fi$e.
%tep ">A at the particu$ar time ca$$ the finish
procedure.%tep "OA stop the program.
7/24/2019 CS6411 Network Lab Manual
283/345
Pror"(set ns 9new %imu$ator:
=efinedifferent
co$ors for dataf$ows 8for N2M; nsco$or " I$uens co$or Red
?pen the Trace fi$ese
t
fi$e
"9ope
n
out.
tr
7/24/2019 CS6411 Network Lab Manual
284/345
w:
ns
trace#
a$
$f
i$e"
7/24/2019 CS6411 Network Lab Manual
285/345
?pentheN2Mtracefi$
e
setfi$e
9open
7/24/2019 CS6411 Network Lab Manual
286/345
out.n
amw:
nsn
amtrace#a$$
fi$e
=e
finea
U
7/24/2019 CS6411 Network Lab Manual
287/345
fin
is
hU
proced
ur
epr
ocfin
i
sh7G
7
g$ob
a$ns
fi
7/24/2019 CS6411 Network Lab Manual
288/345
$e"
f
i$e
ns
f
$ush
#trace
c$os
efi$
e"
c$
os
7/24/2019 CS6411 Network Lab Manual
289/345
e
fi
$ee(ecnam
out.namP
e(it-
G
Ne(t $ine shou$d be
commented out to ha*e thestatic routing ns rtproto=V
3reate si( nodesset n! 9ns node:set n" 9ns node:set n 9ns node:set n 9ns node:set n 9ns node:set n0 9ns node:
7/24/2019 CS6411 Network Lab Manual
290/345
3reate $inks between the nodesns dup$e(#$ink n! n" !.-Mb "!ms =ropTai$ns dup$e(#$ink n" n !.-Mb "!ms =ropTai$ns dup$e(#$ink n n- !.-Mb "!ms =ropTai$
ns dup$e(#$ink n" n !.-Mb "!ms =ropTai$ns dup$e(#$ink n- n0 !.0Mb "!ms =ropTai$ns dup$e(#$ink n n0 !.0Mb "!ms =ropTai$
+i*e node position 8for N2M;ns dup$e(#$ink#op n! n" orient rightns dup$e(#$ink#op n" n orient rightns dup$e(#$ink#op n n- orient upns dup$e(#$ink#op n" n orient up#$eftns dup$e(#$ink#op n- n0 orient $eft#upns dup$e(#$ink#op n n0 orient right#up
%etup a T3& connection
settc
p
9ne
w2gen
t/
T3&/
Newr
7/24/2019 CS6411 Network Lab Manual
291/345
eno
:
ns
attac
h#
agen
tn!
tcp
setsink9new2gent/T3&%ink/=e$2ck:nsattach#
7/24/2019 CS6411 Network Lab Manual
292/345
agentn0sink
nscon
nect
tcps
ink
tcpse
t
fid_
"
7/24/2019 CS6411 Network Lab Manual
293/345
%etupaFT&o*erT3&c
onnections
etftp9
7/24/2019 CS6411 Network Lab Manual
294/345
new2
pp$ication/F
T&:
ftpa
ttach#agent
tcpftp set type_ FT&
7/24/2019 CS6411 Network Lab Manual
295/345
nsrt
mode$#at".
!downn"
n
nsrtm
ode$#at
7/24/2019 CS6411 Network Lab Manual
296/345
.0up
n"n
ns at !." @ftp start@
n
s
a
t
4
.
!
@
f
i
n
i
7/24/2019 CS6411 Network Lab Manual
297/345
s
h
@
n
s
r
u
n
7/24/2019 CS6411 Network Lab Manual
298/345
E8*o*11%#' MULTICASTING ROUTING PROTOCOL
A0(To write a ns program for imp$ementing mu$ticasting routing protoco$.
Aor0t4(
%tep "A start the program.
7/24/2019 CS6411 Network Lab Manual
299/345
%tep A dec$are the g$oba$*ariab$es ns for creating a newsimu$ator. %tep -A set the co$or
for packets.%tep A open the network animator fi$e in
the name of fi$e in the write mode. %tep0A open the trace fi$e in the name of fi$e "in the write mode.%tep 4A set the mu$ticast routing protoco$to transfer the packets in network. %tep Acreate the mu$ticast capab$e no of nodes.%tep >A create the dup$e(#$ink between the nodes inc$uding the
de$ay time,bandwidth and droppingueue mechanism.
%tep OA gi*e the position for the $inks between the nodes.
7/24/2019 CS6411 Network Lab Manual
300/345
%tep "!A set a udp connection for source node.
%tep ""A set the destination node ,port and random fa$sefor the source and destination fi$es. %tep "A setup atraffic generator 3IR for the source and destinationfi$es.%tep "-A down the connection between any nodes at aparticu$ar time.%tep "A create the recei*e agent for )oining and$ea*ing if the nodes in the group.%tep "0A define the finish procedure.%tep "4A in the definition of the finish procedure dec$are the g$oba$ *ariab$es.
%tep "A c$ose the trace fi$e and namefi$e and
e(ecute the network animation fi$e. %tep ">Aat the particu$ar time ca$$ the finishprocedure.%tep "OA stop the program.
Pror"( 3reate schedu$er3reate ane*entschedu$er witmu$ticastturned on setns 9new%imu$ator#mu$ticast on:
ns mu$ticast
Turn on Tracing
7/24/2019 CS6411 Network Lab Manual
301/345
settf
9openoutp
ut.trw:ns
trace#a$$
tf
Turn on nam Tracings
et
7/24/2019 CS6411 Network Lab Manual
302/345
fd
9o
pen
mcast
.n
amw
:ns
n
amtra
ce#a$$
fd
3reate nodes
set n! 9ns node:set n" 9ns node:
7/24/2019 CS6411 Network Lab Manual
303/345
set n 9ns node:set n- 9ns node:set n 9ns node:set n0 9ns node:set n4 9ns node:
set n 9ns node:
3reate $inks
ns dup$e(#$ink n! n ".0Mb "!ms =ropTai$
7/24/2019 CS6411 Network Lab Manual
304/345
ns dup$e(#$ink n" n ".0Mb "!ms =ropTai$
ns dup$e(#$ink n n- ".0Mb "!ms =ropTai$ns dup$e(#$ink n- n ".0Mb "!ms =ropTai$ns dup$e(#$ink n- n ".0Mb "!ms =ropTai$ns dup$e(#$ink n n0 ".0Mb "!ms =ropTai$ns dup$e(#$ink n n4 ".0Mb "!ms =ropTai$
Routing
pro
toco$Asaydistanc
e*ector&roto
co$
sA3trMcast,=
M,%T,I%Tsetmp
roto=Mset mrthand$e 9ns mrtproto mproto 7G:
2$$ocate group addresses
7/24/2019 CS6411 Network Lab Manual
305/345
set
g
rou
p"9No
de
a$$
ocaddr
:
set
group
9Nod
e
7/24/2019 CS6411 Network Lab Manual
306/345
a$$
oc
add
r:
=&Transport agentfor thetrafficsourceset udp!9new2gent/=&:ns
att
ac
h#age
ntn!
ud
p
7/24/2019 CS6411 Network Lab Manual
307/345
!
u
dp!
setd
st
_add
r_gr
o
up"
udp!
setds
t_
7/24/2019 CS6411 Network Lab Manual
308/345
por
t_
!
setcbr"9new2pp$ication/Traffic/3I
R:cbr"attach#agentudp!
Transp
ortagentforthetra
ffic
sourceset
udp"9new
7/24/2019 CS6411 Network Lab Manual
309/345
7/24/2019 CS6411 Network Lab Manual
310/345
_addr
_group
udp"setds
t_port_!setcbr
9new
2pp$ication/Traffic/3I
7/24/2019 CS6411 Network Lab Manual
311/345
R:cbr
attach#
agentud
p"
3reate recei*er
s
etr
c*
r"9ne
w2
gen
t/Nu$$
:
ns
att
7/24/2019 CS6411 Network Lab Manual
312/345
ach
#a
gen
tn0
r
c*r"
ns at".!@n0)oin#grouprc*r"
group"@ setrc*r9new
2gent/Nu$$:ns attach#agent n4 rc*rns at
".0@n4)oin#
grouprc*r
group"@ setrc*r-9new
7/24/2019 CS6411 Network Lab Manual
313/345
2gent/Nu$$:ns attach#agent n rc*r-
ns at.!
@n)oin#grouprc*r-
group"@ setrc*r9new2gent/Nu$$:ns attach#agent n0 rc*r"
ns at.0@n0)oin#
grouprc*r
group@ set
rc*r09new
2gent/Nu$$:ns attach#agent n4 rc*rns at
-.!@n4)oin#grouprc*r0
group
@ setrc*r49new2gent/
Nu$$:ns attach#agent n rc*r-
7/24/2019 CS6411 Network Lab Manual
314/345
ns at -.0 @n )oin#group rc*r4 group@
ns at .! @n0 $ea*e#group rc*r" group"@ns at .0 @n4 $ea*e#group rc*r group"@ns at 0.! @n $ea*e#group rc*r- group"@ns at 0.0 @n0 $ea*e#group rc*r group@ns at 4.! @n4 $ea*e#group rc*r0 group@ns at 4.0 @n $ea*e#group rc*r4 group@
%chedu$e e*ents
ns
at!.0@cbr"start@
nsatO
7/24/2019 CS6411 Network Lab Manual
315/345
.0@
cbr"stop@
nsat!.0
@cbrstar
t@
ns
7/24/2019 CS6411 Network Lab Manual
316/345
atO.
0@cbrstop@
post#processing
nsa
t"!.
!@fin
i
sh@
pro
7/24/2019 CS6411 Network Lab Manual
317/345
cf
in
ish
7G7
g$oba$ ns tf
ns
f$ush
#tr
ace
c$os
e
tfe(ec
7/24/2019 CS6411 Network Lab Manual
318/345
nammc
ast.namP
e(it!
G
For nam3o$ors for
packetsfromtwo
mcastgroupsnsco$or"! red
nsco$
or
7/24/2019 CS6411 Network Lab Manual
319/345
""
gr
een
ns
co
$or
-!pur
p
$e
nsco$
or-"
gr
7/24/2019 CS6411 Network Lab Manual
320/345
een
Manua$ $ayoutA order of the $ink is significant
ns dup$e(#$ink#op n! n" orient rightns dup$e(#$ink#op n! n orient right#upns dup$e(#$ink#op n! n- orient right#down %how ueue on simp$e( $ink n!#n"ns dup$e(#$ink#op n n- ueue&os !.0
+roup ! source
udp!setfid_"
!
n!co$or
redn! $abe$ @%ource "@
7/24/2019 CS6411 Network Lab Manual
321/345
+roup
"source
udp"setfid_""
n"
co$orgr
7/24/2019 CS6411 Network Lab Manual
322/345
een
n"$abe$@%ource@
n0$abe$@R
ecei*er
7/24/2019 CS6411 Network Lab Manual
323/345
"@
7/24/2019 CS6411 Network Lab Manual
324/345
n0 co$or b$ue
n4$abe$@R
ecei*er@
n4co$orb$
uen$
a
7/24/2019 CS6411 Network Lab Manual
325/345
be$
@
Rec
ei*er
-@
n
co$or
b$ue
na
dd#markm
7/24/2019 CS6411 Network Lab Manual
326/345
!red
nde$et
e#markm!@
2nimation rate
nsse
t#ani
mation#
r
7/24/2019 CS6411 Network Lab Manual
327/345
ate
-
.!m
s
ns
r
un
7/24/2019 CS6411 Network Lab Manual
328/345
7/24/2019 CS6411 Network Lab Manual
329/345
E8*o*11%/' CARRIER SENSE MULTIPLE ACCESS
A0(To write a ns program for imp$ementing carrier sense mu$tip$e access.
Aor0t4(
%tep "A start the program.%tep A dec$are the g$oba$*ariab$es ns for creating a newsimu$ator. %tep -A set the co$orfor packets.%tep A open the network animator fi$e in the write mode.
%tep 0A open the tracefi$e and the win fi$e inthe write mode. %tep 4Atransfer the packets innetwork.%tep A create the capab$e no of nodes.
7/24/2019 CS6411 Network Lab Manual
330/345
%tep >A create the dup$e(#$ink between the nodes inc$uding thede$ay time,bandwidth and dropping
ueue mechanism.
%tep OA gi*e theposition for the $inks
between the nodes. %tep"!A set a tcp connectionfor source node.%tep ""A set thedestination node usingtcp sink.%tep "A set the windowsie and the packet siefor the tcp. %tep "-A setup the ftp o*er the tcpconnection.
%tep "A.set the udp and tcp connection for the source and destination.%tep "0A create the traffic generator 3IRfor the source and destination fi$es. %tep"0A define the p$ot window and finishprocedure.%tep "4A in the definition of the finish procedure dec$are the g$oba$ *ariab$es.
%tep "A c$ose the trace fi$e and namefi$e ande(ecute the network animation fi$e. %tep ">Aat the particu$ar time ca$$ the finish
procedure.%tep "OA stop the program.
7/24/2019 CS6411 Network Lab Manual
331/345
Pror"(
setn
s9n
ew
%imu$
ato
r:
nsco
$o
r"
b$ue
7/24/2019 CS6411 Network Lab Manual
332/345
ns co$or redset fi" 9open out.tr w:set
winfi
$e9o
penJin
Fi$e
w
:ns
tra
ce#
a$$
7/24/2019 CS6411 Network Lab Manual
333/345
fi"
se
tf
i9op
en
out
.namw
:
ns
namtra
ce#a$$
7/24/2019 CS6411 Network Lab Manual
334/345
fi
p
roc
finis
h
7G7
g$oba$
nsfi
"fi
nsf
$u
7/24/2019 CS6411 Network Lab Manual
335/345
sh#
tr
ace
c$os
e
fi"c$ose fie(ecnamout.namP
e(it!G
7/24/2019 CS6411 Network Lab Manual
336/345
set n! 9ns node:set n" 9ns node:set n 9ns node:set n- 9ns node:set n 9ns node:
set n0 9ns node:n" co$or redn" shape bo(ns dup$e(#$ink n! n Mb "!ms =ropTai$ns dup$e(#$ink n" n Mb "!ms =ropTai$ns simp$e(#$ink n
n- !.-Mb"!!ms=ropTai$
ns simp$e(#$ink n- n!.-Mb "!!ms
=ropTai$set $an 9ns newBan @n- n n0@ !.0Mb !ms BB]ueue/=ropTai$ M23/3sma/3d 3hanne$: set tcp 9new2gent/T3&/Newreno:ns attach#agent n! tcpset
sink9new2gent
/T3&%ink/=e$2c
k:
nsattach#agent
n
7/24/2019 CS6411 Network Lab Manual
337/345
sink
ns
connecttc
psinktcp
setfid_"tcp set window_ >!!!tcp set packetsie_ 00
set
ft
7/24/2019 CS6411 Network Lab Manual
338/345
p9
ne
w2
pp$ica
ti
on/F
T&:f
t
patt
ach#ag
entt
cp
7/24/2019 CS6411 Network Lab Manual
339/345
ftp set type_ FT&set udp 9new 2gent/=&:ns attach#agent n" udpset nu$$ 9new 2gent/Nu$$:ns attach#agent n0 nu$$
ns connect udp nu$$udp set fid_
set cbr 9new 2pp$ication/Traffic/3IR:
7/24/2019 CS6411 Network Lab Manual
340/345
cbra
ttach#
agent
udp
cbrs
ett
yp
e_3IR
7/24/2019 CS6411 Network Lab Manual
341/345
7/24/2019 CS6411 Network Lab Manual
342/345
set time !."set now 9ns now:set
cwnd9
tcp
%ource
set
cw
nd_:s
et
wnd
9tc
7/24/2019 CS6411 Network Lab Manual
343/345
p%o
ur
ce
setwi
nd
ow_:
puts
fi$e
@now
cwnd@
ns at 9e(pr nowDtime: @p$otwindow
7/24/2019 CS6411 Network Lab Manual
344/345
tcp%ource fi$e@G
ns at ".! @p$otwindow tcp winfi$e@ns at 0
@ns
trace#annotateE@packetdropE@@ns at
"0.!@finish@ns run
?utputA
7/24/2019 CS6411 Network Lab Manual
345/345