#include <common.h>
Inheritance diagram for LossyReceivingPort:
Public Member Functions | |
LossyReceivingPort (float lossyratio) | |
~LossyReceivingPort () | |
Packet * | receivePacket () |
Protected Attributes | |
float | loss_ratio_ |
how probable a packet will get dropped in receiving |
A receiving port which would random drop packets.
Definition at line 322 of file common.h.
|
Constructor with parameter (drop probability p) Definition at line 505 of file common.cpp. 00505 : ReceivingPort(), loss_ratio_(lossyratio) 00506 { 00507 }
|
|
Drop packets with a propabilty equal to loss_ratio Reimplemented from ReceivingPort. Definition at line 512 of file common.cpp. References loss_ratio_, and ReceivingPort::receivePacket(). 00513 { 00514 Packet *p = ReceivingPort::receivePacket(); 00515 float x; 00516 // Set evil seed (initial seed) 00517 srand( (unsigned)time( NULL ) ); 00518 x = (double) rand()/RAND_MAX; 00519 if ( x <= loss_ratio_) 00520 return NULL; 00521 else 00522 return p; 00523 }
|