1,316
社区成员
发帖
与我相关
我的任务
分享
BEGIN{
sendline = 0;
recvline = 0;
fowardline = 0;
package_t =0;
init=0;
time_start=0;
}
{
if($7=="tcp" && $1=="s" && $4 == "AGT" && $8>=1000){
sendline++;
}
if(($1=="f") && $8>=1000){
fowardline++;
}
if($8>=1000 && $1=="r" && $4 == "AGT") {
if(init ==0){
time_start=$2;
init=1;
}
recvline++;
time_end[recvline]=$2;
}
}
END{
printf("start_time: %6f,end_time: %6f\n",time_start,time_end[recvline]);
printf("cbr s:%d,r:%d,r/s Ratio:%4f,F:%d\n",sendline,recvline,recvline/sendline,fowardline);
time=time_end[recvline]-time_start;
package_t=recvline*1040;
through_put=package_t/time;
printf("time=%4f,through_put=%4f\n",time,through_put)
}
set val(chan) Channel/WirelessChannel
set val(prop) Propagation/TwoRayGround
set val(netif) Phy/WirelessPhy
set val(mac) Mac/802_11
set val(ifq) Queue/DropTail/PriQueue
set val(ll) LL
set val(ant) Antenna/OmniAntenna
set val(ifqlen) 50
set val(nn) 3
set val(rp) AODV
set val(x) 800
set val(y) 600
puts "\n"
puts "Simulation of a simple wireless have two nodes\n"
puts "Starting simulation...\n"
set ns_ [new Simulator]
$ns_ color 1 Blue
$ns_ color 2 Red
set tracefd [open node_3_f.tr w]
$ns_ trace-all $tracefd
set namtracefd [open node_3_f.nam w]
$ns_ namtrace-all-wireless $namtracefd $val(x) $val(y)
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
create-god $val(nn)
$ns_ node-config -adhocRouting $val(rp) \
-llType $val(ll) \
-macType $val(mac) \
-ifqType $val(ifq) \
-ifqLen $val(ifqlen) \
-antType $val(ant) \
-propType $val(prop) \
-phyType $val(netif) \
-channelType $val(chan) \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace OFF \
-movementTrace OFF \
for {set i 0} {$i < $val(nn)} {incr i} {
set node_($i) [$ns_ node]
$node_($i) random-motion 0
}
$node_(0) set X_ 300
$node_(0) set Y_ 300
$node_(0) set Z_ 0
$node_(1) set X_ 462
$node_(1) set Y_ 417
$node_(1) set Z_ 0
$node_(2) set X_ 623
$node_(2) set Y_ 300
$node_(2) set Z_ 0
#$ns_ at 10.0 "$node_(0) setdest 800.0 200.0 0.0"
#$ns_ at 10.0 "$node_(1) setdest 200.0 200.0 0.0"
#$ns_ at 10.0 "$node_(2) setdest 200.0 200.0 0.0"
set tcp [new Agent/TCP]
$tcp set class_ 2
set sink [new Agent/TCPSink]
$ns_ attach-agent $node_(0) $tcp
$ns_ attach-agent $node_(2) $sink
$ns_ connect $tcp $sink
$tcp set fid_ 1
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns_ at 2.0 "$ftp start"
for {set i 0} {$i < $val(nn)} {incr i} {
$ns_ initial_node_pos $node_($i) 20
}
for {set i 0} {$i < $val(nn)} {incr i} {
$ns_ at 100 "$node_($i) reset"
}
proc stop {} {
global ns_ tracefd namtracefd
$ns_ flush-trace
close $tracefd
close $namtracefd
exec nam node_3_f.nam &
exit 0
}
$ns_ at 100.1 "stop"
$ns_ at 100.2 "puts \"NS EXITING...\";$ns_ halt"
puts "Starting Simulation...."
$ns_ run