LossyReceivingPort Class Reference

A lossy receiving port. More...

#include <common.h>

Inheritance diagram for LossyReceivingPort:

ReceivingPort Port List of all members.

Public Member Functions

 LossyReceivingPort (float lossyratio)
 ~LossyReceivingPort ()
PacketreceivePacket ()

Protected Attributes

float loss_ratio_
 how probable a packet will get dropped in receiving

Detailed Description

A lossy receiving port.

A receiving port which would random drop packets.

Definition at line 322 of file common.h.


Constructor & Destructor Documentation

LossyReceivingPort::LossyReceivingPort float  lossyratio  ) 
 

Constructor with parameter (drop probability p)

Definition at line 505 of file common.cpp.

00505                                                       : ReceivingPort(), loss_ratio_(lossyratio)
00506 {
00507 }


Member Function Documentation

Packet * LossyReceivingPort::receivePacket  ) 
 

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 }


The documentation for this class was generated from the following files:
Generated on Fri Feb 9 12:49:37 2007 for Common_Classes_Projects_ECE544 by  doxygen 1.4.6