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

Re: [ns] traffic generator with callback





Michael Savoric wrote:

> Hi,
> I want to implement a WWW traffic generator as an application
> and I need a method to inform the generator about the
> transmission completion of the underlying TCP protocol.
> Any hints for me? Thank you.
>
> Best regards,
> Michael Savoric
>
> ======================================================
> E-Mail:         [email protected]
>
> Phone:          (030)314-23840
>
> Postal address: Technical University Berlin
>                 Telecommunication Networks Group (TKN)
>                 Einsteinufer 25, 10587 Berlin
> ======================================================

There is already a built-in function for that job. But if you want to
modify it to collect the statistics (when, size, ...) you can do like
this:
Additional code marked with
^^^^^^^^^^^^^^^^^^^^^^^^^^^


PagePool/WebTraf instproc launch-req { id clnt svr ctcp csnk stcp ssnk
size } {
 global wf_trace
 set ns [Simulator instance]

 # modified to trace web traffic flows.
 puts $wf_trace "REQ $id [$ns now] [$clnt id] [$svr id] $size"
 # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

 # puts "launch request $id : [$clnt id] -> [$svr id] size $size at [$ns
now]"
 # puts "  client: $ctcp $csnk"
 # puts "  server: $stcp $ssnk"

 $ns attach-agent $clnt $ctcp
 $ns attach-agent $svr $csnk
 $ns connect $ctcp $csnk
 $ctcp set fid_ $id

 $ns attach-agent $svr $stcp
 $ns attach-agent $clnt $ssnk
 $ns connect $stcp $ssnk
 $stcp set fid_ $id

 $ctcp proc done {} "$self done-req $id $clnt $svr $ctcp $csnk $stcp
$size"
 $stcp proc done {} "$self done-resp $id $clnt $svr $stcp $ssnk"

 # Send a single packet as a request
 $ctcp advanceby 1
}

PagePool/WebTraf instproc done-resp { id clnt svr stcp ssnk } {
 global wf_trace
 set ns [Simulator instance]

 # modified to trace web traffic flow.
 puts $wf_trace "DONE $id [$ns now] [$clnt id] [$svr id]"
 # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

 # puts "done response $id : [$clnt id] -> [$svr id] at [$ns now]"

 # Recycle server-side TCP agents
 $ns detach-agent $clnt $ssnk
 $ns detach-agent $svr $stcp
 $stcp reset
 $ssnk reset
 $self recycle $stcp $ssnk
 # puts "recycled $stcp $ssnk"
}