32 #include "dsr-errorbuff.h" 
   35 #include "ns3/ipv4-route.h" 
   36 #include "ns3/socket.h" 
   45 ErrorBuffer::GetSize ()
 
   48   return m_errorBuffer.size ();
 
   55   for (std::vector<ErrorBuffEntry>::const_iterator i = m_errorBuffer.begin (); i
 
   56        != m_errorBuffer.end (); ++i)
 
   58       NS_LOG_INFO (
"packet id " << i->GetPacket ()->GetUid () << 
" " << entry.GetPacket ()->
GetUid () << 
" source " << i->GetSource () << 
" " << entry.GetSource ()
 
   59                                 << 
" next hop " << i->GetNextHop () << 
" " << entry.GetNextHop () << 
" dst " << i->GetDestination () << 
" " << entry.GetDestination ());
 
   62       if ((i->GetPacket ()->GetUid () == entry.GetPacket ()->
GetUid ()) && (i->GetSource () == entry.GetSource ()) && (i->GetNextHop () == entry.GetSource ())
 
   63           && (i->GetDestination () == entry.GetDestination ()))
 
   69   entry.SetExpireTime (m_errorBufferTimeout);     
 
   73   if (m_errorBuffer.size () >= m_maxLen)
 
   75       Drop (m_errorBuffer.front (), 
"Drop the most aged packet");         
 
   76       m_errorBuffer.erase (m_errorBuffer.begin ());
 
   79   m_errorBuffer.push_back (entry);
 
   88   std::vector<Ipv4Address> list;
 
   89   list.push_back (source);
 
   90   list.push_back (nextHop);
 
   91   const std::vector<Ipv4Address> link = list;
 
   95   for (std::vector<ErrorBuffEntry>::iterator i = m_errorBuffer.begin (); i
 
   96        != m_errorBuffer.end (); ++i)
 
   98       if (LinkEqual (*i, link))
 
  100           DropLink (*i, 
"DropPacketForErrLink");
 
  103   m_errorBuffer.erase (std::remove_if (m_errorBuffer.begin (), m_errorBuffer.end (),
 
  104                                        std::bind2nd (std::ptr_fun (ErrorBuffer::LinkEqual), link)), m_errorBuffer.end ());
 
  108 ErrorBuffer::Dequeue (Ipv4Address dst, ErrorBuffEntry & entry)
 
  114   for (std::vector<ErrorBuffEntry>::iterator i = m_errorBuffer.begin (); i != m_errorBuffer.end (); ++i)
 
  116       if (i->GetDestination () == dst)
 
  119           m_errorBuffer.erase (i);
 
  120           NS_LOG_DEBUG (
"Packet size while dequeuing " << entry.GetPacket ()->GetSize ());
 
  128 ErrorBuffer::Find (Ipv4Address dst)
 
  133   for (std::vector<ErrorBuffEntry>::const_iterator i = m_errorBuffer.begin (); i
 
  134        != m_errorBuffer.end (); ++i)
 
  136       if (i->GetDestination () == dst)
 
  151     return (e.GetExpireTime () < 
Seconds (0));
 
  156 ErrorBuffer::Purge ()
 
  161   NS_LOG_DEBUG (
"The error buffer size " << m_errorBuffer.size ());
 
  163   for (std::vector<ErrorBuffEntry>::iterator i = m_errorBuffer.begin (); i
 
  164        != m_errorBuffer.end (); ++i)
 
  169           Drop (*i, 
"Drop out-dated packet ");
 
  172   m_errorBuffer.erase (std::remove_if (m_errorBuffer.begin (), m_errorBuffer.end (), pred),
 
  173                        m_errorBuffer.end ());
 
  177 ErrorBuffer::Drop (ErrorBuffEntry en, std::string reason)
 
  179   NS_LOG_LOGIC (reason << en.GetPacket ()->GetUid () << 
" " << en.GetDestination ());
 
  186 ErrorBuffer::DropLink (ErrorBuffEntry en, std::string reason)
 
  188   NS_LOG_LOGIC (reason << en.GetPacket ()->GetUid () << 
" " << en.GetSource () << 
" " << en.GetNextHop ());
 
#define NS_LOG_FUNCTION(parameters)
uint64_t GetUid(void) const 
bool Enqueue(ErrorBuffEntry &entry)
#define NS_LOG_COMPONENT_DEFINE(name)
#define NS_LOG_LOGIC(msg)
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)