--- a/src/dsr/model/dsr-routing.cc Fri Apr 26 02:00:09 2013 +0200
+++ b/src/dsr/model/dsr-routing.cc Fri Apr 26 10:43:20 2013 -0400
@@ -39,12 +39,14 @@
#include <algorithm>
#include <iostream>
+#include "ns3/config.h"
#include "ns3/enum.h"
#include "ns3/string.h"
#include "ns3/ptr.h"
#include "ns3/log.h"
#include "ns3/assert.h"
#include "ns3/uinteger.h"
+#include "ns3/net-device.h"
#include "ns3/packet.h"
#include "ns3/boolean.h"
#include "ns3/node-list.h"
@@ -63,6 +65,8 @@
#include "ns3/udp-l4-protocol.h"
#include "ns3/udp-socket-factory.h"
#include "ns3/tcp-socket-factory.h"
+#include "ns3/llc-snap-header.h"
+#include "ns3/arp-header.h"
#include "dsr-rreq-table.h"
#include "dsr-rcache.h"
@@ -162,7 +166,7 @@
UintegerValue (2),
MakeUintegerAccessor (&DsrRouting::m_maxMaintRexmt),
MakeUintegerChecker<uint32_t> ())
- .AddAttribute ("RequestTableSize","Maximum number of request entries in the request table.",
+ .AddAttribute ("RequestTableSize","Maximum number of request entries in the request table, set this as the number of nodes in the simulation.",
UintegerValue (64),
MakeUintegerAccessor (&DsrRouting::m_requestTableSize),
MakeUintegerChecker<uint32_t> ())
@@ -173,7 +177,7 @@
.AddAttribute ("UniqueRequestIdSize","Maximum number of request Ids in the request table for a single destination.",
UintegerValue (256),
MakeUintegerAccessor (&DsrRouting::m_maxRreqId),
- MakeUintegerChecker<uint16_t> ())
+ MakeUintegerChecker<uint32_t> ())
.AddAttribute ("NonPropRequestTimeout","The timeout value for non-propagation request.",
TimeValue (MilliSeconds (30)),
MakeTimeAccessor (&DsrRouting::m_nonpropRequestTimeout),
@@ -197,7 +201,15 @@
.AddAttribute ("BroadcastJitter","The jitter time to avoid collision for broadcast packets.",
UintegerValue (10),
MakeUintegerAccessor (&DsrRouting::m_broadcastJitter),
- MakeUintegerChecker<uint16_t> ())
+ MakeUintegerChecker<uint32_t> ())
+ .AddAttribute ("LinkAckTimeout","The time a packet in maintenance buffer wait for link acknowledgment.",
+ TimeValue (MilliSeconds (100)),
+ MakeTimeAccessor (&DsrRouting::m_linkAckTimeout),
+ MakeTimeChecker ())
+ .AddAttribute ("TryLinkAcks","The number of link acknowledgment to use.",
+ UintegerValue (1),
+ MakeUintegerAccessor (&DsrRouting::m_tryLinkAcks),
+ MakeUintegerChecker<uint32_t> ())
.AddAttribute ("PassiveAckTimeout","The time a packet in maintenance buffer wait for passive acknowledgment.",
TimeValue (MilliSeconds (100)),
MakeTimeAccessor (&DsrRouting::m_passiveAckTimeout),
@@ -225,11 +237,11 @@
.AddAttribute ("StabilityDecrFactor","The stability decrease factor for link cache",
UintegerValue (2),
MakeUintegerAccessor (&DsrRouting::m_stabilityDecrFactor),
- MakeUintegerChecker<uint64_t> ())
+ MakeUintegerChecker<uint32_t> ())
.AddAttribute ("StabilityIncrFactor","The stability increase factor for link cache",
UintegerValue (4),
MakeUintegerAccessor (&DsrRouting::m_stabilityIncrFactor),
- MakeUintegerChecker<uint64_t> ())
+ MakeUintegerChecker<uint32_t> ())
.AddAttribute ("InitStability","The initial stability factor for link cache",
TimeValue (Seconds (25)),
MakeTimeAccessor (&DsrRouting::m_initStability),
@@ -262,6 +274,10 @@
UintegerValue (2),
MakeUintegerAccessor (&DsrRouting::m_numPriorityQueues),
MakeUintegerChecker<uint32_t> ())
+ .AddAttribute ("LinkAcknowledgment","Enable Link layer acknowledgment mechanism",
+ BooleanValue (false),
+ MakeBooleanAccessor (&DsrRouting::m_linkAck),
+ MakeBooleanChecker ())
.AddTraceSource ("Tx", "Send DSR packet.",
MakeTraceSourceAccessor (&DsrRouting::m_txPacketTrace))
.AddTraceSource ("Drop", "Drop DSR packet",
@@ -341,29 +357,42 @@
void DsrRouting::Start ()
{
NS_LOG_FUNCTION (this << "Start DSR Routing protocol");
- Ptr<dsr::RouteCache> routeCache = CreateObject<dsr::RouteCache> ();
- // Configure the path cache parameters
- routeCache->SetCacheType (m_cacheType);
- routeCache->SetSubRoute (m_subRoute);
- routeCache->SetMaxCacheLen (m_maxCacheLen);
- routeCache->SetCacheTimeout (m_maxCacheTime);
- routeCache->SetMaxEntriesEachDst (m_maxEntriesEachDst);
- // Parameters for link cache
- routeCache->SetStabilityDecrFactor (m_stabilityDecrFactor);
- routeCache->SetStabilityIncrFactor (m_stabilityIncrFactor);
- routeCache->SetInitStability (m_initStability);
- routeCache->SetMinLifeTime (m_minLifeTime);
- routeCache->SetUseExtends (m_useExtends);
- routeCache->ScheduleTimer ();
- // The call back to handle link error and send error message to appropriate nodes
- routeCache->SetCallback (MakeCallback (&DsrRouting::SendRerrWhenBreaksLinkToNextHop, this));
- SetRouteCache (routeCache);
-// Set the passive buffer parameters using just the send buffer parameters
+
+ NS_LOG_INFO ("The number of network queues " << m_numPriorityQueues);
+ for (uint32_t i = 0; i < m_numPriorityQueues; i++)
+ {
+ // Set the network queue max size and the delay
+ NS_LOG_INFO ("The network queue size " << m_maxNetworkSize << " and the queue delay " << m_maxNetworkDelay.GetSeconds ());
+ Ptr<dsr::DsrNetworkQueue> queue_i = CreateObject<dsr::DsrNetworkQueue> (m_maxNetworkSize,m_maxNetworkDelay);
+ std::pair<std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> >::iterator, bool> result_i = m_priorityQueue.insert (std::make_pair (i, queue_i));
+ NS_ASSERT_MSG (result_i.second, "Error in creating queues");
+ }
+ Ptr<dsr::RreqTable> rreqTable = CreateObject<dsr::RreqTable> ();
+ // Set the initial hop limit
+ rreqTable->SetInitHopLimit (m_discoveryHopLimit);
+ // Configure the request table parameters
+ rreqTable->SetRreqTableSize (m_requestTableSize);
+ rreqTable->SetRreqIdSize (m_requestTableIds);
+ rreqTable->SetUniqueRreqIdSize (m_maxRreqId);
+ SetRequestTable (rreqTable);
+ // Set the passive buffer parameters using just the send buffer parameters
Ptr<dsr::PassiveBuffer> passiveBuffer = CreateObject<dsr::PassiveBuffer> ();
passiveBuffer->SetMaxQueueLen (m_maxSendBuffLen);
passiveBuffer->SetPassiveBufferTimeout (m_sendBufferTimeout);
SetPassiveBuffer (passiveBuffer);
+ // Set the send buffer parameters
+ m_sendBuffer.SetMaxQueueLen (m_maxSendBuffLen);
+ m_sendBuffer.SetSendBufferTimeout (m_sendBufferTimeout);
+ // Set the error buffer parameters using just the send buffer parameters
+ m_errorBuffer.SetMaxQueueLen (m_maxSendBuffLen);
+ m_errorBuffer.SetErrorBufferTimeout (m_sendBufferTimeout);
+ // Set the maintenance buffer parameters
+ m_maintainBuffer.SetMaxQueueLen (m_maxMaintainLen);
+ m_maintainBuffer.SetMaintainBufferTimeout (m_maxMaintainTime);
+ // Set the gratuitous reply table size
+ m_graReply.SetGraTableSize (m_graReplyTableSize);
+
if (m_mainAddress == Ipv4Address ())
{
Ipv4Address loopback ("127.0.0.1");
@@ -372,11 +401,30 @@
// Use primary address, if multiple
Ipv4Address addr = m_ipv4->GetAddress (i, 0).GetLocal ();
m_broadcast = m_ipv4->GetAddress (i, 0).GetBroadcast ();
- NS_LOG_DEBUG ("The addr " << addr);
if (addr != loopback)
{
+ /*
+ * Set dsr route cache
+ */
+ Ptr<dsr::RouteCache> routeCache = CreateObject<dsr::RouteCache> ();
+ // Configure the path cache parameters
+ routeCache->SetCacheType (m_cacheType);
+ routeCache->SetSubRoute (m_subRoute);
+ routeCache->SetMaxCacheLen (m_maxCacheLen);
+ routeCache->SetCacheTimeout (m_maxCacheTime);
+ routeCache->SetMaxEntriesEachDst (m_maxEntriesEachDst);
+ // Parameters for link cache
+ routeCache->SetStabilityDecrFactor (m_stabilityDecrFactor);
+ routeCache->SetStabilityIncrFactor (m_stabilityIncrFactor);
+ routeCache->SetInitStability (m_initStability);
+ routeCache->SetMinLifeTime (m_minLifeTime);
+ routeCache->SetUseExtends (m_useExtends);
+ routeCache->ScheduleTimer ();
+ // The call back to handle link error and send error message to appropriate nodes
+ routeCache->SetCallback (MakeCallback (&DsrRouting::SendRerrWhenBreaksLinkToNextHop, this));
+ SetRouteCache (routeCache);
+ // Set the main address as the current ip address
m_mainAddress = addr;
- NS_LOG_DEBUG ("The node Address " << m_mainAddress);
m_ipv4->GetNetDevice (1)->SetPromiscReceiveCallback (MakeCallback (&DsrRouting::PromiscReceive, this));
@@ -393,44 +441,131 @@
break;
}
- // trace back to link mac drop event to process tx error call back
- mac->TraceConnectWithoutContext ("TxErrHeader", routeCache->GetTxErrorCallback ());
routeCache->AddArpCache (m_ipv4->GetInterface (i)->GetArpCache ());
+ NS_LOG_LOGIC ("Starting DSR on node " << m_mainAddress);
break;
}
}
NS_ASSERT (m_mainAddress != Ipv4Address () && m_broadcast != Ipv4Address ());
+ ConnectCallbacks ();
}
-
- NS_LOG_DEBUG ("The number queues " << m_numPriorityQueues);
- for (uint32_t i = 0; i < m_numPriorityQueues; i++)
+}
+
+void DsrRouting::ConnectCallbacks ()
+{
+ // Connect the callbacks
+ Config::Connect ("NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyRxEnd",
+ MakeCallback (&DsrRouting::NotifyDataReceipt, this));
+}
+
+void DsrRouting::NotifyDataReceipt (std::string context, Ptr<const Packet> p)
+{
+ Ptr<NetDevice> ndev = GetNetDeviceFromContext (context);
+ NS_ASSERT (ndev);
+ Ptr<Node> n = ndev->GetNode ();
+ Ptr<Ipv4> ipv4 = n->GetObject<Ipv4> ();
+ NS_ASSERT (n);
+
+ Ptr<WifiNetDevice> netDevice = DynamicCast<WifiNetDevice> (ndev);
+ Mac48Address nodeAddr = netDevice->GetMac()->GetAddress();
+ std::ostringstream oss;
+ oss << nodeAddr;
+
+ Ptr<Packet> newP = p->Copy();
+ WifiMacHeader hdr;
+ newP->RemoveHeader(hdr);
+ /// TODO this is a hard-coded check, need to find a better way to work on this
+ if (newP->GetSize () == 4)
{
- // Set the network queue max size and the delay
- NS_LOG_DEBUG ("The network size " << m_maxNetworkSize << " and the network delay " << m_maxNetworkDelay.GetSeconds ());
- Ptr<dsr::DsrNetworkQueue> queue_i = CreateObject<dsr::DsrNetworkQueue> (m_maxNetworkSize,m_maxNetworkDelay);
- std::pair<std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> >::iterator, bool> result_i = m_priorityQueue.insert (std::make_pair (i, queue_i));
- NS_ASSERT_MSG (result_i.second, "Error in creating queues");
+ NS_LOG_WARN ("WifiMacTrailer left, skip this packet");
+ return;
}
- Ptr<dsr::RreqTable> rreqTable = CreateObject<dsr::RreqTable> ();
- // Set the initial hop limit
- rreqTable->SetInitHopLimit (m_discoveryHopLimit);
- // Configure the request table parameters
- rreqTable->SetRreqTableSize (m_requestTableSize);
- rreqTable->SetRreqIdSize (m_requestTableIds);
- rreqTable->SetUniqueRreqIdSize (m_maxRreqId);
- SetRequestTable (rreqTable);
- // Set the send buffer parameters
- m_sendBuffer.SetMaxQueueLen (m_maxSendBuffLen);
- m_sendBuffer.SetSendBufferTimeout (m_sendBufferTimeout);
- // Set the error buffer parameters using just the send buffer parameters
- m_errorBuffer.SetMaxQueueLen (m_maxSendBuffLen);
- m_errorBuffer.SetErrorBufferTimeout (m_sendBufferTimeout);
- // Set the maintenance buffer parameters
- m_maintainBuffer.SetMaxQueueLen (m_maxMaintainLen);
- m_maintainBuffer.SetMaintainBufferTimeout (m_maxMaintainTime);
- // Set the gratuitous reply table size
- m_graReply.SetGraTableSize (m_graReplyTableSize);
- NS_LOG_DEBUG ("Starting DSR on node " << m_mainAddress);
+
+ LlcSnapHeader llc;
+ if(!newP->PeekHeader (llc))
+ {
+ NS_LOG_WARN ("llc snap header not present");
+ NS_ASSERT (newP->GetSize() < 64);
+ return;
+ }
+ newP->RemoveHeader(llc);
+ /*
+ * Tried to use peekheader here, but for ipv4 header here,
+ * dsr removes the Ipv4Header and then pass the packet and the header
+ * separately to Ipv4L3Protocol. Ipv4L3Protocol then re-adds them
+ * together, which causes the problem. Check Bug 1479
+ */
+ ArpHeader arp;
+ if(newP->PeekHeader (arp))
+ {
+ NS_LOG_WARN ("arp header present, skip this packet");
+ NS_ASSERT (newP->GetSize() < 64);
+ return;
+ }
+ /// Remove the ipv4 header here
+ Ipv4Header ip;
+ newP->RemoveHeader(ip);
+ /// Remove the dsr routing header here
+ DsrRoutingHeader dsrRouting;
+ newP->RemoveHeader(dsrRouting);
+ /*
+ * Message type 2 means the data packet, we will further process the data
+ * packet for delivery notification, safely ignore control packet
+ * Another check here is our own address, if this is the data destinated for us,
+ * process it further, otherwise, just ignore it
+ */
+ Ipv4Address ourAddress = ipv4->GetAddress (1, 0).GetLocal ();
+ // check if the message type is 2 and if the ipv4 address matches
+ if (dsrRouting.GetMessageType () == 2 && ourAddress == m_mainAddress)
+ {
+ NS_LOG_DEBUG ("data packet receives " << p->GetUid());
+ Ipv4Address sourceIp = GetIPfromID (dsrRouting.GetSourceId());
+ Ipv4Address destinationIp = GetIPfromID ( dsrRouting.GetDestId());
+ /// This is the ip address we just received data packet from
+ Ipv4Address previousHop = GetIPfromMAC (hdr.GetAddr2 ());
+
+ Ptr<Packet> p = Create<Packet> ();
+ // Here the segments left value need to plus one to check the earlier hop maintain buffer entry
+ MaintainBuffEntry newEntry;
+ newEntry.SetPacket (p);
+ newEntry.SetSrc (sourceIp);
+ newEntry.SetDst (destinationIp);
+ /// Remember this is the entry for previous node
+ newEntry.SetOurAdd (previousHop);
+ newEntry.SetNextHop (ourAddress);
+ /// Get the previous node's maintenance buffer and passive ack
+ Ptr<Node> node = GetNodeWithAddress (previousHop);
+ Ptr<dsr::DsrRouting> dsr = node->GetObject<dsr::DsrRouting> ();
+ dsr->CancelLinkPacketTimer (newEntry);
+ }
+}
+
+Ptr<NetDevice>
+DsrRouting::GetNetDeviceFromContext (std::string context)
+{
+ // Use "NodeList/*/DeviceList/*/ as reference
+ // where element [1] is the Node Id
+ // element [2] is the NetDevice Id
+ std::vector <std::string> elements = GetElementsFromContext (context);
+ Ptr<Node> n = NodeList::GetNode (atoi (elements[1].c_str ()));
+ NS_ASSERT (n);
+ return n->GetDevice (atoi (elements[3].c_str ()));
+}
+
+std::vector<std::string>
+DsrRouting::GetElementsFromContext (std::string context)
+{
+ std::vector <std::string> elements;
+ size_t pos1=0, pos2;
+ while (pos1 != context.npos)
+ {
+ pos1 = context.find ("/",pos1);
+ pos2 = context.find ("/",pos1+1);
+ elements.push_back (context.substr (pos1+1,pos2-(pos1+1)));
+ pos1 = pos2;
+ pos2 = context.npos;
+ }
+ return elements;
}
void
@@ -509,6 +644,24 @@
return m_passiveBuffer;
}
+Ptr<Node>
+DsrRouting::GetNodeWithAddress (Ipv4Address ipv4Address)
+{
+ NS_LOG_FUNCTION (this << ipv4Address);
+ int32_t nNodes = NodeList::GetNNodes ();
+ for (int32_t i = 0; i < nNodes; ++i)
+ {
+ Ptr<Node> node = NodeList::GetNode (i);
+ Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> ();
+ int32_t ifIndex = ipv4->GetInterfaceForAddress (ipv4Address);
+ if (ifIndex != -1)
+ {
+ return node;
+ }
+ }
+ return 0;
+}
+
bool DsrRouting::IsLinkCache ()
{
return m_routeCache->IsLinkCache ();
@@ -615,7 +768,6 @@
{
if (ipv4Address == (*i))
{
- NS_LOG_DEBUG (ipv4Address << " and " << *i);
nextHop = *(++i);
return nextHop;
}
@@ -713,9 +865,6 @@
Ipv4Address source = entry.GetSrc ();
Ipv4Address destination = entry.GetDst ();
- // Send the data packet out before schedule the next packet transmission
- SendPacket (dequeP, source, nextHop, protocol);
-
DsrRoutingHeader dsrRoutingHeader;
p->RemoveHeader (dsrRoutingHeader);
Ptr<Packet> cleanP = p->Copy ();
@@ -757,11 +906,11 @@
newSR.SetNodesAddress (nodeList);
newSR.SetSegmentsLeft ((nodeList.size () - 2));
newSR.SetSalvage (salvage + 1);
+ /// When found a route and use it, UseExtends to the link cache
if (m_routeCache->IsLinkCache ())
{
m_routeCache->UseExtends (nodeList);
}
-
NetworkKey networkKey;
networkKey.m_ackId = entry.GetAckId ();
networkKey.m_ourAdd = entry.GetOurAdd ();
@@ -775,17 +924,32 @@
passiveKey.m_destination = entry.GetDst ();
passiveKey.m_segsLeft = entry.GetSegsLeft ();
+ LinkKey linkKey;
+ linkKey.m_source = entry.GetSrc ();
+ linkKey.m_destination = entry.GetDst ();
+ linkKey.m_ourAdd = entry.GetOurAdd ();
+ linkKey.m_nextHop = entry.GetNextHop ();
+
m_addressForwardCnt[networkKey] = 0;
m_passiveCnt[passiveKey] = 0;
-
- if (nextHop != destination)
+ m_linkCnt[linkKey] = 0;
+
+ if (m_linkAck)
{
- SchedulePassivePacketRetry (entry, false, protocol);
+ ScheduleLinkPacketRetry (entry, protocol);
}
else
{
- // This is the first network retry
- ScheduleNetworkPacketRetry (entry, true, protocol);
+ NS_LOG_LOGIC ("Not using link acknowledgment");
+ if (nextHop != destination)
+ {
+ SchedulePassivePacketRetry (entry, protocol);
+ }
+ else
+ {
+ // This is the first network retry
+ ScheduleNetworkPacketRetry (entry, true, protocol);
+ }
}
}
else
@@ -892,6 +1056,7 @@
DsrOptionSRHeader sourceRoute;
std::vector<Ipv4Address> errorRoute = toDst.GetVector ();
sourceRoute.SetNodesAddress (errorRoute);
+ /// When found a route and use it, UseExtends to the link cache
if (m_routeCache->IsLinkCache ())
{
m_routeCache->UseExtends (errorRoute);
@@ -922,21 +1087,24 @@
Ptr<NetDevice> dev = m_ip->GetNetDevice (m_ip->GetInterfaceForAddress (m_mainAddress));
m_ipv4Route->SetOutputDevice (dev);
- uint32_t priority = GetPriority (DSR_CONTROL_PACKET);
+ uint32_t priority = GetPriority (DSR_CONTROL_PACKET); /// This will be priority 0
std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> >::iterator i = m_priorityQueue.find (priority);
Ptr<dsr::DsrNetworkQueue> dsrNetworkQueue = i->second;
- NS_LOG_DEBUG ("Will be inserting into priority queue " << dsrNetworkQueue << " number: " << priority);
-
- DsrNetworkQueueEntry newEntry (newPacket, m_mainAddress, nextHop, Simulator::Now (), m_ipv4Route);
-
- if (dsrNetworkQueue->Enqueue (newEntry))
- {
- Scheduler (priority);
- }
- else
- {
- NS_LOG_INFO ("Packet dropped as dsr network queue is full");
- }
+ NS_LOG_LOGIC ("Will be inserting into priority queue number: " << priority);
+
+ m_downTarget (newPacket, m_mainAddress, nextHop, GetProtocolNumber (), m_ipv4Route);
+
+ // TODO
+// DsrNetworkQueueEntry newEntry (newPacket, m_mainAddress, nextHop, Simulator::Now (), m_ipv4Route);
+//
+// if (dsrNetworkQueue->Enqueue (newEntry))
+// {
+// Scheduler (priority);
+// }
+// else
+// {
+// NS_LOG_INFO ("Packet dropped as dsr network queue is full");
+// }
}
}
else
@@ -958,13 +1126,15 @@
sourceRoute.SetNodesAddress (nodeList); // Save the whole route in the source route header of the packet
sourceRoute.SetSegmentsLeft ((nodeList.size () - 2)); // The segmentsLeft field will indicate the hops to go
sourceRoute.SetSalvage (salvage);
-
+ /// When found a route and use it, UseExtends to the link cache
+ if (m_routeCache->IsLinkCache ())
+ {
+ m_routeCache->UseExtends (nodeList);
+ }
uint8_t length = sourceRoute.GetLength ();
dsrRoutingHeader.SetPayloadLength (uint16_t (length) + 2);
dsrRoutingHeader.AddDsrOption (sourceRoute);
cleanP->AddHeader (dsrRoutingHeader);
- // Send the data packet out before schedule the next packet transmission
- SendPacket (cleanP, m_mainAddress, nextHop, protocol);
Ptr<const Packet> mtP = cleanP->Copy ();
// Put the data packet in the maintenance queue for data packet retransmission
MaintainBuffEntry newEntry (/*Packet=*/ mtP, /*Ipv4Address=*/ m_mainAddress, /*nextHop=*/ nextHop,
@@ -986,16 +1156,32 @@
passiveKey.m_destination = newEntry.GetDst ();
passiveKey.m_segsLeft = newEntry.GetSegsLeft ();
+ LinkKey linkKey;
+ linkKey.m_source = newEntry.GetSrc ();
+ linkKey.m_destination = newEntry.GetDst ();
+ linkKey.m_ourAdd = newEntry.GetOurAdd ();
+ linkKey.m_nextHop = newEntry.GetNextHop ();
+
m_addressForwardCnt[networkKey] = 0;
m_passiveCnt[passiveKey] = 0;
- if (nextHop != destination)
+ m_linkCnt[linkKey] = 0;
+
+ if (m_linkAck)
{
- SchedulePassivePacketRetry (newEntry, false, protocol);
+ ScheduleLinkPacketRetry (newEntry, protocol);
}
else
{
- // This is the first network retry
- ScheduleNetworkPacketRetry (newEntry, true, protocol);
+ NS_LOG_LOGIC ("Not using link acknowledgment");
+ if (nextHop != destination)
+ {
+ SchedulePassivePacketRetry (newEntry, protocol);
+ }
+ else
+ {
+ // This is the first network retry
+ ScheduleNetworkPacketRetry (newEntry, true, protocol);
+ }
}
}
// we need to suspend the normal timer that checks the send buffer
@@ -1059,20 +1245,22 @@
optionType = *(data);
Ptr<dsr::DsrOptions> dsrOption;
- Ipv4Address promiscSource = GetIPfromMAC (Mac48Address::ConvertFrom (from));
+
if (optionType == 96) // This is the source route option
{
+ Ipv4Address promiscSource = GetIPfromMAC (Mac48Address::ConvertFrom (from));
+ Ipv4Address promiscDestination = GetIPfromMAC (Mac48Address::ConvertFrom (to));
dsrOption = GetOption (optionType); // Get the relative DSR option and demux to the process function
- NS_LOG_DEBUG (Simulator::Now ().GetSeconds () <<
+ NS_LOG_DEBUG (Simulator::Now ().GetSeconds () <<
" DSR node " << m_mainAddress <<
" overhearing packet PID: " << p->GetUid () <<
" from " << promiscSource <<
- " to " << GetIPfromMAC (Mac48Address::ConvertFrom (to)) <<
+ " to " << promiscDestination <<
" with source IP " << ipv4Header.GetSource () <<
" and destination IP " << ipv4Header.GetDestination () <<
" and packet : " << *dsrPacket);
+
bool isPromisc = true; // Set the boolean value isPromisc as true
-
dsrOption->Process (p, dsrPacket, m_mainAddress, source, ipv4Header, nextHeader, isPromisc, promiscSource);
return true;
}
@@ -1134,6 +1322,7 @@
}
uint8_t salvage = 0;
sourceRoute.SetNodesAddress (nodeList); // Save the whole route in the source route header of the packet
+ /// When found a route and use it, UseExtends to the link cache
if (m_routeCache->IsLinkCache ())
{
m_routeCache->UseExtends (nodeList);
@@ -1145,8 +1334,6 @@
dsrRoutingHeader.SetPayloadLength (uint16_t (length) + 2);
dsrRoutingHeader.AddDsrOption (sourceRoute);
cleanP->AddHeader (dsrRoutingHeader);
- // Send the data packet out before schedule the next packet transmission
- SendPacket (cleanP, source, nextHop, protocol);
Ptr<const Packet> mtP = cleanP->Copy ();
SetRoute (nextHop, m_mainAddress);
// Put the data packet in the maintenance queue for data packet retransmission
@@ -1170,16 +1357,32 @@
passiveKey.m_destination = newEntry.GetDst ();
passiveKey.m_segsLeft = newEntry.GetSegsLeft ();
+ LinkKey linkKey;
+ linkKey.m_source = newEntry.GetSrc ();
+ linkKey.m_destination = newEntry.GetDst ();
+ linkKey.m_ourAdd = newEntry.GetOurAdd ();
+ linkKey.m_nextHop = newEntry.GetNextHop ();
+
m_addressForwardCnt[networkKey] = 0;
m_passiveCnt[passiveKey] = 0;
- if (nextHop != destination)
+ m_linkCnt[linkKey] = 0;
+
+ if (m_linkAck)
{
- SchedulePassivePacketRetry (newEntry, false, protocol);
+ ScheduleLinkPacketRetry (newEntry, protocol);
}
else
{
- // This is the first network retry
- ScheduleNetworkPacketRetry (newEntry, true, protocol);
+ NS_LOG_LOGIC ("Not using link acknowledgment");
+ if (nextHop != destination)
+ {
+ SchedulePassivePacketRetry (newEntry, protocol);
+ }
+ else
+ {
+ // This is the first network retry
+ ScheduleNetworkPacketRetry (newEntry, true, protocol);
+ }
}
}
}
@@ -1247,6 +1450,7 @@
}
DsrOptionSRHeader sourceRoute;
sourceRoute.SetNodesAddress (nodeList);
+ /// When found a route and use it, UseExtends to the link cache
if (m_routeCache->IsLinkCache ())
{
m_routeCache->UseExtends (nodeList);
@@ -1270,16 +1474,19 @@
Ptr<dsr::DsrNetworkQueue> dsrNetworkQueue = i->second;
NS_LOG_DEBUG ("Will be inserting into priority queue " << dsrNetworkQueue << " number: " << priority);
- DsrNetworkQueueEntry newEntry (newPacket, m_mainAddress, nextHop, Simulator::Now (), m_ipv4Route);
-
- if (dsrNetworkQueue->Enqueue (newEntry))
- {
- Scheduler (priority);
- }
- else
- {
- NS_LOG_INFO ("Packet dropped as dsr network queue is full");
- }
+ m_downTarget (newPacket, m_mainAddress, nextHop, GetProtocolNumber (), m_ipv4Route);
+
+ // TODO
+// DsrNetworkQueueEntry newEntry (newPacket, m_mainAddress, nextHop, Simulator::Now (), m_ipv4Route);
+//
+// if (dsrNetworkQueue->Enqueue (newEntry))
+// {
+// Scheduler (priority);
+// }
+// else
+// {
+// NS_LOG_INFO ("Packet dropped as dsr network queue is full");
+// }
}
}
@@ -1312,16 +1519,19 @@
Ptr<dsr::DsrNetworkQueue> dsrNetworkQueue = i->second;
NS_LOG_DEBUG ("Will be inserting into priority queue " << dsrNetworkQueue << " number: " << priority);
- DsrNetworkQueueEntry newEntry (packet, m_mainAddress, nextHop, Simulator::Now (), route);
-
- if (dsrNetworkQueue->Enqueue (newEntry))
- {
- Scheduler (priority);
- }
- else
- {
- NS_LOG_INFO ("Packet dropped as dsr network queue is full");
- }
+ m_downTarget (packet, m_mainAddress, nextHop, GetProtocolNumber (), route);
+
+ // TODO
+// DsrNetworkQueueEntry newEntry (packet, m_mainAddress, nextHop, Simulator::Now (), route);
+//
+// if (dsrNetworkQueue->Enqueue (newEntry))
+// {
+// Scheduler (priority);
+// }
+// else
+// {
+// NS_LOG_INFO ("Packet dropped as dsr network queue is full");
+// }
}
void
@@ -1355,20 +1565,19 @@
if (result)
{
NS_LOG_INFO (Simulator::Now ().GetSeconds ()
- << "s Add packet PID: " << packet->GetUid () << " to queue. Packet: " << *packet);
- NS_LOG_LOGIC ("Send RREQ to " << destination);
+ << "s Add packet PID: " << packet->GetUid () << " to send buffer. Packet: " << *packet);
// Only when there is no existing route request timer when new route request is scheduled
if ((m_addressReqTimer.find (destination) == m_addressReqTimer.end ()) && (m_nonPropReqTimer.find (destination) == m_nonPropReqTimer.end ()))
{
- NS_LOG_DEBUG ("When there is no existing route request for " << destination << ", initialize one");
/*
- * Call the send request function, it will update the request table entry and ttl there
+ * Call the send request function, it will update the request table entry and ttl value
*/
+ NS_LOG_LOGIC ("Send initial RREQ to " << destination);
SendInitialRequest (source, destination, protocol);
}
else
{
- NS_LOG_DEBUG ("There is existing route request timer and the request count here " << m_rreqTable->GetRreqCnt (destination));
+ NS_LOG_LOGIC ("There is existing route request timer with request count " << m_rreqTable->GetRreqCnt (destination));
}
}
}
@@ -1391,6 +1600,7 @@
}
uint8_t salvage = 0;
sourceRoute.SetNodesAddress (nodeList); // Save the whole route in the source route header of the packet
+ /// When found a route and use it, UseExtends to the link cache
if (m_routeCache->IsLinkCache ())
{
m_routeCache->UseExtends (nodeList);
@@ -1403,8 +1613,6 @@
dsrRoutingHeader.SetPayloadLength (uint16_t (length) + 2);
dsrRoutingHeader.AddDsrOption (sourceRoute);
cleanP->AddHeader (dsrRoutingHeader);
- // Send the data packet out before schedule the next packet transmission
- SendPacket (cleanP, source, nextHop, protocol);
Ptr<const Packet> mtP = cleanP->Copy ();
NS_LOG_DEBUG ("maintain packet size " << cleanP->GetSize ());
@@ -1428,21 +1636,41 @@
passiveKey.m_destination = newEntry.GetDst ();
passiveKey.m_segsLeft = newEntry.GetSegsLeft ();
+ LinkKey linkKey;
+ linkKey.m_source = newEntry.GetSrc ();
+ linkKey.m_destination = newEntry.GetDst ();
+ linkKey.m_ourAdd = newEntry.GetOurAdd ();
+ linkKey.m_nextHop = newEntry.GetNextHop ();
+
m_addressForwardCnt[networkKey] = 0;
m_passiveCnt[passiveKey] = 0;
- if (nextHop != destination)
+ m_linkCnt[linkKey] = 0;
+
+ if (m_linkAck)
{
- SchedulePassivePacketRetry (newEntry, false, protocol);
+ ScheduleLinkPacketRetry (newEntry, protocol);
}
else
{
- // This is the first network retry
- ScheduleNetworkPacketRetry (newEntry, true, protocol);
+ NS_LOG_LOGIC ("Not using link acknowledgment");
+ if (nextHop != destination)
+ {
+ SchedulePassivePacketRetry (newEntry, protocol);
+ }
+ else
+ {
+ // This is the first network retry
+ ScheduleNetworkPacketRetry (newEntry, true, protocol);
+ }
}
}
- // Try to send packet from *previously* queued entries from send buffer if any
- Simulator::Schedule (MilliSeconds (m_uniformRandomVariable->GetInteger (0,100)),
- &DsrRouting::SendPacketFromBuffer,this,sourceRoute,nextHop,protocol);
+
+ if (m_sendBuffer.GetSize () != 0 && m_sendBuffer.Find (destination))
+ {
+ // Try to send packet from *previously* queued entries from send buffer if any
+ Simulator::Schedule (MilliSeconds (m_uniformRandomVariable->GetInteger (0,100)),
+ &DsrRouting::SendPacketFromBuffer, this, sourceRoute, nextHop, protocol);
+ }
}
}
}
@@ -1474,7 +1702,6 @@
DsrOptionAckReqHeader ackReq;
m_ackId = m_routeCache->CheckUniqueAckId (nextHop);
ackReq.SetAckId (m_ackId);
-
uint8_t length = (sourceRoute.GetLength () + ackReq.GetLength ());
DsrRoutingHeader newDsrRoutingHeader;
newDsrRoutingHeader.SetNextHeader (protocol);
@@ -1502,18 +1729,21 @@
uint32_t priority = GetPriority (DSR_DATA_PACKET);
std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> >::iterator i = m_priorityQueue.find (priority);
Ptr<dsr::DsrNetworkQueue> dsrNetworkQueue = i->second;
- NS_LOG_DEBUG ("Will be inserting into priority queue " << dsrNetworkQueue << " number: " << priority);
-
- DsrNetworkQueueEntry newEntry (packet, source, nextHop, Simulator::Now (), m_ipv4Route);
-
- if (dsrNetworkQueue->Enqueue (newEntry))
- {
- Scheduler (priority);
- }
- else
- {
- NS_LOG_INFO ("Packet dropped as dsr network queue is full");
- }
+ NS_LOG_INFO ("Will be inserting into priority queue number: " << priority);
+
+ m_downTarget (packet, source, nextHop, GetProtocolNumber (), m_ipv4Route);
+
+ //TODO
+// DsrNetworkQueueEntry newEntry (packet, source, nextHop, Simulator::Now (), m_ipv4Route);
+//
+// if (dsrNetworkQueue->Enqueue (newEntry))
+// {
+// Scheduler (priority);
+// }
+// else
+// {
+// NS_LOG_INFO ("Packet dropped as dsr network queue is full");
+// }
}
void
@@ -1527,7 +1757,6 @@
DsrRouting::PriorityScheduler (uint32_t priority, bool continueWithFirst)
{
NS_LOG_FUNCTION (this << priority << continueWithFirst);
- NS_LOG_DEBUG ("Scheduler looking for packets in network queue");
uint32_t numPriorities;
if (continueWithFirst)
{
@@ -1537,7 +1766,7 @@
{
numPriorities = priority;
}
- // priorities range from 0 to m_numPriorityQueues, with 0 as the highest priority
+ // priorities ranging from 0 to m_numPriorityQueues, with 0 as the highest priority
for (uint32_t i = priority; numPriorities < m_numPriorityQueues; numPriorities++)
{
std::map<uint32_t, Ptr<DsrNetworkQueue> >::iterator q = m_priorityQueue.find (i);
@@ -1559,9 +1788,9 @@
uint32_t totalQueueSize = 0;
for (std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> >::iterator j = m_priorityQueue.begin (); j != m_priorityQueue.end (); j++)
{
- NS_LOG_DEBUG ("The size of the network queue for " << j->first << " is " << j->second->GetSize ());
+ NS_LOG_INFO ("The size of the network queue for " << j->first << " is " << j->second->GetSize ());
totalQueueSize += j->second->GetSize ();
- NS_LOG_DEBUG ("And the total size is " << totalQueueSize);
+ NS_LOG_INFO ("The total network queue size is " << totalQueueSize);
}
if (totalQueueSize > 5)
{
@@ -1572,8 +1801,8 @@
dsrNetworkQueue->Dequeue (newEntry);
if (SendRealDown (newEntry))
{
- NS_LOG_DEBUG ("Packet sent by Dsr. Calling PriorityScheduler after some time");
- //packet was successfully sent down. call scheduler after some time
+ NS_LOG_LOGIC ("Packet sent by Dsr. Calling PriorityScheduler after some time");
+ // packet was successfully sent down. call scheduler after some time
Simulator::Schedule (MicroSeconds (m_uniformRandomVariable->GetInteger (0, 1000)),
&DsrRouting::PriorityScheduler,this, i, false);
}
@@ -1581,9 +1810,10 @@
{
// packet was dropped by Dsr. Call scheduler immediately so that we can
// send another packet immediately.
- NS_LOG_DEBUG ("Packet dropped by Dsr. Calling PriorityScheduler immediately");
+ NS_LOG_LOGIC ("Packet dropped by Dsr. Calling PriorityScheduler immediately");
Simulator::Schedule (Seconds (0), &DsrRouting::PriorityScheduler, this, i, false);
}
+
if ((i == (m_numPriorityQueues - 1)) && continueWithFirst)
{
i = 0;
@@ -1615,7 +1845,6 @@
{
NS_LOG_DEBUG ("The network delay left is " << j->second.GetDelayLeft ());
j->second.SetDelay (j->second.GetDelayLeft () + m_retransIncr);
- NS_LOG_DEBUG ("The new network delay time is " << j->second.GetDelayLeft ());
}
}
}
@@ -1643,21 +1872,17 @@
std::vector<Ipv4Address> nodeList = sourceRoute.GetNodesAddress ();
Ipv4Address destination = nodeList.back ();
Ipv4Address source = nodeList.front (); // Get the source address
-
NS_LOG_INFO ("The nexthop address " << nextHop << " the source " << source << " the destination " << destination);
-
/*
- * Here we try to find data packet from send buffer, if packet with this destiantion found, send it out
+ * Here we try to find data packet from send buffer, if packet with this destination found, send it out
*/
if (m_sendBuffer.Find (destination))
{
+ NS_LOG_DEBUG ("destination over here " << destination);
SendBuffEntry entry;
if (m_sendBuffer.Dequeue (destination, entry))
{
Ptr<Packet> packet = entry.GetPacket ()->Copy ();
- NS_LOG_DEBUG ("The queued packet size " << packet->GetSize ());
-
- NS_LOG_DEBUG ("This is the data packet");
Ptr<Packet> p = packet->Copy (); // get a copy of the packet
// Set the source route option
DsrRoutingHeader dsrRoutingHeader;
@@ -1671,15 +1896,12 @@
dsrRoutingHeader.AddDsrOption (sourceRoute);
p->AddHeader (dsrRoutingHeader);
- // Send the data packet out before schedule the next packet transmission
- NS_LOG_DEBUG ("Send out the data packet");
- SendPacket (p, source, nextHop, protocol);
Ptr<const Packet> mtP = p->Copy ();
// Put the data packet in the maintenance queue for data packet retransmission
MaintainBuffEntry newEntry (/*Packet=*/ mtP, /*ourAddress=*/ m_mainAddress, /*nextHop=*/ nextHop,
- /*source=*/ source, /*destination=*/ destination, /*ackId=*/ 0,
- /*SegsLeft=*/ nodeList.size () - 2, /*expire time=*/ m_maxMaintainTime);
+ /*source=*/ source, /*destination=*/ destination, /*ackId=*/ 0,
+ /*SegsLeft=*/ nodeList.size () - 2, /*expire time=*/ m_maxMaintainTime);
bool result = m_maintainBuffer.Enqueue (newEntry); // Enqueue the packet the the maintenance buffer
if (result)
@@ -1697,29 +1919,46 @@
passiveKey.m_destination = newEntry.GetDst ();
passiveKey.m_segsLeft = newEntry.GetSegsLeft ();
+ LinkKey linkKey;
+ linkKey.m_source = newEntry.GetSrc ();
+ linkKey.m_destination = newEntry.GetDst ();
+ linkKey.m_ourAdd = newEntry.GetOurAdd ();
+ linkKey.m_nextHop = newEntry.GetNextHop ();
+
m_addressForwardCnt[networkKey] = 0;
m_passiveCnt[passiveKey] = 0;
- if (nextHop != destination)
+ m_linkCnt[linkKey] = 0;
+
+ if (m_linkAck)
{
- SchedulePassivePacketRetry (newEntry, false, protocol);
+ ScheduleLinkPacketRetry (newEntry, protocol);
}
else
{
- // This is the first network retry
- ScheduleNetworkPacketRetry (newEntry, true, protocol);
+ NS_LOG_LOGIC ("Not using link acknowledgment");
+ if (nextHop != destination)
+ {
+ SchedulePassivePacketRetry (newEntry, protocol);
+ }
+ else
+ {
+ // This is the first network retry
+ ScheduleNetworkPacketRetry (newEntry, true, protocol);
+ }
}
}
+ NS_LOG_DEBUG ("send buffer size here and the destination " << m_sendBuffer.GetSize() << " " << destination);
if (m_sendBuffer.GetSize () != 0 && m_sendBuffer.Find (destination))
{
- NS_LOG_DEBUG ("Schedule sending the next packet in send buffer");
+ NS_LOG_LOGIC ("Schedule sending the next packet in send buffer");
Simulator::Schedule (MilliSeconds (m_uniformRandomVariable->GetInteger (0,100)),
- &DsrRouting::SendPacketFromBuffer,this,sourceRoute,nextHop,protocol);
+ &DsrRouting::SendPacketFromBuffer, this, sourceRoute, nextHop, protocol);
}
}
else
{
- NS_LOG_DEBUG ("All queued packets are out-dated for the destination in send buffer");
+ NS_LOG_LOGIC ("All queued packets are out-dated for the destination in send buffer");
}
}
/*
@@ -1782,6 +2021,7 @@
newRoutingHeader.SetPayloadLength (uint16_t (length) + 4);
newRoutingHeader.AddDsrOption (newUnreach);
newRoutingHeader.AddDsrOption (sourceRoute);
+ /// When found a route and use it, UseExtends to the link cache
if (m_routeCache->IsLinkCache ())
{
m_routeCache->UseExtends (nodeList);
@@ -1797,24 +2037,27 @@
Ptr<dsr::DsrNetworkQueue> dsrNetworkQueue = i->second;
NS_LOG_DEBUG ("Will be inserting into priority queue " << dsrNetworkQueue << " number: " << priority);
- DsrNetworkQueueEntry newEntry (newPacket, m_mainAddress, nextHop, Simulator::Now (), m_ipv4Route);
-
- if (dsrNetworkQueue->Enqueue (newEntry))
- {
- Scheduler (priority);
- }
- else
- {
- NS_LOG_INFO ("Packet dropped as dsr network queue is full");
- }
+ m_downTarget (newPacket, m_mainAddress, nextHop, GetProtocolNumber (), m_ipv4Route);
+
+ // TODO
+// DsrNetworkQueueEntry newEntry (newPacket, m_mainAddress, nextHop, Simulator::Now (), m_ipv4Route);
+//
+// if (dsrNetworkQueue->Enqueue (newEntry))
+// {
+// Scheduler (priority);
+// }
+// else
+// {
+// NS_LOG_INFO ("Packet dropped as dsr network queue is full");
+// }
}
}
if (m_errorBuffer.GetSize () != 0 && m_errorBuffer.Find (destination))
{
- NS_LOG_DEBUG ("Schedule sending the next packet in send buffer");
+ NS_LOG_LOGIC ("Schedule sending the next packet in error buffer");
Simulator::Schedule (MilliSeconds (m_uniformRandomVariable->GetInteger (0,100)),
- &DsrRouting::SendPacketFromBuffer,this,sourceRoute,nextHop,protocol);
+ &DsrRouting::SendPacketFromBuffer, this, sourceRoute, nextHop, protocol);
}
}
}
@@ -1840,6 +2083,7 @@
newEntry.SetFragmentOffset (fragmentOffset);
newEntry.SetSegsLeft (segsLeft); // We try to make sure the segments left is larger for 1
+
NS_LOG_DEBUG ("The passive buffer size " << m_passiveBuffer->GetSize());
if (m_passiveBuffer->AllEqual (newEntry) && (!saveEntry))
@@ -1855,7 +2099,6 @@
mbEntry.SetAckId (0);
mbEntry.SetSegsLeft (segsLeft + 1);
- /// TODO this needs to be done later
CancelPassivePacketTimer (mbEntry);
return true;
}
@@ -1894,29 +2137,53 @@
return false;
}
-bool
-DsrRouting::FindSamePackets (Ptr<Packet> packet, Ipv4Address source, Ipv4Address destination,
- uint8_t segsLeft)
+void
+DsrRouting::CancelLinkPacketTimer (MaintainBuffEntry & mb)
{
- NS_LOG_FUNCTION (this << packet << source << destination << (uint32_t)segsLeft);
-
- Ptr<Packet> p = packet->Copy ();
- // Here the segments left value need to plus one to check the earlier hop maintain buffer entry
- MaintainBuffEntry newEntry;
- newEntry.SetPacket (p);
- newEntry.SetSrc (source);
- newEntry.SetDst (destination);
- newEntry.SetAckId (0);
- newEntry.SetSegsLeft (segsLeft + 1);
-
- if (m_maintainBuffer.PromiscEqual (newEntry))
+ NS_LOG_FUNCTION (this);
+ LinkKey linkKey;
+ linkKey.m_ourAdd = mb.GetOurAdd ();
+ linkKey.m_nextHop = mb.GetNextHop ();
+ linkKey.m_source = mb.GetSrc ();
+ linkKey.m_destination = mb.GetDst ();
+ /*
+ * Here we have found the entry for send retries, so we get the value and increase it by one
+ */
+ m_linkCnt[linkKey] = 0;
+ m_linkCnt.erase (linkKey);
+
+ NS_LOG_INFO ("ourAdd " << mb.GetOurAdd () << " nextHop " << mb.GetNextHop ()
+ << " source " << mb.GetSrc () << " destination " << mb.GetDst ()
+ );
+ // Find the link acknowledgment timer
+ std::map<LinkKey, Timer>::const_iterator i =
+ m_linkAckTimer.find (linkKey);
+ if (i == m_linkAckTimer.end ())
{
- // The PromiscEqual function will remove the maintain buffer entry if equal value found
- // It only compares the source and destination address, ackId, and the segments left value
- CancelPassivePacketTimer (newEntry);
- return true;
+ NS_LOG_INFO ("did not find the link timer");
}
- return false;
+ else
+ {
+ NS_LOG_INFO ("did find the link timer");
+ /*
+ * Schedule the packet retry
+ * Push back the nextHop, source, destination address
+ */
+ m_linkAckTimer[linkKey].Cancel ();
+ m_linkAckTimer[linkKey].Remove ();
+ if (m_linkAckTimer[linkKey].IsRunning ())
+ {
+ NS_LOG_INFO ("Timer not canceled");
+ }
+ m_linkAckTimer.erase (linkKey);
+ }
+ // Erase the maintenance entry
+ // yet this does not check the segments left value here
+ NS_LOG_DEBUG ("The link buffer size " << m_maintainBuffer.GetSize());
+ if (m_maintainBuffer.LinkEqual (mb))
+ {
+ NS_LOG_INFO ("Link acknowledgment received, remove same maintenance buffer entry");
+ }
}
void
@@ -1926,7 +2193,7 @@
Ipv4Address sender = ipv4Header.GetDestination ();
Ipv4Address receiver = ipv4Header.GetSource ();
/*
- * Create a packet to fill maintenance buffer, not used to compare
+ * Create a packet to fill maintenance buffer, not used to compare with maintainance entry
* The reason is ack header doesn't have the original packet copy
*/
Ptr<Packet> mainP = Create<Packet> ();
@@ -2101,42 +2368,41 @@
sourceRoute.SetSalvage (salvage);
sourceRoute.SetNodesAddress (nodeList); // Save the whole route in the source route header of the packet
sourceRoute.SetSegmentsLeft ((nodeList.size () - 2)); // The segmentsLeft field will indicate the hops to go
- DsrOptionAckReqHeader ackReq;
- m_ackId = m_routeCache->CheckUniqueAckId (nextHop);
- ackReq.SetAckId (m_ackId);
+ /// When found a route and use it, UseExtends to the link cache
if (m_routeCache->IsLinkCache ())
{
m_routeCache->UseExtends (nodeList);
}
-
- uint8_t length = (sourceRoute.GetLength () + ackReq.GetLength ());
- NS_LOG_INFO ("length of source route header " << (uint32_t)(sourceRoute.GetLength ())
- << " length of ack request header " << (uint32_t)(ackReq.GetLength ()));
- newDsrRoutingHeader.SetPayloadLength (uint16_t (length) + 4);
+ uint8_t length = sourceRoute.GetLength ();
+ NS_LOG_INFO ("length of source route header " << (uint32_t)(sourceRoute.GetLength ()));
+ newDsrRoutingHeader.SetPayloadLength (uint16_t (length) + 2);
newDsrRoutingHeader.AddDsrOption (sourceRoute);
- newDsrRoutingHeader.AddDsrOption (ackReq);
p->AddHeader (newDsrRoutingHeader);
SetRoute (nextHop, m_mainAddress);
Ptr<NetDevice> dev = m_ip->GetNetDevice (m_ip->GetInterfaceForAddress (m_mainAddress));
m_ipv4Route->SetOutputDevice (dev);
+
// Send out the data packet
-
uint32_t priority = GetPriority (DSR_DATA_PACKET);
std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> >::iterator i = m_priorityQueue.find (priority);
Ptr<dsr::DsrNetworkQueue> dsrNetworkQueue = i->second;
NS_LOG_DEBUG ("Will be inserting into priority queue " << dsrNetworkQueue << " number: " << priority);
- DsrNetworkQueueEntry newEntry (p, m_mainAddress, nextHop, Simulator::Now (), m_ipv4Route);
-
- if (dsrNetworkQueue->Enqueue (newEntry))
- {
- Scheduler (priority);
- }
- else
- {
- NS_LOG_INFO ("Packet dropped as dsr network queue is full");
- }
+ m_downTarget (p, m_mainAddress, nextHop, GetProtocolNumber (), m_ipv4Route);
+
+ // TODO
+// DsrNetworkQueueEntry newEntry (p, m_mainAddress, nextHop, Simulator::Now (), m_ipv4Route);
+//
+// if (dsrNetworkQueue->Enqueue (newEntry))
+// {
+// Scheduler (priority);
+// }
+// else
+// {
+// NS_LOG_INFO ("Packet dropped as dsr network queue is full");
+// }
+
/*
* Mark the next hop address in blacklist
*/
@@ -2150,11 +2416,47 @@
}
void
+DsrRouting::ScheduleLinkPacketRetry (MaintainBuffEntry & mb,
+ uint8_t protocol)
+{
+ NS_LOG_FUNCTION (this << (uint32_t) protocol);
+
+ Ptr<Packet> p = mb.GetPacket ()->Copy ();
+ Ipv4Address source = mb.GetSrc ();
+ Ipv4Address nextHop = mb.GetNextHop ();
+
+ // Send the data packet out before schedule the next packet transmission
+ SendPacket (p, source, nextHop, protocol);
+
+ LinkKey linkKey;
+ linkKey.m_source = mb.GetSrc ();
+ linkKey.m_destination = mb.GetDst ();
+ linkKey.m_ourAdd = mb.GetOurAdd ();
+ linkKey.m_nextHop = mb.GetNextHop ();
+
+ if (m_linkAckTimer.find (linkKey) == m_linkAckTimer.end ())
+ {
+ Timer timer (Timer::CANCEL_ON_DESTROY);
+ m_linkAckTimer[linkKey] = timer;
+ }
+ m_linkAckTimer[linkKey].SetFunction (&DsrRouting::LinkScheduleTimerExpire, this);
+ m_linkAckTimer[linkKey].Remove ();
+ m_linkAckTimer[linkKey].SetArguments (mb, protocol);
+ m_linkAckTimer[linkKey].Schedule (m_linkAckTimeout);
+}
+
+void
DsrRouting::SchedulePassivePacketRetry (MaintainBuffEntry & mb,
- bool onlyPassive,
uint8_t protocol)
{
- NS_LOG_FUNCTION (this << onlyPassive << (uint32_t)protocol);
+ NS_LOG_FUNCTION (this << (uint32_t)protocol);
+
+ Ptr<Packet> p = mb.GetPacket ()->Copy ();
+ Ipv4Address source = mb.GetSrc ();
+ Ipv4Address nextHop = mb.GetNextHop ();
+
+ // Send the data packet out before schedule the next packet transmission
+ SendPacket (p, source, nextHop, protocol);
PassiveKey passiveKey;
passiveKey.m_ackId = 0;
@@ -2170,7 +2472,7 @@
NS_LOG_DEBUG ("The passive acknowledgment option for data packet");
m_passiveAckTimer[passiveKey].SetFunction (&DsrRouting::PassiveScheduleTimerExpire, this);
m_passiveAckTimer[passiveKey].Remove ();
- m_passiveAckTimer[passiveKey].SetArguments (mb, onlyPassive, protocol);
+ m_passiveAckTimer[passiveKey].SetArguments (mb, protocol);
m_passiveAckTimer[passiveKey].Schedule (m_passiveAckTimeout);
}
@@ -2191,6 +2493,12 @@
p = mb.GetPacket ()->Copy ();
// Here we add the ack request header to the data packet for network acknowledgement
uint16_t ackId = AddAckReqHeader (p, nextHop);
+
+ Ipv4Address source = mb.GetSrc ();
+ Ipv4Address nextHop = mb.GetNextHop ();
+ // Send the data packet out before schedule the next packet transmission
+ SendPacket (p, source, nextHop, protocol);
+
dsrP = p->Copy ();
MaintainBuffEntry newEntry = mb;
// The function AllEqual will find the exact entry and delete it if found
@@ -2219,7 +2527,7 @@
m_addressForwardTimer[networkKey].Remove ();
m_addressForwardTimer[networkKey].SetArguments (newEntry, protocol);
NS_LOG_DEBUG ("The packet retries time for " << newEntry.GetAckId () << " is " << m_sendRetries
- << " and the delay time is " << Time (2 * m_nodeTraversalTime));
+ << " and the delay time is " << Time (2 * m_nodeTraversalTime).GetSeconds ());
// Back-off mechanism
m_addressForwardTimer[networkKey].Schedule (Time (2 * m_nodeTraversalTime));
}
@@ -2239,6 +2547,11 @@
p = mb.GetPacket ()->Copy ();
dsrP = mb.GetPacket ()->Copy ();
+ Ipv4Address source = mb.GetSrc ();
+ Ipv4Address nextHop = mb.GetNextHop ();
+ // Send the data packet out before schedule the next packet transmission
+ SendPacket (p, source, nextHop, protocol);
+
NS_LOG_DEBUG ("The packet with dsr header " << dsrP->GetSize ());
networkKey.m_ackId = mb.GetAckId ();
networkKey.m_ourAdd = mb.GetOurAdd ();
@@ -2262,20 +2575,98 @@
m_addressForwardTimer[networkKey].Remove ();
m_addressForwardTimer[networkKey].SetArguments (mb, protocol);
NS_LOG_DEBUG ("The packet retries time for " << mb.GetAckId () << " is " << m_sendRetries
- << " and the delay time is " << Time (2 * m_sendRetries * m_nodeTraversalTime));
+ << " and the delay time is " << Time (2 * m_sendRetries * m_nodeTraversalTime).GetSeconds ());
// Back-off mechanism
m_addressForwardTimer[networkKey].Schedule (Time (2 * m_sendRetries * m_nodeTraversalTime));
}
}
void
+DsrRouting::LinkScheduleTimerExpire (MaintainBuffEntry & mb,
+ uint8_t protocol)
+{
+ NS_LOG_FUNCTION (this << (uint32_t)protocol);
+ Ipv4Address nextHop = mb.GetNextHop ();
+ Ipv4Address source = mb.GetSrc ();
+ Ptr<const Packet> packet = mb.GetPacket ();
+ SetRoute (nextHop, m_mainAddress);
+ Ptr<Packet> p = packet->Copy ();
+
+ LinkKey lk;
+ lk.m_source = mb.GetSrc ();
+ lk.m_destination = mb.GetDst ();
+ lk.m_ourAdd = mb.GetOurAdd ();
+ lk.m_nextHop = mb.GetNextHop ();
+
+ // Cancel passive ack timer
+ m_linkAckTimer[lk].Cancel ();
+ m_linkAckTimer[lk].Remove ();
+ if (m_linkAckTimer[lk].IsRunning ())
+ {
+ NS_LOG_DEBUG ("Timer not canceled");
+ }
+ m_linkAckTimer.erase (lk);
+
+ // Increase the send retry times
+ m_linkRetries = m_linkCnt[lk];
+ if (m_linkRetries < m_tryLinkAcks)
+ {
+ m_linkCnt[lk] = ++m_linkRetries;
+ ScheduleLinkPacketRetry (mb, protocol);
+ }
+ else
+ {
+ NS_LOG_DEBUG ("We may need to send error messages now");
+ Ptr<Packet> dsrP = mb.GetPacket ()->Copy ();
+ // The packet retries time has exceed the max maintenance retransmission times
+ DsrRoutingHeader dsrRoutingHeader;
+ dsrP->RemoveHeader (dsrRoutingHeader); // Remove the dsr header in whole
+ uint32_t offset = dsrRoutingHeader.GetDsrOptionsOffset ();
+ p->RemoveAtStart (offset);
+
+ // Get the number of routers' address field
+ uint8_t buf[2];
+ p->CopyData (buf, sizeof(buf));
+ uint8_t numberAddress = (buf[1] - 2) / 4;
+ NS_LOG_DEBUG ("The number of addresses " << (uint32_t)numberAddress);
+ DsrOptionSRHeader sourceRoute;
+ sourceRoute.SetNumberAddress (numberAddress);
+ p->RemoveHeader (sourceRoute);
+ std::vector<Ipv4Address> nodeList = sourceRoute.GetNodesAddress ();
+ uint8_t salvage = sourceRoute.GetSalvage ();
+ Ipv4Address address1 = nodeList[1];
+ PrintVector (nodeList);
+
+ // Delete all the routes including the links
+ m_routeCache->DeleteAllRoutesIncludeLink (m_mainAddress, nextHop, m_mainAddress);
+ /*
+ * If the salvage is not 0, use the first address in the route as the error dst in error header
+ * otherwise use the source of packet as the error destination
+ */
+ Ipv4Address errorDst;
+ if (salvage)
+ {
+ errorDst = address1;
+ }
+ else
+ {
+ errorDst = source;
+ }
+ SendUnreachError (nextHop, errorDst, mb.GetDst (), salvage, protocol);
+ /*
+ * here we cancel the packet retransmission time for all the packets have next hop address as nextHop
+ * Also salvage the packet for the all the packet destined for the nextHop address
+ */
+ CancelPacketTimerNextHop (nextHop, protocol);
+ }
+}
+
+void
DsrRouting::PassiveScheduleTimerExpire (MaintainBuffEntry & mb,
- bool onlyPassive,
uint8_t protocol)
{
- NS_LOG_FUNCTION (this << onlyPassive << (uint32_t)protocol);
+ NS_LOG_FUNCTION (this << (uint32_t)protocol);
Ipv4Address nextHop = mb.GetNextHop ();
- Ipv4Address source = mb.GetSrc ();
Ptr<const Packet> packet = mb.GetPacket ();
SetRoute (nextHop, m_mainAddress);
Ptr<Packet> p = packet->Copy ();
@@ -2294,29 +2685,21 @@
NS_LOG_DEBUG ("Timer not canceled");
}
m_passiveAckTimer.erase (pk);
- // Send the data packet out before schedule the next packet transmission
- SendPacket (p, source, nextHop, protocol);
+
// Increase the send retry times
m_passiveRetries = m_passiveCnt[pk];
if (m_passiveRetries < m_tryPassiveAcks)
{
m_passiveCnt[pk] = ++m_passiveRetries;
- SchedulePassivePacketRetry (mb, onlyPassive, protocol);
+ SchedulePassivePacketRetry (mb, protocol);
}
- else if (!onlyPassive)
+ else
{
// This is the first network acknowledgement retry
// Cancel the passive packet timer now and remove maintenance buffer entry for it
CancelPassivePacketTimer (mb);
ScheduleNetworkPacketRetry (mb, true, protocol);
}
- else
- {
- // This is the end of the data retransmission retries
- CancelPassivePacketTimer (mb);
- // The function AllEqual will find the exact entry and delete it if found
- m_maintainBuffer.AllEqual (mb);
- }
}
int64_t
@@ -2343,11 +2726,9 @@
networkKey.m_source = source;
networkKey.m_destination = dst;
- // Send the data packet out before schedule the next packet transmission
- SendPacket (p, source, nextHop, protocol);
// Increase the send retry times
m_sendRetries = m_addressForwardCnt[networkKey];
- NS_LOG_DEBUG ("The send retry time is " << m_sendRetries);
+
if (m_sendRetries >= m_maxMaintRexmt)
{
Ptr<Packet> dsrP = mb.GetPacket ()->Copy ();
@@ -2369,7 +2750,6 @@
std::vector<Ipv4Address> nodeList = sourceRoute.GetNodesAddress ();
uint8_t salvage = sourceRoute.GetSalvage ();
Ipv4Address address1 = nodeList[1];
- NS_LOG_DEBUG ("address1 " << address1);
PrintVector (nodeList);
// Delete all the routes including the links
@@ -2427,14 +2807,11 @@
dsrRoutingHeader.AddDsrOption (sourceRoute);
p->AddHeader (dsrRoutingHeader);
- // Send the data packet out before schedule the next packet transmission
- SendPacket (p, source, nextHop, protocol);
-
Ptr<const Packet> mtP = p->Copy ();
MaintainBuffEntry newEntry (/*Packet=*/ mtP, /*ourAddress=*/ m_mainAddress, /*nextHop=*/ nextHop,
- /*source=*/ source, /*destination=*/ targetAddress,
- /*ackId=*/ m_ackId, /*SegsLeft=*/ sourceRoute.GetSegmentsLeft (), /*expire time=*/ m_maxMaintainTime);
+ /*source=*/ source, /*destination=*/ targetAddress, /*ackId=*/ m_ackId,
+ /*SegsLeft=*/ sourceRoute.GetSegmentsLeft (), /*expire time=*/ m_maxMaintainTime);
bool result = m_maintainBuffer.Enqueue (newEntry);
if (result)
@@ -2452,16 +2829,32 @@
passiveKey.m_destination = newEntry.GetDst ();
passiveKey.m_segsLeft = newEntry.GetSegsLeft ();
+ LinkKey linkKey;
+ linkKey.m_source = newEntry.GetSrc ();
+ linkKey.m_destination = newEntry.GetDst ();
+ linkKey.m_ourAdd = newEntry.GetOurAdd ();
+ linkKey.m_nextHop = newEntry.GetNextHop ();
+
m_addressForwardCnt[networkKey] = 0;
m_passiveCnt[passiveKey] = 0;
- if (nextHop != targetAddress)
+ m_linkCnt[linkKey] = 0;
+
+ if (m_linkAck)
{
- SchedulePassivePacketRetry (newEntry, false, protocol);
+ ScheduleLinkPacketRetry (newEntry, protocol);
}
else
{
- // This is the first network retry
- ScheduleNetworkPacketRetry (newEntry, true, protocol);
+ NS_LOG_LOGIC ("Not using link acknowledgment");
+ if (nextHop != targetAddress)
+ {
+ SchedulePassivePacketRetry (newEntry, protocol);
+ }
+ else
+ {
+ // This is the first network retry
+ ScheduleNetworkPacketRetry (newEntry, true, protocol);
+ }
}
}
}
@@ -2508,6 +2901,8 @@
tag.SetTtl (0);
Ptr<Packet> nonPropPacket = packet->Copy ();
nonPropPacket->AddPacketTag (tag);
+ // Increase the request count
+ m_rreqTable->FindAndUpdate (destination);
SendRequest (nonPropPacket, source);
// Schedule the next route request
ScheduleRreqRetry (packet, address, nonProp, m_requestId, protocol);
@@ -2532,6 +2927,7 @@
DsrOptionSRHeader sourceRoute;
std::vector<Ipv4Address> ip = toDst.GetVector ();
sourceRoute.SetNodesAddress (ip);
+ /// When found a route and use it, UseExtends to the link cache
if (m_routeCache->IsLinkCache ())
{
m_routeCache->UseExtends (ip);
@@ -2549,7 +2945,11 @@
}
SetRoute (nextHop, m_mainAddress);
CancelRreqTimer (dst, true);
- SendPacketFromBuffer (sourceRoute, nextHop, protocol);
+ /// Try to send out the packet from the buffer once we found one route
+ if (m_sendBuffer.GetSize () != 0 && m_sendBuffer.Find (dst))
+ {
+ SendPacketFromBuffer (sourceRoute, nextHop, protocol);
+ }
NS_LOG_LOGIC ("Route to " << dst << " found");
return;
}
@@ -2711,6 +3111,7 @@
if (m_rreqTable->GetRreqCnt (dst))
{
// When the route request count is larger than 0
+ // This is the exponential back-off mechanism for route request
rreqDelay = Time (std::pow (static_cast<double> (m_rreqTable->GetRreqCnt (dst)), 2.0) * m_requestPeriod);
}
else
@@ -2718,16 +3119,16 @@
// This is the first route request retry
rreqDelay = m_requestPeriod;
}
- NS_LOG_DEBUG ("The request count for the destination " << dst << " " << m_rreqTable->GetRreqCnt (dst) << " with time value " << rreqDelay);
+ NS_LOG_LOGIC ("Request count for " << dst << " " << m_rreqTable->GetRreqCnt (dst) << " with delay time " << rreqDelay.GetSeconds () << " second");
if (rreqDelay > m_maxRequestPeriod)
{
// use the max request period
- NS_LOG_DEBUG ("The max request delay time " << m_maxRequestPeriod.GetSeconds ());
+ NS_LOG_LOGIC ("The max request delay time " << m_maxRequestPeriod.GetSeconds ());
m_addressReqTimer[dst].Schedule (m_maxRequestPeriod);
}
else
{
- NS_LOG_DEBUG ("The request delay time " << rreqDelay.GetSeconds ());
+ NS_LOG_LOGIC ("The request delay time " << rreqDelay.GetSeconds () << " second");
m_addressReqTimer[dst].Schedule (rreqDelay);
}
}
@@ -2753,15 +3154,16 @@
DsrOptionSRHeader sourceRoute;
std::vector<Ipv4Address> ip = toDst.GetVector ();
sourceRoute.SetNodesAddress (ip);
+ // When we found the route and use it, UseExtends for the link cache
if (m_routeCache->IsLinkCache ())
{
m_routeCache->UseExtends (ip);
}
sourceRoute.SetSegmentsLeft ((ip.size () - 2));
- uint8_t salvage = 0;
- sourceRoute.SetSalvage (salvage);
+ /// Set the salvage value to 0
+ sourceRoute.SetSalvage (0);
Ipv4Address nextHop = SearchNextHop (m_mainAddress, ip); // Get the next hop address
- NS_LOG_DEBUG ("The nextHop address " << nextHop);
+ NS_LOG_INFO ("The nextHop address is " << nextHop);
if (nextHop == "0.0.0.0")
{
NS_LOG_DEBUG ("Error next hop address");
@@ -2770,7 +3172,11 @@
}
SetRoute (nextHop, m_mainAddress);
CancelRreqTimer (dst, true);
- SendPacketFromBuffer (sourceRoute, nextHop, protocol);
+ /// Try to send out data packet from the send buffer if found
+ if (m_sendBuffer.GetSize () != 0 && m_sendBuffer.Find (dst))
+ {
+ SendPacketFromBuffer (sourceRoute, nextHop, protocol);
+ }
NS_LOG_LOGIC ("Route to " << dst << " found");
return;
}
@@ -2779,7 +3185,7 @@
* receiving any RREP, all data packets destined for the corresponding destination SHOULD be
* dropped from the buffer and a Destination Unreachable message SHOULD be delivered to the application.
*/
- NS_LOG_DEBUG ("The new request count for " << dst << " is " << m_rreqTable->GetRreqCnt (dst) << " the max " << m_rreqRetries);
+ NS_LOG_LOGIC ("The new request count for " << dst << " is " << m_rreqTable->GetRreqCnt (dst) << " the max " << m_rreqRetries);
if (m_rreqTable->GetRreqCnt (dst) >= m_rreqRetries)
{
NS_LOG_LOGIC ("Route discovery to " << dst << " has been attempted " << m_rreqRetries << " times");
@@ -2807,6 +3213,7 @@
Ipv4Address source)
{
NS_LOG_FUNCTION (this << packet << source);
+
NS_ASSERT_MSG (!m_downTarget.IsNull (), "Error, DsrRouting cannot send downward");
/*
* The destination address here is directed broadcast address
@@ -2814,18 +3221,20 @@
uint32_t priority = GetPriority (DSR_CONTROL_PACKET);
std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> >::iterator i = m_priorityQueue.find (priority);
Ptr<dsr::DsrNetworkQueue> dsrNetworkQueue = i->second;
- NS_LOG_DEBUG ("Will be inserting into priority queue " << dsrNetworkQueue << " number: " << priority);
-
- DsrNetworkQueueEntry newEntry (packet, source, m_broadcast, Simulator::Now (), 0);
-
- if (dsrNetworkQueue->Enqueue (newEntry))
- {
- Scheduler (priority);
- }
- else
- {
- NS_LOG_INFO ("Packet dropped as dsr network queue is full");
- }
+ NS_LOG_LOGIC ("Inserting into priority queue number: " << priority);
+
+ m_downTarget (packet, source, m_broadcast, GetProtocolNumber (), 0);
+
+ // TODO
+// DsrNetworkQueueEntry newEntry (packet, source, m_broadcast, Simulator::Now (), 0);
+// if (dsrNetworkQueue->Enqueue (newEntry))
+// {
+// Scheduler (priority);
+// }
+// else
+// {
+// NS_LOG_INFO ("Packet dropped as dsr network queue is full");
+// }
}
void
@@ -2910,6 +3319,7 @@
{
NS_LOG_FUNCTION (this << packet << source << nextHop);
NS_ASSERT_MSG (!m_downTarget.IsNull (), "Error, DsrRouting cannot send downward");
+
Ptr<NetDevice> dev = m_ipv4->GetNetDevice (m_ipv4->GetInterfaceForAddress (m_mainAddress));
route->SetOutputDevice (dev);
NS_LOG_INFO ("The output device " << dev << " packet is: " << *packet);
@@ -2917,18 +3327,20 @@
uint32_t priority = GetPriority (DSR_CONTROL_PACKET);
std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> >::iterator i = m_priorityQueue.find (priority);
Ptr<dsr::DsrNetworkQueue> dsrNetworkQueue = i->second;
- NS_LOG_DEBUG ("Will be inserting into priority queue " << dsrNetworkQueue << " number: " << priority);
-
- DsrNetworkQueueEntry newEntry (packet, source, nextHop, Simulator::Now (), route);
-
- if (dsrNetworkQueue->Enqueue (newEntry))
- {
- Scheduler (priority);
- }
- else
- {
- NS_LOG_INFO ("Packet dropped as dsr network queue is full");
- }
+ NS_LOG_INFO ("Inserting into priority queue number: " << priority);
+
+ m_downTarget (packet, source, nextHop, GetProtocolNumber (), route);
+
+ // TODO
+// DsrNetworkQueueEntry newEntry (packet, source, nextHop, Simulator::Now (), route);
+// if (dsrNetworkQueue->Enqueue (newEntry))
+// {
+// Scheduler (priority);
+// }
+// else
+// {
+// NS_LOG_INFO ("Packet dropped as dsr network queue is full");
+// }
}
void
@@ -2987,23 +3399,25 @@
packet->AddHeader (dsrRoutingHeader);
Ptr<NetDevice> dev = m_ip->GetNetDevice (m_ip->GetInterfaceForAddress (m_mainAddress));
route->SetOutputDevice (dev);
- NS_LOG_DEBUG ("Send out the ACK");
uint32_t priority = GetPriority (DSR_CONTROL_PACKET);
std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> >::iterator i = m_priorityQueue.find (priority);
Ptr<dsr::DsrNetworkQueue> dsrNetworkQueue = i->second;
- NS_LOG_DEBUG ("Will be inserting into priority queue " << dsrNetworkQueue << " number: " << priority);
-
- DsrNetworkQueueEntry newEntry (packet, m_mainAddress, destination, Simulator::Now (), route);
-
- if (dsrNetworkQueue->Enqueue (newEntry))
- {
- Scheduler (priority);
- }
- else
- {
- NS_LOG_INFO ("Packet dropped as dsr network queue is full");
- }
+
+ NS_LOG_LOGIC ("Will be inserting into priority queue " << dsrNetworkQueue << " number: " << priority);
+
+ m_downTarget (packet, m_mainAddress, destination, GetProtocolNumber (), route);
+
+ // TODO
+// DsrNetworkQueueEntry newEntry (packet, m_mainAddress, destination, Simulator::Now (), route);
+// if (dsrNetworkQueue->Enqueue (newEntry))
+// {
+// Scheduler (priority);
+// }
+// else
+// {
+// NS_LOG_INFO ("Packet dropped as dsr network queue is full");
+// }
}
enum IpL4Protocol::RxStatus
@@ -3022,10 +3436,11 @@
DsrRoutingHeader dsrRoutingHeader;
packet->RemoveHeader (dsrRoutingHeader); // Remove the DSR header in whole
Ptr<Packet> copy = packet->Copy ();
+
uint8_t protocol = dsrRoutingHeader.GetNextHeader ();
uint32_t sourceId = dsrRoutingHeader.GetSourceId ();
Ipv4Address source = GetIPfromID (sourceId);
- NS_LOG_DEBUG ("The source address " << source << " with source id " << sourceId);
+ NS_LOG_INFO ("The source address " << source << " with source id " << sourceId);
/*
* Get the IP source and destination address
*/
@@ -3051,16 +3466,15 @@
uint8_t segmentsLeft = 0;
optionType = *(data);
- NS_LOG_LOGIC ("The option type value " << (uint32_t)optionType << " with packet size " << p->GetSize ());
+ NS_LOG_LOGIC ("The option type value " << (uint32_t)optionType << " with packet id " << p->GetUid());
dsrOption = GetOption (optionType); // Get the relative dsr option and demux to the process function
- // This promisc source is just set as empty, only the promisc received packet will have a promisc source value
- Ipv4Address promiscSource;
+ Ipv4Address promiscSource; /// this is just here for the sake of passing in the promisc source
if (optionType == 1) // This is the request option
{
BlackList *blackList = m_rreqTable->FindUnidirectional (src);
if (blackList)
{
- NS_LOG_DEBUG ("Discard this packet due to unidirectional link");
+ NS_LOG_INFO ("Discard this packet due to unidirectional link");
m_dropTrace (p);
}
@@ -3069,7 +3483,7 @@
if (optionLength == 0)
{
- NS_LOG_DEBUG ("Discard this packet");
+ NS_LOG_INFO ("Discard this packet");
m_dropTrace (p);
}
}
@@ -3080,20 +3494,20 @@
if (optionLength == 0)
{
- NS_LOG_DEBUG ("Discard this packet");
+ NS_LOG_INFO ("Discard this packet");
m_dropTrace (p);
}
}
else if (optionType == 32) // This is the ACK option
{
- NS_LOG_DEBUG ("This is the ack option");
+ NS_LOG_INFO ("This is the ack option");
dsrOption = GetOption (optionType);
optionLength = dsrOption->Process (p, packet, m_mainAddress, source, ip, protocol, isPromisc, promiscSource);
if (optionLength == 0)
{
- NS_LOG_DEBUG ("Discard this packet");
+ NS_LOG_INFO ("Discard this packet");
m_dropTrace (p);
}
}
@@ -3101,30 +3515,27 @@
else if (optionType == 3) // This is a route error header
{
// populate this route error
- NS_LOG_DEBUG ("The option type value " << (uint32_t)optionType);
+ NS_LOG_INFO ("The option type value " << (uint32_t)optionType);
dsrOption = GetOption (optionType);
optionLength = dsrOption->Process (p, packet, m_mainAddress, source, ip, protocol, isPromisc, promiscSource);
if (optionLength == 0)
{
- NS_LOG_DEBUG ("Discard this packet");
+ NS_LOG_INFO ("Discard this packet");
m_dropTrace (p);
}
- NS_LOG_DEBUG ("The option Length " << (uint32_t)optionLength);
+ NS_LOG_INFO ("The option Length " << (uint32_t)optionLength);
}
else if (optionType == 96) // This is the source route option
{
- NS_LOG_DEBUG ("This is the source route option " << (uint32_t)optionType);
dsrOption = GetOption (optionType);
optionLength = dsrOption->Process (p, packet, m_mainAddress, source, ip, protocol, isPromisc, promiscSource);
-
segmentsLeft = *(data + 3);
- NS_LOG_DEBUG ("The segments left in source route header " << (uint32_t)segmentsLeft);
if (optionLength == 0)
{
- NS_LOG_DEBUG ("Discard this packet");
+ NS_LOG_INFO ("Discard this packet");
m_dropTrace (p);
}
else
@@ -3140,8 +3551,6 @@
// we need to make a copy in the unlikely event we hit the
// RX_ENDPOINT_UNREACH code path
// Here we can use the packet that has been get off whole DSR header
- NS_LOG_DEBUG ("The packet size here " << copy->GetSize ());
- NS_LOG_DEBUG ("The packet received " << *copy);
enum IpL4Protocol::RxStatus status =
nextProto->Receive (copy, ip, incomingInterface);
NS_LOG_DEBUG ("The receive status " << status);
@@ -3163,6 +3572,10 @@
}
return status;
}
+ else
+ {
+ NS_FATAL_ERROR ("Should not have 0 next protocol value");
+ }
}
else
{
--- a/src/dsr/model/dsr-routing.h Fri Apr 26 02:00:09 2013 +0200
+++ b/src/dsr/model/dsr-routing.h Fri Apr 26 10:43:20 2013 -0400
@@ -166,6 +166,21 @@
//\}
/**
+ * \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
*/
@@ -181,6 +196,11 @@
*/
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.
*/
void PrintVector (std::vector<Ipv4Address>& vec);
@@ -209,22 +229,22 @@
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 @@
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 @@
* \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 @@
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 @@
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 @@
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 @@
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,
@@ -431,6 +475,11 @@
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 @@
* \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 @@
*/
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_linkRetries; ///< # of retries have been sent for link acknowledgment
- uint32_t m_rreqRetries; // /< Maximum number of retransmissions of RREQ with TTL = NetDiameter to discover a route
+ uint32_t m_rreqRetries; ///< Maximum number of retransmissions of RREQ with TTL = NetDiameter to discover a route
- uint32_t m_maxMaintRexmt; // /< Maximum number of retransmissions of data packets
+ uint32_t m_maxMaintRexmt; ///< Maximum number of retransmissions of data packets
- Time m_nodeTraversalTime; // / Time estimated for packet to travel between two nodes
+ Time m_nodeTraversalTime; ///< Time estimated for packet to travel between two nodes
- uint32_t m_maxSendBuffLen; // /< The maximum number of packets that we allow a routing protocol to buffer.
+ uint32_t m_maxSendBuffLen; ///< 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.
+ Time m_sendBufferTimeout; ///< The maximum period of time that a routing protocol is allowed to buffer a packet for.
- SendBuffer m_sendBuffer; // / The send buffer
+ SendBuffer m_sendBuffer; ///< The send buffer
- ErrorBuffer m_errorBuffer; // / The error buffer to save the error messages
+ ErrorBuffer m_errorBuffer; ///< The error buffer to save the error messages
- uint32_t m_maxMaintainLen; // / Max # of entries for maintainance buffer
+ uint32_t m_maxMaintainLen; ///< Max # of entries for maintainance buffer
- Time m_maxMaintainTime; // / Time out for maintainance buffer
+ Time m_maxMaintainTime; ///< Time out for maintainance buffer
- uint32_t m_maxCacheLen; // / Max # of cache entries for route cache
+ uint32_t m_maxCacheLen; ///< Max # of cache entries for route cache
- Time m_maxCacheTime; // / Max time for caching the route cache entry
+ Time m_maxCacheTime; ///< Max time for caching the route cache entry
- Time m_maxRreqTime; // / Max time for caching the route request entry
+ Time m_maxRreqTime; ///< Max time for caching the route request entry
- uint32_t m_maxEntriesEachDst; // / Max number of route entries to save for each destination
+ uint32_t m_maxEntriesEachDst; ///< Max number of route entries to save for each destination
- MaintainBuffer m_maintainBuffer; // / The declaration of maintain buffer
+ MaintainBuffer m_maintainBuffer; ///< The declaration of maintain buffer
- uint32_t m_requestId; // / The id assigned to each route request
+ uint32_t m_requestId; ///< The id assigned to each route request
- uint16_t m_ackId; // / The ack id assigned to each acknowledge
+ uint16_t m_ackId; ///< The ack id assigned to each acknowledge
+
+ uint32_t m_requestTableSize; ///< The max size of the request table size
- uint32_t m_requestTableSize; // / The max size of the request table size
+ uint32_t m_requestTableIds; ///< The request table identifiers
+
+ 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
+ Time m_linkAckTimeout; ///< The timeout value for link acknowledge
- uint32_t m_tryPassiveAcks; // /< Maximum number of packet transmission using passive acknowledgment
+ uint32_t m_tryLinkAcks; ///< Maximum number of packet transmission using link acknowledgment
- Timer m_sendBuffTimer; // / The send buffer timer
+ Timer m_sendBuffTimer; ///< The send buffer timer
- Time m_sendBuffInterval; // / how often to check send buffer
+ Time m_sendBuffInterval; ///< how often to check send buffer
- Time m_gratReplyHoldoff; // / The max gratuitous reply hold off time
+ Time m_gratReplyHoldoff; ///< The max gratuitous reply hold off time
- Time m_maxRequestPeriod; // / The max request period
+ Time m_maxRequestPeriod; ///< The max request period
- uint32_t m_graReplyTableSize; // / Set the gratuitous reply table size
+ uint32_t m_graReplyTableSize; ///< Set the gratuitous reply table size
- std::string m_cacheType; // / The type of route cache
+ std::string m_cacheType; ///< The type of route cache
- std::string m_routeSortType; // / The type of route sort methods
+ std::string m_routeSortType; ///< The type of route sort methods
+
+ uint32_t m_stabilityDecrFactor; ///< The initial decrease factor for link cache
- uint64_t m_stabilityDecrFactor; // / The initial decrease factor for link cache
+ uint32_t m_stabilityIncrFactor; ///< The initial increase factor for link cache
- uint64_t m_stabilityIncrFactor; // / The initial increase factor for link cache
+ Time m_initStability; ///< The initial stability value for link cache
- Time m_initStability; // / The initial stability value for link cache
+ Time m_minLifeTime; ///< The min life time
- Time m_minLifeTime; // / The min life time
+ Time m_useExtends; ///< The use extension of the life time for link cache
- Time m_useExtends; // / The use extension of the life time for link cache
+ bool m_subRoute; ///< Whether to save sub route or not
- bool m_subRoute; // / Whether to save sub route or not
+ Time m_retransIncr; ///< the increase time for retransmission timer when face network congestion
- Time m_retransIncr; // / the increase time for retransmission timer when face network congestion
+ std::vector<Ipv4Address> m_finalRoute; ///< The route cache
- std::vector<Ipv4Address> m_finalRoute; // / The route cache
+ std::map<Ipv4Address, Timer> m_addressReqTimer; ///< Map IP address + RREQ timer.
- std::map<Ipv4Address, Timer> m_addressReqTimer; // / Map IP address + RREQ timer.
+ std::map<Ipv4Address, Timer> m_nonPropReqTimer; ///< Map IP address + RREQ timer.
- std::map<Ipv4Address, Timer> m_nonPropReqTimer; // / Map IP address + RREQ timer.
+ std::map<NetworkKey, Timer> m_addressForwardTimer; ///< Map network key + forward timer.
- std::map<NetworkKey, Timer> m_addressForwardTimer; // / Map network key + forward timer.
+ std::map<NetworkKey, uint32_t> m_addressForwardCnt; ///< Map network key + forward counts.
- std::map<NetworkKey, uint32_t> m_addressForwardCnt; // / Map network key + forward counts.
+ std::map<PassiveKey, uint32_t> m_passiveCnt; ///< Map packet key + passive forward counts.
- 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<PassiveKey, Timer> m_passiveAckTimer; // / The timer for passive acknowledgment
+ std::map<LinkKey, uint32_t> m_linkCnt; ///< Map packet key + link forward counts.
- Ptr<dsr::RouteCache> m_routeCache; // / A "drop-front" queue used by the routing layer to cache routes found.
+ std::map<LinkKey, Timer> m_linkAckTimer; ///< The timer for link acknowledgment
- Ptr<dsr::RreqTable> m_rreqTable; // / A "drop-front" queue used by the routing layer to cache route request sent.
+ 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
+
+ bool m_linkAck; ///< define if we use link acknowledgement or not
- std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> > m_priorityQueue; // / priority queueus
+ std::map<uint32_t, Ptr<dsr::DsrNetworkQueue> > m_priorityQueue; ///< priority queues
- GraReply m_graReply; // / The gratuitous route reply.
+ GraReply m_graReply; ///< The gratuitous route reply.
- std::vector<Ipv4Address> m_clearList; // / The node that is clear to send packet to
+ std::vector<Ipv4Address> m_clearList; ///< The node that is clear to send packet to
+
+ std::vector<Ipv4Address> m_addresses; ///< The bind ipv4 addresses with next hop, src, destination address in sequence
- 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
- /// Provides uniform random variables.
- Ptr<UniformRandomVariable> m_uniformRandomVariable;
+ Ptr<UniformRandomVariable> m_uniformRandomVariable; ///< Provides uniform random variables.
};
} /* namespace dsr */
} /* namespace ns3 */