#include <trf_gen_v3.h>
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) |
Stream * | RemoveStream (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 |
StreamPool * | BusyPool |
StreamPool * | IdlePool |
Packet | NextPacket |
bytestamp_t | Elapsed |
pckt_size_t | MinIFG |
burst_size_t | Tokens |
PF_PCKT_SIZE | pfPcktSize |
Definition at line 371 of file trf_gen_v3.h.
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] |
void GEN::PacketGenerator::AddStream | ( | Stream * | pSrc | ) | [inline] |
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] |
Packet GEN::PacketGenerator::PeekNextPacket | ( | void | ) | const [inline] |
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] |
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 }
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.