Fix DSR bug 1608/1609.

This commit is contained in:
Yufei Cheng
2013-04-26 10:43:20 -04:00
parent 8070ec10a6
commit a84f02b031
18 changed files with 1241 additions and 661 deletions

View File

@@ -42,13 +42,16 @@ and state machine, as defined in the standard. It implements as a STL
map container. The key is the destination IP address.
Protocol operation strongly depends on broken link detection mechanism.
We implement the three heuristics recommended.
We implement the three heuristics recommended based the rfc.
First, we use layer 2 feedback when possible. A link is considered to be
First, we use link layer feedback when possible, which is also the fastest mechanism
in these three to detect link errors. A link is considered to be
broken if frame transmission results in a transmission failure for all
retries. This mechanism is meant for active links and works much faster than
in its absence. Layer 2 feedback implementation relies on TxErrHeader trace
source, currently it is supported in AdhocWifiMac only.
in its absence. DSR is able to detect the link layer transmission failure and
notify that as broken. Recalculation of routes will be triggered when needed.
If user does not want to use link layer acknowledgment, it can be tuned by setting
"LinkAcknowledgment" attribute to false in "dsr-routing.cc".
Second, passive acknowledgment should be used whenever possible. The node
turns on "promiscuous" receive mode, in which it can receive packets not

View File

