IT++ Logo

front_drop_queue.cpp

Go to the documentation of this file.
00001 
00030 #include <itpp/protocol/front_drop_queue.h>
00031 
00032 
00033 namespace itpp {
00034 
00035         void Front_Drop_Queue::push(Packet *packet)
00036         {
00037                 if (debug) {
00038       std::cout << "Front_Drop_Queue::push_packet"
00039                                 //                << " byte_size=" << packet->bit_size()/8
00040                 << " ptr=" << packet
00041                 << " time=" << Event_Queue::now() << std::endl;
00042                 }
00043 
00044                 Packet *hol_packet;
00045                 while ((!std::queue<Packet*>::empty()) &&
00046                                          ((8*bytes_in_queue + packet->bit_size()) >  8*max_bytes_in_queue)) {
00047       hol_packet = std::queue<Packet*>::front();
00048       Front_Drop_Queue::pop();
00049       delete hol_packet;
00050 
00051                         //      TTCPPacket *tcp_packet = (TTCPPacket *) hol_packet;
00052                         //      delete tcp_packet;
00053 
00054       if (debug) {
00055                                 std::cout << "Link_With_Input_Q::received_packet, "
00056                                                                         << "Packet Dropped, buffer overflow."
00057                                                                         << std::endl;
00058       }
00059                 }
00060 
00061                 bytes_in_queue += packet->bit_size()/8;
00062                 std::queue<Packet*>::push(packet);
00063 
00064         }
00065 
00066         void Front_Drop_Queue::pop()
00067         {
00068                 Packet *hol_packet;
00069                 hol_packet = std::queue<Packet*>::front();
00070                 bytes_in_queue -= (hol_packet->bit_size()/8);
00071                 if (debug) {
00072       std::cout << "Front_Drop_Queue::pop_packet"
00073                 << " ptr=" << hol_packet
00074                 << " time=" << Event_Queue::now() << std::endl;
00075                 }
00076                 std::queue<Packet*>::pop();
00077 
00078         }
00079 
00080 } // namespace itpp
SourceForge Logo

Generated on Sat Apr 19 10:43:55 2008 for IT++ by Doxygen 1.5.5