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

Problem with webcache classes?




Chapter 27 of the NS manual describes the "webcache" classes.
Although there are other Http implementations in the examples
directories and so forth, I thought I would try to use the webcache
classes for a simple Http simulation ("simple" meaning that I'm not
doing any caching).

In the sample code below, everything runs fine when NUMCLIENTS is set
to 1, but trouble begins with NUMCLIENTS set to 2.  Things run ok
until 28.7 seconds, at which point the page going to $client(1) gets
"lost" and the simulation pretty much grinds to a halt after that.

    set ns [new Simulator]

    set n0 [$ns node]
    set n1 [$ns node]

    $ns duplex-link $n0 $n1 10Mb 20ms DropTail

    # Create page pool
    set pgp [new PagePool/Math]
    set rv1 [new RandomVariable/Pareto]
    $rv1 set avg_ 8000
    $pgp ranvar-size $rv1
    set rv2 [new RandomVariable/Exponential]
    $rv2 set avg_ 5
    $pgp ranvar-age $rv2

    set server [new Http/Server $ns $n1]
    $server set-page-generator $pgp

    set NUMCLIENTS 2
    set rv3 [new RandomVariable/Exponential]
    $rv3 set avg_ 1
    for {set i 0} {$i < $NUMCLIENTS} {incr i 1} {
	set client($i) [new Http/Client $ns $n0]
	$client($i) set-interval-generator $rv3
	$client($i) set-page-generator $pgp
    }

    proc start {} {
	global server client NUMCLIENTS
	for {set i 0} {$i < $NUMCLIENTS} {incr i 1} {
	    $client($i) connect $server
	    $client($i) start-session $server $server
	}
    }

    $ns at 1 "start"
    $ns at 100 "finish"


It turns out that this happens because I put both Http/Client objects
on the same node.  The real problem here is that HttpApp::add_cnc()
and lookup_cnc() use the id() method of Http/Client to identify the
TcpApp connection, but the init method of Http (in http-agent.tcl)
initializes id_ to [$node_ id].  Hence both clients have the same id,
and only one TcpApp connection ever gets used.

So, my question is how best to fix this?  I see that the Http class
has a getfid() method that serves to draw a unique integer for each
Http/Client.  Perhaps this fid_ could be reused for the id_, or at
least the same pattern could be used to draw a unique id_ for each Http
instance.  Is there anything special about id_ that should be tied to
its node?  (I assume there is no reason, in principle, why I cannot
have multiple Http clients on a single node...)


I should mention that this is all with ns-2.1b5.  I have not checked
to see if this bug is fixed in the current snapshot (but a quick check
of the CVSweb pages indicated that id handling is unchanged).


Thanks for any pointers,

Tom Pavel
[email protected]