20CYS384
Advanced Protocol Engineering
Lab
V. Jayaraj
21026
EX:1 – Installation of Network Simulator
Aim: To install Network simulator (NS2) and NAM
Commands:
sudo apt-get install ns2
sudo spt-get install nam
Output:
EX:2 - Configuration of Network Simulator
Aim: To configure Network simulator (NS2) and construct a star topolgy
Commands:
set ns [new Simulator]
set nf [open exp1.nam w]
$ns namtrace-all $nf
proc finish {} {
global ns nf
$ns flush-trace
close $nf
exec nam exp1.nam &
exit 0
}
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
$ns duplex-link $n0 $n2 10Mb 10ms DropTail
$ns duplex-link $n1 $n2 10Mb 10ms DropTail
$ns duplex-link $n3 $n2 10Mb 10ms DropTail
$ns duplex-link-op $n0 $n2 orient right-down
$ns duplex-link-op $n1 $n2 orient right-up
$ns duplex-link-op $n3 $n2 orient left
$ns at 5.0 "finish"
$ns run
EX:3A– Star Topology using TCP
Aim: To construct a star topolgy using TCP
Commands:
set ns [new Simulator]
set nf [open exp2.nam w]
$ns namtrace-all $nf
set nt [open exp2.tr w]
$ns trace-all $nt
proc finish {} {
global ns nf nt
$ns flush-trace
close $nf
close $nt
exec nam exp2.nam &
exec awk -f exp2.awk exp2.tr &
exit 0
}
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
$ns duplex-link $n0 $n2 10Mb 10ms DropTail
$ns duplex-link $n1 $n2 10Mb 10ms DropTail
$ns duplex-link $n3 $n2 10Mb 10ms DropTail
$ns duplex-link-op $n0 $n2 orient right-down
$ns duplex-link-op $n1 $n2 orient right-up
$ns duplex-link-op $n3 $n2 orient left
set tcp [new Agent/TCP]
$tcp set class_ 2
$ns attach-agent $n0 $tcp
set sink [new Agent/TCPSink]
$ns attach-agent $n3 $sink
$ns connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ftp set type_ FTP
$ftp set packet_size_ 1000
$ftp set rate_ 1mb
$ns at 1.0 "$ftp start"
$ns at 2.0 "$ftp stop"
$ns at 5.0 "finish"
$ns run
EX:3B – Star Topology using UDP
Aim: To construct a star topolgy using TCP
Commands:
EX:4 – Packet loss due to congestion
Aim: To construct a star topolgy using TCP
Commands:
EX:5–Latency and Throughput in a TCP network
Aim:
To find data rate – latency & throughput in a TCP network.
Commands:
(I) exp4.tcl file:
set ns [new Simulator]
set nf [open exp4.nam w]
$ns namtrace-all $nf
set nt [open exp4.tr w]
$ns trace-all $nt
proc finish {} {
global ns nf nt
$ns flush-trace
close $nf
close $nt
exec nam exp4.nam &
exec awk -f exp4.awk exp4.tr &
exit 0
}
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
$ns duplex-link $n0 $n2 10Mb 10ms DropTail
$ns duplex-link $n1 $n2 10Mb 10ms DropTail
$ns duplex-link $n3 $n2 10Mb 10ms DropTail
$ns duplex-link-op $n0 $n2 orient right-down
$ns duplex-link-op $n1 $n2 orient right-up
$ns duplex-link-op $n3 $n2 orient left
set tcp [new Agent/TCP]
$tcp set class_ 2
$ns attach-agent $n0 $tcp
set sink [new Agent/TCPSink]
$ns attach-agent $n3 $sink
$ns connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ftp set type_ FTP
$ftp set packet_size_ 1000
$ftp set rate_ 1mb
$ns at 1.0 "$ftp start"
$ns at 2.0 "$ftp stop"
$ns at 5.0 "finish"
$ns run
(ii) exp4.awk
BEGIN{
stime=0
ftime=0
flag=0
fsize=0
throughput=0
latency=0
}
{
if($1 =="r" && $4 == 3){
fsize += 1
if(flag == 0){
stime = $2
flag = 1
}
ftime = $2
}
}
END{
latency = ftime - stime
throughput = (ftime * 8)/(latency)
printf("\nLatency : %f\n", latency)
printf("\nThroughput : %f\n", throughput)
}
Output:
EX:6–IP Spoofing
Aim:
To implement IP Spoofing using Wireshark.
Commands:
ifconfig
nc –lnvp 12345
sudo dpkg-reconfigure wireshark-common
sudo chmod +x /usr/bin/dumpcap
sudo nmap –sS –Pn –D <src ip> <dest ip>