SimStream Class Reference

#include <simstream.h>

List of all members.

Public Member Functions

 SimStream ()
 ~SimStream ()
int command (int argc, const char *const *argv)
int get_streamid ()
void setLevel (int theValue)
int getLevel ()
void setRcv_rate (double theValue)
double getRcv_rate ()
void setInst_rx_rate (double theValue)
double getInst_rx_rate ()
void setAvg_rx (double theValue)
double getAvg_rx ()
void setAvg_tx (double theValue, int level)
void setLow_tx (double theValue)
void setMedium_tx (double theValue)
void setHigh_tx (double theValue)
double getLow_tx ()
double getMedium_tx ()
double getHigh_tx ()
void compare ()

Public Attributes

SimStreamnext
RTPSessionsessions_

Protected Member Functions

void enter (RTPSession *)
void go_up (int level)
void go_down (int level)

Protected Attributes

int streamid_
int isSender
int isReceiver
int level_
double rcv_rate_
double inst_rx_rate_
list< double > rx_lst
double avg_rx_
double low_tx_
double medium_tx_
double high_tx_
double low_threshold_
double medium_threshold_
double high_threshold_


Detailed Description

Definition at line 52 of file simstream.h.


Constructor & Destructor Documentation

SimStream::SimStream (  ) 

no argument constructor

Definition at line 62 of file simstream.cc.

References avg_rx_, high_threshold_, high_tx_, inst_rx_rate_, isReceiver, isSender, level_, low_threshold_, low_tx_, medium_threshold_, medium_tx_, and rcv_rate_.

00063         : sessions_(0),streamid_(-1)
00064 {
00065         bind_bool("isSender",&isSender);        
00066         bind_bool("isReceiver",&isReceiver);
00067         bind("level_",&level_);
00068         bind("rcv_rate_",&rcv_rate_);
00069         inst_rx_rate_ = 0;
00070         avg_rx_ = 0;
00071         bind("low_tx_",&low_tx_);
00072         bind("medium_tx_",&medium_tx_);
00073         bind("high_tx_",&high_tx_);
00074         bind("low_threshold_", &low_threshold_);
00075         bind("medium_threshold_", &medium_threshold_);
00076         bind("high_threshold_", &high_threshold_);
00077 
00078         
00079 }

SimStream::~SimStream (  ) 

destructor

Definition at line 84 of file simstream.cc.

References RTPSession::next, rx_lst, and sessions_.

00085 {
00086         while (sessions_ != 0) {
00087                 RTPSession* s = sessions_;
00088                 sessions_ = sessions_->next;
00089                 delete s;
00090         }
00091         rx_lst.~list<double>();
00092         
00093         
00094 }


Member Function Documentation

int SimStream::command ( int  argc,
const char *const *  argv 
)

the command function that handles TCL commands

Definition at line 114 of file simstream.cc.

References enter(), and streamid_.

00115 {
00116         if (argc == 3) {
00117                 if (strcmp(argv[1], "session") == 0) {
00118                         RTPSession* s = (RTPSession*)TclObject::lookup(argv[2]);
00119                         enter(s);
00120                         return (TCL_OK);
00121                 }
00122                 if (strcmp(argv[1], "stream-id") == 0) {
00123                         streamid_ = atoi(argv[2]);
00124                         return (TCL_OK);
00125                 }
00126         }
00127 
00128         return (TclObject::command(argc, argv));
00129 }

int SimStream::get_streamid (  )  [inline]

Definition at line 60 of file simstream.h.

References streamid_.

00060 {return streamid_;}

void SimStream::setLevel ( int  theValue  )  [inline]

Definition at line 61 of file simstream.h.

References level_.

00061 {level_ = theValue;}

int SimStream::getLevel (  )  [inline]

Definition at line 62 of file simstream.h.

References level_.

00062 {return level_;}

void SimStream::setRcv_rate ( double  theValue  )  [inline]

Definition at line 63 of file simstream.h.

References rcv_rate_.

Referenced by RTPSession::build_report().

00063 {rcv_rate_ = theValue;}

double SimStream::getRcv_rate (  )  [inline]

Definition at line 64 of file simstream.h.

References rcv_rate_.

00064 {       return rcv_rate_;}

void SimStream::setInst_rx_rate ( double  theValue  ) 

adds the instantaneius receiving rate to the list

Parameters:
theValue the value to be added

Definition at line 136 of file simstream.cc.

References avg_rx_.

