Skip to content

Commit

Permalink
Log number and per cent of stochastic drops.
Browse files Browse the repository at this point in the history
  • Loading branch information
anirudh authored and anirudh committed Sep 19, 2012
1 parent 6c2d911 commit 92af85a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions sender/cellsim.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ class DelayQueue

uint64_t _base_timestamp;

uint32_t _packets_added;
uint32_t _packets_dropped;

void tick( void );

public:
Expand All @@ -83,7 +86,9 @@ DelayQueue::DelayQueue( const string & s_name, const uint64_t s_ms_delay, const
_used_bytes( 0 ),
_queued_bytes( 0 ),
_bin_sec( base_timestamp / 1000 ),
_base_timestamp( base_timestamp )
_base_timestamp( base_timestamp ),
_packets_added ( 0 ),
_packets_dropped( 0 )
{
FILE *f = fopen( filename, "r" );
if ( f == NULL ) {
Expand Down Expand Up @@ -146,8 +151,11 @@ std::vector< string > DelayQueue::read( void )
void DelayQueue::write( const string & packet )
{
float r= rand()/(float)RAND_MAX;
_packets_added++;
if (r < _loss_rate) {
fprintf(stderr, "Stochastic drop of packet \n" );
_packets_dropped++;
fprintf(stderr, "%s , Stochastic drop of packet, _packets_added so far %d , _packets_dropped %d , drop rate %f \n",
_name.c_str(), _packets_added,_packets_dropped , (float)_packets_dropped/(float) _packets_added );
}
else {
uint64_t now( timestamp() );
Expand Down

0 comments on commit 92af85a

Please sign in to comment.