front_drop_queue.cpp
Go to the documentation of this file.
#include <itpp/protocol/front_drop_queue.h>
namespace itpp
{
void Front_Drop_Queue::push(Packet *packet)
{
if (debug) {
std::cout << "Front_Drop_Queue::push_packet"
// << " byte_size=" << packet->bit_size()/8
<< " ptr=" << packet
<< " time=" << Event_Queue::now() << std::endl;
}
Packet *hol_packet;
while ((!std::queue<Packet*>::empty()) &&
((8*bytes_in_queue + packet->bit_size()) > 8*max_bytes_in_queue)) {
hol_packet = std::queue<Packet*>::front();
Front_Drop_Queue::pop();
delete hol_packet;
// TTCPPacket *tcp_packet = (TTCPPacket *) hol_packet;
// delete tcp_packet;
if (debug) {
std::cout << "Link_With_Input_Q::received_packet, "
<< "Packet Dropped, buffer overflow."
<< std::endl;
}
}
bytes_in_queue += packet->bit_size() / 8;
std::queue<Packet*>::push(packet);
}
void Front_Drop_Queue::pop()
{
Packet *hol_packet;
hol_packet = std::queue<Packet*>::front();
bytes_in_queue -= (hol_packet->bit_size() / 8);
if (debug) {
std::cout << "Front_Drop_Queue::pop_packet"
<< " ptr=" << hol_packet
<< " time=" << Event_Queue::now() << std::endl;
}
std::queue<Packet*>::pop();
}
} // namespace itpp
front_drop_queue.h
Definitions of a Front Drop Queue class.
itpp::Packet
Definition: packet.h:55
itpp::Event_Queue::now
static Ttype now()
Return current time.
Definition: events.h:139
itpp::Front_Drop_Queue::push
void push(Packet *packet)
ADD DOCUMENTATION HERE.
Definition: front_drop_queue.cpp:35
itpp::Packet::bit_size
int bit_size()
get size of packet in bits
Definition: packet.h:67
itpp::Front_Drop_Queue::pop
void pop()
ADD DOCUMENTATION HERE.
Definition: front_drop_queue.cpp:66
itpp
itpp namespace
Definition: itmex.h:36

Generated on Thu Aug 20 2015 21:02:51 for IT++ by Doxygen 1.8.9.1