@@ -58,6 +58,7 @@ ErrorBuffer::Enqueue (ErrorBuffEntry & entry)
NS_LOG_INFO ("packet id " << i->GetPacket ()->GetUid () << " " << entry.GetPacket ()->GetUid () << " source " << i->GetSource () << " " << entry.GetSource ()
<< " next hop " << i->GetNextHop () << " " << entry.GetNextHop () << " dst " << i->GetDestination () << " " << entry.GetDestination ());
/// TODO check the source and destination over here
if ((i->GetPacket ()->GetUid () == entry.GetPacket ()->GetUid ()) && (i->GetSource () == entry.GetSource ()) && (i->GetNextHop () == entry.GetSource ())
&& (i->GetDestination () == entry.GetDestination ()))
{

View File

@@ -122,7 +122,7 @@ uint16_t DsrFsHeader::GetDestId () const
void DsrFsHeader::Print (std::ostream &os) const
{
os
<< " nextHeader: " << (uint32_t)GetNextHeader () << " messageType: " << (uint32_t)GetMessageType ()
<< "nextHeader: " << (uint32_t)GetNextHeader () << " messageType: " << (uint32_t)GetMessageType ()
<< " sourceId: " << (uint32_t)GetSourceId () << " destinationId: " << (uint32_t)GetDestId ()
<< " length: " << (uint32_t)GetPayloadLength ();
}

View File

@@ -55,10 +55,10 @@ MaintainBuffer::Enqueue (MaintainBuffEntry & entry)
for (std::vector<MaintainBuffEntry>::const_iterator i = m_maintainBuffer.begin (); i
!= m_maintainBuffer.end (); ++i)
{
NS_LOG_INFO ("nexthop " << i->GetNextHop () << " " << entry.GetNextHop () << " our add " << i->GetOurAdd () << " " << entry.GetOurAdd ()
<< " src " << i->GetSrc () << " " << entry.GetSrc () << " dst " << i->GetDst () << " " << entry.GetDst ()
<< " ackId " << i->GetAckId () << " " << entry.GetAckId () << " SegsLeft " << (uint32_t)i->GetSegsLeft () << " " << (uint32_t)entry.GetSegsLeft ()
);
// NS_LOG_INFO ("nexthop " << i->GetNextHop () << " " << entry.GetNextHop () << " our add " << i->GetOurAdd () << " " << entry.GetOurAdd ()
// << " src " << i->GetSrc () << " " << entry.GetSrc () << " dst " << i->GetDst () << " " << entry.GetDst ()
// << " ackId " << i->GetAckId () << " " << entry.GetAckId () << " SegsLeft " << (uint32_t)i->GetSegsLeft () << " " << (uint32_t)entry.GetSegsLeft ()
// );
if ((i->GetNextHop () == entry.GetNextHop ()) && (i->GetOurAdd () == entry.GetOurAdd ()) && (i->GetSrc () == entry.GetSrc ())
&& (i->GetDst () == entry.GetDst ()) && (i->GetAckId () == entry.GetAckId ()) && (i->GetSegsLeft () == entry.GetSegsLeft ()))
@@ -75,7 +75,6 @@ MaintainBuffer::Enqueue (MaintainBuffEntry & entry)
m_maintainBuffer.erase (m_maintainBuffer.begin ()); // Drop the most aged packet
}
m_maintainBuffer.push_back (entry);
NS_LOG_DEBUG ("The maintain size " << m_maintainBuffer.size ());
return true;
}
@@ -84,7 +83,7 @@ MaintainBuffer::DropPacketWithNextHop (Ipv4Address nextHop)
{
NS_LOG_FUNCTION (this << nextHop);
Purge ();
NS_LOG_DEBUG ("Drop Packet With next hop " << nextHop);
NS_LOG_INFO ("Drop Packet With next hop " << nextHop);
m_maintainBuffer.erase (std::remove_if (m_maintainBuffer.begin (), m_maintainBuffer.end (),
std::bind2nd (std::ptr_fun (MaintainBuffer::IsEqual), nextHop)), m_maintainBuffer.end ());
}
@@ -106,34 +105,6 @@ MaintainBuffer::Dequeue (Ipv4Address nextHop, MaintainBuffEntry & entry)
return false;
}
//bool
//MaintainBuffer::FindMaintainEntry (Ptr<Packet> packet, Ipv4Address ourAdd, Ipv4Address src, Ipv4Address nextHop, Ipv4Address dst, NetworkKey networkKey)
//{
// // TODO if necessary this one can strip the packet header and have more information
// for (std::vector<MaintainBuffEntry>::const_iterator i = m_maintainBuffer.begin (); i
// != m_maintainBuffer.end (); ++i)
// {
// NS_LOG_INFO ("packet " << i->GetPacket () << " " << packet << " nexthop " << i->GetNextHop () << " " << nextHop
// << " our add " << i->GetOurAdd () << " " << ourAdd << " src " << i->GetSrc ()
// << " " << src << " dst " << i->GetDst () << " " << dst
// );
//
// if ((i->GetPacket () == packet) && (i->GetNextHop () == nextHop) && (i->GetOurAdd () == ourAdd) && (i->GetSrc () == src)
// && (i->GetDst () == dst))
// {
// NS_LOG_DEBUG ("Same maintenance entry found");
// networkKey.m_ackId = newEntry.GetAckId ();
// networkKey.m_ourAdd = newEntry.GetOurAdd ();
// networkKey.m_nextHop = newEntry.GetNextHop ();
// networkKey.m_source = newEntry.GetSrc ();
// networkKey.m_destination = newEntry.GetDst ();
// // TODO may need a different network key to have
// return true;
// }
// }
// return false;
//}
bool
MaintainBuffer::Find (Ipv4Address nextHop)
{
@@ -155,10 +126,9 @@ MaintainBuffer::AllEqual (MaintainBuffEntry & entry)
for (std::vector<MaintainBuffEntry>::iterator i = m_maintainBuffer.begin (); i
!= m_maintainBuffer.end (); ++i)
{
NS_LOG_DEBUG ("nexthop " << i->GetNextHop () << " " << entry.GetNextHop () << " our address " << i->GetOurAdd () << " " << entry.GetOurAdd ()
<< " src " << i->GetSrc () << " " << entry.GetSrc () << " dst " << i->GetDst () << " " << entry.GetDst ()
<< " ackId " << i->GetAckId () << " " << entry.GetAckId ());
// NS_LOG_DEBUG ("nexthop " << i->GetNextHop () << " " << entry.GetNextHop () << " our address " << i->GetOurAdd () << " " << entry.GetOurAdd ()
// << " src " << i->GetSrc () << " " << entry.GetSrc () << " dst " << i->GetDst () << " " << entry.GetDst ()
// << " ackId " << i->GetAckId () << " " << entry.GetAckId ());
if ((i->GetOurAdd () == entry.GetOurAdd ()) && (i->GetNextHop () == entry.GetNextHop ())
&& (i->GetSrc () == entry.GetSrc ()) && (i->GetDst () == entry.GetDst ())
@@ -177,10 +147,9 @@ MaintainBuffer::NetworkEqual (MaintainBuffEntry & entry)
for (std::vector<MaintainBuffEntry>::iterator i = m_maintainBuffer.begin (); i
!= m_maintainBuffer.end (); ++i)
{
NS_LOG_DEBUG ("nexthop " << i->GetNextHop () << " " << entry.GetNextHop () << " our address " << i->GetOurAdd () << " " << entry.GetOurAdd ()
<< " src " << i->GetSrc () << " " << entry.GetSrc () << " dst " << i->GetDst () << " " << entry.GetDst ()
<< " ackId " << i->GetAckId () << " " << entry.GetAckId ());
// NS_LOG_DEBUG ("nexthop " << i->GetNextHop () << " " << entry.GetNextHop () << " our address " << i->GetOurAdd () << " " << entry.GetOurAdd ()
// << " src " << i->GetSrc () << " " << entry.GetSrc () << " dst " << i->GetDst () << " " << entry.GetDst ()
// << " ackId " << i->GetAckId () << " " << entry.GetAckId ());
if ((i->GetOurAdd () == entry.GetOurAdd ()) && (i->GetNextHop () == entry.GetNextHop ())
&& (i->GetSrc () == entry.GetSrc ()) && (i->GetDst () == entry.GetDst ())
@@ -200,10 +169,10 @@ MaintainBuffer::PromiscEqual (MaintainBuffEntry & entry)
for (std::vector<MaintainBuffEntry>::iterator i = m_maintainBuffer.begin (); i
!= m_maintainBuffer.end (); ++i)
{
NS_LOG_DEBUG ("src " << i->GetSrc () << " " << entry.GetSrc () << " dst " << i->GetDst () << " " << entry.GetDst ()
<< " SegsLeft " << (uint32_t)i->GetSegsLeft () << " " << (uint32_t)entry.GetSegsLeft () << " ackId " << (uint32_t)i->GetAckId () << " "
<< (uint32_t)entry.GetAckId ()
);
// NS_LOG_DEBUG ("src " << i->GetSrc () << " " << entry.GetSrc () << " dst " << i->GetDst () << " " << entry.GetDst ()
// << " SegsLeft " << (uint32_t)i->GetSegsLeft () << " " << (uint32_t)entry.GetSegsLeft () << " ackId " << (uint32_t)i->GetAckId () << " "
// << (uint32_t)entry.GetAckId ()
// );
if ((i->GetSrc () == entry.GetSrc ()) && (i->GetDst () == entry.GetDst ())
&& (i->GetSegsLeft () == entry.GetSegsLeft ()) && (i->GetAckId () == entry.GetAckId ())
@@ -216,6 +185,29 @@ MaintainBuffer::PromiscEqual (MaintainBuffEntry & entry)
return false;
}
bool
MaintainBuffer::LinkEqual (MaintainBuffEntry & entry)
{
NS_LOG_DEBUG ("The maintenance buffer size " << m_maintainBuffer.size ());
for (std::vector<MaintainBuffEntry>::iterator i = m_maintainBuffer.begin (); i
!= m_maintainBuffer.end (); ++i)
{
// NS_LOG_DEBUG ("src " << i->GetSrc () << " " << entry.GetSrc () << " dst " << i->GetDst () << " " << entry.GetDst ()
// << " OurAddress " << i->GetOurAdd () << " " << entry.GetOurAdd () << " next hop " << i->GetNextHop () << " "
// << entry.GetNextHop ()
// );
if ((i->GetSrc () == entry.GetSrc ()) && (i->GetDst () == entry.GetDst ()) && (i->GetOurAdd () == entry.GetOurAdd ())
&& (i->GetNextHop () == entry.GetNextHop ())
)
{
m_maintainBuffer.erase (i); // Erase the same maintain buffer entry for the promisc received packet
return true;
}
}
return false;
}
struct IsExpired
{
bool

View File

@@ -40,13 +40,29 @@
namespace ns3 {
namespace dsr {
/*
/**
* The maintenance buffer is responsible for maintaining packet next hop delivery
* The data packet is saved in maintenance buffer whenever the data packet is sent out of send buffer
*/
/*
* The packet timer key for controlling data packet retransmission
*/
struct LinkKey
{
Ipv4Address m_source;
Ipv4Address m_destination;
Ipv4Address m_ourAdd;
Ipv4Address m_nextHop;
/**
* Compare maintain Buffer entries
* \return true if equal
*/
bool operator < (LinkKey const & o) const
{
return ((m_source < o.m_source) && (m_destination < o.m_destination)
&& (m_ourAdd < o.m_nextHop) && (m_nextHop < o.m_nextHop)
);
}
};
struct NetworkKey
{
uint16_t m_ackId;
@@ -178,7 +194,7 @@ public:
private:
// / Data packet
Ptr<const Packet> m_packet;
// / our own ip address
// / Our own ip address
Ipv4Address m_ourAdd;
// / Next hop Ip address
Ipv4Address m_nextHop;
@@ -235,7 +251,10 @@ public:
{
m_maintainBufferTimeout = t;
}
// / Verify if all the elements in the maintainence buffer entry is the same
bool AllEqual (MaintainBuffEntry & entry);
// / Verify if the maintain buffer entry is the same in every field for link ack
bool LinkEqual (MaintainBuffEntry & entry);
// / Verify if the maintain buffer entry is the same in every field for network ack
bool NetworkEqual (MaintainBuffEntry & entry);
// / Verify if the maintain buffer entry is the same in every field for promiscuous ack

View File

@@ -31,9 +31,9 @@
#include "dsr-network-queue.h"
#include "ns3/test.h"
#include <map>
#include <algorithm>
#include <functional>
#include <map>
#include "ns3/log.h"
#include "ns3/ipv4-route.h"
#include "ns3/socket.h"
@@ -60,17 +60,17 @@ DsrNetworkQueue::DsrNetworkQueue (uint32_t maxLen, Time maxDelay)
m_maxSize (maxLen),
m_maxDelay (maxDelay)
{
NS_LOG_FUNCTION (this );
NS_LOG_FUNCTION (this);
}
DsrNetworkQueue::DsrNetworkQueue () : m_size (0)
{
NS_LOG_FUNCTION (this );
NS_LOG_FUNCTION (this);
}
DsrNetworkQueue::~DsrNetworkQueue ()
{
NS_LOG_FUNCTION (this );
NS_LOG_FUNCTION (this);
Flush ();
}
@@ -110,7 +110,7 @@ DsrNetworkQueue::Enqueue (DsrNetworkQueueEntry & entry)
entry.SetInsertedTimeStamp (now);
m_dsrNetworkQueue.push_back (entry);
m_size++;
NS_LOG_DEBUG ("The network queue size for now " << m_size);
NS_LOG_LOGIC ("The network queue size is " << m_size);
return true;
}
@@ -123,7 +123,7 @@ DsrNetworkQueue::Dequeue (DsrNetworkQueueEntry & entry)
if (i == m_dsrNetworkQueue.end ())
{
// no elements in array
NS_LOG_DEBUG ("Does not find the queued packet in the network queue");
NS_LOG_LOGIC ("No queued packet in the network queue");
return false;
}
entry = *i;
@@ -151,6 +151,7 @@ DsrNetworkQueue::Cleanup (void)
}
else
{
NS_LOG_LOGIC ("Outdated packet");
i = m_dsrNetworkQueue.erase (i);
n++;
}

View File

@@ -337,6 +337,16 @@ public:
* \return the router IPv4 Address
*/
Ipv4Address GetNodeAddress (uint8_t index) const;
/**
* \brief Set the data length.
* \param dataLength the data length
*/
void SetDataLength (uint32_t dataLength);
/**
* \brief Get the data length.
* \return the data length
*/
uint32_t GetDataLength () const;
/**
* \brief Set the request id number.
* \param the identification number
@@ -502,6 +512,12 @@ public:
* \return the router IPv4 Address
*/
Ipv4Address GetNodeAddress (uint8_t index) const;
/*
* \brief Search the next hop Ipv4 address
* \param Our own IP address
* \return The next hop address of the route
*/
Ipv4Address SearchNextHop (Ipv4Address ipv4Address);
/**
* \brief Print some informations about the packet.
* \param os output stream

View File

@@ -562,16 +562,24 @@ uint8_t DsrOptionRreq::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Addres
// check whether we have received this request or not, if not, it will save the request in the table for
// later use, if not found, return false, and push the newly received source request entry in the cache
bool dupRequest = dsr->FindSourceEntry (sourceAddress, targetAddress, requestId);
// Get the TTL value, this is used to test if the packet will be forwarded or not
uint8_t ttl = ipv4Header.GetTtl ();
bool dupRequest = false; // initialize the duplicate request check value
if (ttl)
{
// if the ttl value is not 0, then this request will be forwarded, then we need to
// save it in the source entry
dupRequest = dsr->FindSourceEntry (sourceAddress, targetAddress, requestId);
}
/*
* Before processing the route request, we need to check two things
* 1. if this is the exact same request we have just received, ignore it
* 2. if our address is already in the path list, ignore it
* 3. otherwise process further
*/
if (dupRequest)
{
NS_LOG_DEBUG ("We have received duplicate request");
// We have received this same route reqeust before, not forwarding it now
NS_LOG_LOGIC ("Duplicate request. Drop!");
m_dropTrace (packet); // call drop trace
@@ -591,7 +599,6 @@ uint8_t DsrOptionRreq::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Addres
{
// A node ignores all RREQs received from any node in its blacklist
RouteCacheEntry toPrev;
/*
* When the reverse route is created or updated, the following actions on the route are also carried out:
* 3. the next hop in the routing table becomes the node from which the RREQ was received
@@ -1189,8 +1196,6 @@ uint8_t DsrOptionSR::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Address
// The route size saved in the source route
std::vector<Ipv4Address> nodeList = sourceRoute.GetNodesAddress ();
uint8_t segsLeft = sourceRoute.GetSegmentsLeft ();
/// TODO remove this one later
NS_LOG_DEBUG ("The segment left here " << (uint32_t) segsLeft);
uint8_t salvage = sourceRoute.GetSalvage ();
/*
* Get the node from IP address and get the DSR extension object
@@ -1222,12 +1227,10 @@ uint8_t DsrOptionSR::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Address
uint16_t fragmentOffset = ipv4Header.GetFragmentOffset ();
uint16_t identification = ipv4Header.GetIdentification ();
/// TODO add the link ack over here
if (destAddress != destination)
{
NS_LOG_DEBUG ("Process the promiscuously received packet");
bool findPassive = false;
bool findPassive;
int32_t nNodes = NodeList::GetNNodes ();
for (int32_t i = 0; i < nNodes; ++i)
{
@@ -1255,9 +1258,6 @@ uint8_t DsrOptionSR::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Address
NS_LOG_DEBUG ("promisc source " << promiscSource);
Ptr<Node> node = GetNodeWithAddress (promiscSource);
Ptr<dsr::DsrRouting> dsrSrc = node->GetObject<dsr::DsrRouting> ();
/// TODO need to think about this part
/// TODO this is temporarily disabled to enable other
dsrSrc->CancelPassiveTimer (packet, source, destination, segsLeft);
}
else

View File

@@ -142,12 +142,12 @@ public:
* \brief Print out the elements in the route vector
*/
void PrintVector (std::vector<Ipv4Address>& vec);
/*
/**
* \brief Check if the two vectors contain duplicate or not
* \return true if contains duplicate
*/
bool IfDuplicates (std::vector<Ipv4Address>& vec, std::vector<Ipv4Address>& vec2);
/*
/**
* \brief Check if the route already contains the node ip address
* \return true if it already exists
*/
@@ -225,7 +225,7 @@ protected:
* \brief The active route timeout value.
*/
Time ActiveRouteTimeout;
/*
/**
* The receive trace back, only triggered when final destination receive data packet
*/
TracedCallback <const DsrOptionSRHeader &> m_rxPacketTrace;

View File

@@ -74,10 +74,10 @@ PassiveBuffer::Enqueue (PassiveBuffEntry & entry)
for (std::vector<PassiveBuffEntry>::const_iterator i = m_passiveBuffer.begin (); i
!= m_passiveBuffer.end (); ++i)
{
NS_LOG_INFO ("packet id " << i->GetPacket ()->GetUid () << " " << entry.GetPacket ()->GetUid () << " source " << i->GetSource () << " " << entry.GetSource ()
<< " dst " << i->GetDestination () << " " << entry.GetDestination () << " identification " << i->GetIdentification () << " "
<< entry.GetIdentification () << " fragment " << i->GetFragmentOffset () << " " << entry.GetFragmentOffset ()
<< " segLeft " << i->GetSegsLeft () << " " << entry.GetSegsLeft ());
// NS_LOG_INFO ("packet id " << i->GetPacket ()->GetUid () << " " << entry.GetPacket ()->GetUid () << " source " << i->GetSource () << " " << entry.GetSource ()
// << " dst " << i->GetDestination () << " " << entry.GetDestination () << " identification " << i->GetIdentification () << " "
// << entry.GetIdentification () << " fragment " << i->GetFragmentOffset () << " " << entry.GetFragmentOffset ()
// << " segLeft " << i->GetSegsLeft () << " " << entry.GetSegsLeft ());
if ((i->GetPacket ()->GetUid () == entry.GetPacket ()->GetUid ()) && (i->GetSource () == entry.GetSource ()) && (i->GetNextHop () == entry.GetNextHop ())
&& (i->GetDestination () == entry.GetDestination ()) && (i->GetIdentification () == entry.GetIdentification ()) && (i->GetFragmentOffset () == entry.GetFragmentOffset ())
@@ -107,10 +107,10 @@ PassiveBuffer::AllEqual (PassiveBuffEntry & entry)
for (std::vector<PassiveBuffEntry>::iterator i = m_passiveBuffer.begin (); i
!= m_passiveBuffer.end (); ++i)
{
NS_LOG_INFO ("packet id " << i->GetPacket ()->GetUid () << " " << entry.GetPacket ()->GetUid () << " source " << i->GetSource () << " " << entry.GetSource ()
<< " dst " << i->GetDestination () << " " << entry.GetDestination () << " identification " << i->GetIdentification () << " "
<< entry.GetIdentification () << " fragment " << i->GetFragmentOffset () << " " << entry.GetFragmentOffset ()
<< " segLeft " << (uint32_t) i->GetSegsLeft () << " " << (uint32_t) entry.GetSegsLeft ());
// NS_LOG_INFO ("packet id " << i->GetPacket ()->GetUid () << " " << entry.GetPacket ()->GetUid () << " source " << i->GetSource () << " " << entry.GetSource ()
// << " dst " << i->GetDestination () << " " << entry.GetDestination () << " identification " << i->GetIdentification () << " "
// << entry.GetIdentification () << " fragment " << i->GetFragmentOffset () << " " << entry.GetFragmentOffset ()
// << " segLeft " << (uint32_t) i->GetSegsLeft () << " " << (uint32_t) entry.GetSegsLeft ());
if ((i->GetPacket ()->GetUid () == entry.GetPacket ()->GetUid ()) && (i->GetSource () == entry.GetSource ()) && (i->GetNextHop () == entry.GetNextHop ())
&& (i->GetDestination () == entry.GetDestination ()) && (i->GetIdentification () == entry.GetIdentification ()) && (i->GetFragmentOffset () == entry.GetFragmentOffset ())

View File

@@ -214,11 +214,6 @@ public:
}
// \}
std::vector<PassiveBuffEntry> & GetBuffer () /// TODO may need to remove this one here
{
return m_passiveBuffer;
}
private:
// / The send buffer to cache unsent packet
std::vector<PassiveBuffEntry> m_passiveBuffer;

View File

@@ -97,7 +97,7 @@ LinkStab::~LinkStab ()
void LinkStab::Print ( ) const
{
NS_LOG_DEBUG ("LifeTime: " << GetLinkStability ().GetSeconds ());
NS_LOG_LOGIC ("LifeTime: " << GetLinkStability ().GetSeconds ());
}
typedef std::list<RouteCacheEntry>::value_type route_pair;
@@ -168,7 +168,7 @@ void
RouteCache::RemoveLastEntry (std::list<RouteCacheEntry> & rtVector)
{
NS_LOG_FUNCTION (this);
// release the last entry of route list
// Release the last entry of route list
rtVector.pop_back ();
}
@@ -180,7 +180,7 @@ RouteCache::UpdateRouteEntry (Ipv4Address dst)
m_sortedRoutes.find (dst);
if (i == m_sortedRoutes.end ())
{
NS_LOG_DEBUG ("Failed to find the route entry for the destination " << dst);
NS_LOG_LOGIC ("Failed to find the route entry for the destination " << dst);
return false;
}
else
@@ -190,8 +190,8 @@ RouteCache::UpdateRouteEntry (Ipv4Address dst)
successEntry.SetExpireTime (RouteCacheTimeout);
rtVector.pop_front ();
rtVector.push_back (successEntry);
rtVector.sort (CompareRoutesExpire); // sort the route vector first
m_sortedRoutes.erase (dst); // erase the entry first
rtVector.sort (CompareRoutesExpire); // sort the route vector first
m_sortedRoutes.erase (dst); // erase the entry first
/*
* Save the new route cache along with the destination address in map
*/
@@ -272,7 +272,7 @@ RouteCache::LookupRoute (Ipv4Address id, RouteCacheEntry & rt)
std::map<Ipv4Address, std::list<RouteCacheEntry> >::const_iterator m = m_sortedRoutes.find (id);
if (m == m_sortedRoutes.end ())
{
NS_LOG_DEBUG ("No updated route till last time");
NS_LOG_LOGIC ("No updated route till last time");
return false;
}
/*
@@ -280,7 +280,7 @@ RouteCache::LookupRoute (Ipv4Address id, RouteCacheEntry & rt)
*/
std::list<RouteCacheEntry> rtVector = m->second;
rt = rtVector.front (); // use the first entry in the route vector
NS_LOG_DEBUG ("Route to " << id << " with route size " << rtVector.size ());
NS_LOG_LOGIC ("Route to " << id << " with route size " << rtVector.size ());
return true;
}
}
@@ -299,7 +299,7 @@ RouteCache::SetCacheType (std::string type)
}
else
{
m_isLinkCache = false; // use path cache as default
m_isLinkCache = true; // use link cache as default
NS_LOG_INFO ("Error Cache Type");
}
}
@@ -351,7 +351,7 @@ RouteCache::RebuildBestRouteTable (Ipv4Address source)
Ipv4Address ip = j->first;
if (s.find (ip) == s.end ())
{
/**
/*
* \brief The followings are for comparison
*/
if (j->second <= temp)
@@ -371,7 +371,7 @@ RouteCache::RebuildBestRouteTable (Ipv4Address source)
d[k->first] = d[tempip] + k->second;
pre[k->first] = tempip;
}
/**
/*
* Selects the shortest-length route that has the longest expected lifetime
* (highest minimum timeout of any link in the route)
* For the computation overhead and complexity
@@ -414,15 +414,13 @@ RouteCache::RebuildBestRouteTable (Ipv4Address source)
iptemp = pre[iptemp];
}
route.push_back (source);
/**
* \brief Reverse the route
*/
// Reverse the route
RouteCacheEntry::IP_VECTOR reverseroute;
for (RouteCacheEntry::IP_VECTOR::reverse_iterator j = route.rbegin (); j != route.rend (); ++j)
{
reverseroute.push_back (*j);
}
NS_LOG_DEBUG ("Add Route: ");
NS_LOG_LOGIC ("Add newly calculated best routes");
PrintVector (reverseroute);
m_bestRoutesTable_link[i->first] = reverseroute;
}
@@ -433,17 +431,19 @@ bool
RouteCache::LookupRoute_Link (Ipv4Address id, RouteCacheEntry & rt)
{
NS_LOG_FUNCTION (this << id);
/// We need to purge the link node cache
PurgeLinkNode ();
std::map<Ipv4Address, RouteCacheEntry::IP_VECTOR>::const_iterator i = m_bestRoutesTable_link.find (id);
if (i == m_bestRoutesTable_link.end ())
{
NS_LOG_INFO ("No Route To " << id);
NS_LOG_INFO ("No route find to " << id);
return false;
}
else
{
if (i->second.size () < 2)
{
NS_LOG_DEBUG ("Route To " << id << " error");
NS_LOG_LOGIC ("Route to " << id << " error");
return false;
}
@@ -451,7 +451,7 @@ RouteCache::LookupRoute_Link (Ipv4Address id, RouteCacheEntry & rt)
newEntry.SetVector (i->second);
newEntry.SetDestination (id);
newEntry.SetExpireTime (RouteCacheTimeout);
NS_LOG_INFO ("Route to " << id << " found with the route length " << i->second.size ());
NS_LOG_INFO ("Route to " << id << " found with the length " << i->second.size ());
rt = newEntry;
std::vector<Ipv4Address> path = rt.GetVector ();
PrintVector (path);
@@ -463,10 +463,9 @@ void
RouteCache::PurgeLinkNode ()
{
NS_LOG_FUNCTION (this);
NS_LOG_DEBUG ("The size of the link cache before " << m_linkCache.size ());
for (std::map<Link, LinkStab>::iterator i = m_linkCache.begin (); i != m_linkCache.end (); )
{
NS_LOG_DEBUG ("The link stability " << i->second.GetLinkStability ());
NS_LOG_DEBUG ("The link stability " << i->second.GetLinkStability ().GetSeconds ());
std::map<Link, LinkStab>::iterator itmp = i;
if (i->second.GetLinkStability () <= Seconds (0))
{
@@ -478,10 +477,10 @@ RouteCache::PurgeLinkNode ()
++i;
}
}
NS_LOG_DEBUG ("The size of the node cache before " << m_nodeCache.size ());
/// may need to remove them after verify
for (std::map<Ipv4Address, NodeStab>::iterator i = m_nodeCache.begin (); i != m_nodeCache.end (); )
{
NS_LOG_DEBUG ("The node stability " << i->second.GetNodeStability ());
NS_LOG_DEBUG ("The node stability " << i->second.GetNodeStability ().GetSeconds ());
std::map<Ipv4Address, NodeStab>::iterator itmp = i;
if (i->second.GetNodeStability () <= Seconds (0))
{
@@ -503,6 +502,7 @@ RouteCache::UpdateNetGraph ()
for (std::map<Link, LinkStab>::iterator i = m_linkCache.begin (); i != m_linkCache.end (); ++i)
{
// Here the weight is set as 1
// May need to set different weight for different link here later TODO
uint32_t weight = 1;
m_netGraph[i->first.m_low][i->first.m_high] = weight;
m_netGraph[i->first.m_high][i->first.m_low] = weight;
@@ -523,6 +523,9 @@ RouteCache::IncStability (Ipv4Address node)
}
else
{
/// TODO get rid of the debug here
NS_LOG_INFO ("The node stability " << i->second.GetNodeStability ().GetSeconds ());
NS_LOG_INFO ("The stability here " << Time (i->second.GetNodeStability () * m_stabilityIncrFactor).GetSeconds ());
NodeStab ns (Time (i->second.GetNodeStability () * m_stabilityIncrFactor));
m_nodeCache[node] = ns;
return true;
@@ -543,6 +546,9 @@ RouteCache::DecStability (Ipv4Address node)
}
else
{
// TODO remove it here
NS_LOG_INFO ("The stability here " << i->second.GetNodeStability ().GetSeconds ());
NS_LOG_INFO ("The stability here " << Time (i->second.GetNodeStability () / m_stabilityDecrFactor).GetSeconds ());
NodeStab ns (Time (i->second.GetNodeStability () / m_stabilityDecrFactor));
m_nodeCache[node] = ns;
return true;
@@ -554,10 +560,12 @@ bool
RouteCache::AddRoute_Link (RouteCacheEntry::IP_VECTOR nodelist, Ipv4Address source)
{
NS_LOG_FUNCTION (this << source);
NS_LOG_DEBUG ("Use Link Cache");
NS_LOG_LOGIC ("Use Link Cache");
/// Purge the link node cache first
PurgeLinkNode ();
for (uint32_t i = 0; i < nodelist.size () - 1; i++)
{
NodeStab ns;
NodeStab ns; /// This is the node stability
ns.SetNodeStability (m_initStability);
if (m_nodeCache.find (nodelist[i]) == m_nodeCache.end ())
@@ -568,9 +576,10 @@ RouteCache::AddRoute_Link (RouteCacheEntry::IP_VECTOR nodelist, Ipv4Address sour
{
m_nodeCache[nodelist[i + 1]] = ns;
}
Link link (nodelist[i], nodelist[i + 1]);
LinkStab stab;
Link link (nodelist[i], nodelist[i + 1]); /// Link represent the one link for the route
LinkStab stab; /// Link stability
stab.SetLinkStability (m_initStability);
/// Set the link stability as the smallest node stability
if (m_nodeCache[nodelist[i]].GetNodeStability () < m_nodeCache[nodelist[i + 1]].GetNodeStability ())
{
stab.SetLinkStability (m_nodeCache[nodelist[i]].GetNodeStability ());
@@ -581,7 +590,8 @@ RouteCache::AddRoute_Link (RouteCacheEntry::IP_VECTOR nodelist, Ipv4Address sour
}
if (stab.GetLinkStability () < m_minLifeTime)
{
NS_LOG_DEBUG ("Stability: " << stab.GetLinkStability ().GetSeconds ());
NS_LOG_LOGIC ("Stability: " << stab.GetLinkStability ().GetSeconds ());
/// Set the link stability as the m)minLifeTime, default is 1 second
stab.SetLinkStability (m_minLifeTime);
}
m_linkCache[link] = stab;
@@ -590,7 +600,6 @@ RouteCache::AddRoute_Link (RouteCacheEntry::IP_VECTOR nodelist, Ipv4Address sour
NS_LOG_DEBUG ("Link Info");
stab.Print ();
}
PurgeLinkNode ();
UpdateNetGraph ();
RebuildBestRouteTable (source);
return true;
@@ -600,9 +609,12 @@ void
RouteCache::UseExtends (RouteCacheEntry::IP_VECTOR rt)
{
NS_LOG_FUNCTION (this);
/// Purge the link node cache first
PurgeLinkNode ();
if (rt.size () < 2)
{
NS_LOG_INFO ("The route is too short");
return;
}
for (RouteCacheEntry::IP_VECTOR::iterator i = rt.begin (); i != rt.end () - 1; ++i)
{
@@ -612,20 +624,21 @@ RouteCache::UseExtends (RouteCacheEntry::IP_VECTOR rt)
if (m_linkCache[link].GetLinkStability () < m_useExtends)
{
m_linkCache[link].SetLinkStability (m_useExtends);
NS_LOG_DEBUG ("The time of the link " << m_linkCache[link].GetLinkStability ().GetSeconds ());
/// TODO remove after debug
NS_LOG_INFO ("The time of the link " << m_linkCache[link].GetLinkStability ().GetSeconds ());
}
}
else
{
NS_LOG_INFO ("we cannot find a link in cache");
NS_LOG_INFO ("We cannot find a link in cache");
}
}
// Increase the stability of the node cache
/// Increase the stability of the node cache
for (RouteCacheEntry::IP_VECTOR::iterator i = rt.begin (); i != rt.end (); ++i)
{
if (m_nodeCache.find (*i) != m_nodeCache.end ())
{
NS_LOG_DEBUG ("Increase the stability");
NS_LOG_LOGIC ("Increase the stability");
if (m_nodeCache[*i].GetNodeStability () <= m_initStability)
{
IncStability (*i);
@@ -761,16 +774,21 @@ RouteCache::DeleteAllRoutesIncludeLink (Ipv4Address errorSrc, Ipv4Address unreac
NS_LOG_FUNCTION (this << errorSrc << unreachNode << node);
if (IsLinkCache ())
{
// Purge the link node cache first
PurgeLinkNode ();
/*
* The followings are for cleaning the broken link in linkcache
*
* The followings are for cleaning the broken link in link cache
* We basically remove the link between errorSrc and unreachNode
*/
Link link1 (errorSrc, unreachNode);
Link link2 (unreachNode, errorSrc);
// erase the two kind of links to make sure the link is removed from the link cache
NS_LOG_DEBUG ("Erase the route ");
NS_LOG_DEBUG ("Erase the route");
m_linkCache.erase (link1);
/// TODO get rid of this one
NS_LOG_DEBUG ("The link cache size " << m_linkCache.size());
m_linkCache.erase (link2);
NS_LOG_DEBUG ("The link cache size " << m_linkCache.size());
std::map<Ipv4Address, NodeStab>::iterator i = m_nodeCache.find (errorSrc);
if (i == m_nodeCache.end ())
@@ -790,7 +808,6 @@ RouteCache::DeleteAllRoutesIncludeLink (Ipv4Address errorSrc, Ipv4Address unreac
{
DecStability (i->first);
}
PurgeLinkNode ();
UpdateNetGraph ();
RebuildBestRouteTable (node);
}

View File

@@ -60,7 +60,7 @@ namespace ns3 {
class Time;
namespace dsr {
/*
/**
* The route cache structure
\verbatim
+-+-+-+-+-+-+-+-+-+-+-+- +-+-+-+-+-+-+-+-+-+-+- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
@@ -130,6 +130,9 @@ public:
*/
virtual ~LinkStab ();
/**
* \brief set/get the link stability
*/
void SetLinkStability (Time linkStab)
{
m_linkStability = linkStab + Simulator::Now ();
@@ -142,7 +145,7 @@ public:
void Print () const;
private:
/*
/**
* The link stability lifetime expected, when the time is due, the link expires the expiration happens
* when purge the node and link cache before update them when receiving new information
*/
@@ -177,8 +180,8 @@ private:
class RouteCacheEntry
{
public:
typedef std::vector<Ipv4Address> IP_VECTOR; // Define the vector to hold Ip address
typedef std::vector<Ipv4Address>::iterator Iterator; // Define the iterator
typedef std::vector<Ipv4Address> IP_VECTOR; ///< Define the vector to hold Ip address
typedef std::vector<Ipv4Address>::iterator Iterator; ///< Define the iterator
// / c-tor
/**
* \brief Constructor
@@ -273,26 +276,26 @@ public:
// \}
private:
// / RREP_ACK timer
Timer m_ackTimer;
// / The destination Ip address
Ipv4Address m_dst;
// / brief The IP address constructed route
IP_VECTOR m_path;
// / Expire time for queue entry
Time m_expire;
// / Output interface address
Ipv4InterfaceAddress m_iface;
// / Number of route requests
uint8_t m_reqCount;
// / Indicate if this entry is in "blacklist"
bool m_blackListState;
// / Time for which the node is put into the blacklist
Time m_blackListTimeout;
// / The Ipv4 route
Ptr<Ipv4Route> m_ipv4Route;
// / The Ipv4 layer 3
Ptr<Ipv4> m_ipv4;
Timer m_ackTimer; ///< RREP_ACK timer
Ipv4Address m_dst; ///< The destination Ip address
IP_VECTOR m_path; ///< brief The IP address constructed route
Time m_expire; ///< Expire time for queue entry
Ipv4InterfaceAddress m_iface; ///< Output interface address
uint8_t m_reqCount; ///< Number of route requests
bool m_blackListState; ///< Indicate if this entry is in "blacklist"
Time m_blackListTimeout; ///< Time for which the node is put into the blacklist
Ptr<Ipv4Route> m_ipv4Route; ///< The Ipv4 route
Ptr<Ipv4> m_ipv4; ///< The Ipv4 layer 3
};
/**
* \ingroup dsr
@@ -316,10 +319,26 @@ public:
* \brief Destructor.
*/
virtual ~RouteCache ();
// / Remove the aged route cache entries when the route cache is full
/**
* \brief Remove the aged route cache entries when the route cache is full
*/
void RemoveLastEntry (std::list<RouteCacheEntry> & rtVector);
// / Define the vector of route entries.
/**
* \brief Define the vector of route entries.
*/
typedef std::list<RouteCacheEntry::IP_VECTOR> routeVector;
/**
* \brief Get the destination address of the route.
*/
Ipv4Address GetDestination (void) const;
/**
* \brief Remove all packets with destination IP address dst
*/
void DropPathWithDst (Ipv4Address dst);
/**
* \brief To know if the two entries are the same
*/
bool IsEqual (RouteCacheEntry ca);
// /\name Fields
// \{
bool GetSubRoute () const
@@ -404,49 +423,53 @@ public:
}
// \}
/**
* Update route cache entry if it has been recently used and successfully delivered the data packet
* \brief Update route cache entry if it has been recently used and successfully delivered the data packet
* \param dst destination address of the route
* \param vec the route vector
* \return true in success
*/
bool UpdateRouteEntry (Ipv4Address dst);
/**
* Add route cache entry if it doesn't yet exist in route cache
* \brief Add route cache entry if it doesn't yet exist in route cache
* \param rt route cache entry
* \return true in success
*/
bool AddRoute (RouteCacheEntry & rt);
/**
* Lookup route cache entry with destination address dst
* \brief Lookup route cache entry with destination address dst
* \param dst destination address
* \param rt entry with destination address dst, if exists
* \return true on success
*/
bool LookupRoute (Ipv4Address id, RouteCacheEntry & rt);
/**
* Print the route vector elements
* \brief Print the route vector elements
* \param vec the route vector
*/
void PrintVector (std::vector<Ipv4Address>& vec);
/**
* Print all the route vector elements from the route list
* \brief Print all the route vector elements from the route list
* \param route the route list
*/
void PrintRouteVector (std::list<RouteCacheEntry> route);
/**
* Find the same route in the route cache
* \brief Find the same route in the route cache
* \param rt entry with destination address dst, if exists
* \param rtVector the route vector
*/
bool FindSameRoute (RouteCacheEntry & rt, std::list<RouteCacheEntry> & rtVector);
/**
* Delete the route with certain destination address
* \brief Delete the route with certain destination address
* \param dst the destination address of the routes that should be deleted
*/
bool DeleteRoute (Ipv4Address dst);
/*
* Delete all the routes which includes the link from next hop address that has just been notified
/**
* \brief Delete all the routes which includes the link from next hop address that has just been notified
* as unreachable
*
* \param errorSrc The error source address
* \param unreachNode The unreachable node
* \param node This node's ip address
*/
void DeleteAllRoutesIncludeLink (Ipv4Address errorSrc, Ipv4Address unreachNode, Ipv4Address node);
// / Delete all entries from routing table
@@ -460,16 +483,17 @@ public:
void Print (std::ostream &os);
//------------------------------------------------------------------------------------------
/*
* The following code deals with duplicate ack ids
/**
* \brief Check for duplicate ids and save new entries if the id is not present in the table
*/
// / Check for duplicate ids and save new entries if the id is not present in the table
uint16_t CheckUniqueAckId (Ipv4Address nextHop);
// / Get the ack table size
/**
* \brief Get the ack table size
*/
uint16_t GetAckSize ();
// --------------------------------------------------------------------------------------------
/*
/**
* The following code handles link-layer acks
*/
// / Neighbor description
@@ -490,30 +514,47 @@ public:
Neighbor () {} // For Python bindings
};
// / Return expire time for neighbor node with address addr, if exists, else return 0.
/**
* \brief Return expire time for neighbor node with address addr, if exists, else return 0.
*/
Time GetExpireTime (Ipv4Address addr);
// / Check that node with address addr is neighbor
/**
* \brief Check that node with address addr is neighbor
*/
bool IsNeighbor (Ipv4Address addr);
// / Update expire time for entry with address addr, if it exists, else add new entry
/**
* \brief Update expire time for entry with address addr, if it exists, else add new entry
*/
void UpdateNeighbor (std::vector<Ipv4Address> nodeList, Time expire);
// / Add to the neighbor list
/**
* \brief Add to the neighbor list
*/
void AddNeighbor (std::vector<Ipv4Address> nodeList, Ipv4Address ownAddress, Time expire);
// / Remove all expired mac entries
/**
* \brief Remove all expired mac entries
*/
void PurgeMac ();
// / Schedule m_ntimer.
/**
* \brief Schedule m_ntimer.
*/
void ScheduleTimer ();
// / Remove all entries
/**
* \brief Remove all entries
*/
void ClearMac ()
{
m_nb.clear ();
}
// / Add ARP cache to be used to allow layer 2 notifications processing
/**
* \brief Add ARP cache to be used to allow layer 2 notifications processing
*/
void AddArpCache (Ptr<ArpCache>);
// / Don't use given ARP cache any more (interface is down)
/**
* \brief Don't use given ARP cache any more (interface is down)
*/
void DelArpCache (Ptr<ArpCache>);
// / Get callback to ProcessTxError
/*
* This callback is trying to use the wifi mac tx error header to notify a link layer drop event, however,
/**
* \brief Get callback to ProcessTxError, this callback is trying to use the wifi mac tx error header to notify a link layer drop event, however,
* it is not fully supported yet
*/
Callback<void, WifiMacHeader const &> GetTxErrorCallback () const
@@ -534,34 +575,34 @@ public:
private:
RouteCache & operator= (RouteCache const &);
RouteCacheEntry::IP_VECTOR m_vector; // /< The route vector to save the ip addresses for intermediate nodes.
uint32_t m_maxCacheLen; // /< The maximum number of packets that we allow a routing protocol to buffer.
Time RouteCacheTimeout; // /< The maximum period of time that dsr is allowed to for an unused route.
Time m_badLinkLifetime; // /< The time for which the neighboring node is put into the blacklist.
/*
RouteCacheEntry::IP_VECTOR m_vector; ///< The route vector to save the ip addresses for intermediate nodes.
uint32_t m_maxCacheLen; ///< The maximum number of packets that we allow a routing protocol to buffer.
Time RouteCacheTimeout; ///< The maximum period of time that dsr is allowed to for an unused route.
Time m_badLinkLifetime; ///< The time for which the neighboring node is put into the blacklist.
/**
* Define the parameters for link cache type
*/
uint64_t m_stabilityDecrFactor;
uint64_t m_stabilityIncrFactor;
uint32_t m_stabilityDecrFactor;
uint32_t m_stabilityIncrFactor;
Time m_initStability;
Time m_minLifeTime;
Time m_useExtends;
/*
/**
* Define the route cache data structure
*/
typedef std::list<RouteCacheEntry> routeEntryVector;
// / Map the ipv4Address to route entry vector
std::map<Ipv4Address, routeEntryVector> m_sortedRoutes;
// Define the route vector
routeEntryVector m_routeEntryVector;
// / number of entries for each destination
uint32_t m_maxEntriesEachDst;
// / The id cache to ensure all the ids are unique
std::map<Ipv4Address, uint16_t> m_ackIdCache;
// / Check if the route is using path cache or link cache
bool m_isLinkCache;
// / Check if save the sub route entries or not
bool m_subRoute;
std::map<Ipv4Address, routeEntryVector> m_sortedRoutes; ///< Map the ipv4Address to route entry vector
routeEntryVector m_routeEntryVector; ///< Define the route vector
uint32_t m_maxEntriesEachDst; ///< number of entries for each destination
std::map<Ipv4Address, uint16_t> m_ackIdCache; ///< The id cache to ensure all the ids are unique
bool m_isLinkCache; ///< Check if the route is using path cache or link cache
bool m_subRoute; ///< Check if save the sub route entries or not
/**
* The link cache to update all the link status, bi-link is two link for link is a struct
* when the weight is calculated we normalized them: 100*weight/max of Weight
@@ -573,27 +614,39 @@ private:
* change the weight and then recompute the best choice for each node
*/
std::map<Ipv4Address, std::map<Ipv4Address, uint32_t> > m_netGraph;
// for link route cache
std::map<Ipv4Address, RouteCacheEntry::IP_VECTOR> m_bestRoutesTable_link;
std::map<Link, LinkStab> m_linkCache;
std::map<Ipv4Address, NodeStab> m_nodeCache;
// used by LookupRoute when LinkCache
std::map<Ipv4Address, RouteCacheEntry::IP_VECTOR> m_bestRoutesTable_link; ///< for link route cache
std::map<Link, LinkStab> m_linkCache; ///< The data structure to store link info
std::map<Ipv4Address, NodeStab> m_nodeCache; ///< The data structure to store node info
/**
* \brief used by LookupRoute when LinkCache
* \param id the ip address we are looking for
* \param rt the route cache entry to store the found one
*/
bool LookupRoute_Link (Ipv4Address id, RouteCacheEntry & rt);
/**
* \brief increase the stability of the node
* \param node the ip address of the node we want to increase stability
*/
bool IncStability (Ipv4Address node);
/**
* \brief decrease the stability of the node
* \param node the ip address of the node we want to decrease stability
*/
bool DecStability (Ipv4Address node);
public:
/**
* \brief dijsktra algorithm to get the best route from m_netGraph and update the m_bestRoutesTable_link
* \when current graph information has changed
* \param The type of the cache
*/
void SetCacheType (std::string type);
bool IsLinkCache ();
bool AddRoute_Link (RouteCacheEntry::IP_VECTOR nodelist, Ipv4Address node);
/**
* \brief USE MAXWEIGHT TO REPRESENT MAX; USE BROADCAST ADDRESS TO REPRESENT NULL PRECEEDING ADDRESS
* \param The source address the routes based on
*/
void RebuildBestRouteTable (Ipv4Address source);
void PurgeLinkNode ();
@@ -612,22 +665,21 @@ public:
/**
* The following code handles link-layer acks
*/
// / link failure callback
Callback<void, Ipv4Address, uint8_t > m_handleLinkFailure;
// / TX error callback
Callback<void, WifiMacHeader const &> m_txErrorCallback;
// / Timer for neighbor's list. Schedule Purge().
Timer m_ntimer;
// / vector of entries
std::vector<Neighbor> m_nb;
// / list of ARP cached to be used for layer 2 notifications processing
std::vector<Ptr<ArpCache> > m_arp;
// This timeout deals with the passive ack
Time m_delay;
// / Find MAC address by IP using list of ARP caches
Mac48Address LookupMacAddress (Ipv4Address);
// / Process layer 2 TX error notification
void ProcessTxError (WifiMacHeader const &);
Callback<void, Ipv4Address, uint8_t > m_handleLinkFailure; ///< link failure callback
Callback<void, WifiMacHeader const &> m_txErrorCallback; ///< TX error callback
Timer m_ntimer; ///< Timer for neighbor's list. Schedule Purge().
std::vector<Neighbor> m_nb; ///< vector of entries
std::vector<Ptr<ArpCache> > m_arp; ///< list of ARP cached to be used for layer 2 notifications processing
Time m_delay; ///< This timeout deals with the passive ack
Mac48Address LookupMacAddress (Ipv4Address); ///< Find MAC address by IP using list of ARP caches
void ProcessTxError (WifiMacHeader const &); ///< Process layer 2 TX error notification
};
} // namespace dsr
} // namespace ns3

File diff suppressed because it is too large Load Diff

View File

@@ -165,6 +165,21 @@ public:
bool FindSourceEntry (Ipv4Address src, Ipv4Address dst, uint16_t id);
//\}
/**
* \brief Connect the callback for the tracing event.
* \return void
*/
void ConnectCallbacks ();
/**
* \brief Get the netdevice from the context.
* \return the netdevice we are looking for
*/
Ptr<NetDevice> GetNetDeviceFromContext (std::string context);
/**
* \brief Get the elements from the tracing context.
* \return the elements we are looking for
*/
std::vector<std::string> GetElementsFromContext (std::string context);
/**
* \brief Get the node id from ip address.
* \return the node id
@@ -180,6 +195,11 @@ public:
* \return the ip address
*/
Ipv4Address GetIPfromMAC (Mac48Address address);
/**
* \brief Get the node with give ip address.
* \return the node associated with the ip address
*/
Ptr<Node> GetNodeWithAddress (Ipv4Address ipv4Address);
/**
* \brief Print the route vector.
*/
@@ -209,22 +229,22 @@ public:
Ipv4Address source,
Ipv4Address destination,
uint8_t protocol);
/*
/**
* \brief Set the route to use for data packets
* \return the route
* \used by the option headers when sending data/control packets
*/
Ptr<Ipv4Route> SetRoute (Ipv4Address nextHop, Ipv4Address srcAddress);
/*
/**
* \brief Set the priority of the packet in network queue
* \return the priority value
*/
uint32_t GetPriority (DsrMessageType messageType);
/*
/**
* \brief This function is responsible for sending error packets in case of break link to next hop
*/
void SendUnreachError (Ipv4Address errorHop, Ipv4Address destination, Ipv4Address originalDst, uint8_t salvage, uint8_t protocol);
/*
/**
* \brief This function is responsible for forwarding error packets along the route
*/
void ForwardErrPacket (DsrOptionRerrUnreachHeader &rerr,
@@ -232,37 +252,37 @@ public:
Ipv4Address nextHop,
uint8_t protocol,
Ptr<Ipv4Route> route);
/*
/**
* \brief This function is called by higher layer protocol when sending packets
*/
void Send (Ptr<Packet> packet, Ipv4Address source,
Ipv4Address destination, uint8_t protocol, Ptr<Ipv4Route> route);
/*
/**
* \brief This function is called to add ack request header for network acknowledgement
*/
uint16_t AddAckReqHeader (Ptr<Packet> &packet, Ipv4Address nextHop);
/*
/**
* \brief This function is called by when really sending out the packet
*/
void SendPacket (Ptr<Packet> packet, Ipv4Address source, Ipv4Address nextHop, uint8_t protocol);
/*
/**
* \brief This function is called to schedule sending packets from the network queue
*/
void Scheduler (uint32_t priority);
/*
/**
* \brief This function is called to schedule sending packets from the network queue by priority
*/
void PriorityScheduler (uint32_t priority, bool continueWithFirst);
/*
/**
* \brief This function is called to increase the retransmission timer for data packet in the network queue
*/
void IncreaseRetransTimer ();
/*
/**
* \brief This function is called to send packets down stack
*/
bool SendRealDown (DsrNetworkQueueEntry & newEntry);
/*
* This function is responsible for sending out data packets when have route, if no route found, it will
/**
* \brief This function is responsible for sending out data packets when have route, if no route found, it will
* cache the packet and send out route requests
*/
void SendPacketFromBuffer (DsrOptionSRHeader const &sourceRoute,
@@ -272,60 +292,75 @@ public:
* \brief Find the same passive entry
*/
bool PassiveEntryCheck (Ptr<Packet> packet, Ipv4Address source, Ipv4Address destination, uint8_t segsLeft,
uint16_t fragmentOffset, uint16_t identification, bool saveEntry);
uint16_t fragmentOffset, uint16_t identification, bool saveEntry);
/**
* \brief Cancel the passive timer
*/
bool CancelPassiveTimer (Ptr<Packet> packet, Ipv4Address source, Ipv4Address destination, uint8_t segsLeft);
/*
* \brief Find the similar entries in the maintenance buffer
*/
bool FindSamePackets (Ptr<Packet> packet, Ipv4Address source, Ipv4Address destination, uint8_t segsLeft);
/*
* Call the cancel packet retransmission timer function
/**
* \brief Call the cancel packet retransmission timer function
*/
void CallCancelPacketTimer (uint16_t ackId, Ipv4Header const& ipv4Header, Ipv4Address realSrc, Ipv4Address realDst);
/*
* Cancel the network packet retransmission timer for a specific maintenance entry
/**
* \brief Cancel the network packet retransmission timer for a specific maintenance entry
*/
void CancelNetworkPacketTimer (MaintainBuffEntry & mb);
/*
* Cancel the passive packet retransmission timer for a specific maintenance entry
/**
* \brief Cancel the passive packet retransmission timer for a specific maintenance entry
*/
void CancelPassivePacketTimer (MaintainBuffEntry & mb);
/*
* Cancel the packet retransmission timer for a all maintenance entries with nextHop address
/**
* \brief Cancel the link packet retransmission timer for a specific maintenance entry
*/
void CancelLinkPacketTimer (MaintainBuffEntry & mb);
/**
* \brief Cancel the packet retransmission timer for a all maintenance entries with nextHop address
*/
void CancelPacketTimerNextHop (Ipv4Address nextHop, uint8_t protocol);
/*
* Salvage the packet which has been transmitted for 3 times
/**
* \brief Salvage the packet which has been transmitted for 3 times
*/
void SalvagePacket (Ptr<const Packet> packet, Ipv4Address source, Ipv4Address dst, uint8_t protocol);
/*
* Schedule the packet retransmission when the packet has not reached to the next hop address
/**
* \brief Schedule the packet retransmission based on link-layer acknowledgment
* \param mb maintainenace buffer entry
* \param protocol the protocol number
*/
void ScheduleLinkPacketRetry (MaintainBuffEntry & mb,
uint8_t protocol);
/**
* \brief Schedule the packet retransmission based on passive acknowledgment
* \param mb maintainenace buffer entry
* \param protocol the protocol number
*/
void SchedulePassivePacketRetry (MaintainBuffEntry & mb,
bool onlyPassive,
uint8_t protocol);
/*
* Schedule the packet retransmission when the packet has not reached to the next hop address
/**
* \brief Schedule the packet retransmission based on network layer acknowledgment
* \param mb maintainenace buffer entry
* \param isFirst see if this is the first packet retry or not
* \param protocol the protocol number
*/
void ScheduleNetworkPacketRetry (MaintainBuffEntry & mb,
bool isFirst,
uint8_t protocol);
/*
* This function deals with packet retransmission timer expire
/**
* \brief This function deals with packet retransmission timer expire using link acknowledgment
*/
void LinkScheduleTimerExpire (MaintainBuffEntry & mb,
uint8_t protocol);
/**
* \brief This function deals with packet retransmission timer expire using network acknowledgment
*/
void NetworkScheduleTimerExpire (MaintainBuffEntry & mb,
uint8_t protocol);
/*
* This function deals with packet retransmission timer expire
/**
* \brief This function deals with packet retransmission timer expire using passive acknowledgment
*/
void PassiveScheduleTimerExpire (MaintainBuffEntry & mb,
bool onlyPassive,
uint8_t protocol);
/*
* Forward the packet using the route saved in the source route option header
/**
* \brief Forward the packet using the route saved in the source route option header
*/
void ForwardPacket (Ptr<const Packet> packet,
DsrOptionSRHeader &sourceRoute,
@@ -335,33 +370,42 @@ public:
Ipv4Address targetAddress,
uint8_t protocol,
Ptr<Ipv4Route> route);
/*
* Broadcast the route request packet in subnet
/**
* \brief Broadcast the route request packet in subnet
*/
void SendInitialRequest (Ipv4Address source,
Ipv4Address destination,
uint8_t protocol);
/*
/**
* \brief Send the error request packet
* \param the route error header
* \param the protocol number
*/
void SendErrorRequest (DsrOptionRerrUnreachHeader &rerr, uint8_t protocol);
/*
/**
* \brief Send the route request and increment the request count
* \param the original packet
* \param source address
* \param destination address
*/
void SendRequestAndIncrement (Ptr<Packet> packet,
Ipv4Address source,
Ipv4Address destination);
/**
* \brief Forward the route request if the node is not the destination
* \param the original packet
* \param source address
*/
void SendRequest (Ptr<Packet> packet,
Ipv4Address source);
/*
/**
* \brief Schedule the intermediate route request
* \param the original packet
* \param source The source address
* \param destination The destination address
*/
void ScheduleInterRequest (Ptr<Packet> packet);
/*
/**
* \brief Send the gratuitous reply
* \param replyTo The destination address to send the reply to
* \param replyFrom The source address sending the reply
@@ -370,14 +414,14 @@ public:
Ipv4Address replyFrom,
std::vector<Ipv4Address> &nodeList,
uint8_t protocol);
/*
/**
* Send the route reply back to the request originator with the cumulated route
*/
void SendReply (Ptr<Packet> packet,
Ipv4Address source,
Ipv4Address nextHop,
Ptr<Ipv4Route> route);
/*
/**
* this is a generating the initial route reply from the destination address, a random delay time
* [0, m_broadcastJitter] is used before unicasting back the route reply packet
*/
@@ -385,7 +429,7 @@ public:
Ipv4Address source,
Ipv4Address nextHop,
Ptr<Ipv4Route> route);
/*
/**
* Schedule the cached reply to a random start time to avoid possible route reply storm
*/
void ScheduleCachedReply (Ptr<Packet> packet,
@@ -393,7 +437,7 @@ public:
Ipv4Address destination,
Ptr<Ipv4Route> route,
double hops);
/*
/**
* Send network layer acknowledgment back to the earlier hop to notify the receipt of data packet
*/
void SendAck (uint16_t ackId,
@@ -430,6 +474,11 @@ public:
void SetDownTarget6 (IpL4Protocol::DownTargetCallback6 callback);
IpL4Protocol::DownTargetCallback GetDownTarget (void) const;
IpL4Protocol::DownTargetCallback6 GetDownTarget6 (void) const;
/**
* \brief Get the extension number.
* \return extension number
*/
uint8_t GetExtensionNumber () const;
/**
* \brief Process method
* Called from Ipv4L3Protocol::Receive.
@@ -487,20 +536,32 @@ protected:
* \brief Drop trace callback.
*/
virtual void DoDispose (void);
/*
/**
* The trace for drop, receive and send data packets
*/
TracedCallback<Ptr<const Packet> > m_dropTrace;
TracedCallback <const DsrOptionSRHeader &> m_txPacketTrace;
private:
void Start ();
/**
* \brief Notify the data receipt.
* \return void
*/
void NotifyDataReceipt (std::string context, Ptr<const Packet> p);
/**
* \brief Send the route error message when the link breaks to the next hop.
*/
void SendRerrWhenBreaksLinkToNextHop (Ipv4Address nextHop, uint8_t protocol);
/**
* \brief Promiscuous receive data packets destined to some other node.
* \param device The network device
* \param packet Data packet we just received
* \param protocol The protocol we receive, need to verify it is dsr protocol
* \param from The from address we received the packet
* \param to The address this packet is destined for
* \param packetType The dsr packet type, 0 is for control packet, 1 for data packet
*/
bool PromiscReceive (Ptr<NetDevice> device, Ptr<const Packet> packet, uint16_t protocol, const Address &from,
const Address &to, NetDevice::PacketType packetType);
@@ -513,144 +574,157 @@ private:
*/
DsrOptionList_t m_options;
Ptr<Ipv4L3Protocol> m_ipv4; // / Ipv4l3Protocol
Ptr<Ipv4L3Protocol> m_ipv4; ///< Ipv4l3Protocol
Ptr<Ipv4Route> m_ipv4Route; // / Ipv4 Route
Ptr<Ipv4Route> m_ipv4Route; ///< Ipv4 Route
Ptr<Ipv4> m_ip; // / The ip ptr
Ptr<Ipv4> m_ip; ///< The ip ptr
Ptr<Node> m_node; // / The node ptr
Ptr<Node> m_node; ///< The node ptr
Ipv4Address m_mainAddress; // / Our own Ip address
Ipv4Address m_mainAddress; ///< Our own Ip address
uint8_t segsLeft; // / The segment left value from SR header
uint8_t segsLeft; ///< The segment left value from SR header
IpL4Protocol::DownTargetCallback m_downTarget; // The callback for down layer
IpL4Protocol::DownTargetCallback m_downTarget; ///< The callback for down layer
uint32_t m_maxNetworkSize; // / Maximum network queue size
uint32_t m_maxNetworkSize; ///< Maximum network queue size
Time m_maxNetworkDelay; // / Maximum network delay
Time m_maxNetworkDelay; ///< Maximum network delay
uint32_t m_discoveryHopLimit; // / Maximum hops to go for route request
uint32_t m_discoveryHopLimit; ///< Maximum hops to go for route request
uint8_t m_maxSalvageCount; // / Maximum # times to salvage a packet
uint8_t m_maxSalvageCount; ///< Maximum # times to salvage a packet
Time m_requestPeriod; // / The base time interval between route requests
Time m_requestPeriod; ///< The base time interval between route requests
Time m_nonpropRequestTimeout; // / The non-propagation request timeout
Time m_nonpropRequestTimeout; ///< The non-propagation request timeout
uint32_t m_sendRetries; // / # of retries have been sent for network acknowledgment
uint32_t m_sendRetries; ///< # of retries have been sent for network acknowledgment
uint32_t m_passiveRetries; // / # of retries have been sent for passive acknowledgment
uint32_t m_passiveRetries; ///< # of retries have been sent for passive acknowledgment
uint32_t m_rreqRetries; // /< Maximum number of retransmissions of RREQ with TTL = NetDiameter to discover a route
uint32_t m_linkRetries; ///< # of retries have been sent for link acknowledgment
uint32_t m_maxMaintRexmt; // /< Maximum number of retransmissions of data packets
uint32_t m_rreqRetries; ///< Maximum number of retransmissions of RREQ with TTL = NetDiameter to discover a route
Time m_nodeTraversalTime; // / Time estimated for packet to travel between two nodes
uint32_t m_maxMaintRexmt; ///< Maximum number of retransmissions of data packets
uint32_t m_maxSendBuffLen; // /< The maximum number of packets that we allow a routing protocol to buffer.
Time m_nodeTraversalTime; ///< Time estimated for packet to travel between two nodes
Time m_sendBufferTimeout; // /< The maximum period of time that a routing protocol is allowed to buffer a packet for.
uint32_t m_maxSendBuffLen; ///< The maximum number of packets that we allow a routing protocol to buffer.
SendBuffer m_sendBuffer; // / The send buffer
Time m_sendBufferTimeout; ///< The maximum period of time that a routing protocol is allowed to buffer a packet for.
ErrorBuffer m_errorBuffer; // / The error buffer to save the error messages
SendBuffer m_sendBuffer; ///< The send buffer
uint32_t m_maxMaintainLen; // / Max # of entries for maintainance buffer
ErrorBuffer m_errorBuffer; ///< The error buffer to save the error messages
Time m_maxMaintainTime; // / Time out for maintainance buffer
uint32_t m_maxMaintainLen; ///< Max # of entries for maintainance buffer
uint32_t m_maxCacheLen; // / Max # of cache entries for route cache
Time m_maxMaintainTime; ///< Time out for maintainance buffer
Time m_maxCacheTime; // / Max time for caching the route cache entry
uint32_t m_maxCacheLen; ///< Max # of cache entries for route cache
Time m_maxRreqTime; // / Max time for caching the route request entry
Time m_maxCacheTime; ///< Max time for caching the route cache entry
uint32_t m_maxEntriesEachDst; // / Max number of route entries to save for each destination
Time m_maxRreqTime; ///< Max time for caching the route request entry
MaintainBuffer m_maintainBuffer; // / The declaration of maintain buffer
uint32_t m_maxEntriesEachDst; ///< Max number of route entries to save for each destination
uint32_t m_requestId; // / The id assigned to each route request
MaintainBuffer m_maintainBuffer; ///< The declaration of maintain buffer
uint16_t m_ackId; // / The ack id assigned to each acknowledge
uint32_t m_requestId; ///< The id assigned to each route request
uint32_t m_requestTableSize; // / The max size of the request table size
uint16_t m_ackId; ///< The ack id assigned to each acknowledge
uint32_t m_requestTableIds; // / The request table identifiers
uint32_t m_requestTableSize; ///< The max size of the request table size
uint32_t m_maxRreqId; // / The max number of request ids for a single destination
uint32_t m_requestTableIds; ///< The request table identifiers
Time m_blacklistTimeout; // / The black list time out
uint32_t m_maxRreqId; ///< The max number of request ids for a single destination
Ipv4Address m_broadcast; // / The broadcast IP address
Time m_blacklistTimeout; ///< The black list time out
uint32_t m_broadcastJitter; // / The max time to delay route request broadcast.
Ipv4Address m_broadcast; ///< The broadcast IP address
Time m_passiveAckTimeout; // / The timeout value for passive acknowledge
uint32_t m_broadcastJitter; ///< The max time to delay route request broadcast.
uint32_t m_tryPassiveAcks; // /< Maximum number of packet transmission using passive acknowledgment
Time m_passiveAckTimeout; ///< The timeout value for passive acknowledge
Timer m_sendBuffTimer; // / The send buffer timer
uint32_t m_tryPassiveAcks; ///< Maximum number of packet transmission using passive acknowledgment
Time m_sendBuffInterval; // / how often to check send buffer
Time m_linkAckTimeout; ///< The timeout value for link acknowledge
Time m_gratReplyHoldoff; // / The max gratuitous reply hold off time
uint32_t m_tryLinkAcks; ///< Maximum number of packet transmission using link acknowledgment
Time m_maxRequestPeriod; // / The max request period
Timer m_sendBuffTimer; ///< The send buffer timer
uint32_t m_graReplyTableSize; // / Set the gratuitous reply table size
Time m_sendBuffInterval; ///< how often to check send buffer
std::string m_cacheType; // / The type of route cache
Time m_gratReplyHoldoff; ///< The max gratuitous reply hold off time
std::string m_routeSortType; // / The type of route sort methods
Time m_maxRequestPeriod; ///< The max request period
uint64_t m_stabilityDecrFactor; // / The initial decrease factor for link cache
uint32_t m_graReplyTableSize; ///< Set the gratuitous reply table size
uint64_t m_stabilityIncrFactor; // / The initial increase factor for link cache
std::string m_cacheType; ///< The type of route cache
Time m_initStability; // / The initial stability value for link cache
std::string m_routeSortType; ///< The type of route sort methods
Time m_minLifeTime; // / The min life time
uint32_t m_stabilityDecrFactor; ///< The initial decrease factor for link cache
Time m_useExtends; // / The use extension of the life time for link cache
uint32_t m_stabilityIncrFactor; ///< The initial increase factor for link cache
bool m_subRoute; // / Whether to save sub route or not
Time m_initStability; ///< The initial stability value for link cache
Time m_retransIncr; // / the increase time for retransmission timer when face network congestion
Time m_minLifeTime; ///< The min life time
std::vector<Ipv4Address> m_finalRoute; // / The route cache
Time m_useExtends; ///< The use extension of the life time for link cache
std::map<Ipv4Address, Timer> m_addressReqTimer; // / Map IP address + RREQ timer.
bool m_subRoute; ///< Whether to save sub route or not
std::map<Ipv4Address, Timer> m_nonPropReqTimer; // / Map IP address + RREQ timer.
Time m_retransIncr; ///< the increase time for retransmission timer when face network congestion
std::map<NetworkKey, Timer> m_addressForwardTimer; // / Map network key + forward timer.
std::vector<Ipv4Address> m_finalRoute; ///< The route cache
std::map<NetworkKey, uint32_t> m_addressForwardCnt; // / Map network key + forward counts.
std::map<Ipv4Address, Timer> m_addressReqTimer; ///< Map IP address + RREQ timer.
std::map<PassiveKey, uint32_t> m_passiveCnt; // / Map packet key + passive forward counts.
std::map<Ipv4Address, Timer> m_nonPropReqTimer; ///< Map IP address + RREQ timer.
std::map<PassiveKey, Timer> m_passiveAckTimer; // / The timer for passive acknowledgment
std::map<NetworkKey, Timer> m_addressForwardTimer; ///< Map network key + forward timer.
Ptr<dsr::RouteCache> m_routeCache; // / A "drop-front" queue used by the routing layer to cache routes found.
std::map<NetworkKey, uint32_t> m_addressForwardCnt; ///< Map network key + forward counts.
Ptr<dsr::RreqTable> m_rreqTable; // / A "drop-front" queue used by the routing layer to cache route request sent.
std::map<PassiveKey, uint32_t> m_passiveCnt; ///< Map packet key + passive forward counts.
std::map<PassiveKey, Timer> m_passiveAckTimer; ///< The timer for passive acknowledgment
std::map<LinkKey, uint32_t> m_linkCnt; ///< Map packet key + link forward counts.
std::map<LinkKey, Timer> m_linkAckTimer; ///< The timer for link acknowledgment
Ptr<dsr::RouteCache> m_routeCache; ///< A "drop-front" queue used by the routing layer to cache routes found.
Ptr<dsr::RreqTable> m_rreqTable; ///< A "drop-front" queue used by the routing layer to cache route request sent.
Ptr<dsr::PassiveBuffer> m_passiveBuffer; ///< A "drop-front" queue used by the routing layer to cache route request sent.
uint32_t m_numPriorityQueues;
uint32_t m_numPriorityQueues; ///< The number of priority queues used
std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> > m_priorityQueue; // / priority queueus
bool m_linkAck; ///< define if we use link acknowledgement or not
GraReply m_graReply; // / The gratuitous route reply.
std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> > m_priorityQueue; ///< priority queues
std::vector<Ipv4Address> m_clearList; // / The node that is clear to send packet to
GraReply m_graReply; ///< The gratuitous route reply.
std::vector<Ipv4Address> m_addresses; // / The bind ipv4 addresses with next hop, src, destination address in sequence
std::vector<Ipv4Address> m_clearList; ///< The node that is clear to send packet to
/// Provides uniform random variables.
Ptr<UniformRandomVariable> m_uniformRandomVariable;
std::vector<Ipv4Address> m_addresses; ///< The bind ipv4 addresses with next hop, src, destination address in sequence
std::map <std::string, uint32_t> m_macToNodeIdMap; ///< The map of mac address to node id
Ptr<UniformRandomVariable> m_uniformRandomVariable; ///< Provides uniform random variables.
};
} /* namespace dsr */
} /* namespace ns3 */

View File

@@ -70,7 +70,7 @@ struct RreqTableEntry
uint32_t m_reqNo;
Time m_expire;
};
/*
/**
* The request entry for intermediate nodes to check if they have received this request or not
* This is used to control the duplication request from being processed
*/
@@ -84,7 +84,7 @@ public:
{
}
/**
* Compare send buffer entries
* \brief Compare send buffer entries
* \return true if equal
*/
bool operator== (ReceivedRreqEntry const & o) const
@@ -213,18 +213,20 @@ public:
* set the unidirectional entry as QUESTIONABLE state
*/
void Invalidate ();
/** Verify if entry is unidirectional or not(e.g. add this neighbor to "blacklist" for blacklistTimeout period)
/**
* \brief Verify if entry is unidirectional or not(e.g. add this neighbor to "blacklist" for blacklistTimeout period)
* \param neighbor - neighbor address link to which assumed to be unidirectional
* \return true on success
*/
BlackList* FindUnidirectional (Ipv4Address neighbor);
/** Mark entry as unidirectional (e.g. add this neighbor to "blacklist" for blacklistTimeout period)
/**
* \brief Mark entry as unidirectional (e.g. add this neighbor to "blacklist" for blacklistTimeout period)
* \param neighbor - neighbor address link to which assumed to be unidirectional
* \param blacklistTimeout - time for which the neighboring node is put into the blacklist
* \return true on success
*/
bool MarkLinkAsUnidirectional (Ipv4Address neighbor, Time blacklistTimeout);
// / Remove all expired black list entries
///< Remove all expired black list entries
void PurgeNeighbor ();
// ----------------------------------------------------------------------------------------------------------
/**

View File

@@ -55,8 +55,8 @@ SendBuffer::Enqueue (SendBuffEntry & entry)
for (std::vector<SendBuffEntry>::const_iterator i = m_sendBuffer.begin (); i
!= m_sendBuffer.end (); ++i)
{
NS_LOG_INFO ("packet id " << i->GetPacket ()->GetUid () << " " << entry.GetPacket ()->GetUid ()
<< " dst " << i->GetDestination () << " " << entry.GetDestination ());
// NS_LOG_DEBUG ("packet id " << i->GetPacket ()->GetUid () << " " << entry.GetPacket ()->GetUid ()
// << " dst " << i->GetDestination () << " " << entry.GetDestination ());
if ((i->GetPacket ()->GetUid () == entry.GetPacket ()->GetUid ())
&& (i->GetDestination () == entry.GetDestination ()))
@@ -153,7 +153,7 @@ SendBuffer::Purge ()
/*
* Purge the buffer to eliminate expired entries
*/
NS_LOG_DEBUG ("The send buffer size " << m_sendBuffer.size ());
NS_LOG_INFO ("The send buffer size " << m_sendBuffer.size ());
IsExpired pred;
for (std::vector<SendBuffEntry>::iterator i = m_sendBuffer.begin (); i
!= m_sendBuffer.end (); ++i)

View File

@@ -156,18 +156,13 @@ public:
}
private:
// / The send buffer to cache unsent packet
std::vector<SendBuffEntry> m_sendBuffer;
// / Remove all expired entries
void Purge ();
// / Notify that packet is dropped from queue by timeout
void Drop (SendBuffEntry en, std::string reason);
// / The maximum number of packets that we allow a routing protocol to buffer.
uint32_t m_maxLen;
// / The maximum period of time that a routing protocol is allowed to buffer a packet for, seconds.
Time m_sendBufferTimeout;
// / Check if the send buffer entry is the same or not
static bool IsEqual (SendBuffEntry en, const Ipv4Address dst)
std::vector<SendBuffEntry> m_sendBuffer; ///< The send buffer to cache unsent packet
void Purge (); ///< Remove all expired entries
void Drop (SendBuffEntry en, std::string reason); ///< Notify that packet is dropped from queue by timeout
uint32_t m_maxLen; ///< The maximum number of packets that we allow a routing protocol to buffer.
Time m_sendBufferTimeout; ///< The maximum period of time that a routing protocol is allowed to buffer a packet for, seconds.
static bool IsEqual (SendBuffEntry en, const Ipv4Address dst) ///< Check if the send buffer entry is the same or not
{
return (en.GetDestination () == dst);
}