~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Open Mash Cross Reference
mash/tcl/degas/degasserver/degas-session.tcl

Component: ~ [ mash ] ~ [ apps ] ~ [ gsm ] ~ [ lib ] ~ [ otcl ] ~ [ srm ] ~ [ tcl8.3 ] ~ [ tclcl ] ~ [ tk8.3 ] ~ [ tutorials ] ~

  1 import NetworkManager
  2 
  3 DegasSession instproc init {agent spec} {
  4         $self next 0 0
  5         $self instvar agent_ netmgr_ 
  6         set agent_ $agent
  7         set netmgr_ null
  8         set address_block [new AddressBlock $spec/1]
  9         $self reset $address_block
 10         delete $address_block
 11 }
 12 
 13 DegasSession instproc reset {addrblock} {
 14         $self instvar agent_ netmgr_
 15 
 16         if {$netmgr_ != "null"} {
 17                 delete $netmgr_
 18         }
 19         set netmgr_ [new NetworkManager $addrblock $self $agent_]
 20 
 21         for {set i 0} {$i < [$netmgr_ nchan]} {incr i} {
 22                 set net [$netmgr_ set net_($i)]
 23                 [$net data-net] loopback 1
 24                 [$net ctrl-net] loopback 1
 25         }
 26 }
 27 
 28 DegasSession instproc destroy {} {
 29         $self instvar netmgr_ 
 30         if {$netmgr_ != "null"} {
 31                 delete $netmgr_
 32         }
 33 
 34 #   Clear all bandwidth counters
 35         $self instvar start_nb_
 36         global bps_
 37         foreach src [array names start_nb_] {
 38                 unset start_nb_($src)
 39                 unset bps_($src,$self)
 40         }
 41 
 42         $self next
 43 }
 44 
 45 DegasSession instproc get {item} {
 46         return "$self$item"
 47 }
 48 
 49 
 50 DegasSession instproc recv_sr {source latency num_of_bytes} {
 51         $self instvar agent_ start_nb_ 
 52 
 53 #   We compute the bandwidth of the input source $source by
 54 #   looking at the $num_of_bytes (sr_nb field of a SR RTCP packet).   
 55 #   This gives us the total number of bytes sent since the source
 56 #   start sending.  Since we are using a rate_variable (from tclcl)
 57 #   to compute the bandwidth, we need to keep track of the number of
 58 #   bytes  the source has sent when we join its session.
 59 
 60         global bps_
 61         if {![info exists bps_($source,$self)]} {
 62                 # This is the first time we see this source.
 63                 # Remember the value "num_of_bytes"
 64                 rate_variable bps_($source,$self) 0.1
 65                 set start_nb_($source) $num_of_bytes
 66                 puts "reset bps_ ($source) [$self set start_nb_($source)]"
 67                 set bps_($source,$self) 0
 68         } else {
 69                 set bps_($source,$self) [expr $num_of_bytes - $start_nb_($source)]
 70         }
 71         if {[$agent_ info vars aglp_] != ""} {
 72                 set aglp [$agent_ set aglp_]
 73                 $aglp set_bandwidth $source $bps_($source,$self)
 74                 $aglp set_latency $source $latency
 75         }
 76 }
 77 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.