31 #include "dsdv-packet-queue.h"
34 #include "ns3/ipv4-route.h"
35 #include "ns3/socket.h"
46 return m_queue.size ();
54 uint32_t numPacketswithdst;
55 for (std::vector<QueueEntry>::const_iterator i = m_queue.begin (); i
56 != m_queue.end (); ++i)
58 if ((i->GetPacket ()->GetUid () == entry.GetPacket ()->
GetUid ())
59 && (i->GetIpv4Header ().GetDestination ()
66 NS_LOG_DEBUG (
"Number of packets with this destination: " << numPacketswithdst);
70 NS_LOG_DEBUG (
"Max packets reached for this destination. Not queuing any further packets");
77 m_queue.push_back (entry);
87 for (std::vector<QueueEntry>::iterator i = m_queue.begin (); i
88 != m_queue.end (); ++i)
90 if (IsEqual (*i, dst))
92 Drop (*i,
"DropPacketWithDst ");
95 m_queue.erase (std::remove_if (m_queue.begin (), m_queue.end (),
96 std::bind2nd (std::ptr_fun (PacketQueue::IsEqual), dst)), m_queue.end ());
104 for (std::vector<QueueEntry>::iterator i = m_queue.begin (); i != m_queue.end (); ++i)
106 if (i->GetIpv4Header ().GetDestination () == dst)
119 for (std::vector<QueueEntry>::const_iterator i = m_queue.begin (); i
120 != m_queue.end (); ++i)
122 if (i->GetIpv4Header ().GetDestination () == dst)
135 for (std::vector<QueueEntry>::const_iterator i = m_queue.begin (); i
136 != m_queue.end (); ++i)
138 if (i->GetIpv4Header ().GetDestination () == dst)
152 return (e.GetExpireTime () <
Seconds (0));
161 for (std::vector<QueueEntry>::iterator i = m_queue.begin (); i
162 != m_queue.end (); ++i)
167 Drop (*i,
"Drop outdated packet ");
170 m_queue.erase (std::remove_if (m_queue.begin (), m_queue.end (), pred),
#define NS_LOG_FUNCTION(parameters)
uint64_t GetUid(void) const
#define NS_LOG_COMPONENT_DEFINE(name)
uint32_t GetCountForPacketsWithDst(Ipv4Address dst)
Get count of packets with destination dst in the queue.
#define NS_LOG_LOGIC(msg)
void DropPacketWithDst(Ipv4Address dst)
Remove all packets with destination IP address dst.
bool Dequeue(Ipv4Address dst, QueueEntry &entry)
Return first found (the earliest) entry for given destination.
void Purge()
Remove all expired entries.
Ipv4 addresses are stored in host order in this class.
Time Seconds(double seconds)
create ns3::Time instances in units of seconds.
#define NS_LOG_DEBUG(msg)
uint32_t GetSize()
Number of entries.
uint32_t m_maxLen
The maximum number of packets that we allow a routing protocol to buffer.
void Drop(QueueEntry en, std::string reason)
Notify that packet is dropped from queue by timeout.
bool Find(Ipv4Address dst)
Finds whether a packet with destination dst exists in the queue.
Time m_queueTimeout
The maximum period of time that a routing protocol is allowed to buffer a packet for, seconds.
uint32_t m_maxLenPerDst
The maximum number of packets that we allow per destination to buffer.
bool Enqueue(QueueEntry &entry)
Push entry in queue, if there is no entry with the same packet and destination address in queue...