Professional Documents
Culture Documents
DCN Exp2
DCN Exp2
AIM:
SOFTWARE USED:
PROGRAM:
CODE:
1. First of all, create a TCL script file with its extension (using gedit)
3. Now, we will create two files, nam-trace file and trace file. Then, we
will setup in those files. In nam-file, all the data like nodes,
connection, topology etc. is present and in normal trace file, log data,
like delay no. of packets etc. are present.
set nf [open out.nam w]
# We created two variable nf and tf, in which we will create and open
the files out.nam and out.tr with write permisiion. Then we are
setting up respective tracing using suitable commands. Dollar sign is
used to access the value of that variable.
4. Now we will write the finish procedure, which should come in the
ending of script.
proc finish {} {
global ns nf tf
$ns flush-trace
close $nf
close $tf
exec nam out.nam &
exit 0
}
# We create protocol object for udp and assign it to node n0. Now,
we want n1 to be receiver alone, hence create an assign a null object
to it and finally, connect both the objects.
7. Now, we will generate some traffic by using CBR (Constant Bit Rate)
8. Now we will schedule the events for cbr object and ending.
$ns run
# Now, we have defined for how long the traffic will take place. The
finish line should be given after the finish procedure. In the end,
don’t forget to give the run statement.
Additional Commands: