#include <common.h>
Inheritance diagram for LossyReceivingPort:

Public Member Functions | |
| LossyReceivingPort (float lossyratio) | |
| Packet * | receivePacket () |
Protected Attributes | |
| float | loss_ratio_ |
| how probable a packet will get dropped in receiving | |
| int | secdelay_ |
| how large is the link propagation delay. | |
A receiving port which would random drop packets and delay packet reception in 1 second.
Definition at line 390 of file common.h.
|
|
Constructor with parameter (drop probability p) Using a fixed link delay: 1 second Definition at line 507 of file common.cpp. 00507 : ReceivingPort(), loss_ratio_(lossyratio),secdelay_(1) 00508 { 00509 }
|
|
|
Simulate link delay of 1 seconds. Drop packets with a propabilty equal to loss_ratio Reimplemented from ReceivingPort. Definition at line 514 of file common.cpp. References loss_ratio_, ReceivingPort::receivePacket(), and secdelay_. 00515 {
00516 Packet *p = ReceivingPort::receivePacket();
00517 //simulate some delay
00518 sleep(secdelay_); //delay
00519 float x;
00520 // Set evil seed (initial seed)
00521 srand( (unsigned)time( NULL ) );
00522 x = (double) rand()/RAND_MAX;
00523 //cout << x << endl;
00524 if ( x <= loss_ratio_)
00525 return NULL;
00526 else
00527 return p;
00528 }
|
1.4.2