GEN::PacketGenerator Class Reference

PacketGenerator class to create packets according to a specified distribution. More...

#include <trf_gen_v3.h>

List of all members.

Classes

class  StreamPool

Public Member Functions

 PacketGenerator (source_id_t source_id, pckt_size_t inter_packet_gap)
 PacketGenerator (source_id_t source_id, pckt_size_t inter_packet_gap, float mean_burst, PF_STREAM_CTOR pf_strm, PF_PCKT_SIZE pf_size, int16s pool_size, load_t load)
virtual ~PacketGenerator ()
void Reset (void)
int32s GetStreams (void) const
void AddStream (Stream *pSrc)
void RemoveStream (Stream *pSrc)
StreamRemoveStream (void)
Packet PeekNextPacket (void) const
Packet GetNextPacket (void)
void SetLoad (load_t load)
void SetLoadReset (load_t load)
void Clear (void)

Public Attributes

StreamPool Pool1
StreamPool Pool2
StreamPoolBusyPool
StreamPoolIdlePool
Packet NextPacket
bytestamp_t Elapsed
pckt_size_t MinIFG
burst_size_t Tokens
PF_PCKT_SIZE pfPcktSize


Detailed Description

PacketGenerator class to create packets according to a specified distribution.

Definition at line 371 of file trf_gen_v3.h.


Constructor & Destructor Documentation

GEN::PacketGenerator::PacketGenerator ( source_id_t  source_id,
pckt_size_t  inter_packet_gap 
) [inline]

Definition at line 406 of file trf_gen_v3.h.

00406                                                                                                        {
00407             MinIFG    = inter_packet_gap;
00408             BusyPool  = &Pool1;
00409             IdlePool  = &Pool2;
00410 
00411             Tokens = 0;
00412             Elapsed   = 0;
00413 
00414             NextPacket.SourceId = source_id;
00415             NextPacket.PcktSize = 0;
00416             NextPacket.Interval = NextPacket.PcktSize + MinIFG;
00417 
00418         }

GEN::PacketGenerator::PacketGenerator ( source_id_t  source_id,
pckt_size_t  inter_packet_gap,
float  mean_burst,
PF_STREAM_CTOR  pf_strm,
PF_PCKT_SIZE  pf_size,
int16s  pool_size,
load_t  load 
) [inline]

Definition at line 421 of file trf_gen_v3.h.

00428         {
00429             MinIFG     = inter_packet_gap;
00430             BusyPool   = &Pool1;
00431             IdlePool   = &Pool2;
00432             pfPcktSize = pf_size;
00433             Tokens  = 0;
00434             Elapsed    = 0;
00435 
00436 
00437 
00438 
00439             NextPacket.SourceId = source_id;
00440             NextPacket.PcktSize = pfPcktSize();
00441             NextPacket.Interval = NextPacket.PcktSize + MinIFG;
00442 
00443 
00444             for( int16s s = 0; s < pool_size; s++ )
00445             {
00446                 AddStream( pf_strm( load / pool_size, mean_burst,s ) );
00447 
00448             }
00449 
00450         }

virtual GEN::PacketGenerator::~PacketGenerator (  )  [inline, virtual]

Definition at line 457 of file trf_gen_v3.h.

00457 { Clear(); }


Member Function Documentation

void GEN::PacketGenerator::AddStream ( Stream pSrc  )  [inline]

Definition at line 485 of file trf_gen_v3.h.

00485 { BusyPool->AddNode( pSrc ); }

void GEN::PacketGenerator::Clear ( void   )  [inline]

Definition at line 606 of file trf_gen_v3.h.

00607         {
00608             for( Stream*  pNode = RemoveStream(); pNode; pNode = RemoveStream() )
00609                 delete pNode;
00610 
00611             Reset();
00612         }

Packet GEN::PacketGenerator::GetNextPacket ( void   )  [inline]

Definition at line 525 of file trf_gen_v3.h.

