Professional Documents
Culture Documents
Commands used:
For installation of ns2
Sample Program
set a 2.3
set b 4.7
set add [expr $a + $b]
set msg "Sum: "
puts "$msg $add"
Aim: To configure star topology for TCP and UDP connection using ns2
Procedure:
Program:
proc finish {} {
global ns nf
$ns flush-trace
close $nf
exec nam exp1.nam &
exit 0
}
$ns run
Output:
Star Topology using TCP
Program:
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
}
$ns run
Output
Star Topology using UDP
Program:
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
}
$ns run
Output:
Experiment #3 : Latency and Throughput Calculation
Aim : To calculate the Throughput and Latency of Star Topology using AWK script
Procedure:
AWK script:
BEGIN{
stime=0
ftime=0
flag=0
fsize=0
throughput=0
latency=0
}
{
if($1=="r"&&$4==3)
{
fsize+=$6
if(flag==0)
{
stime=$2
flag=1
}
ftime=$2
}
}
END{
latency=ftime-stime
throughput=(fsize*8)/latency
printf("\n Latency : %f", latency)
printf("\n Throughput : %f \n",throughput)
}
Output:
Experiment #4 : ping command simulation
Procedure:
.tcl file
proc finish {} {
global ns nf tf
exec awk -f lab.awk lab.tr &
exec nam lab2.nam &
$ns flush-trace
close $tf
close $nf
exit 0
}
.awk file
BEGIN {
count=0;
}
{
event=$1;
if(event=="d")
{
count++;
}
}
END {
printf("No of packets dropped : %d\n",count);
}
Output
Experiment #5 : IP Spoofing using nmap
Procedure:
1. First, we need to have two machines for this experiment. We first find out the IP addresses of
both the machines.
MACHINE 1
MACHINE 2
2. In the second machine we open a port using netcat. We use the command
nc lnvp [port-number]
4. Now we use the nmap to spoof the IP using the below command.
where,
-sS – Stealth Scan
-Pn – skip host discovery
-D – decoy scan
We can also mention use a random IP address instead of mentioning it by using the
command -RND.
5. Finally, we check whether the spoofing is done successfully by checking the incoming traffic in
wireshark. We can filter the spoofed ip using the filter.
Procedure:
1. First, we need to have two machines for this experiment. We first find out the IP addresses of
both the machines.
MACHINE 1
MACHINE 2
2. We install hping3 to our system using
3. In the second machine we open a port using netcat. We use the command
nc lnvp [port-number]
where
-S: specifies SYN packets.
• –flood: replies will be ignored and packets will be sent as fast as possible.
• -V: Verbosity.
• -p <portnumber>: port number
5. In the second machine, in wireshark we will see the flooded SYN packets. We can filter this
using the command