[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ns] fix snoop




Hi,

  Thanks for the tip. Actually I tried to add

$ll_ ifq $ifq_

in vlan.tcl (Class LanIface) which define the lan interface. Since there
is already a "ifq" method defined in command() in ll.cc, adding
"$ll_ ifq  $ifq_" should trigger the command() and give the LLSnoop object
a pointer to the ifq. Actually this does give the Snoop agent a pointer
to ifq, but I still get the seg fault.

  Then I tried your tip, adding "$ll ifq $ifq" in "add-interface"
method of Node/MobileNode in  ns-mobilenode.tcl and add the command()
function to LLSnoop which invokes the  command function of the parent class, i.e.
the LL class. The code looks like:

(in LLSnoop:)

int command(int argc, const char*const* argv) {
		return LL::command(argc, argv);
	}


but I still got the same seg fault message.


  I wonder if there is any trick to write the command() function or
something else?





Ben
---------------------------------------------------------

On Sun, 1 Apr 2001, Prashant Ratanchandani wrote:

> Hi,
> 	I had made these changes before. For getting rid of
> segmentation fault, add the following line in the
> "add-interface" method of Node/MobileNode in
> ns-mobilenode.tcl :
> #
> # link layer
> #
> $ll ifq $ifq
>
> This is not sufficient. We have to add the "command"
> function to LLSnoop in which we have to invoke the
> command function of the parent class, i.e. the LL
> class.
> This will properly set the ifq_ variable and won't
> give any segmentation fault.
>
> Prashant
> --- Benyuan Liu <[email protected]> wrote:
> >
> > Hi,
> >
> >   The Berkerly Snoop in NS has been broken since
> > version ns-2.1.b4. I
> > looked into the code recently and was able to make
> > it work except for
> > a small problem. In the following I will describe
> > how I fixed and
> > validated the code. Hope this will help other people
> > in the community.
> >
> >    The reason that Snoop doesn't work in current
> > version is due to the
> > change in MAC layer. In Snoop, (Handler *h == 0) is
> > used to
> > determine the direction of the packet (up or down).
> > But in current
> > implementation of ns,  MAC class is a subclass of
> > BiConnector. In
> > BiConnector, ( HDR_CMN(p)->direction()), instead of
> > the (Handler *h==
> > 0) is used to determine whether to send up or down.
> > So one need to
> > replace all conditions (h==0) with
> > (HDR_CMN(p)->direction() == hdr_cmn::UP)
> > in Snoop.cc.
> >
> >   Also, to send a packet down at the link
> > layer(snoop.cc), one needs to
> > specify the direction of the packet. For example, in
> >
> > void Snoop::recv() and  int Snoop::snoop_rxmit(),
> > add
> >
> > 			hdr_cmn *ch = HDR_CMN(p);
> > 			ch->direction() = hdr_cmn::DOWN;
> >
> > before calling parent_->sendDown(p);
> >
> >  For some reason, in snoop.cc,
> > parent_->ifq()->length() always causes
> > segmentation fault. The reason may be the C++ side
> > doesn't get the correct
> > pointer to the interface queue (ifq_). For now I
> > just commented out
> > the condition and make the queue limit to be big so
> > the queue doesn't
> > overflow.
> >
> >  After the above changes, the Snoop agent should be
> > able to work. I
> > validated the functionality of the Snoop agent by
> > manually droping
> > some packets and studying the detail trace. I
> > validated all the major
> > operations like :
> >    (X)  Snoop timeout retransmission
> >    (X)  Ack suppress
> >    (X)  Snoop Buffer operations
> >
> > and the program works correctly.
> >
> >  By the way, the original snoop test file
> > (snoop.tcl) doesn't work.
> > One problem "add-error" procedure uses old
> > interface. The following is
> > my own test file.
> >
> >
> -------------------------------------------------------------------------
> > puts "sourcing tcl/lan/vlan.tcl..."
> > source tcl/lan/vlan.tcl
> > source tcl/lan/ns-mac.tcl
> >
> >
> > set opt(tr)	out.tr
> > set opt(namtr)	"MySnoop.nam"
> > set opt(seed)	0
> > set opt(stop)	10
> > set opt(node)	2
> >
> > set opt(qsize)	100
> > set opt(bw)	10Mb
> > set opt(delay)	1ms
> > set opt(ll)	LL
> > set opt(ifq)	Queue/DropTail
> > set opt(mac)	Mac/802_3
> > set opt(chan)	Channel
> > set opt(tcp)	TCP/Reno
> > set opt(sink)	TCPSink
> >
> > set opt(app)	FTP
> >
> > set loss_prob 10
> >
> >
> > proc finish {} {
> > 	global ns opt
> >
> > 	$ns flush-trace
> >
> > 	exec nam $opt(namtr) &
> >
> > 	exit 0
> > }
> >
> >
> > proc create-trace {} {
> > 	global ns opt
> >
> > 	if [file exists $opt(tr)] {
> > 		catch "exec rm -f $opt(tr) $opt(tr)-bw [glob
> > $opt(tr).*]"
> > 	}
> >
> > 	set trfd [open $opt(tr) w]
> > 	$ns trace-all $trfd
> > 	if {$opt(namtr) != ""} {
> > 		$ns namtrace-all [open $opt(namtr) w]
> > 	}
> > 	return $trfd
> > }
> >
> > proc add-error {LossyLink} {
> >
> >     global loss_prob
> >
> >     # creating the uniform distribution random
> > variable
> >     set loss_random_variable [new
> > RandomVariable/Uniform]
> >     $loss_random_variable set min_ 0    # set the
> > range of the random variable;
> >     $loss_random_variable set max_ 100
> >
> >     # create the error model;
> >     set loss_module [new ErrorModel]
> >     $loss_module drop-target [new Agent/Null]
> >     $loss_module set rate_ $loss_prob  # set error
> > rate to (0.1 = 10 / (100 - 0));
> >     # error unit: packets (the default);
> >     $loss_module unit pkt
> >
> >     # attach random var. to loss module;
> >     $loss_module ranvar $loss_random_variable
> >
> >     # keep a handle to the loss module;
> >     #set sessionhelper [$ns create-session $n0
> > $tcp0]
> >     $LossyLink errormodule $loss_module
> >
> >
> >
> > }
> >
> > proc create-topology {} {
> > 	global ns opt
> > 	global lan node s d
> >
> > 	set num $opt(node)
> > 	for {set i 1} {$i < $num} {incr i} {
> > 		set node($i) [$ns node]
> > 		lappend nodelist $node($i)
> > 	}
> >
> >
> > 	set lan [$ns make-lan $nodelist $opt(bw) \
> > 			$opt(delay) $opt(ll) $opt(ifq) $opt(mac)
> > $opt(chan)]
> >
> >
> > 	set opt(ll) LL/LLSnoop
> >
> > 	set opt(ifq) Queue/DropTail
> > 	$opt(ifq) set limit_ 100
> >
> > 	# set up snoop agent
> > 	set node(0) [$ns node]
> > 	$lan addNode [list $node(0)]  $opt(bw) $opt(delay)
> > $opt(ll) $opt(ifq) $opt(mac)
> >
> > 	# set source and connect to node(0)
> > 	set s [$ns node]
> > 	$ns duplex-link $s $node(0) 20Mb 20ms DropTail
> > 	$ns queue-limit $s $node(0) 100000
> > 	$ns duplex-link-op $s $node(0) orient right
> >
> > 	# set dest and connect to node(1)
> > 	set d [$ns node]
> > 	$ns duplex-link $node(1) $d 10Mb 0ms DropTail
> > 	$ns queue-limit $node(1) $d 1000
> > 	$ns duplex-link-op $d $node(1) orient left
> >
> >
> >
> > 	set LossyLink [$ns link $node(1) $d]
> >
> > 	add-error $LossyLink
> > }
> >
> > ## MAIN ##
> >
> === message truncated ===
>
>
> __________________________________________________
> Do You Yahoo!?
> Get email at your own domain with Yahoo! Mail.
> http://personal.mail.yahoo.com/?.refer=text
>