Hi
*I have installed the ns2 2.31 all in one version on cygwin in Windows Vista
environment. I've added some modules to ns for my designed routing.Therer
is no error in making however,when I run the below example, the ns2 will
segmentation fault (core dumped).I use GDB to find where the problem is,and
the GDB gives the information:
*Program received signal SIGSEGV, Segmentation fault.
0x0046370f in Queue::recv (this=0x39ac458, p=0x39d0a40) at
queue/queue.cc:137
137 downtarget_-recv(p, qh_);
Then i use bt to find the detail,it shows:
(gdb) bt
#0 0x0046370f in Queue::recv (this=0x39ac458, p=0x39d0a40)
at queue/queue.cc:137
#1 0x006a7514 in Connector::send (this=0x39af360, p=0x39d0a40, h=0x0)
at ./common/connector.h:56
#2 0x0040dd9d in Trace::recv (this=0x39af360, p=0x39d0a40, h=0x0)
at trace/trace.cc:432
#3 0x006a7514 in Connector::send (this=0x39ae708, p=0x39d0a40, h=0x0)
at ./common/connector.h:56
#4 0x0040c611 in Connector::recv (this=0x39ae708, p=0x39d0a40, h=0x0)
at common/connector.cc:103
#5 0x0040f189 in Classifier::recv (this=0x3999cb0, p=0x39d0a40, h=0x0)
at classifier/classifier.cc:151
#6 0x0041e81b in UdpAgent::sendmsg (this=0x39c5418, nbytes=1000, data=0x0,
flags=0x0) at apps/udp.cc:107
#7 0x006a639a in UdpAgent::sendmsg (this=0x39c5418, nbytes=1000, flags=0x0)
at apps/udp.h:61
#8 0x00414bad in Application::send (this=0x39c5ce8, nbytes=1000)
at apps/app.cc:111
#9 0x0041522c in TrafficGenerator::timeout (this=0x39c5ce8)
at tools/trafgen.cc:74
#10 0x004169a6 in CBR_Traffic::start (this=0x39c5ce8)
at tools/cbr_traffic.cc:101
#11 0x004149b8 in Application::command (this=0x39c5ce8, argc=2,
argv=0x22a22c)
My queue.cc is:
void Queue::recv(Packet* p, Handler*)
{
double now = Scheduler::instance().clock();
enque(p);
//printQueue();
if (!blocked_) {
/*
* We're not blocked. Get a packet and send it on.
* We perform an extra check because the queue
* might drop the packet even if it was
* previously empty! (e.g., RED can do this.)
*/
p = deque();
if (p != 0) {
utilUpdate(last_change_, now, blocked_);
last_change_ = now;
blocked_ = 1;
downtarget_-recv(p, qh_);//here I made a change for my routing protocol
}
}
}
Thank you very much in advance !
set ns [new Simulator]
$ns color 1 Blue
$ns color 2 Red
set nf [open out.nam w]
$ns namtrace-all $nf
set nd [open out.tr w]
$ns trace-all $nd
proc finish {} {
global ns nf nd
$ns flush-trace
close $nf
close $nd
exec nam out.nam
exit 0
}
set s1 [$ns node]
set s2 [$ns node]
set r [$ns node]
set d [$ns node]
$ns duplex-link $s1 $r 2Mb 10ms DropTail
$ns duplex-link $s2 $r 2Mb 10ms DropTail
$ns duplex-link $r $d 1.7Mb 20ms DropTail
$ns queue-limit $r $d 10
$ns duplex-link-op $s1 $r orient right-down
$ns duplex-link-op $s2 $r orient right-up
$ns duplex-link-op $r $d orient right
$ns duplex-link-op $r $d queuePos 0.5
set tcp [new Agent/TCP]
$ns attach-agent $s1 $tcp
set sink [new Agent/TCPSink]
$ns attach-agent $d $sink
$ns connect $tcp $sink
$tcp set fid_ 1
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ftp set type_ FTP
set udp [new Agent/UDP]
$ns attach-agent $s2 $udp
set null [new Agent/Null]
$ns attach-agent $d $null
$ns connect $udp $null
$udp set fid_ 2
set cbr [new Application/Traffic/CBR]
$cbr attach-agent $udp
$cbr set type_ CBR
$cbr set packet_size_ 1000
$cbr set rate_ 1mb
$cbr set random_ false
$ns at 0.1 $cbr start
$ns at 1.0 $ftp start
$ns at 4.0 $ftp stop
$ns at 4.5 $cbr stop
$ns at 4.5 $ns detach-agent $s1 $tcp ; $ns detach-agent $d $sink
$ns at 5.0 finish
$ns run