Referenced by RTPSession::smooth_rate().

00137 { 
00138         avg_rx_ = avg_rx_ * 0.5 + 0.5 * theValue;
00139         
00140 }

double SimStream::getInst_rx_rate (  )  [inline]

Definition at line 66 of file simstream.h.

References inst_rx_rate_.

00066 { return inst_rx_rate_;}

void SimStream::setAvg_rx ( double  theValue  )  [inline]

Definition at line 67 of file simstream.h.

References avg_rx_.

00067 {avg_rx_ = theValue;    }

double SimStream::getAvg_rx (  )  [inline]

Definition at line 68 of file simstream.h.

References avg_rx_.

Referenced by RTPSession::build_report().

00068 {return avg_rx_;}

void SimStream::setAvg_tx ( double  theValue,
int  level 
)

sets the average values of all streams

Parameters:
theValue the average transmission rate
level the stream level

Definition at line 147 of file simstream.cc.

References high_tx_, low_tx_, and medium_tx_.

Referenced by RTPSession::timeout().

00148 {
00149         if(level==1) {
00150                 low_tx_ =  theValue;
00151         } else if(level==2) {
00152                 medium_tx_ = theValue;
00153         } else high_tx_ = theValue;
00154 
00155 
00156 }

void SimStream::setLow_tx ( double  theValue  )  [inline]

Definition at line 70 of file simstream.h.

References low_tx_.

Referenced by RTPSession::recv_ctrl().

00070 {low_tx_ = theValue;}

void SimStream::setMedium_tx ( double  theValue  )  [inline]

Definition at line 71 of file simstream.h.

References medium_tx_.

Referenced by RTPSession::recv_ctrl().

00071 {medium_tx_ = theValue;}

void SimStream::setHigh_tx ( double  theValue  )  [inline]

Definition at line 72 of file simstream.h.

References high_tx_.

Referenced by RTPSession::recv_ctrl().

00072 {high_tx_=theValue;}

double SimStream::getLow_tx (  )  [inline]

Definition at line 73 of file simstream.h.

References low_tx_.

Referenced by RTPSession::build_report().

00073 {return low_tx_;}

double SimStream::getMedium_tx (  )  [inline]

Definition at line 74 of file simstream.h.

References medium_tx_.

Referenced by RTPSession::build_report().

00074 {       return medium_tx_;}

double SimStream::getHigh_tx (  )  [inline]

Definition at line 75 of file simstream.h.

References high_tx_.

Referenced by RTPSession::build_report().

00075 {return high_tx_;}

void SimStream::compare (  ) 

campares the average receiving rate with stream limits and average transmission rates

Definition at line 163 of file simstream.cc.

References avg_rx_, DOWN_LEVEL_FACTOR, go_down(), go_up(), high_threshold_, high_tx_, level_, medium_threshold_, medium_tx_, RATE_FACTOR, and UP_LEVEL_FACTOR.

Referenced by RTPSession::recv().

00164 {
00165 
00166         switch(level_) {
00167                 case 1  :
00168                         
00169                         if(avg_rx_ >= UP_LEVEL_FACTOR * medium_threshold_ && avg_rx_ >= medium_tx_ * RATE_FACTOR) {
00170 
00171                          go_up(level_);
00172                         }
00173                         break;
00174                 case 2  :
00175                 
00176                         if(avg_rx_ <= DOWN_LEVEL_FACTOR * medium_threshold_) {
00177 
00178                                 go_down(level_);
00179                         } else if(avg_rx_ >= UP_LEVEL_FACTOR * high_threshold_ && avg_rx_ >= high_tx_ * RATE_FACTOR) {
00180 
00181                                 go_up(level_);
00182                         }
00183                         break;
00184                 case 3  :
00185         
00186                         if(avg_rx_ <= DOWN_LEVEL_FACTOR * high_threshold_ ) {
00187 
00188                         go_down(level_);
00189                         }
00190                         break;
00191                 default :       
00192                 printf("Error...no level found\n");
00193         }
00194                 
00195 }

void SimStream::enter ( RTPSession s  )  [protected]

enters a session

Parameters:
s the session to be added

Definition at line 100 of file simstream.cc.

References RTPSession::next, NOW, sessions_, RTPSession::srcid(), and streamid_.

Referenced by command().

00101 {
00102         
00103         printf("Time:%f Stream:%d ...I add session %d \n", NOW,streamid_ , s->srcid());
00104         s->next = sessions_;
00105         sessions_ = s;
00106         
00107 }

