Update DSR code to ns-3-dev
This commit is contained in:
@@ -16,7 +16,7 @@ DSR Routing Overview
|
||||
This model implements the base specification of the Dynamic Source Routing (DSR)
|
||||
protocol. Implementation is based on RFC4728.
|
||||
|
||||
Class dsr::DsrRouting implements all functionality of service packet exchange and inherits Ipv4L4Protocol.
|
||||
Class dsr::DsrRouting implements all functionality of service packet exchange and inherits IpL4Protocol.
|
||||
|
||||
Class dsr::DsrOptions implements functionality of packet processing and talk to DsrRouting to send/receive packets
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
#include "ns3/ipv4-address.h"
|
||||
#include "ns3/ipv4-route.h"
|
||||
#include "ns3/icmpv4-l4-protocol.h"
|
||||
#include "ns3/ipv4-l4-protocol.h"
|
||||
#include "ns3/ip-l4-protocol.h"
|
||||
|
||||
#include "dsr-option-header.h"
|
||||
#include "dsr-options.h"
|
||||
@@ -475,7 +475,6 @@ uint8_t DsrOptionRreq::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Addres
|
||||
NS_LOG_FUNCTION (this << packet << dsrP << ipv4Address << source << ipv4Header << (uint32_t)protocol << isPromisc);
|
||||
// Fields from IP header
|
||||
Ipv4Address srcAddress = ipv4Header.GetSource ();
|
||||
Ipv4Address destAddress = ipv4Header.GetDestination ();
|
||||
/*
|
||||
* \ when the ip source address is equal to the address of our own, this is request packet originated
|
||||
* \ by the node itself, discard it
|
||||
@@ -492,8 +491,6 @@ uint8_t DsrOptionRreq::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Addres
|
||||
Ptr<Node> node = GetNodeWithAddress (ipv4Address);
|
||||
Ptr<dsr::DsrRouting> dsr = node->GetObject<dsr::DsrRouting> ();
|
||||
|
||||
// Set the isError boolean value as false
|
||||
bool isError = false;
|
||||
Ptr<Packet> p = packet->Copy (); // The packet here doesn't contain the fixed size dsr header
|
||||
/*
|
||||
* \brief Get the number of routers' address field before removing the header
|
||||
@@ -862,7 +859,6 @@ uint8_t DsrOptionRreq::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Addres
|
||||
}
|
||||
else
|
||||
{
|
||||
isError = true;
|
||||
dsr->DeleteAllRoutesIncludeLink (errorSrc, unreachNode, ipv4Address);
|
||||
|
||||
DsrOptionRerrUnreachHeader newUnreach;
|
||||
|
||||
@@ -39,7 +39,6 @@
|
||||
#include "ns3/packet.h"
|
||||
#include "ns3/callback.h"
|
||||
#include "ns3/ptr.h"
|
||||
#include "ns3/ipv4-l4-protocol.h"
|
||||
#include "ns3/udp-l4-protocol.h"
|
||||
#include "ns3/ipv4.h"
|
||||
#include "ns3/ipv4-route.h"
|
||||
|
||||
@@ -984,7 +984,6 @@ RouteCache::Purge ()
|
||||
/*
|
||||
* Save the new route cache along with the destination address in map
|
||||
*/
|
||||
std::pair<std::map<Ipv4Address, std::list<RouteCacheEntry> >::iterator, bool> result =
|
||||
m_sortedRoutes.insert (std::make_pair (dst, rtVector));
|
||||
}
|
||||
else
|
||||
|
||||
@@ -54,7 +54,6 @@
|
||||
#include "ns3/ipv4-address.h"
|
||||
#include "ns3/ipv4-header.h"
|
||||
#include "ns3/ipv4-l3-protocol.h"
|
||||
#include "ns3/ipv4-l4-protocol.h"
|
||||
#include "ns3/ipv4-route.h"
|
||||
#include "ns3/trace-source-accessor.h"
|
||||
#include "ns3/random-variable.h"
|
||||
@@ -103,7 +102,7 @@ const uint8_t DsrRouting::PROT_NUMBER = 48;
|
||||
TypeId DsrRouting::GetTypeId ()
|
||||
{
|
||||
static TypeId tid = TypeId ("ns3::dsr::DsrRouting")
|
||||
.SetParent<Ipv4L4Protocol> ()
|
||||
.SetParent<IpL4Protocol> ()
|
||||
.AddConstructor<DsrRouting> ()
|
||||
.AddAttribute ("RouteCache", "The route cache for saving routes from route discovery process.",
|
||||
PointerValue (0),
|
||||
@@ -443,7 +442,7 @@ DsrRouting::DoDispose (void)
|
||||
}
|
||||
}
|
||||
}
|
||||
Ipv4L4Protocol::DoDispose ();
|
||||
IpL4Protocol::DoDispose ();
|
||||
}
|
||||
|
||||
void
|
||||
@@ -724,7 +723,6 @@ void DsrRouting::SendRerrWhenBreaksLinkToNextHop (Ipv4Address nextHop, uint8_t p
|
||||
if (findRoute && (salvage < m_maxSalvageCount))
|
||||
{
|
||||
// Need to salvage the packet instead of discard it
|
||||
Ipv4Address source = nodeList.front ();
|
||||
std::vector<Ipv4Address> nodeList = salvageRoute.GetVector ();
|
||||
DsrOptionSRHeader newSR;
|
||||
newSR.SetNodesAddress (nodeList);
|
||||
@@ -1029,9 +1027,8 @@ bool DsrRouting::PromiscReceive (Ptr<NetDevice> device, Ptr<const Packet> packet
|
||||
uint8_t *data = new uint8_t[size];
|
||||
p->CopyData (data, size);
|
||||
uint8_t optionType = 0;
|
||||
uint8_t optionLength = 0;
|
||||
|
||||
optionType = *(data);
|
||||
|
||||
Ptr<dsr::DsrOptions> dsrOption;
|
||||
|
||||
if (optionType == 96) // This is the source route option
|
||||
@@ -1047,7 +1044,7 @@ bool DsrRouting::PromiscReceive (Ptr<NetDevice> device, Ptr<const Packet> packet
|
||||
" and destination IP " << ipv4Header.GetDestination () <<
|
||||
" and packet : " << *dsrPacket);
|
||||
bool isPromisc = true; // Set the boolean value isPromisc as true
|
||||
optionLength = dsrOption->Process (p, dsrPacket, m_mainAddress, source, ipv4Header, nextHeader, isPromisc);
|
||||
dsrOption->Process (p, dsrPacket, m_mainAddress, source, ipv4Header, nextHeader, isPromisc);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -2059,9 +2056,6 @@ DsrRouting::SchedulePassivePacketRetry (MaintainBuffEntry & mb,
|
||||
uint8_t protocol)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << onlyPassive << (uint32_t)protocol);
|
||||
Ipv4Address nextHop = mb.GetNextHop ();
|
||||
Ipv4Address source = mb.GetSrc ();
|
||||
Ipv4Address dst = mb.GetDst ();
|
||||
|
||||
PassiveKey passiveKey;
|
||||
passiveKey.m_ackId = 0;
|
||||
@@ -2091,8 +2085,6 @@ DsrRouting::ScheduleNetworkPacketRetry (MaintainBuffEntry & mb,
|
||||
// The new entry will be used for retransmission
|
||||
NetworkKey networkKey;
|
||||
Ipv4Address nextHop = mb.GetNextHop ();
|
||||
Ipv4Address source = mb.GetSrc ();
|
||||
Ipv4Address dst = mb.GetDst ();
|
||||
NS_LOG_DEBUG ("is the first retry or not " << isFirst);
|
||||
if (isFirst)
|
||||
{
|
||||
@@ -2185,7 +2177,6 @@ DsrRouting::PassiveScheduleTimerExpire (MaintainBuffEntry & mb,
|
||||
NS_LOG_FUNCTION (this << onlyPassive << (uint32_t)protocol);
|
||||
Ipv4Address nextHop = mb.GetNextHop ();
|
||||
Ipv4Address source = mb.GetSrc ();
|
||||
Ipv4Address dst = mb.GetDst ();
|
||||
Ptr<const Packet> packet = mb.GetPacket ();
|
||||
SetRoute (nextHop, m_mainAddress);
|
||||
Ptr<Packet> p = packet->Copy ();
|
||||
@@ -2459,7 +2450,6 @@ DsrRouting::SendErrorRequest (DsrOptionRerrUnreachHeader &rerr, uint8_t protocol
|
||||
{
|
||||
NS_LOG_INFO ("No route found, initiate route error request");
|
||||
Ptr<Packet> packet = Create<Packet> ();
|
||||
Ipv4Address unreachAddress = rerr.GetUnreachNode ();
|
||||
Ipv4Address originalDst = rerr.GetOriginalDst ();
|
||||
// Create an empty route ptr
|
||||
Ptr<Ipv4Route> route = 0;
|
||||
@@ -2910,7 +2900,7 @@ DsrRouting::SendAck (uint16_t ackId,
|
||||
}
|
||||
}
|
||||
|
||||
enum Ipv4L4Protocol::RxStatus
|
||||
enum IpL4Protocol::RxStatus
|
||||
DsrRouting::Receive (Ptr<Packet> p,
|
||||
Ipv4Header const &ip,
|
||||
Ptr<Ipv4Interface> incomingInterface)
|
||||
@@ -3037,7 +3027,7 @@ DsrRouting::Receive (Ptr<Packet> p,
|
||||
// / Get the next header
|
||||
uint8_t nextHeader = dsrRoutingHeader.GetNextHeader ();
|
||||
Ptr<Ipv4L3Protocol> l3proto = m_node->GetObject<Ipv4L3Protocol> ();
|
||||
Ptr<Ipv4L4Protocol> nextProto = l3proto->GetProtocol (nextHeader);
|
||||
Ptr<IpL4Protocol> nextProto = l3proto->GetProtocol (nextHeader);
|
||||
if (nextProto != 0)
|
||||
{
|
||||
// we need to make a copy in the unlikely event we hit the
|
||||
@@ -3045,18 +3035,18 @@ DsrRouting::Receive (Ptr<Packet> p,
|
||||
// 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 Ipv4L4Protocol::RxStatus status =
|
||||
enum IpL4Protocol::RxStatus status =
|
||||
nextProto->Receive (copy, ip, incomingInterface);
|
||||
NS_LOG_DEBUG ("The receive status " << status);
|
||||
switch (status)
|
||||
{
|
||||
case Ipv4L4Protocol::RX_OK:
|
||||
case IpL4Protocol::RX_OK:
|
||||
// fall through
|
||||
case Ipv4L4Protocol::RX_ENDPOINT_CLOSED:
|
||||
case IpL4Protocol::RX_ENDPOINT_CLOSED:
|
||||
// fall through
|
||||
case Ipv4L4Protocol::RX_CSUM_FAILED:
|
||||
case IpL4Protocol::RX_CSUM_FAILED:
|
||||
break;
|
||||
case Ipv4L4Protocol::RX_ENDPOINT_UNREACH:
|
||||
case IpL4Protocol::RX_ENDPOINT_UNREACH:
|
||||
if (ip.GetDestination ().IsBroadcast () == true
|
||||
|| ip.GetDestination ().IsMulticast () == true)
|
||||
{
|
||||
@@ -3094,7 +3084,17 @@ DsrRouting::Receive (Ptr<Packet> p,
|
||||
*/
|
||||
// SendError (rerrUnsupportHeader, 0, protocol); // Send the error packet
|
||||
}
|
||||
return Ipv4L4Protocol::RX_OK;
|
||||
return IpL4Protocol::RX_OK;
|
||||
}
|
||||
|
||||
enum IpL4Protocol::RxStatus
|
||||
DsrRouting::Receive (Ptr<Packet> p,
|
||||
Ipv6Address &src,
|
||||
Ipv6Address &dst,
|
||||
Ptr<Ipv6Interface> incomingInterface)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << p << src << dst << incomingInterface);
|
||||
return IpL4Protocol::RX_ENDPOINT_UNREACH;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -3103,12 +3103,26 @@ DsrRouting::SetDownTarget (DownTargetCallback callback)
|
||||
m_downTarget = callback;
|
||||
}
|
||||
|
||||
Ipv4L4Protocol::DownTargetCallback
|
||||
void
|
||||
DsrRouting::SetDownTarget6 (DownTargetCallback6 callback)
|
||||
{
|
||||
NS_FATAL_ERROR ("Unimplemented");
|
||||
}
|
||||
|
||||
|
||||
IpL4Protocol::DownTargetCallback
|
||||
DsrRouting::GetDownTarget (void) const
|
||||
{
|
||||
return m_downTarget;
|
||||
}
|
||||
|
||||
IpL4Protocol::DownTargetCallback6
|
||||
DsrRouting::GetDownTarget6 (void) const
|
||||
{
|
||||
NS_FATAL_ERROR ("Unimplemented");
|
||||
return MakeNullCallback<void,Ptr<Packet>, Ipv6Address, Ipv6Address, uint8_t, Ptr<Ipv6Route> > ();
|
||||
}
|
||||
|
||||
void DsrRouting::Insert (Ptr<dsr::DsrOptions> option)
|
||||
{
|
||||
m_options.push_back (option);
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
#include "ns3/buffer.h"
|
||||
#include "ns3/packet.h"
|
||||
#include "ns3/ipv4.h"
|
||||
#include "ns3/ipv4-l4-protocol.h"
|
||||
#include "ns3/ip-l4-protocol.h"
|
||||
#include "ns3/ipv4-l3-protocol.h"
|
||||
#include "ns3/icmpv4-l4-protocol.h"
|
||||
#include "ns3/ipv4-interface.h"
|
||||
@@ -90,7 +90,7 @@ class DsrOptions;
|
||||
* \class DsrRouting
|
||||
* \brief Dsr Routing base
|
||||
*/
|
||||
class DsrRouting : public Ipv4L4Protocol
|
||||
class DsrRouting : public IpL4Protocol
|
||||
{
|
||||
public:
|
||||
/**
|
||||
@@ -401,12 +401,28 @@ public:
|
||||
* Called from lower-level layers to send the packet up
|
||||
* in the stack.
|
||||
*/
|
||||
virtual enum Ipv4L4Protocol::RxStatus Receive (Ptr<Packet> p,
|
||||
virtual enum IpL4Protocol::RxStatus Receive (Ptr<Packet> p,
|
||||
Ipv4Header const &header,
|
||||
Ptr<Ipv4Interface> incomingInterface);
|
||||
|
||||
void SetDownTarget (Ipv4L4Protocol::DownTargetCallback callback);
|
||||
Ipv4L4Protocol::DownTargetCallback GetDownTarget (void) const;
|
||||
/**
|
||||
* \param p packet to forward up
|
||||
* \param src source IPv6 address
|
||||
* \param dst destination IPv6 address
|
||||
* \param incomingInterface the Ipv6Interface on which the packet arrived
|
||||
*
|
||||
* Called from lower-level layers to send the packet up
|
||||
* in the stack. Not implemented (IPv6).
|
||||
*/
|
||||
virtual enum IpL4Protocol::RxStatus Receive (Ptr<Packet> p,
|
||||
Ipv6Address &src,
|
||||
Ipv6Address &dst,
|
||||
Ptr<Ipv6Interface> incomingInterface);
|
||||
|
||||
void SetDownTarget (IpL4Protocol::DownTargetCallback callback);
|
||||
void SetDownTarget6 (IpL4Protocol::DownTargetCallback6 callback);
|
||||
IpL4Protocol::DownTargetCallback GetDownTarget (void) const;
|
||||
IpL4Protocol::DownTargetCallback6 GetDownTarget6 (void) const;
|
||||
/**
|
||||
* \brief Get the extension number.
|
||||
* \return extension number
|
||||
@@ -497,7 +513,7 @@ private:
|
||||
|
||||
uint8_t segsLeft; // / The segment left value from SR header
|
||||
|
||||
Ipv4L4Protocol::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
|
||||
|
||||
|
||||
@@ -84,7 +84,6 @@ SendBuffer::DropPacketWithDst (Ipv4Address dst)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << dst);
|
||||
Purge ();
|
||||
const Ipv4Address addr = dst;
|
||||
/*
|
||||
* Drop the packet with destination address dst
|
||||
*/
|
||||
|
||||
@@ -45,4 +45,4 @@ def build(bld):
|
||||
if (bld.env['ENABLE_EXAMPLES']):
|
||||
bld.add_subdirs('examples')
|
||||
|
||||
bld.ns3_python_bindings()
|
||||
#bld.ns3_python_bindings()
|
||||
|
||||
Reference in New Issue
Block a user