18 Kasım 2008 Salı

Implementing new agent in NS

in packet.h file you have to add the lines;
static const packet_t PT_BBB = 62; (Certainly, 62 is based on your own packet.h file..)
and
name_[PT_BBB]="BBB";
Also, makefile must be edited to compile agentBB.cc file.
TCL Example;



set ns [new Simulator]

set testTime 20

set namFile [open out.nam w]
$ns namtrace-all $namFile

set traceFile [open out.tr w]
$ns trace-all $traceFile

proc bitir {} {
global ns traceFile namFile
$ns flush-trace
close $traceFile
close $namFile
#exec perl throughput.pl &
#exec nam out.nam &

exit 0
}


set src [$ns node]
set dst [$ns node]

$ns duplex-link $src $dst 10Mb 5ms DropTail
$ns duplex-link $dst $src 10Mb 5ms DropTail


set agentBB1 [new Agent/agentBB]
$ns attach-agent $src $agentBB1
set agentBB2 [new Agent/agentBB]
$ns attach-agent $dst $agentBB2
$ns connect $agentBB1 $agentBB2

$ns at 1.0 "$agentBB2 sendto $agentBB1 0"

$ns at [expr $testTime + 1.0] "bitir"

$ns run




Ferhat Umut Dizdar

Hiç yorum yok:

Yorum Gönder