void SimStream::go_up ( int  level  )  [protected]

go up one level

Parameters:
level the current level

Definition at line 201 of file simstream.cc.

References avg_rx_, high_tx_, low_tx_, medium_tx_, NOW, and streamid_.

Referenced by compare().

00202 {
00203         Tcl::instance().evalf("%s go-up %d",name(),level);
00204         printf("Time:%f Stream:%d level:%d I go UP  Avg_rx: %f Avg_Tx_Low:%f Avg_Tx_Medium:%f Avg_Tx_High:%f \n", NOW,streamid_ , level, avg_rx_ * 8, low_tx_ * 8, medium_tx_ * 8, high_tx_ * 8  );
00205         
00206 }

void SimStream::go_down ( int  level  )  [protected]

go down one level

Parameters:
level the current level

Definition at line 212 of file simstream.cc.

References avg_rx_, high_tx_, low_tx_, medium_tx_, NOW, and streamid_.

Referenced by compare().

00213 {
00214         Tcl::instance().evalf("%s go-down %d",name(),level);
00215         printf("Time:%f Stream:%d level:%d I go DOWN  Avg_rx: %f Avg_Tx_Low:%f Avg_Tx_Medium:%f Avg_Tx_High:%f \n", NOW,streamid_ , level, avg_rx_ * 8, low_tx_ * 8, medium_tx_ * 8, high_tx_ * 8  );
00216 }


Member Data Documentation

Definition at line 56 of file simstream.h.

Definition at line 57 of file simstream.h.

Referenced by enter(), and ~SimStream().

int SimStream::streamid_ [protected]

the stream id

Definition at line 85 of file simstream.h.

Referenced by command(), enter(), get_streamid(), go_down(), and go_up().

int SimStream::isSender [protected]

binded from tcl script

Definition at line 87 of file simstream.h.

Referenced by SimStream().

int SimStream::isReceiver [protected]

binded from the tcl script

Definition at line 89 of file simstream.h.

Referenced by SimStream().

int SimStream::level_ [protected]

the level of the stream. see definition in ns-default.tcl

Definition at line 91 of file simstream.h.

Referenced by compare(), getLevel(), setLevel(), and SimStream().

double SimStream::rcv_rate_ [protected]

the receiving rate

Definition at line 93 of file simstream.h.

Referenced by getRcv_rate(), setRcv_rate(), and SimStream().

double SimStream::inst_rx_rate_ [protected]

instantaneous receiving rate

Definition at line 95 of file simstream.h.

Referenced by getInst_rx_rate(), and SimStream().

list<double> SimStream::rx_lst [protected]

a list to keep all calculating TCP-friendly estimations over Δt

Definition at line 97 of file simstream.h.

Referenced by ~SimStream().

double SimStream::avg_rx_ [protected]

the average receiving rate

Definition at line 99 of file simstream.h.

Referenced by compare(), getAvg_rx(), go_down(), go_up(), setAvg_rx(), setInst_rx_rate(), and SimStream().

double SimStream::low_tx_ [protected]

transmission rate of the low capacity stream

Definition at line 101 of file simstream.h.

Referenced by getLow_tx(), go_down(), go_up(), setAvg_tx(), setLow_tx(), and SimStream().

double SimStream::medium_tx_ [protected]

transmission rate of the medium capacity stream

Definition at line 103 of file simstream.h.

Referenced by compare(), getMedium_tx(), go_down(), go_up(), setAvg_tx(), setMedium_tx(), and SimStream().

double SimStream::high_tx_ [protected]

transmission rate of the high capacity stream

Definition at line 105 of file simstream.h.

Referenced by compare(), getHigh_tx(), go_down(), go_up(), setAvg_tx(), setHigh_tx(), and SimStream().

double SimStream::low_threshold_ [protected]

the low linit of the low capacity stream

Definition at line 109 of file simstream.h.

Referenced by SimStream().

double SimStream::medium_threshold_ [protected]

the low linit of the medium capacity stream

Definition at line 111 of file simstream.h.

Referenced by compare(), and SimStream().

double SimStream::high_threshold_ [protected]

the low linit of the high capacity stream

Definition at line 113 of file simstream.h.

Referenced by compare(), and SimStream().


The documentation for this class was generated from the following files:

Generated on Sun Jun 1 20:54:53 2008 for ASMP_S by  doxygen 1.5.5