00526         {
00527             Stream*     pStrm;
00528             Packet      next_packet = NextPacket;
00529             pckt_size_t pckt_size   = pfPcktSize();
00530             bytestamp_t pckt_time   = Elapsed;
00531 
00532             //Variable added by Natalia
00533             pause_size_t   interarrival_time;
00534 
00535 
00536 
00537             // if the remaining burst size is less then the packet size,
00538             // aggregate additional bursts
00539 
00540 
00541             while( Tokens < pckt_size && (pStrm = (Stream*)BusyPool->RemoveHead()) != NULL )
00542             {
00543                 if( pStrm->GetArrival() > pckt_time + Tokens )
00544                     pckt_time = pStrm->GetArrival() - Tokens;
00545 
00546                 Tokens += pStrm->GetBurstSize();
00547                 pStrm->ExtractBurst();        // receive new burst
00548                 BusyPool->AddNode( pStrm );   // place the stream in BusyPool
00549             }
00550 
00551             Tokens -= pckt_size;
00552             pckt_time += pckt_size + MinIFG;  // now pckt_time points to the last bit of the packet
00553 
00554             // update next packet
00555             NextPacket.PcktSize = pckt_size;
00556             NextPacket.Interval  =(pause_size_t)( pckt_time - Elapsed );
00557             interarrival_time= NextPacket.Interval - NextPacket.PcktSize;
00558 
00559             Elapsed = pckt_time;
00560             return next_packet;
00561         }

int32s GEN::PacketGenerator::GetStreams ( void   )  const [inline]

Definition at line 479 of file trf_gen_v3.h.

00479 { return BusyPool->GetCount(); }

Packet GEN::PacketGenerator::PeekNextPacket ( void   )  const [inline]

Definition at line 508 of file trf_gen_v3.h.

00508 { return NextPacket;  }

Stream* GEN::PacketGenerator::RemoveStream ( void   )  [inline]

Definition at line 498 of file trf_gen_v3.h.

00499                 {
00500                 return (Stream*)BusyPool->RemoveHead();
00501                 }

void GEN::PacketGenerator::RemoveStream ( Stream pSrc  )  [inline]

Definition at line 492 of file trf_gen_v3.h.

00493         {
00494                 BusyPool->RemoveNode( pSrc );
00495         }

void GEN::PacketGenerator::Reset ( void   )  [inline]

Definition at line 465 of file trf_gen_v3.h.

00466         {
00467             for( Stream* pNode = RemoveStream(); pNode; pNode = RemoveStream() )
00468             {
00469                 pNode->Reset();
00470                 IdlePool->AddNode( pNode );
00471             }
00472 
00473             SWAP<StreamPool*>( BusyPool, IdlePool );
00474             Elapsed = 0;
00475         }

void GEN::PacketGenerator::SetLoad ( load_t  load  )  [inline]

Definition at line 569 of file trf_gen_v3.h.

00570         {
00571             if( BusyPool->GetRoot() )
00572                 BusyPool->GetRoot()->SetLoadRecursive( load / GetStreams() );
00573         }

void GEN::PacketGenerator::SetLoadReset ( load_t  load  )  [inline]

Definition at line 585 of file trf_gen_v3.h.

00586         {
00587             load /= GetStreams();
00588 
00589             for( Stream* pNode = RemoveStream(); pNode; pNode = RemoveStream() )
00590             {
00591                 pNode->SetLoad( load );
00592                 pNode->Reset();
00593                 IdlePool->AddNode( pNode );
00594 
00595             }
00596 
00597             SWAP<StreamPool*>( BusyPool, IdlePool );
00598             Elapsed = 0;
00599         }


Member Data Documentation

Definition at line 388 of file trf_gen_v3.h.

Definition at line 392 of file trf_gen_v3.h.

Definition at line 389 of file trf_gen_v3.h.

Definition at line 393 of file trf_gen_v3.h.

Definition at line 391 of file trf_gen_v3.h.

Definition at line 396 of file trf_gen_v3.h.

Definition at line 387 of file trf_gen_v3.h.

Definition at line 387 of file trf_gen_v3.h.

Definition at line 394 of file trf_gen_v3.h.


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

Generated on Thu Nov 28 14:47:26 2013 for red_wireless by  doxygen 1.5.7.1