Compare commits

...
Author SHA1 Message Date
Alexander Afanasyev 26c785f7f4 flow-monitor: Correcting usage of new PacketTag API 2012-05-31 16:11:10 -07:00
Alexander Afanasyev c36547fb62 network: Correcting test cases for new PacketTag API 2012-05-31 16:11:10 -07:00
Alexander Afanasyev a7ec40805a network+all: Changing all cases of PacketTag API usage (source, examples, and tests) 2012-05-31 16:11:10 -07:00
Alexander Afanasyev f8ba98843a network: !!! Change PacketTag API !!! 2012-05-31 16:11:10 -07:00
Alexander Afanasyev c5037d1594 visualizer: Fix dependency on ns3.lte/virtual_net_device 2012-05-31 16:11:09 -07:00
Alexander Afanasyev 613a332306 internet: Corrections of RttEstimator:
Introducing RTO upper bound
Introducing gain2 for smoothing the variance
Making RTO calculation according to the RFC

For future: may need to calculate RTO as in linux implementation
2012-05-31 16:11:09 -07:00
Alexander Afanasyev e474e93667 point-to-point: Making loss (again) independent on packet type 2012-05-31 16:11:09 -07:00
Alexander Afanasyev 6ea2a97ca0 point-to-point: Add experimental support for random losses 2012-05-31 16:11:09 -07:00
Alexander Afanasyev fe9a8cca8e internet: rescanned bindings and small modification 2012-05-31 16:11:09 -07:00
Alexander Afanasyev b1ec1fde9a internet: Solving very serious bug in Ipv4GlobalRoutingHelper
Somehow, the metric values for "disabled faces" in
PopulateAllPossibleRoutingTables function were set to random values,
instead of UINT16_MAX.  This caused a lot of unexpected thing that were
hard to track down.
2012-05-31 16:11:09 -07:00
Alexander Afanasyev b26d351756 internet: Repairing GlobalRouting lookup 2012-05-31 16:11:09 -07:00
Alexander Afanasyev 8a0c45ea89 internet: Adding necessary methods to implement alternative-interface global routing table 2012-05-31 16:11:09 -07:00
Alexander Afanasyev 10c2679ebf internet: Updating global routing controller 2012-05-31 16:11:09 -07:00
Alexander Afanasyev 9615e4936d internet: Disable host routes in GlobalRouteManagerImpl. All of them are covered by stub LSAs 2012-05-31 16:11:08 -07:00
Alexander Afanasyev 14b5c3bb39 internet+network: Ipv4GlobalRouting is rewritten to use PATRICIA Trie lookups.
Trie implementation is based on gcc libstc++ pb_ds extension.

! Attention ! ECMP link randomization in Ipv4GlobalRouting is broken at
the moment. Such (similar) possibility will be implemented in different
place.
2012-05-31 16:11:08 -07:00
Alexander Afanasyev bfa8e6db50 point-to-point, netanim: Adding ChannelID to PointToPointChannel trace 2012-05-31 16:11:08 -07:00
Alexander Afanasyev b81d969ba3 visualizer: temporary fix for the visualizer-related bugs (asserts) 2012-05-31 16:11:08 -07:00
Alexander Afanasyev 7b321fba3e network: Adding Read (Buffer::Iterator start, uint32_t size) and PeakU8 methods to ns3::Buffer::Iterator class 2012-05-31 16:11:08 -07:00
Alexander Afanasyev 19a649bbe2 internet: A new templated static method Ipv(4|6)RoutingHelper::GetRouting that allows search for any routing protocol
Examples:
Ptr<Ipv4RoutingProtocol> ptr = ...

...

Ptr<Ipv4StaticRouting> sr = Ipv4RoutingHelper::GetRouting<Ipv4StaticRouting> (ptr);
2012-05-31 16:11:08 -07:00
Alexander Afanasyev 27e2cbc0d9 core+openflow: Moving boost-related configuration to main wscript.
There is a problem when two different modules require different boost
libs.  Only requirements of the last module are actually picked up by
the build system.
2012-05-31 16:11:08 -07:00
Alexander Afanasyev c8d890d17c visualizer: Making a periodic topology rescan 2012-05-31 16:11:08 -07:00
Alexander Afanasyev b7874cc528 visualizer: Adding plugin to display a CCNx FIB state 2012-05-31 16:11:08 -07:00
Alexander Afanasyev c26183766b core: Adding inline specifiers for DoMakeAttributeAccessor (there was a
strange duplicate symbols error using apple compiler...)
2012-05-31 16:11:08 -07:00
Alexander Afanasyev 8fd5b780c3 internet: Making rtt-estimator.h of the Internet module accessible to other modules 2012-05-31 15:40:04 -07:00
Alexander Afanasyev 9cb65dfc01 core: Small extension of Vector class (math operations) 2012-05-31 15:40:04 -07:00
Alexander Afanasyev 0d6945be98 topology-read: Making default constructor for TopologyReader::Link public.
This is necessary for some STL containers operations.
2012-05-31 15:40:04 -07:00
Alexander Afanasyev b28ffde9d5 topology-read: TopologyReader and derivatives are no longer Objects
To allow smart pointers, TopologyReader is just inherited from
SimpleRefCount<TopologyReader> class
2012-05-31 15:40:04 -07:00
Alexander Afanasyev d824a1339b topology-read: Several extensions of TopologyReader 2012-05-31 15:40:04 -07:00
Ilya Moiseenko 8cca1f7e34 point-to-point: Add support of PPP->Ethernet and Ethernet->PPP frame type conversion for CCNx protocol
point-to-point: Adding support for CCNx payload in PppHeader::Print method
2012-05-31 15:40:04 -07:00
Alexander Afanasyev cb0af6394c Adding .gitignore 2012-05-31 15:40:04 -07:00
96 changed files with 3211 additions and 1986 deletions

No files matched your search

+49
View File
@@ -0,0 +1,49 @@
*.pyc
.waf*
src/NDNabstraction
build/
doc/html/
doc/latex/
\.rej$
\.orig$
\.o$
~$
^build-dir
^build
^testpy-output
^doc/html
^doc/latex
.lock-wscript
doc/ns3-object.txt
doc/introspected-doxygen.h
.lock-waf_darwin_build
.lock-waf_linux2_build
.lock-waf_cygwin_build
.lock-waf_freebsd7_build
.lock-waf_freebsd8_build
.lock-waf_freebsd9_build
.waf
^doc/introspected-doxygen\.h$
.*\.py[co]$
\.pcap$
\.mob$
\.routes$
^doc/manual/build
^doc/tutorial/build
^doc/testing/build
^doc/models/build
^doc/models/source-temp
^doc/manual/figures/.*eps
^doc/manual/figures/.*pdf
^doc/manual/figures/.*png
^bindings/python/pybindgen/
ms_print.*
massif.*
\.patch$
\.diff$
\.tr$
\#[^\#/]+\#$
.lock-wscript
.lock-wafbuild
*~
\#*\#
+10 -12
View File
@@ -122,24 +122,22 @@ RoutingExperiment::RoutingExperiment ()
std::string
PrintReceivedPacket (Ptr<Socket> socket, Ptr<Packet> packet)
{
SocketAddressTag tag;
bool found;
found = packet->PeekPacketTag (tag);
Ptr<const SocketAddressTag> tag = packet->PeekPacketTag<SocketAddressTag> ();
std::ostringstream oss;
oss << Simulator::Now ().GetSeconds () << " " << socket->GetNode ()->GetId ();
if (found)
{
InetSocketAddress addr = InetSocketAddress::ConvertFrom (tag.GetAddress ());
if (tag != 0)
{
InetSocketAddress addr = InetSocketAddress::ConvertFrom (tag->GetAddress ());
oss << " received one packet from " << addr.GetIpv4 ();
}
else
{
}
else
{
oss << " received one packet!";
}
}
return oss.str ();
}
}
void
RoutingExperiment::ReceivePacket (Ptr<Socket> socket)
@@ -150,7 +148,7 @@ RoutingExperiment::ReceivePacket (Ptr<Socket> socket)
bytesTotal += packet->GetSize ();
packetsReceived += 1;
NS_LOG_UNCOND (PrintReceivedPacket (socket, packet));
}
}
}
void
+7 -8
View File
@@ -352,9 +352,9 @@ RoutingProtocol::RouteOutput (Ptr<Packet> p, const Ipv4Header &header,
// Actual route request will be deferred until packet will be fully formed,
// routed to loopback, received from loopback and passed to RouteInput (see below)
uint32_t iif = (oif ? m_ipv4->GetInterfaceForDevice (oif) : -1);
DeferredRouteOutputTag tag (iif);
if (!p->PeekPacketTag (tag))
if (p->PeekPacketTag<DeferredRouteOutputTag> () == 0)
{
Ptr<DeferredRouteOutputTag> tag = CreateObject<DeferredRouteOutputTag> (iif);
p->AddPacketTag (tag);
}
return LoopbackRoute (header, oif);
@@ -405,8 +405,7 @@ RoutingProtocol::RouteInput (Ptr<const Packet> p, const Ipv4Header &header,
// Deferred route request
if (idev == m_lo)
{
DeferredRouteOutputTag tag;
if (p->PeekPacketTag (tag))
if (p->PeekPacketTag<DeferredRouteOutputTag> () != 0)
{
DeferredRouteOutput (p, header, ucb, ecb);
return true;
@@ -1594,11 +1593,11 @@ RoutingProtocol::SendPacketFromQueue (Ipv4Address dst, Ptr<Ipv4Route> route)
QueueEntry queueEntry;
while (m_queue.Dequeue (dst, queueEntry))
{
DeferredRouteOutputTag tag;
Ptr<Packet> p = ConstCast<Packet> (queueEntry.GetPacket ());
if (p->RemovePacketTag (tag) &&
tag.GetInterface() != -1 &&
tag.GetInterface() != m_ipv4->GetInterfaceForDevice (route->GetOutputDevice ()))
Ptr<const DeferredRouteOutputTag> tag = p->RemovePacketTag<DeferredRouteOutputTag> ();
if (tag != 0 &&
tag->GetInterface() != -1 &&
tag->GetInterface() != m_ipv4->GetInterfaceForDevice (route->GetOutputDevice ()))
{
NS_LOG_DEBUG ("Output device doesn't match. Dropped.");
return;
+2 -2
View File
@@ -211,8 +211,8 @@ void Radvd::Send (Ptr<RadvdInterface> config, Ipv6Address dst, bool reschedule)
/* Router advertisements MUST always have a ttl of 255
* The ttl value should be set as a socket option, but this is not yet implemented
*/
SocketIpTtlTag ttl;
ttl.SetTtl (255);
Ptr<SocketIpTtlTag> ttl = CreateObject<SocketIpTtlTag> ();
ttl->SetTtl (255);
p->AddPacketTag (ttl);
/* send RA */
+6 -6
View File
@@ -199,7 +199,7 @@ private:
}
template <typename W, typename T, typename U, typename V>
Ptr<const AttributeAccessor>
inline Ptr<const AttributeAccessor>
DoMakeAccessorHelperTwo (void (T::*setter)(U),
V (T::*getter)(void) const)
{
@@ -240,7 +240,7 @@ private:
}
template <typename W, typename T, typename U, typename V>
Ptr<const AttributeAccessor>
inline Ptr<const AttributeAccessor>
DoMakeAccessorHelperTwo (V (T::*getter)(void) const,
void (T::*setter)(U))
{
@@ -248,7 +248,7 @@ DoMakeAccessorHelperTwo (V (T::*getter)(void) const,
}
template <typename W, typename T, typename U, typename V>
Ptr<const AttributeAccessor>
inline Ptr<const AttributeAccessor>
DoMakeAccessorHelperTwo (bool (T::*setter)(U),
V (T::*getter)(void) const)
{
@@ -289,7 +289,7 @@ private:
}
template <typename W, typename T, typename U, typename V>
Ptr<const AttributeAccessor>
inline Ptr<const AttributeAccessor>
DoMakeAccessorHelperTwo (bool (T::*getter)(void) const,
void (T::*setter)(U))
{
@@ -297,14 +297,14 @@ DoMakeAccessorHelperTwo (bool (T::*getter)(void) const,
}
template <typename V, typename T1>
Ptr<const AttributeAccessor>
inline Ptr<const AttributeAccessor>
MakeAccessorHelper (T1 a1)
{
return DoMakeAccessorHelperOne<V> (a1);
}
template <typename V, typename T1, typename T2>
Ptr<const AttributeAccessor>
inline Ptr<const AttributeAccessor>
MakeAccessorHelper (T1 a1, T2 a2)
{
return DoMakeAccessorHelperTwo<V> (a1, a2);
+2 -1
View File
@@ -149,7 +149,8 @@ IidManager::AddConstructor (uint16_t uid, ns3::Callback<ns3::ObjectBase *> callb
struct IidInformation *information = LookupInformation (uid);
if (information->hasConstructor)
{
NS_FATAL_ERROR (information->name<<" already has a constructor.");
return;
// NS_FATAL_ERROR (information->name<<" already has a constructor.");
}
information->hasConstructor = true;
information->constructor = callback;
+137
View File
@@ -47,6 +47,68 @@ Vector3D::Vector3D ()
{
}
double
Vector3D::GetLength () const
{
return sqrt (x*x + y*y + z*z);
}
Vector3D&
Vector3D::operator += (const Vector3D &v)
{
x += v.x;
y += v.y;
z += v.z;
return *this;
}
Vector3D&
Vector3D::operator += (double v)
{
x += v;
y += v;
z += v;
return *this;
}
Vector3D
Vector3D::operator + (const Vector3D &v) const
{
return Vector3D (x+v.x, y+v.y, z+v.z);
}
Vector3D
Vector3D::operator + (double v) const
{
return Vector3D (x+v, y+v, z+v);
}
Vector3D
Vector3D::operator * (const Vector3D &v) const
{
return Vector3D (x*v.x, y*v.y, z*v.z);
}
Vector3D
Vector3D::operator * (double v) const
{
return Vector3D (x*v, y*v, z*v);
}
Vector3D
Vector3D::operator - (const Vector3D &v) const
{
return Vector3D (x-v.x, y-v.y, z-v.z);
}
Vector3D
Vector3D::operator / (double div) const
{
return Vector3D (x/div, y/div, z/div);
}
Vector2D::Vector2D (double _x, double _y)
: x (_x),
y (_y)
@@ -59,6 +121,66 @@ Vector2D::Vector2D ()
{
}
double
Vector2D::GetLength () const
{
return sqrt (x*x + y*y);
}
Vector2D&
Vector2D::operator += (const Vector2D &v)
{
x += v.x;
y += v.y;
return *this;
}
Vector2D&
Vector2D::operator += (double v)
{
x += v;
y += v;
return *this;
}
Vector2D
Vector2D::operator + (const Vector2D &v) const
{
return Vector2D (x+v.x, y+v.y);
}
Vector2D
Vector2D::operator + (double v) const
{
return Vector2D (x+v, y+v);
}
Vector2D
Vector2D::operator * (const Vector2D &v) const
{
return Vector2D (x*v.x, y*v.y);
}
Vector2D
Vector2D::operator * (double v) const
{
return Vector2D (x*v, y*v);
}
Vector2D
Vector2D::operator - (const Vector2D &v) const
{
return Vector2D (x-v.x, y-v.y);
}
Vector2D
Vector2D::operator / (double div) const
{
return Vector2D (x/div, y/div);
}
double
CalculateDistance (const Vector3D &a, const Vector3D &b)
{
@@ -77,6 +199,21 @@ CalculateDistance (const Vector2D &a, const Vector2D &b)
return distance;
}
double
ScalarMultiplication (const Vector3D &a, const Vector3D &b)
{
Vector3D tmp = a * b;
return tmp.x + tmp.y + tmp.z;
}
double
ScalarMultiplication (const Vector2D &a, const Vector2D &b)
{
Vector2D tmp = a * b;
return tmp.x + tmp.y;
}
std::ostream &operator << (std::ostream &os, const Vector3D &vector)
{
os << vector.x << ":" << vector.y << ":" << vector.z;
+35
View File
@@ -55,6 +55,17 @@ public:
* z coordinate of vector
*/
double z;
double GetLength () const;
Vector3D& operator += (const Vector3D &);
Vector3D& operator += (double);
Vector3D operator + (const Vector3D &) const;
Vector3D operator + (double) const;
Vector3D operator * (const Vector3D &) const;
Vector3D operator * (double v) const;
Vector3D operator - (const Vector3D &) const;
Vector3D operator / (double) const;
};
/**
@@ -82,6 +93,17 @@ public:
* y coordinate of vector
*/
double y;
double GetLength () const;
Vector2D& operator += (const Vector2D &);
Vector2D& operator += (double);
Vector2D operator + (const Vector2D &) const;
Vector2D operator + (double) const;
Vector2D operator * (const Vector2D &) const;
Vector2D operator * (double v) const;
Vector2D operator - (const Vector2D &) const;
Vector2D operator / (double) const;
};
/**
@@ -98,6 +120,19 @@ double CalculateDistance (const Vector3D &a, const Vector3D &b);
*/
double CalculateDistance (const Vector2D &a, const Vector2D &b);
/**
* \brief Calculate scalar multiplication between two vectors
* \param a one point
* \param b another point
*/
double ScalarMultiplication (const Vector3D &a, const Vector3D &b);
/**
* \brief Calculate scalar multiplication between two vectors
* \param a one point
* \param b another point
*/
double ScalarMultiplication (const Vector2D &a, const Vector2D &b);
/**
* \class ns3::Vector3DValue
* \brief hold objects of type ns3::Vector3D
+6 -8
View File
@@ -317,10 +317,9 @@ RoutingProtocol::RouteOutput (Ptr<Packet> p,
if (EnableBuffering)
{
uint32_t iif = (oif ? m_ipv4->GetInterfaceForDevice (oif) : -1);
DeferredRouteOutputTag tag (iif);
if (!p->PeekPacketTag (tag))
if (p->PeekPacketTag<DeferredRouteOutputTag> () == 0)
{
p->AddPacketTag (tag);
p->AddPacketTag (CreateObject<DeferredRouteOutputTag> (iif));
}
}
return LoopbackRoute (header,oif);
@@ -377,8 +376,7 @@ RoutingProtocol::RouteInput (Ptr<const Packet> p,
// Deferred route request
if (EnableBuffering == true && idev == m_lo)
{
DeferredRouteOutputTag tag;
if (p->PeekPacketTag (tag))
if (p->PeekPacketTag<DeferredRouteOutputTag> () != 0)
{
DeferredRouteOutput (p,header,ucb,ecb);
return true;
@@ -1121,11 +1119,11 @@ RoutingProtocol::SendPacketFromQueue (Ipv4Address dst,
QueueEntry queueEntry;
if (m_queue.Dequeue (dst,queueEntry))
{
DeferredRouteOutputTag tag;
Ptr<Packet> p = ConstCast<Packet> (queueEntry.GetPacket ());
if (p->RemovePacketTag (tag))
Ptr<const DeferredRouteOutputTag> tag = p->RemovePacketTag<DeferredRouteOutputTag> ();
if (tag != 0)
{
if (tag.oif != -1 && tag.oif != m_ipv4->GetInterfaceForDevice (route->GetOutputDevice ()))
if (tag->oif != -1 && tag->oif != m_ipv4->GetInterfaceForDevice (route->GetOutputDevice ()))
{
NS_LOG_DEBUG ("Output device doesn't match. Dropped.");
return;
+10 -13
View File
@@ -204,8 +204,8 @@ Ipv4FlowProbe::SendOutgoingLogger (const Ipv4Header &ipHeader, Ptr<const Packet>
// tag the packet with the flow id and packet id, so that the packet can be identified even
// when Ipv4Header is not accessible at some non-IPv4 protocol layer
Ipv4FlowProbeTag fTag (flowId, packetId, size);
ipPayload->AddPacketTag (fTag);
Ptr<Ipv4FlowProbeTag> fTag = CreateObject<Ipv4FlowProbeTag> (flowId, packetId, size);
ConstCast<Packet> (ipPayload)->AddPacketTag (fTag);
}
}
@@ -233,10 +233,9 @@ Ipv4FlowProbe::ForwardUpLogger (const Ipv4Header &ipHeader, Ptr<const Packet> ip
if (m_classifier->Classify (ipHeader, ipPayload, &flowId, &packetId))
{
// remove the tags that are added by Ipv4FlowProbe::SendOutgoingLogger ()
Ipv4FlowProbeTag fTag;
// ConstCast: see http://www.nsnam.org/bugzilla/show_bug.cgi?id=904
ConstCast<Packet> (ipPayload)->RemovePacketTag (fTag);
ConstCast<Packet> (ipPayload)->RemovePacketTag<Ipv4FlowProbeTag> ();
uint32_t size = (ipPayload->GetSize () + ipHeader.GetSerializedSize ());
NS_LOG_DEBUG ("ReportLastRx ("<<this<<", "<<flowId<<", "<<packetId<<", "<<size<<");");
@@ -272,10 +271,9 @@ Ipv4FlowProbe::DropLogger (const Ipv4Header &ipHeader, Ptr<const Packet> ipPaylo
if (m_classifier->Classify (ipHeader, ipPayload, &flowId, &packetId))
{
// remove the tags that are added by Ipv4FlowProbe::SendOutgoingLogger ()
Ipv4FlowProbeTag fTag;
// ConstCast: see http://www.nsnam.org/bugzilla/show_bug.cgi?id=904
ConstCast<Packet> (ipPayload)->RemovePacketTag (fTag);
ConstCast<Packet> (ipPayload)->RemovePacketTag<Ipv4FlowProbeTag> ();
uint32_t size = (ipPayload->GetSize () + ipHeader.GetSerializedSize ());
NS_LOG_DEBUG ("Drop ("<<this<<", "<<flowId<<", "<<packetId<<", "<<size<<", " << reason
@@ -325,19 +323,18 @@ void
Ipv4FlowProbe::QueueDropLogger (Ptr<const Packet> ipPayload)
{
// remove the tags that are added by Ipv4FlowProbe::SendOutgoingLogger ()
Ipv4FlowProbeTag fTag;
// ConstCast: see http://www.nsnam.org/bugzilla/show_bug.cgi?id=904
bool tagFound;
tagFound = ConstCast<Packet> (ipPayload)->RemovePacketTag (fTag);
if (!tagFound)
Ptr<const Ipv4FlowProbeTag> fTag = ConstCast<Packet> (ipPayload)->RemovePacketTag<Ipv4FlowProbeTag> ();
if (!fTag)
{
return;
}
FlowId flowId = fTag.GetFlowId ();
FlowPacketId packetId = fTag.GetPacketId ();
uint32_t size = fTag.GetPacketSize ();
FlowId flowId = fTag->GetFlowId ();
FlowPacketId packetId = fTag->GetPacketId ();
uint32_t size = fTag->GetPacketSize ();
NS_LOG_DEBUG ("Drop ("<<this<<", "<<flowId<<", "<<packetId<<", "<<size<<", " << DROP_QUEUE
<< "); ");
+128 -84
View File
@@ -110,6 +110,10 @@ def register_types(module):
module.add_class('Ipv4AddressGenerator')
## ipv4-address-helper.h (module 'internet'): ns3::Ipv4AddressHelper [class]
module.add_class('Ipv4AddressHelper')
## trie.h (module 'network'): ns3::Ipv4AddressTrieEAccessTraits [class]
module.add_class('Ipv4AddressTrieEAccessTraits', import_from_module='ns.network')
## trie.h (module 'network'): ns3::Ipv4AddressTrieEAccessTraits [enumeration]
module.add_enum('', ['min_e_val', 'max_e_val', 'max_size'], outer_class=root_module['ns3::Ipv4AddressTrieEAccessTraits'], import_from_module='ns.network')
## ipv4-end-point.h (module 'internet'): ns3::Ipv4EndPoint [class]
module.add_class('Ipv4EndPoint')
## ipv4-interface-address.h (module 'internet'): ns3::Ipv4InterfaceAddress [class]
@@ -322,6 +326,8 @@ def register_types(module):
module.add_class('InternetStackHelper', parent=[root_module['ns3::PcapHelperForIpv4'], root_module['ns3::PcapHelperForIpv6'], root_module['ns3::AsciiTraceHelperForIpv4'], root_module['ns3::AsciiTraceHelperForIpv6']])
## ipv4-global-routing-helper.h (module 'internet'): ns3::Ipv4GlobalRoutingHelper [class]
module.add_class('Ipv4GlobalRoutingHelper', parent=root_module['ns3::Ipv4RoutingHelper'])
## ipv4-global-routing-helper.h (module 'internet'): ns3::Ipv4GlobalRoutingHelper::GlobalRoutingType [enumeration]
module.add_enum('GlobalRoutingType', ['ONE_NEXT_HOP', 'ORDERED_NEXT_HOPS', 'UNORDERED_NEXT_HOPS'], outer_class=root_module['ns3::Ipv4GlobalRoutingHelper'])
## ipv4-header.h (module 'internet'): ns3::Ipv4Header [class]
module.add_class('Ipv4Header', parent=root_module['ns3::Header'])
## ipv4-header.h (module 'internet'): ns3::Ipv4Header::DscpType [enumeration]
@@ -590,6 +596,8 @@ def register_types(module):
module.add_class('Icmpv6L4Protocol', parent=root_module['ns3::IpL4Protocol'])
## ipv4-global-routing.h (module 'internet'): ns3::Ipv4GlobalRouting [class]
module.add_class('Ipv4GlobalRouting', parent=root_module['ns3::Ipv4RoutingProtocol'])
## ipv4-global-routing-one-nexthop.h (module 'internet'): ns3::Ipv4GlobalRoutingOneNexthop [class]
module.add_class('Ipv4GlobalRoutingOneNexthop', parent=root_module['ns3::Ipv4GlobalRouting'])
## ipv4-list-routing.h (module 'internet'): ns3::Ipv4ListRouting [class]
module.add_class('Ipv4ListRouting', parent=root_module['ns3::Ipv4RoutingProtocol'])
## ipv6-list-routing.h (module 'internet'): ns3::Ipv6ListRouting [class]
@@ -651,6 +659,7 @@ def register_methods(root_module):
register_Ns3Ipv4Address_methods(root_module, root_module['ns3::Ipv4Address'])
register_Ns3Ipv4AddressGenerator_methods(root_module, root_module['ns3::Ipv4AddressGenerator'])
register_Ns3Ipv4AddressHelper_methods(root_module, root_module['ns3::Ipv4AddressHelper'])
register_Ns3Ipv4AddressTrieEAccessTraits_methods(root_module, root_module['ns3::Ipv4AddressTrieEAccessTraits'])
register_Ns3Ipv4EndPoint_methods(root_module, root_module['ns3::Ipv4EndPoint'])
register_Ns3Ipv4InterfaceAddress_methods(root_module, root_module['ns3::Ipv4InterfaceAddress'])
register_Ns3Ipv4InterfaceContainer_methods(root_module, root_module['ns3::Ipv4InterfaceContainer'])
@@ -859,6 +868,7 @@ def register_methods(root_module):
register_Ns3Icmpv4L4Protocol_methods(root_module, root_module['ns3::Icmpv4L4Protocol'])
register_Ns3Icmpv6L4Protocol_methods(root_module, root_module['ns3::Icmpv6L4Protocol'])
register_Ns3Ipv4GlobalRouting_methods(root_module, root_module['ns3::Ipv4GlobalRouting'])
register_Ns3Ipv4GlobalRoutingOneNexthop_methods(root_module, root_module['ns3::Ipv4GlobalRoutingOneNexthop'])
register_Ns3Ipv4ListRouting_methods(root_module, root_module['ns3::Ipv4ListRouting'])
register_Ns3Ipv6ListRouting_methods(root_module, root_module['ns3::Ipv6ListRouting'])
register_Ns3LoopbackNetDevice_methods(root_module, root_module['ns3::LoopbackNetDevice'])
@@ -1679,6 +1689,11 @@ def register_Ns3GlobalRouteManager_methods(root_module, cls):
'void',
[],
is_static=True)
## global-route-manager.h (module 'internet'): static void ns3::GlobalRouteManager::ClearLSDB() [member function]
cls.add_method('ClearLSDB',
'void',
[],
is_static=True)
## global-route-manager.h (module 'internet'): static void ns3::GlobalRouteManager::BuildGlobalRoutingDatabase() [member function]
cls.add_method('BuildGlobalRoutingDatabase',
'void',
@@ -1699,6 +1714,11 @@ def register_Ns3GlobalRouteManagerImpl_methods(root_module, cls):
'void',
[],
is_virtual=True)
## global-route-manager-impl.h (module 'internet'): void ns3::GlobalRouteManagerImpl::ClearLSDB() [member function]
cls.add_method('ClearLSDB',
'void',
[],
is_virtual=True)
## global-route-manager-impl.h (module 'internet'): void ns3::GlobalRouteManagerImpl::BuildGlobalRoutingDatabase() [member function]
cls.add_method('BuildGlobalRoutingDatabase',
'void',
@@ -1984,9 +2004,9 @@ def register_Ns3Ipv4Address_methods(root_module, cls):
'ns3::Ipv4Address',
[param('uint8_t const *', 'buf')],
is_static=True)
## ipv4-address.h (module 'network'): uint32_t ns3::Ipv4Address::Get() const [member function]
## ipv4-address.h (module 'network'): uint32_t const & ns3::Ipv4Address::Get() const [member function]
cls.add_method('Get',
'uint32_t',
'uint32_t const &',
[],
is_const=True)
## ipv4-address.h (module 'network'): static ns3::Ipv4Address ns3::Ipv4Address::GetAny() [member function]
@@ -2141,6 +2161,28 @@ def register_Ns3Ipv4AddressHelper_methods(root_module, cls):
[param('ns3::Ipv4Address', 'network'), param('ns3::Ipv4Mask', 'mask'), param('ns3::Ipv4Address', 'base', default_value='"0.0.0.1"')])
return
def register_Ns3Ipv4AddressTrieEAccessTraits_methods(root_module, cls):
## trie.h (module 'network'): ns3::Ipv4AddressTrieEAccessTraits::Ipv4AddressTrieEAccessTraits() [constructor]
cls.add_constructor([])
## trie.h (module 'network'): ns3::Ipv4AddressTrieEAccessTraits::Ipv4AddressTrieEAccessTraits(ns3::Ipv4AddressTrieEAccessTraits const & arg0) [copy constructor]
cls.add_constructor([param('ns3::Ipv4AddressTrieEAccessTraits const &', 'arg0')])
## trie.h (module 'network'): static uint8_t const * ns3::Ipv4AddressTrieEAccessTraits::begin(ns3::Ipv4Address const & r_key) [member function]
cls.add_method('begin',
'uint8_t const *',
[param('ns3::Ipv4Address const &', 'r_key')],
is_static=True)
## trie.h (module 'network'): static size_t ns3::Ipv4AddressTrieEAccessTraits::e_pos(uint8_t e) [member function]
cls.add_method('e_pos',
'size_t',
[param('uint8_t', 'e')],
is_static=True)
## trie.h (module 'network'): static uint8_t const * ns3::Ipv4AddressTrieEAccessTraits::end(ns3::Ipv4Address const & r_key) [member function]
cls.add_method('end',
'uint8_t const *',
[param('ns3::Ipv4Address const &', 'r_key')],
is_static=True)
return
def register_Ns3Ipv4EndPoint_methods(root_module, cls):
## ipv4-end-point.h (module 'internet'): ns3::Ipv4EndPoint::Ipv4EndPoint(ns3::Ipv4EndPoint const & arg0) [copy constructor]
cls.add_constructor([param('ns3::Ipv4EndPoint const &', 'arg0')])
@@ -2466,30 +2508,30 @@ def register_Ns3Ipv4RoutingTableEntry_methods(root_module, cls):
cls.add_constructor([param('ns3::Ipv4RoutingTableEntry const &', 'route')])
## ipv4-routing-table-entry.h (module 'internet'): ns3::Ipv4RoutingTableEntry::Ipv4RoutingTableEntry(ns3::Ipv4RoutingTableEntry const * route) [constructor]
cls.add_constructor([param('ns3::Ipv4RoutingTableEntry const *', 'route')])
## ipv4-routing-table-entry.h (module 'internet'): static ns3::Ipv4RoutingTableEntry ns3::Ipv4RoutingTableEntry::CreateDefaultRoute(ns3::Ipv4Address nextHop, uint32_t interface) [member function]
## ipv4-routing-table-entry.h (module 'internet'): static ns3::Ipv4RoutingTableEntry ns3::Ipv4RoutingTableEntry::CreateDefaultRoute(ns3::Ipv4Address nextHop, uint32_t interface, uint32_t metric=0) [member function]
cls.add_method('CreateDefaultRoute',
'ns3::Ipv4RoutingTableEntry',
[param('ns3::Ipv4Address', 'nextHop'), param('uint32_t', 'interface')],
[param('ns3::Ipv4Address', 'nextHop'), param('uint32_t', 'interface'), param('uint32_t', 'metric', default_value='0')],
is_static=True)
## ipv4-routing-table-entry.h (module 'internet'): static ns3::Ipv4RoutingTableEntry ns3::Ipv4RoutingTableEntry::CreateHostRouteTo(ns3::Ipv4Address dest, ns3::Ipv4Address nextHop, uint32_t interface) [member function]
## ipv4-routing-table-entry.h (module 'internet'): static ns3::Ipv4RoutingTableEntry ns3::Ipv4RoutingTableEntry::CreateHostRouteTo(ns3::Ipv4Address dest, ns3::Ipv4Address nextHop, uint32_t interface, uint32_t metric=0) [member function]
cls.add_method('CreateHostRouteTo',
'ns3::Ipv4RoutingTableEntry',
[param('ns3::Ipv4Address', 'dest'), param('ns3::Ipv4Address', 'nextHop'), param('uint32_t', 'interface')],
[param('ns3::Ipv4Address', 'dest'), param('ns3::Ipv4Address', 'nextHop'), param('uint32_t', 'interface'), param('uint32_t', 'metric', default_value='0')],
is_static=True)
## ipv4-routing-table-entry.h (module 'internet'): static ns3::Ipv4RoutingTableEntry ns3::Ipv4RoutingTableEntry::CreateHostRouteTo(ns3::Ipv4Address dest, uint32_t interface) [member function]
## ipv4-routing-table-entry.h (module 'internet'): static ns3::Ipv4RoutingTableEntry ns3::Ipv4RoutingTableEntry::CreateHostRouteTo(ns3::Ipv4Address dest, uint32_t interface, uint32_t metric=0) [member function]
cls.add_method('CreateHostRouteTo',
'ns3::Ipv4RoutingTableEntry',
[param('ns3::Ipv4Address', 'dest'), param('uint32_t', 'interface')],
[param('ns3::Ipv4Address', 'dest'), param('uint32_t', 'interface'), param('uint32_t', 'metric', default_value='0')],
is_static=True)
## ipv4-routing-table-entry.h (module 'internet'): static ns3::Ipv4RoutingTableEntry ns3::Ipv4RoutingTableEntry::CreateNetworkRouteTo(ns3::Ipv4Address network, ns3::Ipv4Mask networkMask, ns3::Ipv4Address nextHop, uint32_t interface) [member function]
## ipv4-routing-table-entry.h (module 'internet'): static ns3::Ipv4RoutingTableEntry ns3::Ipv4RoutingTableEntry::CreateNetworkRouteTo(ns3::Ipv4Address network, ns3::Ipv4Mask networkMask, ns3::Ipv4Address nextHop, uint32_t interface, uint32_t metric=0) [member function]
cls.add_method('CreateNetworkRouteTo',
'ns3::Ipv4RoutingTableEntry',
[param('ns3::Ipv4Address', 'network'), param('ns3::Ipv4Mask', 'networkMask'), param('ns3::Ipv4Address', 'nextHop'), param('uint32_t', 'interface')],
[param('ns3::Ipv4Address', 'network'), param('ns3::Ipv4Mask', 'networkMask'), param('ns3::Ipv4Address', 'nextHop'), param('uint32_t', 'interface'), param('uint32_t', 'metric', default_value='0')],
is_static=True)
## ipv4-routing-table-entry.h (module 'internet'): static ns3::Ipv4RoutingTableEntry ns3::Ipv4RoutingTableEntry::CreateNetworkRouteTo(ns3::Ipv4Address network, ns3::Ipv4Mask networkMask, uint32_t interface) [member function]
## ipv4-routing-table-entry.h (module 'internet'): static ns3::Ipv4RoutingTableEntry ns3::Ipv4RoutingTableEntry::CreateNetworkRouteTo(ns3::Ipv4Address network, ns3::Ipv4Mask networkMask, uint32_t interface, uint32_t metric=0) [member function]
cls.add_method('CreateNetworkRouteTo',
'ns3::Ipv4RoutingTableEntry',
[param('ns3::Ipv4Address', 'network'), param('ns3::Ipv4Mask', 'networkMask'), param('uint32_t', 'interface')],
[param('ns3::Ipv4Address', 'network'), param('ns3::Ipv4Mask', 'networkMask'), param('uint32_t', 'interface'), param('uint32_t', 'metric', default_value='0')],
is_static=True)
## ipv4-routing-table-entry.h (module 'internet'): ns3::Ipv4Address ns3::Ipv4RoutingTableEntry::GetDest() const [member function]
cls.add_method('GetDest',
@@ -2516,6 +2558,11 @@ def register_Ns3Ipv4RoutingTableEntry_methods(root_module, cls):
'uint32_t',
[],
is_const=True)
## ipv4-routing-table-entry.h (module 'internet'): uint32_t ns3::Ipv4RoutingTableEntry::GetMetric() const [member function]
cls.add_method('GetMetric',
'uint32_t',
[],
is_const=True)
## ipv4-routing-table-entry.h (module 'internet'): bool ns3::Ipv4RoutingTableEntry::IsDefault() const [member function]
cls.add_method('IsDefault',
'bool',
@@ -2536,6 +2583,10 @@ def register_Ns3Ipv4RoutingTableEntry_methods(root_module, cls):
'bool',
[],
is_const=True)
## ipv4-routing-table-entry.h (module 'internet'): void ns3::Ipv4RoutingTableEntry::SetMetric(uint32_t metric) [member function]
cls.add_method('SetMetric',
'void',
[param('uint32_t', 'metric')])
return
def register_Ns3Ipv4StaticRoutingHelper_methods(root_module, cls):
@@ -6130,8 +6181,8 @@ def register_Ns3InternetStackHelper_methods(root_module, cls):
return
def register_Ns3Ipv4GlobalRoutingHelper_methods(root_module, cls):
## ipv4-global-routing-helper.h (module 'internet'): ns3::Ipv4GlobalRoutingHelper::Ipv4GlobalRoutingHelper() [constructor]
cls.add_constructor([])
## ipv4-global-routing-helper.h (module 'internet'): ns3::Ipv4GlobalRoutingHelper::Ipv4GlobalRoutingHelper(std::string const & type="ns3::Ipv4GlobalRoutingOneNexthop") [constructor]
cls.add_constructor([param('std::string const &', 'type', default_value='"ns3::Ipv4GlobalRoutingOneNexthop"')])
## ipv4-global-routing-helper.h (module 'internet'): ns3::Ipv4GlobalRoutingHelper::Ipv4GlobalRoutingHelper(ns3::Ipv4GlobalRoutingHelper const & arg0) [copy constructor]
cls.add_constructor([param('ns3::Ipv4GlobalRoutingHelper const &', 'arg0')])
## ipv4-global-routing-helper.h (module 'internet'): ns3::Ipv4GlobalRoutingHelper * ns3::Ipv4GlobalRoutingHelper::Copy() const [member function]
@@ -6149,6 +6200,11 @@ def register_Ns3Ipv4GlobalRoutingHelper_methods(root_module, cls):
'void',
[],
is_static=True)
## ipv4-global-routing-helper.h (module 'internet'): static void ns3::Ipv4GlobalRoutingHelper::PopulateAllPossibleRoutingTables() [member function]
cls.add_method('PopulateAllPossibleRoutingTables',
'void',
[],
is_static=True)
## ipv4-global-routing-helper.h (module 'internet'): static void ns3::Ipv4GlobalRoutingHelper::RecomputeRoutingTables() [member function]
cls.add_method('RecomputeRoutingTables',
'void',
@@ -8876,14 +8932,6 @@ def register_Ns3GlobalRouter_methods(root_module, cls):
is_static=True)
## global-router-interface.h (module 'internet'): ns3::GlobalRouter::GlobalRouter() [constructor]
cls.add_constructor([])
## global-router-interface.h (module 'internet'): void ns3::GlobalRouter::SetRoutingProtocol(ns3::Ptr<ns3::Ipv4GlobalRouting> routing) [member function]
cls.add_method('SetRoutingProtocol',
'void',
[param('ns3::Ptr< ns3::Ipv4GlobalRouting >', 'routing')])
## global-router-interface.h (module 'internet'): ns3::Ptr<ns3::Ipv4GlobalRouting> ns3::GlobalRouter::GetRoutingProtocol() [member function]
cls.add_method('GetRoutingProtocol',
'ns3::Ptr< ns3::Ipv4GlobalRouting >',
[])
## global-router-interface.h (module 'internet'): ns3::Ipv4Address ns3::GlobalRouter::GetRouterId() const [member function]
cls.add_method('GetRouterId',
'ns3::Ipv4Address',
@@ -8903,22 +8951,10 @@ def register_Ns3GlobalRouter_methods(root_module, cls):
'bool',
[param('uint32_t', 'n'), param('ns3::GlobalRoutingLSA &', 'lsa')],
is_const=True)
## global-router-interface.h (module 'internet'): void ns3::GlobalRouter::InjectRoute(ns3::Ipv4Address network, ns3::Ipv4Mask networkMask) [member function]
## global-router-interface.h (module 'internet'): void ns3::GlobalRouter::InjectRoute(ns3::Ipv4Address network, ns3::Ipv4Mask networkMask, uint32_t metric=1) [member function]
cls.add_method('InjectRoute',
'void',
[param('ns3::Ipv4Address', 'network'), param('ns3::Ipv4Mask', 'networkMask')])
## global-router-interface.h (module 'internet'): uint32_t ns3::GlobalRouter::GetNInjectedRoutes() [member function]
cls.add_method('GetNInjectedRoutes',
'uint32_t',
[])
## global-router-interface.h (module 'internet'): ns3::Ipv4RoutingTableEntry * ns3::GlobalRouter::GetInjectedRoute(uint32_t i) [member function]
cls.add_method('GetInjectedRoute',
retval('ns3::Ipv4RoutingTableEntry *', caller_owns_return=False),
[param('uint32_t', 'i')])
## global-router-interface.h (module 'internet'): void ns3::GlobalRouter::RemoveInjectedRoute(uint32_t i) [member function]
cls.add_method('RemoveInjectedRoute',
'void',
[param('uint32_t', 'i')])
[param('ns3::Ipv4Address', 'network'), param('ns3::Ipv4Mask', 'networkMask'), param('uint32_t', 'metric', default_value='1')])
## global-router-interface.h (module 'internet'): bool ns3::GlobalRouter::WithdrawRoute(ns3::Ipv4Address network, ns3::Ipv4Mask networkMask) [member function]
cls.add_method('WithdrawRoute',
'bool',
@@ -12799,36 +12835,16 @@ def register_Ns3Ipv4GlobalRouting_methods(root_module, cls):
cls.add_constructor([param('ns3::Ipv4GlobalRouting const &', 'arg0')])
## ipv4-global-routing.h (module 'internet'): ns3::Ipv4GlobalRouting::Ipv4GlobalRouting() [constructor]
cls.add_constructor([])
## ipv4-global-routing.h (module 'internet'): void ns3::Ipv4GlobalRouting::AddASExternalRouteTo(ns3::Ipv4Address network, ns3::Ipv4Mask networkMask, ns3::Ipv4Address nextHop, uint32_t interface) [member function]
cls.add_method('AddASExternalRouteTo',
## ipv4-global-routing.h (module 'internet'): void ns3::Ipv4GlobalRouting::AddRouteTo(ns3::Ipv4Address dest, ns3::Ipv4Mask destMask, ns3::Ipv4Address nextHop, uint32_t interface, uint32_t metric=0) [member function]
cls.add_method('AddRouteTo',
'void',
[param('ns3::Ipv4Address', 'network'), param('ns3::Ipv4Mask', 'networkMask'), param('ns3::Ipv4Address', 'nextHop'), param('uint32_t', 'interface')])
## ipv4-global-routing.h (module 'internet'): void ns3::Ipv4GlobalRouting::AddHostRouteTo(ns3::Ipv4Address dest, ns3::Ipv4Address nextHop, uint32_t interface) [member function]
cls.add_method('AddHostRouteTo',
[param('ns3::Ipv4Address', 'dest'), param('ns3::Ipv4Mask', 'destMask'), param('ns3::Ipv4Address', 'nextHop'), param('uint32_t', 'interface'), param('uint32_t', 'metric', default_value='0')],
is_pure_virtual=True, is_virtual=True)
## ipv4-global-routing.h (module 'internet'): void ns3::Ipv4GlobalRouting::DeleteRoutes() [member function]
cls.add_method('DeleteRoutes',
'void',
[param('ns3::Ipv4Address', 'dest'), param('ns3::Ipv4Address', 'nextHop'), param('uint32_t', 'interface')])
## ipv4-global-routing.h (module 'internet'): void ns3::Ipv4GlobalRouting::AddHostRouteTo(ns3::Ipv4Address dest, uint32_t interface) [member function]
cls.add_method('AddHostRouteTo',
'void',
[param('ns3::Ipv4Address', 'dest'), param('uint32_t', 'interface')])
## ipv4-global-routing.h (module 'internet'): void ns3::Ipv4GlobalRouting::AddNetworkRouteTo(ns3::Ipv4Address network, ns3::Ipv4Mask networkMask, ns3::Ipv4Address nextHop, uint32_t interface) [member function]
cls.add_method('AddNetworkRouteTo',
'void',
[param('ns3::Ipv4Address', 'network'), param('ns3::Ipv4Mask', 'networkMask'), param('ns3::Ipv4Address', 'nextHop'), param('uint32_t', 'interface')])
## ipv4-global-routing.h (module 'internet'): void ns3::Ipv4GlobalRouting::AddNetworkRouteTo(ns3::Ipv4Address network, ns3::Ipv4Mask networkMask, uint32_t interface) [member function]
cls.add_method('AddNetworkRouteTo',
'void',
[param('ns3::Ipv4Address', 'network'), param('ns3::Ipv4Mask', 'networkMask'), param('uint32_t', 'interface')])
## ipv4-global-routing.h (module 'internet'): uint32_t ns3::Ipv4GlobalRouting::GetNRoutes() const [member function]
cls.add_method('GetNRoutes',
'uint32_t',
[],
is_const=True)
## ipv4-global-routing.h (module 'internet'): ns3::Ipv4RoutingTableEntry * ns3::Ipv4GlobalRouting::GetRoute(uint32_t i) const [member function]
cls.add_method('GetRoute',
retval('ns3::Ipv4RoutingTableEntry *', caller_owns_return=False),
[param('uint32_t', 'i')],
is_const=True)
is_pure_virtual=True, is_virtual=True)
## ipv4-global-routing.h (module 'internet'): static ns3::TypeId ns3::Ipv4GlobalRouting::GetTypeId() [member function]
cls.add_method('GetTypeId',
'ns3::TypeId',
@@ -12854,34 +12870,62 @@ def register_Ns3Ipv4GlobalRouting_methods(root_module, cls):
'void',
[param('uint32_t', 'interface'), param('ns3::Ipv4InterfaceAddress', 'address')],
is_virtual=True)
## ipv4-global-routing.h (module 'internet'): void ns3::Ipv4GlobalRouting::PrintRoutingTable(ns3::Ptr<ns3::OutputStreamWrapper> stream) const [member function]
cls.add_method('PrintRoutingTable',
'void',
[param('ns3::Ptr< ns3::OutputStreamWrapper >', 'stream')],
is_const=True, is_virtual=True)
## ipv4-global-routing.h (module 'internet'): void ns3::Ipv4GlobalRouting::RemoveRoute(uint32_t i) [member function]
cls.add_method('RemoveRoute',
'void',
[param('uint32_t', 'i')])
## ipv4-global-routing.h (module 'internet'): bool ns3::Ipv4GlobalRouting::RouteInput(ns3::Ptr<const ns3::Packet> p, ns3::Ipv4Header const & header, ns3::Ptr<const ns3::NetDevice> idev, ns3::Callback<void,ns3::Ptr<ns3::Ipv4Route>,ns3::Ptr<const ns3::Packet>,const ns3::Ipv4Header&,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty> ucb, ns3::Callback<void,ns3::Ptr<ns3::Ipv4MulticastRoute>,ns3::Ptr<const ns3::Packet>,const ns3::Ipv4Header&,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty> mcb, ns3::Callback<void,ns3::Ptr<const ns3::Packet>,const ns3::Ipv4Header&,unsigned int,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty> lcb, ns3::Callback<void,ns3::Ptr<const ns3::Packet>,const ns3::Ipv4Header&,ns3::Socket::SocketErrno,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty> ecb) [member function]
cls.add_method('RouteInput',
'bool',
[param('ns3::Ptr< ns3::Packet const >', 'p'), param('ns3::Ipv4Header const &', 'header'), param('ns3::Ptr< ns3::NetDevice const >', 'idev'), param('ns3::Callback< void, ns3::Ptr< ns3::Ipv4Route >, ns3::Ptr< ns3::Packet const >, ns3::Ipv4Header const &, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'ucb'), param('ns3::Callback< void, ns3::Ptr< ns3::Ipv4MulticastRoute >, ns3::Ptr< ns3::Packet const >, ns3::Ipv4Header const &, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'mcb'), param('ns3::Callback< void, ns3::Ptr< ns3::Packet const >, ns3::Ipv4Header const &, unsigned int, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'lcb'), param('ns3::Callback< void, ns3::Ptr< ns3::Packet const >, ns3::Ipv4Header const &, ns3::Socket::SocketErrno, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'ecb')],
is_virtual=True)
## ipv4-global-routing.h (module 'internet'): ns3::Ptr<ns3::Ipv4Route> ns3::Ipv4GlobalRouting::RouteOutput(ns3::Ptr<ns3::Packet> p, ns3::Ipv4Header const & header, ns3::Ptr<ns3::NetDevice> oif, ns3::Socket::SocketErrno & sockerr) [member function]
cls.add_method('RouteOutput',
'ns3::Ptr< ns3::Ipv4Route >',
[param('ns3::Ptr< ns3::Packet >', 'p'), param('ns3::Ipv4Header const &', 'header'), param('ns3::Ptr< ns3::NetDevice >', 'oif'), param('ns3::Socket::SocketErrno &', 'sockerr')],
is_virtual=True)
## ipv4-global-routing.h (module 'internet'): void ns3::Ipv4GlobalRouting::SetIpv4(ns3::Ptr<ns3::Ipv4> ipv4) [member function]
cls.add_method('SetIpv4',
'void',
[param('ns3::Ptr< ns3::Ipv4 >', 'ipv4')],
is_virtual=True)
## ipv4-global-routing.h (module 'internet'): void ns3::Ipv4GlobalRouting::DoDispose() [member function]
cls.add_method('DoDispose',
return
def register_Ns3Ipv4GlobalRoutingOneNexthop_methods(root_module, cls):
## ipv4-global-routing-one-nexthop.h (module 'internet'): ns3::Ipv4GlobalRoutingOneNexthop::Ipv4GlobalRoutingOneNexthop() [constructor]
cls.add_constructor([])
## ipv4-global-routing-one-nexthop.h (module 'internet'): ns3::Ipv4GlobalRoutingOneNexthop::Ipv4GlobalRoutingOneNexthop(ns3::Ipv4GlobalRoutingOneNexthop const & arg0) [copy constructor]
cls.add_constructor([param('ns3::Ipv4GlobalRoutingOneNexthop const &', 'arg0')])
## ipv4-global-routing-one-nexthop.h (module 'internet'): void ns3::Ipv4GlobalRoutingOneNexthop::AddRouteTo(ns3::Ipv4Address dest, ns3::Ipv4Mask destMask, ns3::Ipv4Address nextHop, uint32_t interface, uint32_t metric=0) [member function]
cls.add_method('AddRouteTo',
'void',
[param('ns3::Ipv4Address', 'dest'), param('ns3::Ipv4Mask', 'destMask'), param('ns3::Ipv4Address', 'nextHop'), param('uint32_t', 'interface'), param('uint32_t', 'metric', default_value='0')],
is_virtual=True)
## ipv4-global-routing-one-nexthop.h (module 'internet'): void ns3::Ipv4GlobalRoutingOneNexthop::DeleteRoutes() [member function]
cls.add_method('DeleteRoutes',
'void',
[],
is_virtual=True)
## ipv4-global-routing-one-nexthop.h (module 'internet'): uint32_t ns3::Ipv4GlobalRoutingOneNexthop::GetNRoutes() const [member function]
cls.add_method('GetNRoutes',
'uint32_t',
[],
is_const=True)
## ipv4-global-routing-one-nexthop.h (module 'internet'): ns3::Ipv4RoutingTableEntry ns3::Ipv4GlobalRoutingOneNexthop::GetRoute(uint32_t i) const [member function]
cls.add_method('GetRoute',
'ns3::Ipv4RoutingTableEntry',
[param('uint32_t', 'i')],
is_const=True)
## ipv4-global-routing-one-nexthop.h (module 'internet'): static ns3::TypeId ns3::Ipv4GlobalRoutingOneNexthop::GetTypeId() [member function]
cls.add_method('GetTypeId',
'ns3::TypeId',
[],
is_static=True)
## ipv4-global-routing-one-nexthop.h (module 'internet'): void ns3::Ipv4GlobalRoutingOneNexthop::PrintRoutingTable(ns3::Ptr<ns3::OutputStreamWrapper> stream) const [member function]
cls.add_method('PrintRoutingTable',
'void',
[param('ns3::Ptr< ns3::OutputStreamWrapper >', 'stream')],
is_const=True, is_virtual=True)
## ipv4-global-routing-one-nexthop.h (module 'internet'): bool ns3::Ipv4GlobalRoutingOneNexthop::RouteInput(ns3::Ptr<const ns3::Packet> p, ns3::Ipv4Header const & header, ns3::Ptr<const ns3::NetDevice> idev, ns3::Callback<void,ns3::Ptr<ns3::Ipv4Route>,ns3::Ptr<const ns3::Packet>,const ns3::Ipv4Header&,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty> ucb, ns3::Callback<void,ns3::Ptr<ns3::Ipv4MulticastRoute>,ns3::Ptr<const ns3::Packet>,const ns3::Ipv4Header&,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty> mcb, ns3::Callback<void,ns3::Ptr<const ns3::Packet>,const ns3::Ipv4Header&,unsigned int,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty> lcb, ns3::Callback<void,ns3::Ptr<const ns3::Packet>,const ns3::Ipv4Header&,ns3::Socket::SocketErrno,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty> ecb) [member function]
cls.add_method('RouteInput',
'bool',
[param('ns3::Ptr< ns3::Packet const >', 'p'), param('ns3::Ipv4Header const &', 'header'), param('ns3::Ptr< ns3::NetDevice const >', 'idev'), param('ns3::Callback< void, ns3::Ptr< ns3::Ipv4Route >, ns3::Ptr< ns3::Packet const >, ns3::Ipv4Header const &, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'ucb'), param('ns3::Callback< void, ns3::Ptr< ns3::Ipv4MulticastRoute >, ns3::Ptr< ns3::Packet const >, ns3::Ipv4Header const &, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'mcb'), param('ns3::Callback< void, ns3::Ptr< ns3::Packet const >, ns3::Ipv4Header const &, unsigned int, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'lcb'), param('ns3::Callback< void, ns3::Ptr< ns3::Packet const >, ns3::Ipv4Header const &, ns3::Socket::SocketErrno, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'ecb')],
is_virtual=True)
## ipv4-global-routing-one-nexthop.h (module 'internet'): ns3::Ptr<ns3::Ipv4Route> ns3::Ipv4GlobalRoutingOneNexthop::RouteOutput(ns3::Ptr<ns3::Packet> p, ns3::Ipv4Header const & header, ns3::Ptr<ns3::NetDevice> oif, ns3::Socket::SocketErrno & sockerr) [member function]
cls.add_method('RouteOutput',
'ns3::Ptr< ns3::Ipv4Route >',
[param('ns3::Ptr< ns3::Packet >', 'p'), param('ns3::Ipv4Header const &', 'header'), param('ns3::Ptr< ns3::NetDevice >', 'oif'), param('ns3::Socket::SocketErrno &', 'sockerr')],
is_virtual=True)
## ipv4-global-routing-one-nexthop.h (module 'internet'): ns3::Ptr<ns3::Ipv4Route> ns3::Ipv4GlobalRoutingOneNexthop::LookupGlobal(ns3::Ipv4Address dest, ns3::Ptr<ns3::NetDevice> oif=0) [member function]
cls.add_method('LookupGlobal',
'ns3::Ptr< ns3::Ipv4Route >',
[param('ns3::Ipv4Address', 'dest'), param('ns3::Ptr< ns3::NetDevice >', 'oif', default_value='0')],
visibility='protected', is_virtual=True)
return
+128 -84
View File
@@ -110,6 +110,10 @@ def register_types(module):
module.add_class('Ipv4AddressGenerator')
## ipv4-address-helper.h (module 'internet'): ns3::Ipv4AddressHelper [class]
module.add_class('Ipv4AddressHelper')
## trie.h (module 'network'): ns3::Ipv4AddressTrieEAccessTraits [class]
module.add_class('Ipv4AddressTrieEAccessTraits', import_from_module='ns.network')
## trie.h (module 'network'): ns3::Ipv4AddressTrieEAccessTraits [enumeration]
module.add_enum('', ['min_e_val', 'max_e_val', 'max_size'], outer_class=root_module['ns3::Ipv4AddressTrieEAccessTraits'], import_from_module='ns.network')
## ipv4-end-point.h (module 'internet'): ns3::Ipv4EndPoint [class]
module.add_class('Ipv4EndPoint')
## ipv4-interface-address.h (module 'internet'): ns3::Ipv4InterfaceAddress [class]
@@ -322,6 +326,8 @@ def register_types(module):
module.add_class('InternetStackHelper', parent=[root_module['ns3::PcapHelperForIpv4'], root_module['ns3::PcapHelperForIpv6'], root_module['ns3::AsciiTraceHelperForIpv4'], root_module['ns3::AsciiTraceHelperForIpv6']])
## ipv4-global-routing-helper.h (module 'internet'): ns3::Ipv4GlobalRoutingHelper [class]
module.add_class('Ipv4GlobalRoutingHelper', parent=root_module['ns3::Ipv4RoutingHelper'])
## ipv4-global-routing-helper.h (module 'internet'): ns3::Ipv4GlobalRoutingHelper::GlobalRoutingType [enumeration]
module.add_enum('GlobalRoutingType', ['ONE_NEXT_HOP', 'ORDERED_NEXT_HOPS', 'UNORDERED_NEXT_HOPS'], outer_class=root_module['ns3::Ipv4GlobalRoutingHelper'])
## ipv4-header.h (module 'internet'): ns3::Ipv4Header [class]
module.add_class('Ipv4Header', parent=root_module['ns3::Header'])
## ipv4-header.h (module 'internet'): ns3::Ipv4Header::DscpType [enumeration]
@@ -590,6 +596,8 @@ def register_types(module):
module.add_class('Icmpv6L4Protocol', parent=root_module['ns3::IpL4Protocol'])
## ipv4-global-routing.h (module 'internet'): ns3::Ipv4GlobalRouting [class]
module.add_class('Ipv4GlobalRouting', parent=root_module['ns3::Ipv4RoutingProtocol'])
## ipv4-global-routing-one-nexthop.h (module 'internet'): ns3::Ipv4GlobalRoutingOneNexthop [class]
module.add_class('Ipv4GlobalRoutingOneNexthop', parent=root_module['ns3::Ipv4GlobalRouting'])
## ipv4-list-routing.h (module 'internet'): ns3::Ipv4ListRouting [class]
module.add_class('Ipv4ListRouting', parent=root_module['ns3::Ipv4RoutingProtocol'])
## ipv6-list-routing.h (module 'internet'): ns3::Ipv6ListRouting [class]
@@ -651,6 +659,7 @@ def register_methods(root_module):
register_Ns3Ipv4Address_methods(root_module, root_module['ns3::Ipv4Address'])
register_Ns3Ipv4AddressGenerator_methods(root_module, root_module['ns3::Ipv4AddressGenerator'])
register_Ns3Ipv4AddressHelper_methods(root_module, root_module['ns3::Ipv4AddressHelper'])
register_Ns3Ipv4AddressTrieEAccessTraits_methods(root_module, root_module['ns3::Ipv4AddressTrieEAccessTraits'])
register_Ns3Ipv4EndPoint_methods(root_module, root_module['ns3::Ipv4EndPoint'])
register_Ns3Ipv4InterfaceAddress_methods(root_module, root_module['ns3::Ipv4InterfaceAddress'])
register_Ns3Ipv4InterfaceContainer_methods(root_module, root_module['ns3::Ipv4InterfaceContainer'])
@@ -859,6 +868,7 @@ def register_methods(root_module):
register_Ns3Icmpv4L4Protocol_methods(root_module, root_module['ns3::Icmpv4L4Protocol'])
register_Ns3Icmpv6L4Protocol_methods(root_module, root_module['ns3::Icmpv6L4Protocol'])
register_Ns3Ipv4GlobalRouting_methods(root_module, root_module['ns3::Ipv4GlobalRouting'])
register_Ns3Ipv4GlobalRoutingOneNexthop_methods(root_module, root_module['ns3::Ipv4GlobalRoutingOneNexthop'])
register_Ns3Ipv4ListRouting_methods(root_module, root_module['ns3::Ipv4ListRouting'])
register_Ns3Ipv6ListRouting_methods(root_module, root_module['ns3::Ipv6ListRouting'])
register_Ns3LoopbackNetDevice_methods(root_module, root_module['ns3::LoopbackNetDevice'])
@@ -1679,6 +1689,11 @@ def register_Ns3GlobalRouteManager_methods(root_module, cls):
'void',
[],
is_static=True)
## global-route-manager.h (module 'internet'): static void ns3::GlobalRouteManager::ClearLSDB() [member function]
cls.add_method('ClearLSDB',
'void',
[],
is_static=True)
## global-route-manager.h (module 'internet'): static void ns3::GlobalRouteManager::BuildGlobalRoutingDatabase() [member function]
cls.add_method('BuildGlobalRoutingDatabase',
'void',
@@ -1699,6 +1714,11 @@ def register_Ns3GlobalRouteManagerImpl_methods(root_module, cls):
'void',
[],
is_virtual=True)
## global-route-manager-impl.h (module 'internet'): void ns3::GlobalRouteManagerImpl::ClearLSDB() [member function]
cls.add_method('ClearLSDB',
'void',
[],
is_virtual=True)
## global-route-manager-impl.h (module 'internet'): void ns3::GlobalRouteManagerImpl::BuildGlobalRoutingDatabase() [member function]
cls.add_method('BuildGlobalRoutingDatabase',
'void',
@@ -1984,9 +2004,9 @@ def register_Ns3Ipv4Address_methods(root_module, cls):
'ns3::Ipv4Address',
[param('uint8_t const *', 'buf')],
is_static=True)
## ipv4-address.h (module 'network'): uint32_t ns3::Ipv4Address::Get() const [member function]
## ipv4-address.h (module 'network'): uint32_t const & ns3::Ipv4Address::Get() const [member function]
cls.add_method('Get',
'uint32_t',
'uint32_t const &',
[],
is_const=True)
## ipv4-address.h (module 'network'): static ns3::Ipv4Address ns3::Ipv4Address::GetAny() [member function]
@@ -2141,6 +2161,28 @@ def register_Ns3Ipv4AddressHelper_methods(root_module, cls):
[param('ns3::Ipv4Address', 'network'), param('ns3::Ipv4Mask', 'mask'), param('ns3::Ipv4Address', 'base', default_value='"0.0.0.1"')])
return
def register_Ns3Ipv4AddressTrieEAccessTraits_methods(root_module, cls):
## trie.h (module 'network'): ns3::Ipv4AddressTrieEAccessTraits::Ipv4AddressTrieEAccessTraits() [constructor]
cls.add_constructor([])
## trie.h (module 'network'): ns3::Ipv4AddressTrieEAccessTraits::Ipv4AddressTrieEAccessTraits(ns3::Ipv4AddressTrieEAccessTraits const & arg0) [copy constructor]
cls.add_constructor([param('ns3::Ipv4AddressTrieEAccessTraits const &', 'arg0')])
## trie.h (module 'network'): static uint8_t const * ns3::Ipv4AddressTrieEAccessTraits::begin(ns3::Ipv4Address const & r_key) [member function]
cls.add_method('begin',
'uint8_t const *',
[param('ns3::Ipv4Address const &', 'r_key')],
is_static=True)
## trie.h (module 'network'): static size_t ns3::Ipv4AddressTrieEAccessTraits::e_pos(uint8_t e) [member function]
cls.add_method('e_pos',
'size_t',
[param('uint8_t', 'e')],
is_static=True)
## trie.h (module 'network'): static uint8_t const * ns3::Ipv4AddressTrieEAccessTraits::end(ns3::Ipv4Address const & r_key) [member function]
cls.add_method('end',
'uint8_t const *',
[param('ns3::Ipv4Address const &', 'r_key')],
is_static=True)
return
def register_Ns3Ipv4EndPoint_methods(root_module, cls):
## ipv4-end-point.h (module 'internet'): ns3::Ipv4EndPoint::Ipv4EndPoint(ns3::Ipv4EndPoint const & arg0) [copy constructor]
cls.add_constructor([param('ns3::Ipv4EndPoint const &', 'arg0')])
@@ -2466,30 +2508,30 @@ def register_Ns3Ipv4RoutingTableEntry_methods(root_module, cls):
cls.add_constructor([param('ns3::Ipv4RoutingTableEntry const &', 'route')])
## ipv4-routing-table-entry.h (module 'internet'): ns3::Ipv4RoutingTableEntry::Ipv4RoutingTableEntry(ns3::Ipv4RoutingTableEntry const * route) [constructor]
cls.add_constructor([param('ns3::Ipv4RoutingTableEntry const *', 'route')])
## ipv4-routing-table-entry.h (module 'internet'): static ns3::Ipv4RoutingTableEntry ns3::Ipv4RoutingTableEntry::CreateDefaultRoute(ns3::Ipv4Address nextHop, uint32_t interface) [member function]
## ipv4-routing-table-entry.h (module 'internet'): static ns3::Ipv4RoutingTableEntry ns3::Ipv4RoutingTableEntry::CreateDefaultRoute(ns3::Ipv4Address nextHop, uint32_t interface, uint32_t metric=0) [member function]
cls.add_method('CreateDefaultRoute',
'ns3::Ipv4RoutingTableEntry',
[param('ns3::Ipv4Address', 'nextHop'), param('uint32_t', 'interface')],
[param('ns3::Ipv4Address', 'nextHop'), param('uint32_t', 'interface'), param('uint32_t', 'metric', default_value='0')],
is_static=True)
## ipv4-routing-table-entry.h (module 'internet'): static ns3::Ipv4RoutingTableEntry ns3::Ipv4RoutingTableEntry::CreateHostRouteTo(ns3::Ipv4Address dest, ns3::Ipv4Address nextHop, uint32_t interface) [member function]
## ipv4-routing-table-entry.h (module 'internet'): static ns3::Ipv4RoutingTableEntry ns3::Ipv4RoutingTableEntry::CreateHostRouteTo(ns3::Ipv4Address dest, ns3::Ipv4Address nextHop, uint32_t interface, uint32_t metric=0) [member function]
cls.add_method('CreateHostRouteTo',
'ns3::Ipv4RoutingTableEntry',
[param('ns3::Ipv4Address', 'dest'), param('ns3::Ipv4Address', 'nextHop'), param('uint32_t', 'interface')],
[param('ns3::Ipv4Address', 'dest'), param('ns3::Ipv4Address', 'nextHop'), param('uint32_t', 'interface'), param('uint32_t', 'metric', default_value='0')],
is_static=True)
## ipv4-routing-table-entry.h (module 'internet'): static ns3::Ipv4RoutingTableEntry ns3::Ipv4RoutingTableEntry::CreateHostRouteTo(ns3::Ipv4Address dest, uint32_t interface) [member function]
## ipv4-routing-table-entry.h (module 'internet'): static ns3::Ipv4RoutingTableEntry ns3::Ipv4RoutingTableEntry::CreateHostRouteTo(ns3::Ipv4Address dest, uint32_t interface, uint32_t metric=0) [member function]
cls.add_method('CreateHostRouteTo',
'ns3::Ipv4RoutingTableEntry',
[param('ns3::Ipv4Address', 'dest'), param('uint32_t', 'interface')],
[param('ns3::Ipv4Address', 'dest'), param('uint32_t', 'interface'), param('uint32_t', 'metric', default_value='0')],
is_static=True)
## ipv4-routing-table-entry.h (module 'internet'): static ns3::Ipv4RoutingTableEntry ns3::Ipv4RoutingTableEntry::CreateNetworkRouteTo(ns3::Ipv4Address network, ns3::Ipv4Mask networkMask, ns3::Ipv4Address nextHop, uint32_t interface) [member function]
## ipv4-routing-table-entry.h (module 'internet'): static ns3::Ipv4RoutingTableEntry ns3::Ipv4RoutingTableEntry::CreateNetworkRouteTo(ns3::Ipv4Address network, ns3::Ipv4Mask networkMask, ns3::Ipv4Address nextHop, uint32_t interface, uint32_t metric=0) [member function]
cls.add_method('CreateNetworkRouteTo',
'ns3::Ipv4RoutingTableEntry',
[param('ns3::Ipv4Address', 'network'), param('ns3::Ipv4Mask', 'networkMask'), param('ns3::Ipv4Address', 'nextHop'), param('uint32_t', 'interface')],
[param('ns3::Ipv4Address', 'network'), param('ns3::Ipv4Mask', 'networkMask'), param('ns3::Ipv4Address', 'nextHop'), param('uint32_t', 'interface'), param('uint32_t', 'metric', default_value='0')],
is_static=True)
## ipv4-routing-table-entry.h (module 'internet'): static ns3::Ipv4RoutingTableEntry ns3::Ipv4RoutingTableEntry::CreateNetworkRouteTo(ns3::Ipv4Address network, ns3::Ipv4Mask networkMask, uint32_t interface) [member function]
## ipv4-routing-table-entry.h (module 'internet'): static ns3::Ipv4RoutingTableEntry ns3::Ipv4RoutingTableEntry::CreateNetworkRouteTo(ns3::Ipv4Address network, ns3::Ipv4Mask networkMask, uint32_t interface, uint32_t metric=0) [member function]
cls.add_method('CreateNetworkRouteTo',
'ns3::Ipv4RoutingTableEntry',
[param('ns3::Ipv4Address', 'network'), param('ns3::Ipv4Mask', 'networkMask'), param('uint32_t', 'interface')],
[param('ns3::Ipv4Address', 'network'), param('ns3::Ipv4Mask', 'networkMask'), param('uint32_t', 'interface'), param('uint32_t', 'metric', default_value='0')],
is_static=True)
## ipv4-routing-table-entry.h (module 'internet'): ns3::Ipv4Address ns3::Ipv4RoutingTableEntry::GetDest() const [member function]
cls.add_method('GetDest',
@@ -2516,6 +2558,11 @@ def register_Ns3Ipv4RoutingTableEntry_methods(root_module, cls):
'uint32_t',
[],
is_const=True)
## ipv4-routing-table-entry.h (module 'internet'): uint32_t ns3::Ipv4RoutingTableEntry::GetMetric() const [member function]
cls.add_method('GetMetric',
'uint32_t',
[],
is_const=True)
## ipv4-routing-table-entry.h (module 'internet'): bool ns3::Ipv4RoutingTableEntry::IsDefault() const [member function]
cls.add_method('IsDefault',
'bool',
@@ -2536,6 +2583,10 @@ def register_Ns3Ipv4RoutingTableEntry_methods(root_module, cls):
'bool',
[],
is_const=True)
## ipv4-routing-table-entry.h (module 'internet'): void ns3::Ipv4RoutingTableEntry::SetMetric(uint32_t metric) [member function]
cls.add_method('SetMetric',
'void',
[param('uint32_t', 'metric')])
return
def register_Ns3Ipv4StaticRoutingHelper_methods(root_module, cls):
@@ -6130,8 +6181,8 @@ def register_Ns3InternetStackHelper_methods(root_module, cls):
return
def register_Ns3Ipv4GlobalRoutingHelper_methods(root_module, cls):
## ipv4-global-routing-helper.h (module 'internet'): ns3::Ipv4GlobalRoutingHelper::Ipv4GlobalRoutingHelper() [constructor]
cls.add_constructor([])
## ipv4-global-routing-helper.h (module 'internet'): ns3::Ipv4GlobalRoutingHelper::Ipv4GlobalRoutingHelper(std::string const & type="ns3::Ipv4GlobalRoutingOneNexthop") [constructor]
cls.add_constructor([param('std::string const &', 'type', default_value='"ns3::Ipv4GlobalRoutingOneNexthop"')])
## ipv4-global-routing-helper.h (module 'internet'): ns3::Ipv4GlobalRoutingHelper::Ipv4GlobalRoutingHelper(ns3::Ipv4GlobalRoutingHelper const & arg0) [copy constructor]
cls.add_constructor([param('ns3::Ipv4GlobalRoutingHelper const &', 'arg0')])
## ipv4-global-routing-helper.h (module 'internet'): ns3::Ipv4GlobalRoutingHelper * ns3::Ipv4GlobalRoutingHelper::Copy() const [member function]
@@ -6149,6 +6200,11 @@ def register_Ns3Ipv4GlobalRoutingHelper_methods(root_module, cls):
'void',
[],
is_static=True)
## ipv4-global-routing-helper.h (module 'internet'): static void ns3::Ipv4GlobalRoutingHelper::PopulateAllPossibleRoutingTables() [member function]
cls.add_method('PopulateAllPossibleRoutingTables',
'void',
[],
is_static=True)
## ipv4-global-routing-helper.h (module 'internet'): static void ns3::Ipv4GlobalRoutingHelper::RecomputeRoutingTables() [member function]
cls.add_method('RecomputeRoutingTables',
'void',
@@ -8876,14 +8932,6 @@ def register_Ns3GlobalRouter_methods(root_module, cls):
is_static=True)
## global-router-interface.h (module 'internet'): ns3::GlobalRouter::GlobalRouter() [constructor]
cls.add_constructor([])
## global-router-interface.h (module 'internet'): void ns3::GlobalRouter::SetRoutingProtocol(ns3::Ptr<ns3::Ipv4GlobalRouting> routing) [member function]
cls.add_method('SetRoutingProtocol',
'void',
[param('ns3::Ptr< ns3::Ipv4GlobalRouting >', 'routing')])
## global-router-interface.h (module 'internet'): ns3::Ptr<ns3::Ipv4GlobalRouting> ns3::GlobalRouter::GetRoutingProtocol() [member function]
cls.add_method('GetRoutingProtocol',
'ns3::Ptr< ns3::Ipv4GlobalRouting >',
[])
## global-router-interface.h (module 'internet'): ns3::Ipv4Address ns3::GlobalRouter::GetRouterId() const [member function]
cls.add_method('GetRouterId',
'ns3::Ipv4Address',
@@ -8903,22 +8951,10 @@ def register_Ns3GlobalRouter_methods(root_module, cls):
'bool',
[param('uint32_t', 'n'), param('ns3::GlobalRoutingLSA &', 'lsa')],
is_const=True)
## global-router-interface.h (module 'internet'): void ns3::GlobalRouter::InjectRoute(ns3::Ipv4Address network, ns3::Ipv4Mask networkMask) [member function]
## global-router-interface.h (module 'internet'): void ns3::GlobalRouter::InjectRoute(ns3::Ipv4Address network, ns3::Ipv4Mask networkMask, uint32_t metric=1) [member function]
cls.add_method('InjectRoute',
'void',
[param('ns3::Ipv4Address', 'network'), param('ns3::Ipv4Mask', 'networkMask')])
## global-router-interface.h (module 'internet'): uint32_t ns3::GlobalRouter::GetNInjectedRoutes() [member function]
cls.add_method('GetNInjectedRoutes',
'uint32_t',
[])
## global-router-interface.h (module 'internet'): ns3::Ipv4RoutingTableEntry * ns3::GlobalRouter::GetInjectedRoute(uint32_t i) [member function]
cls.add_method('GetInjectedRoute',
retval('ns3::Ipv4RoutingTableEntry *', caller_owns_return=False),
[param('uint32_t', 'i')])
## global-router-interface.h (module 'internet'): void ns3::GlobalRouter::RemoveInjectedRoute(uint32_t i) [member function]
cls.add_method('RemoveInjectedRoute',
'void',
[param('uint32_t', 'i')])
[param('ns3::Ipv4Address', 'network'), param('ns3::Ipv4Mask', 'networkMask'), param('uint32_t', 'metric', default_value='1')])
## global-router-interface.h (module 'internet'): bool ns3::GlobalRouter::WithdrawRoute(ns3::Ipv4Address network, ns3::Ipv4Mask networkMask) [member function]
cls.add_method('WithdrawRoute',
'bool',
@@ -12799,36 +12835,16 @@ def register_Ns3Ipv4GlobalRouting_methods(root_module, cls):
cls.add_constructor([param('ns3::Ipv4GlobalRouting const &', 'arg0')])
## ipv4-global-routing.h (module 'internet'): ns3::Ipv4GlobalRouting::Ipv4GlobalRouting() [constructor]
cls.add_constructor([])
## ipv4-global-routing.h (module 'internet'): void ns3::Ipv4GlobalRouting::AddASExternalRouteTo(ns3::Ipv4Address network, ns3::Ipv4Mask networkMask, ns3::Ipv4Address nextHop, uint32_t interface) [member function]
cls.add_method('AddASExternalRouteTo',
## ipv4-global-routing.h (module 'internet'): void ns3::Ipv4GlobalRouting::AddRouteTo(ns3::Ipv4Address dest, ns3::Ipv4Mask destMask, ns3::Ipv4Address nextHop, uint32_t interface, uint32_t metric=0) [member function]
cls.add_method('AddRouteTo',
'void',
[param('ns3::Ipv4Address', 'network'), param('ns3::Ipv4Mask', 'networkMask'), param('ns3::Ipv4Address', 'nextHop'), param('uint32_t', 'interface')])
## ipv4-global-routing.h (module 'internet'): void ns3::Ipv4GlobalRouting::AddHostRouteTo(ns3::Ipv4Address dest, ns3::Ipv4Address nextHop, uint32_t interface) [member function]
cls.add_method('AddHostRouteTo',
[param('ns3::Ipv4Address', 'dest'), param('ns3::Ipv4Mask', 'destMask'), param('ns3::Ipv4Address', 'nextHop'), param('uint32_t', 'interface'), param('uint32_t', 'metric', default_value='0')],
is_pure_virtual=True, is_virtual=True)
## ipv4-global-routing.h (module 'internet'): void ns3::Ipv4GlobalRouting::DeleteRoutes() [member function]
cls.add_method('DeleteRoutes',
'void',
[param('ns3::Ipv4Address', 'dest'), param('ns3::Ipv4Address', 'nextHop'), param('uint32_t', 'interface')])
## ipv4-global-routing.h (module 'internet'): void ns3::Ipv4GlobalRouting::AddHostRouteTo(ns3::Ipv4Address dest, uint32_t interface) [member function]
cls.add_method('AddHostRouteTo',
'void',
[param('ns3::Ipv4Address', 'dest'), param('uint32_t', 'interface')])
## ipv4-global-routing.h (module 'internet'): void ns3::Ipv4GlobalRouting::AddNetworkRouteTo(ns3::Ipv4Address network, ns3::Ipv4Mask networkMask, ns3::Ipv4Address nextHop, uint32_t interface) [member function]
cls.add_method('AddNetworkRouteTo',
'void',
[param('ns3::Ipv4Address', 'network'), param('ns3::Ipv4Mask', 'networkMask'), param('ns3::Ipv4Address', 'nextHop'), param('uint32_t', 'interface')])
## ipv4-global-routing.h (module 'internet'): void ns3::Ipv4GlobalRouting::AddNetworkRouteTo(ns3::Ipv4Address network, ns3::Ipv4Mask networkMask, uint32_t interface) [member function]
cls.add_method('AddNetworkRouteTo',
'void',
[param('ns3::Ipv4Address', 'network'), param('ns3::Ipv4Mask', 'networkMask'), param('uint32_t', 'interface')])
## ipv4-global-routing.h (module 'internet'): uint32_t ns3::Ipv4GlobalRouting::GetNRoutes() const [member function]
cls.add_method('GetNRoutes',
'uint32_t',
[],
is_const=True)
## ipv4-global-routing.h (module 'internet'): ns3::Ipv4RoutingTableEntry * ns3::Ipv4GlobalRouting::GetRoute(uint32_t i) const [member function]
cls.add_method('GetRoute',
retval('ns3::Ipv4RoutingTableEntry *', caller_owns_return=False),
[param('uint32_t', 'i')],
is_const=True)
is_pure_virtual=True, is_virtual=True)
## ipv4-global-routing.h (module 'internet'): static ns3::TypeId ns3::Ipv4GlobalRouting::GetTypeId() [member function]
cls.add_method('GetTypeId',
'ns3::TypeId',
@@ -12854,34 +12870,62 @@ def register_Ns3Ipv4GlobalRouting_methods(root_module, cls):
'void',
[param('uint32_t', 'interface'), param('ns3::Ipv4InterfaceAddress', 'address')],
is_virtual=True)
## ipv4-global-routing.h (module 'internet'): void ns3::Ipv4GlobalRouting::PrintRoutingTable(ns3::Ptr<ns3::OutputStreamWrapper> stream) const [member function]
cls.add_method('PrintRoutingTable',
'void',
[param('ns3::Ptr< ns3::OutputStreamWrapper >', 'stream')],
is_const=True, is_virtual=True)
## ipv4-global-routing.h (module 'internet'): void ns3::Ipv4GlobalRouting::RemoveRoute(uint32_t i) [member function]
cls.add_method('RemoveRoute',
'void',
[param('uint32_t', 'i')])
## ipv4-global-routing.h (module 'internet'): bool ns3::Ipv4GlobalRouting::RouteInput(ns3::Ptr<const ns3::Packet> p, ns3::Ipv4Header const & header, ns3::Ptr<const ns3::NetDevice> idev, ns3::Callback<void,ns3::Ptr<ns3::Ipv4Route>,ns3::Ptr<const ns3::Packet>,const ns3::Ipv4Header&,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty> ucb, ns3::Callback<void,ns3::Ptr<ns3::Ipv4MulticastRoute>,ns3::Ptr<const ns3::Packet>,const ns3::Ipv4Header&,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty> mcb, ns3::Callback<void,ns3::Ptr<const ns3::Packet>,const ns3::Ipv4Header&,unsigned int,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty> lcb, ns3::Callback<void,ns3::Ptr<const ns3::Packet>,const ns3::Ipv4Header&,ns3::Socket::SocketErrno,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty> ecb) [member function]
cls.add_method('RouteInput',
'bool',
[param('ns3::Ptr< ns3::Packet const >', 'p'), param('ns3::Ipv4Header const &', 'header'), param('ns3::Ptr< ns3::NetDevice const >', 'idev'), param('ns3::Callback< void, ns3::Ptr< ns3::Ipv4Route >, ns3::Ptr< ns3::Packet const >, ns3::Ipv4Header const &, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'ucb'), param('ns3::Callback< void, ns3::Ptr< ns3::Ipv4MulticastRoute >, ns3::Ptr< ns3::Packet const >, ns3::Ipv4Header const &, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'mcb'), param('ns3::Callback< void, ns3::Ptr< ns3::Packet const >, ns3::Ipv4Header const &, unsigned int, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'lcb'), param('ns3::Callback< void, ns3::Ptr< ns3::Packet const >, ns3::Ipv4Header const &, ns3::Socket::SocketErrno, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'ecb')],
is_virtual=True)
## ipv4-global-routing.h (module 'internet'): ns3::Ptr<ns3::Ipv4Route> ns3::Ipv4GlobalRouting::RouteOutput(ns3::Ptr<ns3::Packet> p, ns3::Ipv4Header const & header, ns3::Ptr<ns3::NetDevice> oif, ns3::Socket::SocketErrno & sockerr) [member function]
cls.add_method('RouteOutput',
'ns3::Ptr< ns3::Ipv4Route >',
[param('ns3::Ptr< ns3::Packet >', 'p'), param('ns3::Ipv4Header const &', 'header'), param('ns3::Ptr< ns3::NetDevice >', 'oif'), param('ns3::Socket::SocketErrno &', 'sockerr')],
is_virtual=True)
## ipv4-global-routing.h (module 'internet'): void ns3::Ipv4GlobalRouting::SetIpv4(ns3::Ptr<ns3::Ipv4> ipv4) [member function]
cls.add_method('SetIpv4',
'void',
[param('ns3::Ptr< ns3::Ipv4 >', 'ipv4')],
is_virtual=True)
## ipv4-global-routing.h (module 'internet'): void ns3::Ipv4GlobalRouting::DoDispose() [member function]
cls.add_method('DoDispose',
return
def register_Ns3Ipv4GlobalRoutingOneNexthop_methods(root_module, cls):
## ipv4-global-routing-one-nexthop.h (module 'internet'): ns3::Ipv4GlobalRoutingOneNexthop::Ipv4GlobalRoutingOneNexthop() [constructor]
cls.add_constructor([])
## ipv4-global-routing-one-nexthop.h (module 'internet'): ns3::Ipv4GlobalRoutingOneNexthop::Ipv4GlobalRoutingOneNexthop(ns3::Ipv4GlobalRoutingOneNexthop const & arg0) [copy constructor]
cls.add_constructor([param('ns3::Ipv4GlobalRoutingOneNexthop const &', 'arg0')])
## ipv4-global-routing-one-nexthop.h (module 'internet'): void ns3::Ipv4GlobalRoutingOneNexthop::AddRouteTo(ns3::Ipv4Address dest, ns3::Ipv4Mask destMask, ns3::Ipv4Address nextHop, uint32_t interface, uint32_t metric=0) [member function]
cls.add_method('AddRouteTo',
'void',
[param('ns3::Ipv4Address', 'dest'), param('ns3::Ipv4Mask', 'destMask'), param('ns3::Ipv4Address', 'nextHop'), param('uint32_t', 'interface'), param('uint32_t', 'metric', default_value='0')],
is_virtual=True)
## ipv4-global-routing-one-nexthop.h (module 'internet'): void ns3::Ipv4GlobalRoutingOneNexthop::DeleteRoutes() [member function]
cls.add_method('DeleteRoutes',
'void',
[],
is_virtual=True)
## ipv4-global-routing-one-nexthop.h (module 'internet'): uint32_t ns3::Ipv4GlobalRoutingOneNexthop::GetNRoutes() const [member function]
cls.add_method('GetNRoutes',
'uint32_t',
[],
is_const=True)
## ipv4-global-routing-one-nexthop.h (module 'internet'): ns3::Ipv4RoutingTableEntry ns3::Ipv4GlobalRoutingOneNexthop::GetRoute(uint32_t i) const [member function]
cls.add_method('GetRoute',
'ns3::Ipv4RoutingTableEntry',
[param('uint32_t', 'i')],
is_const=True)
## ipv4-global-routing-one-nexthop.h (module 'internet'): static ns3::TypeId ns3::Ipv4GlobalRoutingOneNexthop::GetTypeId() [member function]
cls.add_method('GetTypeId',
'ns3::TypeId',
[],
is_static=True)
## ipv4-global-routing-one-nexthop.h (module 'internet'): void ns3::Ipv4GlobalRoutingOneNexthop::PrintRoutingTable(ns3::Ptr<ns3::OutputStreamWrapper> stream) const [member function]
cls.add_method('PrintRoutingTable',
'void',
[param('ns3::Ptr< ns3::OutputStreamWrapper >', 'stream')],
is_const=True, is_virtual=True)
## ipv4-global-routing-one-nexthop.h (module 'internet'): bool ns3::Ipv4GlobalRoutingOneNexthop::RouteInput(ns3::Ptr<const ns3::Packet> p, ns3::Ipv4Header const & header, ns3::Ptr<const ns3::NetDevice> idev, ns3::Callback<void,ns3::Ptr<ns3::Ipv4Route>,ns3::Ptr<const ns3::Packet>,const ns3::Ipv4Header&,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty> ucb, ns3::Callback<void,ns3::Ptr<ns3::Ipv4MulticastRoute>,ns3::Ptr<const ns3::Packet>,const ns3::Ipv4Header&,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty> mcb, ns3::Callback<void,ns3::Ptr<const ns3::Packet>,const ns3::Ipv4Header&,unsigned int,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty> lcb, ns3::Callback<void,ns3::Ptr<const ns3::Packet>,const ns3::Ipv4Header&,ns3::Socket::SocketErrno,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty> ecb) [member function]
cls.add_method('RouteInput',
'bool',
[param('ns3::Ptr< ns3::Packet const >', 'p'), param('ns3::Ipv4Header const &', 'header'), param('ns3::Ptr< ns3::NetDevice const >', 'idev'), param('ns3::Callback< void, ns3::Ptr< ns3::Ipv4Route >, ns3::Ptr< ns3::Packet const >, ns3::Ipv4Header const &, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'ucb'), param('ns3::Callback< void, ns3::Ptr< ns3::Ipv4MulticastRoute >, ns3::Ptr< ns3::Packet const >, ns3::Ipv4Header const &, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'mcb'), param('ns3::Callback< void, ns3::Ptr< ns3::Packet const >, ns3::Ipv4Header const &, unsigned int, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'lcb'), param('ns3::Callback< void, ns3::Ptr< ns3::Packet const >, ns3::Ipv4Header const &, ns3::Socket::SocketErrno, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'ecb')],
is_virtual=True)
## ipv4-global-routing-one-nexthop.h (module 'internet'): ns3::Ptr<ns3::Ipv4Route> ns3::Ipv4GlobalRoutingOneNexthop::RouteOutput(ns3::Ptr<ns3::Packet> p, ns3::Ipv4Header const & header, ns3::Ptr<ns3::NetDevice> oif, ns3::Socket::SocketErrno & sockerr) [member function]
cls.add_method('RouteOutput',
'ns3::Ptr< ns3::Ipv4Route >',
[param('ns3::Ptr< ns3::Packet >', 'p'), param('ns3::Ipv4Header const &', 'header'), param('ns3::Ptr< ns3::NetDevice >', 'oif'), param('ns3::Socket::SocketErrno &', 'sockerr')],
is_virtual=True)
## ipv4-global-routing-one-nexthop.h (module 'internet'): ns3::Ptr<ns3::Ipv4Route> ns3::Ipv4GlobalRoutingOneNexthop::LookupGlobal(ns3::Ipv4Address dest, ns3::Ptr<ns3::NetDevice> oif=0) [member function]
cls.add_method('LookupGlobal',
'ns3::Ptr< ns3::Ipv4Route >',
[param('ns3::Ipv4Address', 'dest'), param('ns3::Ptr< ns3::NetDevice >', 'oif', default_value='0')],
visibility='protected', is_virtual=True)
return
@@ -20,18 +20,24 @@
#include "ipv4-global-routing-helper.h"
#include "ns3/global-router-interface.h"
#include "ns3/ipv4-global-routing.h"
#include "ns3/ipv4-global-routing-one-nexthop.h"
#include "ns3/ipv4-list-routing.h"
#include "ns3/log.h"
#include "ns3/node-list.h"
NS_LOG_COMPONENT_DEFINE ("GlobalRoutingHelper");
namespace ns3 {
Ipv4GlobalRoutingHelper::Ipv4GlobalRoutingHelper ()
UniformVariable Ipv4GlobalRoutingHelper::m_rand;
Ipv4GlobalRoutingHelper::Ipv4GlobalRoutingHelper (const std::string &type/* = "ns3::Ipv4GlobalRoutingOneNexthop"*/)
: m_type (type)
{
}
Ipv4GlobalRoutingHelper::Ipv4GlobalRoutingHelper (const Ipv4GlobalRoutingHelper &o)
: m_type (o.m_type)
{
}
@@ -51,8 +57,10 @@ Ipv4GlobalRoutingHelper::Create (Ptr<Node> node) const
node->AggregateObject (globalRouter);
NS_LOG_LOGIC ("Adding GlobalRouting Protocol to node " << node->GetId ());
Ptr<Ipv4GlobalRouting> globalRouting = CreateObject<Ipv4GlobalRouting> ();
globalRouter->SetRoutingProtocol (globalRouting);
ObjectFactory factory;
factory.SetTypeId (m_type);
Ptr<Ipv4GlobalRouting> globalRouting = DynamicCast<Ipv4GlobalRouting> (factory.Create<Object> ());
return globalRouting;
}
@@ -63,6 +71,101 @@ Ipv4GlobalRoutingHelper::PopulateRoutingTables (void)
GlobalRouteManager::BuildGlobalRoutingDatabase ();
GlobalRouteManager::InitializeRoutes ();
}
void
Ipv4GlobalRoutingHelper::PopulateAllPossibleRoutingTables (void)
{
NodeList::Iterator listEnd = NodeList::End ();
for (NodeList::Iterator node = NodeList::Begin (); node != listEnd; node++)
{
// if ((*node)->GetId ()!=3) continue;
Ptr<Ipv4> ipv4 = (*node)->GetObject<Ipv4> ();
NS_ASSERT (ipv4 != 0);
// remember interface statuses
std::vector<uint16_t> originalMetric (ipv4->GetNInterfaces ());
for (uint32_t iface = 1; iface < ipv4->GetNInterfaces (); iface++)
{
originalMetric[iface] = ipv4->GetMetric (iface);
}
// enable interfaces one by one and calculate routes
for (uint32_t enabledInterface = 1; enabledInterface < ipv4->GetNInterfaces (); enabledInterface++)
{
NS_LOG_ERROR ("Enabled interface: " << enabledInterface);
for (uint32_t iface = 1; iface < ipv4->GetNInterfaces (); iface++)
{
ipv4->SetMetric (iface, UINT16_MAX);
}
ipv4->SetMetric (enabledInterface, originalMetric[enabledInterface]);
GlobalRouteManager::ClearLSDB ();
GlobalRouteManager::BuildGlobalRoutingDatabase ();
GlobalRouteManager::InitializeRoutes ();
}
// restore original interface statuses
for (uint32_t iface = 1; iface < ipv4->GetNInterfaces (); iface++)
{
ipv4->SetMetric (iface, originalMetric[iface]);
}
}
}
// void
// Ipv4GlobalRoutingHelper::PopulateAllPossibleRoutingTables (void)
// {
// for (int xx = 0; xx < 100; xx++)
// {
// for (NodeList::Iterator node = NodeList::Begin (); node != NodeList::End (); node++)
// {
// Ptr<Ipv4> ipv4 = (*node)->GetObject<Ipv4> ();
// NS_ASSERT (ipv4 != 0);
// // // remember interface statuses
// // std::vector<uint16_t> originalMetric (ipv4->GetNInterfaces ());
// // for (uint32_t iface = 1; iface < ipv4->GetNInterfaces (); iface++)
// // {
// // originalMetric[iface] = ipv4->GetMetric (iface);
// // }
// // enable interfaces one by one and calculate routes
// // for (uint32_t enabledInterface = 1; enabledInterface < ipv4->GetNInterfaces (); enabledInterface++)
// // {
// // NS_LOG_ERROR ("Enabled interface: " << enabledInterface);
// for (uint32_t iface = 1; iface < ipv4->GetNInterfaces (); iface++)
// {
// ipv4->SetMetric (iface, m_rand.GetInteger (1, 500));
// }
// // ipv4->SetMetric (enabledInterface, originalMetric[enabledInterface]);
// // }
// // // restore original interface statuses
// // for (uint32_t iface = 1; iface < ipv4->GetNInterfaces (); iface++)
// // {
// // ipv4->SetMetric (iface, originalMetric[iface]);
// // }
// }
// GlobalRouteManager::ClearLSDB ();
// GlobalRouteManager::BuildGlobalRoutingDatabase ();
// GlobalRouteManager::InitializeRoutes ();
// // Ptr<GlobalRouter> rtr =
// // (*node)->GetObject<GlobalRouter> ();
// // if (rtr && rtr->GetNumLSAs () )
// // {
// // SimulationSingleton<GlobalRouteManagerImpl>::Get ()->
// // SPFCalculate (rtr->GetRouterId ());
// // }
// }
// }
void
Ipv4GlobalRoutingHelper::RecomputeRoutingTables (void)
{
@@ -22,6 +22,7 @@
#include "ns3/node-container.h"
#include "ns3/ipv4-routing-helper.h"
#include "ns3/random-variable.h"
namespace ns3 {
@@ -31,11 +32,18 @@ namespace ns3 {
class Ipv4GlobalRoutingHelper : public Ipv4RoutingHelper
{
public:
enum GlobalRoutingType
{ ONE_NEXT_HOP = 0,
ORDERED_NEXT_HOPS = 1,
UNORDERED_NEXT_HOPS = 2};
/**
* \brief Construct a GlobalRoutingHelper to make life easier for managing
* global routing tasks.
*
* param type Type of the global routing
*/
Ipv4GlobalRoutingHelper ();
Ipv4GlobalRoutingHelper (const std::string &type = "ns3::Ipv4GlobalRoutingOneNexthop");
/**
* \brief Construct a GlobalRoutingHelper from another previously initialized
@@ -70,6 +78,8 @@ public:
*
*/
static void PopulateRoutingTables (void);
static void PopulateAllPossibleRoutingTables ();
/**
* \brief Remove all routes that were previously installed in a prior call
* to either PopulateRoutingTables() or RecomputeRoutingTables(), and
@@ -90,6 +100,10 @@ private:
* assignment and prevent the compiler from happily inserting its own.
*/
Ipv4GlobalRoutingHelper &operator = (const Ipv4GlobalRoutingHelper &o);
std::string m_type;
static UniformVariable m_rand;
};
} // namespace ns3
+37
View File
@@ -23,6 +23,7 @@
#include "ns3/ptr.h"
#include "ns3/nstime.h"
#include "ns3/output-stream-wrapper.h"
#include "ns3/ipv4-list-routing.h"
namespace ns3 {
@@ -107,11 +108,47 @@ public:
*/
void PrintRoutingTableEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
/**
* @brief Request a specified routing protocol <T> from Ipv4RoutingProtocol protocol
*
* If protocol is Ipv4ListRouting, then protocol will be searched in the list,
* otherwise a simple DynamicCast will be performed
*
* @param protocol Smart pointer to Ipv4RoutingProtocol object
*/
template<class T>
static Ptr<T> GetRouting (Ptr<Ipv4RoutingProtocol> protocol);
private:
void Print (Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
void PrintEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
};
// This function does a recursive search for a requested routing protocol.
// Strictly speaking this recursion is not necessary, but why not?
template<class T>
Ptr<T> Ipv4RoutingHelper::GetRouting (Ptr<Ipv4RoutingProtocol> protocol)
{
Ptr<T> ret = DynamicCast<T> (protocol);
if (ret == 0)
{
// trying to check if protocol is a list routing
Ptr<Ipv4ListRouting> lrp = DynamicCast<Ipv4ListRouting> (protocol);
if (lrp != 0)
{
for (uint32_t i = 0; i < lrp->GetNRoutingProtocols (); i++)
{
int16_t priority;
ret = GetRouting<T> (lrp->GetRoutingProtocol (i, priority)); // potential recursion, if inside ListRouting is ListRouting
if (ret != 0)
break;
}
}
}
return ret;
}
} // namespace ns3
+37
View File
@@ -24,6 +24,7 @@
#include "ns3/ptr.h"
#include "ns3/nstime.h"
#include "ns3/output-stream-wrapper.h"
#include "ns3/ipv6-list-routing.h"
namespace ns3 {
@@ -110,11 +111,47 @@ public:
*/
void PrintRoutingTableEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
/**
* @brief Request a specified routing protocol <T> from Ipv4RoutingProtocol protocol
*
* If protocol is Ipv4ListRouting, then protocol will be searched in the list,
* otherwise a simple DynamicCast will be performed
*
* @param protocol Smart pointer to Ipv4RoutingProtocol object
*/
template<class T>
static Ptr<T> GetRouting (Ptr<Ipv6RoutingProtocol> protocol);
private:
void Print (Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
void PrintEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
};
// This function does a recursive search for a requested routing protocol.
// Strictly speaking this recursion is not necessary, but why not?
template<class T>
Ptr<T> Ipv6RoutingHelper::GetRouting (Ptr<Ipv6RoutingProtocol> protocol)
{
Ptr<T> ret = DynamicCast<T> (protocol);
if (ret == 0)
{
// trying to check if protocol is a list routing
Ptr<Ipv6ListRouting> lrp = DynamicCast<Ipv6ListRouting> (protocol);
if (lrp != 0)
{
for (uint32_t i = 0; i < lrp->GetNRoutingProtocols (); i++)
{
int16_t priority;
ret = GetRouting<T> (lrp->GetRoutingProtocol (i, priority)); // potential recursion, if inside ListRouting is ListRouting
if (ret != 0)
break;
}
}
}
return ret;
}
} // namespace ns3
+186 -153
View File
@@ -35,6 +35,7 @@
#include "ns3/ipv4-routing-protocol.h"
#include "ns3/ipv4-list-routing.h"
#include "ns3/mpi-interface.h"
#include "ns3/ipv4-routing-helper.h"
#include "global-router-interface.h"
#include "global-route-manager-impl.h"
#include "candidate-queue.h"
@@ -566,19 +567,15 @@ GlobalRouteManagerImpl::DeleteGlobalRoutes ()
{
continue;
}
Ptr<Ipv4GlobalRouting> gr = router->GetRoutingProtocol ();
uint32_t j = 0;
uint32_t nRoutes = gr->GetNRoutes ();
NS_LOG_LOGIC ("Deleting " << gr->GetNRoutes ()<< " routes from node " << node->GetId ());
// Each time we delete route 0, the route index shifts downward
// We can delete all routes if we delete the route numbered 0
// nRoutes times
for (j = 0; j < nRoutes; j++)
{
NS_LOG_LOGIC ("Deleting global route " << j << " from node " << node->GetId ());
gr->RemoveRoute (0);
}
NS_LOG_LOGIC ("Deleted " << j << " global routes from node "<< node->GetId ());
Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> ();
NS_ASSERT_MSG (ipv4 != 0, "GlobalRouteManagerImpl requires IPv4 stack to be installed on the node");
Ptr<Ipv4GlobalRouting> gr = Ipv4RoutingHelper::
GetRouting<Ipv4GlobalRouting> (ipv4->GetRoutingProtocol ());
NS_ASSERT_MSG (gr != 0, "GlobalRouteManagerImpl needs an instance of Ipv4GlobalRouting to be installed on the node");
gr->DeleteRoutes ();
}
if (m_lsdb)
{
@@ -588,6 +585,14 @@ GlobalRouteManagerImpl::DeleteGlobalRoutes ()
}
}
void
GlobalRouteManagerImpl::ClearLSDB ()
{
NS_LOG_LOGIC ("Deleting LSDB, creating new one");
delete m_lsdb;
m_lsdb = new GlobalRouteManagerLSDB ();
}
//
// In order to build the routing database, we need to walk the list of nodes
// in the system and look for those that support the GlobalRouter interface.
@@ -626,7 +631,14 @@ GlobalRouteManagerImpl::BuildGlobalRoutingDatabase ()
// DiscoverLSAs () will get zero as the number since no routes have been
// found.
//
Ptr<Ipv4GlobalRouting> grouting = rtr->GetRoutingProtocol ();
Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> ();
NS_ASSERT_MSG (ipv4 != 0, "GlobalRouteManagerImpl requires IPv4 stack to be installed on the node");
Ptr<Ipv4GlobalRouting> grouting = Ipv4RoutingHelper::
GetRouting<Ipv4GlobalRouting> (ipv4->GetRoutingProtocol ());
NS_ASSERT_MSG (grouting != 0, "GlobalRouteManagerImpl needs an instance of Ipv4GlobalRouting to be installed on the node");
uint32_t numLSAs = rtr->DiscoverLSAs ();
NS_LOG_LOGIC ("Found " << numLSAs << " LSAs");
@@ -692,6 +704,7 @@ GlobalRouteManagerImpl::InitializeRoutes ()
for (NodeList::Iterator i = NodeList::Begin (); i != listEnd; i++)
{
Ptr<Node> node = *i;
//
// Look for the GlobalRouter interface that indicates that the node is
// participating in routing.
@@ -876,7 +889,7 @@ GlobalRouteManagerImpl::SPFNext (SPFVertex* v, CandidateQueue& candidate)
else if (w_lsa->GetStatus () == GlobalRoutingLSA::LSA_SPF_CANDIDATE)
{
//
// We have already considered the link represented by <w>. What wse have to
// We have already considered the link represented by <w>. What we have to
// do now is to decide if this new router represents a route with a shorter
// distance metric.
//
@@ -1305,12 +1318,15 @@ GlobalRouteManagerImpl::CheckForStubNode (Ipv4Address root)
if (lr->GetLinkId () == myRouterId)
{
// Next hop is stored in the LinkID field of lr
Ptr<GlobalRouter> router = rlsa->GetNode ()->GetObject<GlobalRouter> ();
NS_ASSERT (router);
Ptr<Ipv4GlobalRouting> gr = router->GetRoutingProtocol ();
NS_ASSERT (gr);
gr->AddNetworkRouteTo (Ipv4Address ("0.0.0.0"), Ipv4Mask ("0.0.0.0"), lr->GetLinkData (),
FindOutgoingInterfaceId (transitLink->GetLinkData ()));
Ptr<Ipv4> ipv4 = rlsa->GetNode ()->GetObject<Ipv4> ();
NS_ASSERT_MSG (ipv4 != 0, "GlobalRouteManagerImpl requires IPv4 stack to be installed on the node");
Ptr<Ipv4GlobalRouting> gr = Ipv4RoutingHelper::
GetRouting<Ipv4GlobalRouting> (ipv4->GetRoutingProtocol ());
NS_ASSERT_MSG (gr != 0, "GlobalRouteManagerImpl needs an instance of Ipv4GlobalRouting to be installed on the node");
gr->AddRouteTo (Ipv4Address ("0.0.0.0"), Ipv4Mask ("0.0.0.0"), lr->GetLinkData (),
FindOutgoingInterfaceId (transitLink->GetLinkData ()));
NS_LOG_LOGIC ("Inserting default route for node " << myRouterId << " to next hop " <<
lr->GetLinkData () << " via interface " <<
FindOutgoingInterfaceId (transitLink->GetLinkData ()));
@@ -1329,11 +1345,8 @@ GlobalRouteManagerImpl::SPFCalculate (Ipv4Address root)
NS_LOG_FUNCTION (this << root);
SPFVertex *v;
//
// Initialize the Link State Database.
//
m_lsdb->Initialize ();
//
//
// The candidate queue is a priority queue of SPFVertex objects, with the top
// of the queue being the closest vertex in terms of distance from the root
// of the tree. Initially, this queue is empty.
@@ -1351,105 +1364,115 @@ GlobalRouteManagerImpl::SPFCalculate (Ipv4Address root)
// We also mark this vertex as being in the SPF tree.
//
m_spfroot= v;
NS_ASSERT_MSG (m_spfroot->GetVertexType () == SPFVertex::VertexRouter,
"Root node has to be router");
//
// Initialize the Link State Database.
//
m_lsdb->Initialize ();
v->SetDistanceFromRoot (0);
v->GetLSA ()->SetStatus (GlobalRoutingLSA::LSA_SPF_IN_SPFTREE);
NS_LOG_LOGIC ("Starting SPFCalculate for node " << root);
//
// Optimize SPF calculation, for ns-3.
// We do not need to calculate SPF for every node in the network if this
// node has only one interface through which another router can be
// reached. Instead, short-circuit this computation and just install
// a default route in the CheckForStubNode() method.
//
if (NodeList::GetNNodes () > 0 && CheckForStubNode (root))
{
NS_LOG_LOGIC ("SPFCalculate truncated for stub node " << root);
delete m_spfroot;
return;
}
//
// Optimize SPF calculation, for ns-3.
// We do not need to calculate SPF for every node in the network if this
// node has only one interface through which another router can be
// reached. Instead, short-circuit this computation and just install
// a default route in the CheckForStubNode() method.
//
// if (NodeList::GetNNodes () > 0 && CheckForStubNode (root))
// {
// NS_LOG_LOGIC ("SPFCalculate truncated for stub node " << root);
// delete m_spfroot;
// return;
// }
for (;;)
{
//
// The operations we need to do are given in the OSPF RFC which we reference
// as we go along.
//
// RFC2328 16.1. (2).
//
// We examine the Global Router Link Records in the Link State
// Advertisements of the current vertex. If there are any point-to-point
// links to unexplored adjacent vertices we add them to the tree and update
// the distance and next hop information on how to get there. We also add
// the new vertices to the candidate queue (the priority queue ordered by
// shortest path). If the new vertices represent shorter paths, we use them
// and update the path cost.
//
//
// The operations we need to do are given in the OSPF RFC which we reference
// as we go along.
//
// RFC2328 16.1. (2).
//
// We examine the Global Router Link Records in the Link State
// Advertisements of the current vertex. If there are any point-to-point
// links to unexplored adjacent vertices we add them to the tree and update
// the distance and next hop information on how to get there. We also add
// the new vertices to the candidate queue (the priority queue ordered by
// shortest path). If the new vertices represent shorter paths, we use them
// and update the path cost.
//
SPFNext (v, candidate);
//
// RFC2328 16.1. (3).
//
// If at this step the candidate list is empty, the shortest-path tree (of
// transit vertices) has been completely built and this stage of the
// procedure terminates.
//
//
// RFC2328 16.1. (3).
//
// If at this step the candidate list is empty, the shortest-path tree (of
// transit vertices) has been completely built and this stage of the
// procedure terminates.
//
if (candidate.Size () == 0)
{
break;
}
//
// Choose the vertex belonging to the candidate list that is closest to the
// root, and add it to the shortest-path tree (removing it from the candidate
// list in the process).
//
// Recall that in the previous step, we created SPFVertex structures for each
// of the routers found in the Global Router Link Records and added tehm to
// the candidate list.
//
//
// Choose the vertex belonging to the candidate list that is closest to the
// root, and add it to the shortest-path tree (removing it from the candidate
// list in the process).
//
// Recall that in the previous step, we created SPFVertex structures for each
// of the routers found in the Global Router Link Records and added tehm to
// the candidate list.
//
NS_LOG_LOGIC (candidate);
v = candidate.Pop ();
NS_LOG_LOGIC ("Popped vertex " << v->GetVertexId ());
//
// Update the status field of the vertex to indicate that it is in the SPF
// tree.
//
//
// Update the status field of the vertex to indicate that it is in the SPF
// tree.
//
v->GetLSA ()->SetStatus (GlobalRoutingLSA::LSA_SPF_IN_SPFTREE);
//
// The current vertex has a parent pointer. By calling this rather oddly
// named method (blame quagga) we add the current vertex to the list of
// children of that parent vertex. In the next hop calculation called during
// SPFNext, the parent pointer was set but the vertex has been orphaned up
// to now.
//
//
// The current vertex has a parent pointer. By calling this rather oddly
// named method (blame quagga) we add the current vertex to the list of
// children of that parent vertex. In the next hop calculation called during
// SPFNext, the parent pointer was set but the vertex has been orphaned up
// to now.
//
SPFVertexAddParent (v);
//
// Note that when there is a choice of vertices closest to the root, network
// vertices must be chosen before router vertices in order to necessarily
// find all equal-cost paths.
//
// RFC2328 16.1. (4).
//
// This is the method that actually adds the routes. It'll walk the list
// of nodes in the system, looking for the node corresponding to the router
// ID of the root of the tree -- that is the router we're building the routes
// for. It looks for the Ipv4 interface of that node and remembers it. So
// we are only actually adding routes to that one node at the root of the SPF
// tree.
//
// We're going to pop of a pointer to every vertex in the tree except the
// root in order of distance from the root. For each of the vertices, we call
// SPFIntraAddRouter (). Down in SPFIntraAddRouter, we look at all of the
// point-to-point Global Router Link Records (the links to nodes adjacent to
// the node represented by the vertex). We add a route to the IP address
// specified by the m_linkData field of each of those link records. This will
// be the *local* IP address associated with the interface attached to the
// link. We use the outbound interface and next hop information present in
// the vertex <v> which have possibly been inherited from the root.
//
// To summarize, we're going to look at the node represented by <v> and loop
// through its point-to-point links, adding a *host* route to the local IP
// address (at the <v> side) for each of those links.
//
//
// Note that when there is a choice of vertices closest to the root, network
// vertices must be chosen before router vertices in order to necessarily
// find all equal-cost paths.
//
// RFC2328 16.1. (4).
//
// This is the method that actually adds the routes. It'll walk the list
// of nodes in the system, looking for the node corresponding to the router
// ID of the root of the tree -- that is the router we're building the routes
// for. It looks for the Ipv4 interface of that node and remembers it. So
// we are only actually adding routes to that one node at the root of the SPF
// tree.
//
// We're going to pop of a pointer to every vertex in the tree except the
// root in order of distance from the root. For each of the vertices, we call
// SPFIntraAddRouter (). Down in SPFIntraAddRouter, we look at all of the
// point-to-point Global Router Link Records (the links to nodes adjacent to
// the node represented by the vertex). We add a route to the IP address
// specified by the m_linkData field of each of those link records. This will
// be the *local* IP address associated with the interface attached to the
// link. We use the outbound interface and next hop information present in
// the vertex <v> which have possibly been inherited from the root.
//
// To summarize, we're going to look at the node represented by <v> and loop
// through its point-to-point links, adding a *host* route to the local IP
// address (at the <v> side) for each of those links.
//
if (v->GetVertexType () == SPFVertex::VertexRouter)
{
SPFIntraAddRouter (v);
@@ -1462,15 +1485,15 @@ GlobalRouteManagerImpl::SPFCalculate (Ipv4Address root)
{
NS_ASSERT_MSG (0, "illegal SPFVertex type");
}
//
// RFC2328 16.1. (5).
//
// Iterate the algorithm by returning to Step 2 until there are no more
// candidate vertices.
//
// RFC2328 16.1. (5).
//
// Iterate the algorithm by returning to Step 2 until there are no more
// candidate vertices.
} // end for loop
// Second stage of SPF calculation procedure
// Second stage of SPF calculation procedure
SPFProcessStubs (m_spfroot);
for (uint32_t i = 0; i < m_lsdb->GetNumExtLSAs (); i++)
{
@@ -1479,7 +1502,6 @@ GlobalRouteManagerImpl::SPFCalculate (Ipv4Address root)
NS_LOG_LOGIC ("Processing External LSA with id " << extlsa->GetLinkStateId ());
ProcessASExternals (m_spfroot, extlsa);
}
//
// We're all done setting the routing information for the node at the root of
// the SPF tree. Delete all of the vertices and corresponding resources. Go
@@ -1616,8 +1638,10 @@ GlobalRouteManagerImpl::SPFAddASExternal (GlobalRoutingLSA *extlsa, SPFVertex *v
{
continue;
}
Ptr<Ipv4GlobalRouting> gr = router->GetRoutingProtocol ();
NS_ASSERT (gr);
Ptr<Ipv4GlobalRouting> gr = Ipv4RoutingHelper::
GetRouting<Ipv4GlobalRouting> (ipv4->GetRoutingProtocol ());
NS_ASSERT_MSG (gr != 0, "GlobalRouteManagerImpl needs an instance of Ipv4GlobalRouting to be installed on the node");
// walk through all next-hop-IPs and out-going-interfaces for reaching
// the stub network gateway 'v' from the root node
for (uint32_t i = 0; i < v->GetNRootExitDirections (); i++)
@@ -1627,7 +1651,7 @@ GlobalRouteManagerImpl::SPFAddASExternal (GlobalRoutingLSA *extlsa, SPFVertex *v
int32_t outIf = exit.second;
if (outIf >= 0)
{
gr->AddASExternalRouteTo (tempip, tempmask, nextHop, outIf);
gr->AddRouteTo (tempip, tempmask, nextHop, outIf, v->GetDistanceFromRoot ());
NS_LOG_LOGIC ("(Route " << i << ") Node " << node->GetId () <<
" add external network route to " << tempip <<
" using next hop " << nextHop <<
@@ -1702,7 +1726,7 @@ GlobalRouteManagerImpl::SPFIntraAddStub (GlobalRoutingLinkRecord *l, SPFVertex*
NS_LOG_LOGIC ("Stub is on local host: " << v->GetVertexId () << "; returning");
return;
}
NS_LOG_LOGIC ("Stub is on remote host: " << v->GetVertexId () << "; installing");
NS_LOG_LOGIC ("Stub is on remote host: " << v->GetVertexId () << "; installing (" << v->GetDistanceFromRoot () << ")");
//
// The root of the Shortest Path First tree is the router to which we are
// going to write the actual routing table entries. The vertex corresponding
@@ -1787,8 +1811,10 @@ GlobalRouteManagerImpl::SPFIntraAddStub (GlobalRoutingLinkRecord *l, SPFVertex*
{
continue;
}
Ptr<Ipv4GlobalRouting> gr = router->GetRoutingProtocol ();
NS_ASSERT (gr);
Ptr<Ipv4GlobalRouting> gr = Ipv4RoutingHelper::
GetRouting<Ipv4GlobalRouting> (ipv4->GetRoutingProtocol ());
NS_ASSERT_MSG (gr != 0, "GlobalRouteManagerImpl needs an instance of Ipv4GlobalRouting to be installed on the node");
// walk through all next-hop-IPs and out-going-interfaces for reaching
// the stub network gateway 'v' from the root node
for (uint32_t i = 0; i < v->GetNRootExitDirections (); i++)
@@ -1798,11 +1824,12 @@ GlobalRouteManagerImpl::SPFIntraAddStub (GlobalRoutingLinkRecord *l, SPFVertex*
int32_t outIf = exit.second;
if (outIf >= 0)
{
gr->AddNetworkRouteTo (tempip, tempmask, nextHop, outIf);
gr->AddRouteTo (tempip, tempmask, nextHop, outIf, v->GetDistanceFromRoot ());
NS_LOG_LOGIC ("(Route " << i << ") Node " << node->GetId () <<
" add network route to " << tempip <<
" using next hop " << nextHop <<
" via interface " << outIf);
" via interface " << outIf <<
" metric " << v->GetDistanceFromRoot () );
}
else
{
@@ -2021,33 +2048,36 @@ GlobalRouteManagerImpl::SPFIntraAddRouter (SPFVertex* v)
{
continue;
}
Ptr<Ipv4GlobalRouting> gr = router->GetRoutingProtocol ();
NS_ASSERT (gr);
// walk through all available exit directions due to ECMP,
// and add host route for each of the exit direction toward
// the vertex 'v'
for (uint32_t i = 0; i < v->GetNRootExitDirections (); i++)
{
SPFVertex::NodeExit_t exit = v->GetRootExitDirection (i);
Ipv4Address nextHop = exit.first;
int32_t outIf = exit.second;
if (outIf >= 0)
{
gr->AddHostRouteTo (lr->GetLinkData (), nextHop,
outIf);
NS_LOG_LOGIC ("(Route " << i << ") Node " << node->GetId () <<
" adding host route to " << lr->GetLinkData () <<
" using next hop " << nextHop <<
" and outgoing interface " << outIf);
}
else
{
NS_LOG_LOGIC ("(Route " << i << ") Node " << node->GetId () <<
" NOT able to add host route to " << lr->GetLinkData () <<
" using next hop " << nextHop <<
" since outgoing interface id is negative " << outIf);
}
} // for all routes from the root the vertex 'v'
// Ptr<Ipv4GlobalRouting> gr = Ipv4RoutingHelper::
// GetRouting<Ipv4GlobalRouting> (ipv4->GetRoutingProtocol ());
// NS_ASSERT_MSG (gr != 0, "GlobalRouteManagerImpl needs an instance of Ipv4GlobalRouting to be installed on the node");
// // walk through all available exit directions due to ECMP,
// // and add host route for each of the exit direction toward
// // the vertex 'v'
// for (uint32_t i = 0; i < v->GetNRootExitDirections (); i++)
// {
// SPFVertex::NodeExit_t exit = v->GetRootExitDirection (i);
// Ipv4Address nextHop = exit.first;
// int32_t outIf = exit.second;
// if (outIf >= 0)
// {
// gr->AddRouteTo (lr->GetLinkData (), Ipv4Mask::GetOnes (), nextHop,
// outIf, v->GetDistanceFromRoot ());
// NS_LOG_LOGIC ("(Route " << i << ") Node " << node->GetId () <<
// " adding host route to " << lr->GetLinkData () <<
// " using next hop " << nextHop <<
// " and outgoing interface " << outIf);
// }
// else
// {
// NS_LOG_LOGIC ("(Route " << i << ") Node " << node->GetId () <<
// " NOT able to add host route to " << lr->GetLinkData () <<
// " using next hop " << nextHop <<
// " since outgoing interface id is negative " << outIf);
// }
// } // for all routes from the root the vertex 'v'
}
//
// Done adding the routes for the selected node.
@@ -2134,8 +2164,11 @@ GlobalRouteManagerImpl::SPFIntraAddTransit (SPFVertex* v)
{
continue;
}
Ptr<Ipv4GlobalRouting> gr = router->GetRoutingProtocol ();
NS_ASSERT (gr);
Ptr<Ipv4GlobalRouting> gr = Ipv4RoutingHelper::
GetRouting<Ipv4GlobalRouting> (ipv4->GetRoutingProtocol ());
NS_ASSERT_MSG (gr != 0, "GlobalRouteManagerImpl needs an instance of Ipv4GlobalRouting to be installed on the node");
// walk through all available exit directions due to ECMP,
// and add host route for each of the exit direction toward
// the vertex 'v'
@@ -2147,7 +2180,7 @@ GlobalRouteManagerImpl::SPFIntraAddTransit (SPFVertex* v)
if (outIf >= 0)
{
gr->AddNetworkRouteTo (tempip, tempmask, nextHop, outIf);
gr->AddRouteTo (tempip, tempmask, nextHop, outIf, v->GetDistanceFromRoot ());
NS_LOG_LOGIC ("(Route " << i << ") Node " << node->GetId () <<
" add network route to " << tempip <<
" using next hop " << nextHop <<
@@ -715,6 +715,11 @@ public:
*/
virtual void DeleteGlobalRoutes ();
/**
* @brief Reset LSDB without clearing routing entries
*/
virtual void ClearLSDB ();
/**
* @brief Build the routing database by gathering Link State Advertisements
* from each node exporting a GlobalRouter interface.
+18 -1
View File
@@ -24,6 +24,8 @@
#include "global-route-manager.h"
#include "global-route-manager-impl.h"
NS_LOG_COMPONENT_DEFINE ("GlobalRouteManager1");
namespace ns3 {
// ---------------------------------------------------------------------------
@@ -35,13 +37,24 @@ namespace ns3 {
void
GlobalRouteManager::DeleteGlobalRoutes ()
{
NS_LOG_FUNCTION (0);
SimulationSingleton<GlobalRouteManagerImpl>::Get ()->
DeleteGlobalRoutes ();
DeleteGlobalRoutes ();
}
void
GlobalRouteManager::ClearLSDB ()
{
NS_LOG_FUNCTION (0);
SimulationSingleton<GlobalRouteManagerImpl>::Get ()->
ClearLSDB ();
}
void
GlobalRouteManager::BuildGlobalRoutingDatabase (void)
{
NS_LOG_FUNCTION (0);
SimulationSingleton<GlobalRouteManagerImpl>::Get ()->
BuildGlobalRoutingDatabase ();
}
@@ -49,6 +62,8 @@ GlobalRouteManager::BuildGlobalRoutingDatabase (void)
void
GlobalRouteManager::InitializeRoutes (void)
{
NS_LOG_FUNCTION (0);
SimulationSingleton<GlobalRouteManagerImpl>::Get ()->
InitializeRoutes ();
}
@@ -56,6 +71,8 @@ GlobalRouteManager::InitializeRoutes (void)
uint32_t
GlobalRouteManager::AllocateRouterId (void)
{
NS_LOG_FUNCTION (0);
static uint32_t routerId = 0;
return routerId++;
}
@@ -52,6 +52,11 @@ public:
*/
static void DeleteGlobalRoutes ();
/**
* @breif Clear LSA database without removing any entry in global routing table
*/
static void ClearLSDB ();
/**
* @brief Build the routing database by gathering Link State Advertisements
* from each node exporting a GlobalRouter interface.
+80 -79
View File
@@ -28,9 +28,11 @@
#include "ns3/ipv4.h"
#include "ns3/bridge-net-device.h"
#include "ipv4-global-routing.h"
#include "ns3/loopback-net-device.h"
#include "global-router-interface.h"
#include <vector>
NS_LOG_COMPONENT_DEFINE ("GlobalRouter");
namespace ns3 {
@@ -526,28 +528,28 @@ GlobalRouter::~GlobalRouter ()
ClearLSAs ();
}
void
GlobalRouter::SetRoutingProtocol (Ptr<Ipv4GlobalRouting> routing)
{
m_routingProtocol = routing;
}
Ptr<Ipv4GlobalRouting>
GlobalRouter::GetRoutingProtocol (void)
{
return m_routingProtocol;
}
// void
// GlobalRouter::SetRoutingProtocol (Ptr<Ipv4GlobalRouting> routing)
// {
// m_routingProtocol = routing;
// }
// Ptr<Ipv4GlobalRouting>
// GlobalRouter::GetRoutingProtocol (void)
// {
// return m_routingProtocol;
// }
void
GlobalRouter::DoDispose ()
{
NS_LOG_FUNCTION_NOARGS ();
m_routingProtocol = 0;
for (InjectedRoutesI k = m_injectedRoutes.begin ();
k != m_injectedRoutes.end ();
k = m_injectedRoutes.erase (k))
{
delete (*k);
}
// m_routingProtocol = 0;
// for (InjectedRoutesI k = m_injectedRoutes.begin ();
// k != m_injectedRoutes.end ();
// k = m_injectedRoutes.erase (k))
// {
// delete (*k);
// }
Object::DoDispose ();
}
@@ -717,17 +719,17 @@ GlobalRouter::DiscoverLSAs ()
// Build injected route LSAs as external routes
// RFC 2328, section 12.4.4
//
for (InjectedRoutesCI i = m_injectedRoutes.begin ();
for (RouteList::const_iterator i = m_injectedRoutes.begin ();
i != m_injectedRoutes.end ();
i++)
{
GlobalRoutingLSA *pLSA = new GlobalRoutingLSA;
pLSA->SetLSType (GlobalRoutingLSA::ASExternalLSAs);
pLSA->SetLinkStateId ((*i)->GetDestNetwork ());
pLSA->SetLinkStateId (i->GetDestNetwork ());
pLSA->SetAdvertisingRouter (m_routerId);
pLSA->SetNetworkLSANetworkMask ((*i)->GetDestNetworkMask ());
pLSA->SetNetworkLSANetworkMask (i->GetDestNetworkMask ());
pLSA->SetStatus (GlobalRoutingLSA::LSA_SPF_NOT_EXPLORED);
m_LSAs.push_back (pLSA);
m_LSAs.push_back (pLSA);
}
return m_LSAs.size ();
}
@@ -752,6 +754,8 @@ GlobalRouter::ProcessSingleBroadcastLink (Ptr<NetDevice> nd, GlobalRoutingLSA *p
{
NS_LOG_FUNCTION (nd << pLSA << &c);
if (DynamicCast<LoopbackNetDevice> (nd)) return; //don't announce loopback addresses
GlobalRoutingLinkRecord *plr = new GlobalRoutingLinkRecord;
NS_ABORT_MSG_IF (plr == 0, "GlobalRouter::ProcessSingleBroadcastLink(): Can't alloc link record");
@@ -1503,77 +1507,74 @@ GlobalRouter::GetLSA (uint32_t n, GlobalRoutingLSA &lsa) const
}
void
GlobalRouter::InjectRoute (Ipv4Address network, Ipv4Mask networkMask)
GlobalRouter::InjectRoute (Ipv4Address network, Ipv4Mask networkMask, uint32_t metric/*=1*/)
{
NS_LOG_FUNCTION (network << networkMask);
Ipv4RoutingTableEntry *route = new Ipv4RoutingTableEntry ();
//
// Interface number does not matter here, using 1.
//
*route = Ipv4RoutingTableEntry::CreateNetworkRouteTo (network,
networkMask,
1);
m_injectedRoutes.push_back (route);
NS_LOG_FUNCTION (network << networkMask << metric);
WithdrawRoute (network, networkMask); //slight inefficiency to prevent duplicate routes
m_injectedRoutes.push_back (Ipv4RoutingTableEntry::CreateNetworkRouteTo (network,
networkMask,
metric));
}
Ipv4RoutingTableEntry *
GlobalRouter::GetInjectedRoute (uint32_t index)
{
NS_LOG_FUNCTION (index);
if (index < m_injectedRoutes.size ())
{
uint32_t tmp = 0;
for (InjectedRoutesCI i = m_injectedRoutes.begin ();
i != m_injectedRoutes.end ();
i++)
{
if (tmp == index)
{
return *i;
}
tmp++;
}
}
NS_ASSERT (false);
// quiet compiler.
return 0;
}
// Ipv4RoutingTableEntry *
// GlobalRouter::GetInjectedRoute (uint32_t index)
// {
// NS_LOG_FUNCTION (index);
// if (index < m_injectedRoutes.size ())
// {
// uint32_t tmp = 0;
// for (InjectedRoutesCI i = m_injectedRoutes.begin ();
// i != m_injectedRoutes.end ();
// i++)
// {
// if (tmp == index)
// {
// return *i;
// }
// tmp++;
// }
// }
// NS_ASSERT (false);
// // quiet compiler.
// return 0;
// }
uint32_t
GlobalRouter::GetNInjectedRoutes ()
{
return m_injectedRoutes.size ();
}
// uint32_t
// GlobalRouter::GetNInjectedRoutes ()
// {
// return m_injectedRoutes.size ();
// }
void
GlobalRouter::RemoveInjectedRoute (uint32_t index)
{
NS_LOG_FUNCTION (index);
NS_ASSERT (index < m_injectedRoutes.size ());
uint32_t tmp = 0;
for (InjectedRoutesI i = m_injectedRoutes.begin (); i != m_injectedRoutes.end (); i++)
{
if (tmp == index)
{
NS_LOG_LOGIC ("Removing route " << index << "; size = " << m_injectedRoutes.size ());
delete *i;
m_injectedRoutes.erase (i);
return;
}
tmp++;
}
}
// void
// GlobalRouter::RemoveInjectedRoute (uint32_t index)
// {
// NS_LOG_FUNCTION (index);
// NS_ASSERT (index < m_injectedRoutes.size ());
// uint32_t tmp = 0;
// for (InjectedRoutesI i = m_injectedRoutes.begin (); i != m_injectedRoutes.end (); i++)
// {
// if (tmp == index)
// {
// NS_LOG_LOGIC ("Removing route " << index << "; size = " << m_injectedRoutes.size ());
// delete *i;
// m_injectedRoutes.erase (i);
// return;
// }
// tmp++;
// }
// }
bool
GlobalRouter::WithdrawRoute (Ipv4Address network, Ipv4Mask networkMask)
{
NS_LOG_FUNCTION (network << networkMask);
for (InjectedRoutesI i = m_injectedRoutes.begin (); i != m_injectedRoutes.end (); i++)
for (RouteList::iterator i = m_injectedRoutes.begin (); i != m_injectedRoutes.end (); i++)
{
if ((*i)->GetDestNetwork () == network && (*i)->GetDestNetworkMask () == networkMask)
if (i->GetDestNetwork () == network && i->GetDestNetworkMask () == networkMask)
{
NS_LOG_LOGIC ("Withdrawing route to network/mask " << network << "/" << networkMask);
delete *i;
m_injectedRoutes.erase (i);
return true;
}
+29 -36
View File
@@ -37,7 +37,6 @@
namespace ns3 {
class GlobalRouter;
class Ipv4GlobalRouting;
/**
* @brief A single link record for a link state advertisement.
@@ -588,10 +587,6 @@ public:
*/
GlobalRouter ();
void SetRoutingProtocol (Ptr<Ipv4GlobalRouting> routing);
Ptr<Ipv4GlobalRouting> GetRoutingProtocol (void);
/**
* @brief Get the Router ID associated with this Global Router.
*
@@ -666,35 +661,35 @@ public:
* @param network The Network to inject
* @param networkMask The Network Mask to inject
*/
void InjectRoute (Ipv4Address network, Ipv4Mask networkMask);
void InjectRoute (Ipv4Address network, Ipv4Mask networkMask, uint32_t metric=1);
/**
* @brief Get the number of injected routes that have been added
* to the routing table.
* @return number of injected routes
*/
uint32_t GetNInjectedRoutes (void);
// /**
// * @brief Get the number of injected routes that have been added
// * to the routing table.
// * @return number of injected routes
// */
// uint32_t GetNInjectedRoutes (void) const;
/**
* @brief Return the injected route indexed by i
* @param i the index of the route
* @return a pointer to that Ipv4RoutingTableEntry is returned
*
*/
Ipv4RoutingTableEntry *GetInjectedRoute (uint32_t i);
// /**
// * @brief Return the injected route indexed by i
// * @param i the index of the route
// * @return a pointer to that Ipv4RoutingTableEntry is returned
// *
// */
// const Ipv4RoutingTableEntry& GetInjectedRoute (uint32_t i) const;
/**
* @brief Withdraw a route from the global unicast routing table.
*
* Calling this function will cause all indexed routes numbered above
* index i to have their index decremented. For instance, it is possible to
* remove N injected routes by calling RemoveInjectedRoute (0) N times.
*
* @param i The index (into the injected routing list) of the route to remove.
*
* @see GlobalRouter::WithdrawRoute ()
*/
void RemoveInjectedRoute (uint32_t i);
// /**
// * @brief Withdraw a route from the global unicast routing table.
// *
// * Calling this function will cause all indexed routes numbered above
// * index i to have their index decremented. For instance, it is possible to
// * remove N injected routes by calling RemoveInjectedRoute (0) N times.
// *
// * @param i The index (into the injected routing list) of the route to remove.
// *
// * @see GlobalRouter::WithdrawRoute ()
// */
// void RemoveInjectedRoute (uint32_t i);
/**
* @brief Withdraw a route from the global unicast routing table.
@@ -728,12 +723,10 @@ private:
ListOfLSAs_t m_LSAs;
Ipv4Address m_routerId;
Ptr<Ipv4GlobalRouting> m_routingProtocol;
// Ptr<Ipv4GlobalRouting> m_routingProtocol;
typedef std::list<Ipv4RoutingTableEntry *> InjectedRoutes;
typedef std::list<Ipv4RoutingTableEntry *>::const_iterator InjectedRoutesCI;
typedef std::list<Ipv4RoutingTableEntry *>::iterator InjectedRoutesI;
InjectedRoutes m_injectedRoutes; // Routes we are exporting
typedef std::list<Ipv4RoutingTableEntry> RouteList;
RouteList m_injectedRoutes; // Routes we are exporting
// inherited from Object
virtual void DoDispose (void);
+4 -4
View File
@@ -846,10 +846,10 @@ void Icmpv6L4Protocol::SendMessage (Ptr<Packet> packet, Ipv6Address src, Ipv6Add
{
NS_LOG_FUNCTION (this << packet << src << dst << (uint32_t)ttl);
Ptr<Ipv6L3Protocol> ipv6 = m_node->GetObject<Ipv6L3Protocol> ();
SocketIpTtlTag tag;
NS_ASSERT (ipv6 != 0);
tag.SetTtl (ttl);
Ptr<SocketIpTtlTag> tag = CreateObject<SocketIpTtlTag> ();
tag->SetTtl (ttl);
packet->AddPacketTag (tag);
m_downTarget (packet, src, dst, PROT_NUMBER, 0);
}
@@ -860,7 +860,6 @@ void Icmpv6L4Protocol::SendMessage (Ptr<Packet> packet, Ipv6Address dst, Icmpv6H
Ptr<Ipv6L3Protocol> ipv6 = m_node->GetObject<Ipv6L3Protocol> ();
NS_ASSERT (ipv6 != 0 && ipv6->GetRoutingProtocol () != 0);
Ipv6Header header;
SocketIpTtlTag tag;
Socket::SocketErrno err;
Ptr<Ipv6Route> route;
Ptr<NetDevice> oif (0); //specify non-zero if bound to a source address
@@ -871,7 +870,8 @@ void Icmpv6L4Protocol::SendMessage (Ptr<Packet> packet, Ipv6Address dst, Icmpv6H
if (route != 0)
{
NS_LOG_LOGIC ("Route exists");
tag.SetTtl (ttl);
Ptr<SocketIpTtlTag> tag = CreateObject<SocketIpTtlTag> ();
tag->SetTtl (ttl);
packet->AddPacketTag (tag);
Ipv6Address src = route->GetSource ();
@@ -0,0 +1,317 @@
// -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*-
//
// Copyright (c) 2008 University of Washington
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation;
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#include "ns3/names.h"
#include "ns3/log.h"
#include "ns3/simulator.h"
#include "ns3/object.h"
#include "ns3/packet.h"
#include "ns3/net-device.h"
#include "ns3/ipv4-route.h"
#include "ipv4-global-routing-one-nexthop.h"
#include <iomanip>
NS_LOG_COMPONENT_DEFINE ("Ipv4GlobalRoutingOneNexthop");
namespace ns3 {
NS_OBJECT_ENSURE_REGISTERED (Ipv4GlobalRoutingOneNexthop);
TypeId
Ipv4GlobalRoutingOneNexthop::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::Ipv4GlobalRoutingOneNexthop")
.SetParent<Ipv4GlobalRouting> ()
.AddConstructor<Ipv4GlobalRoutingOneNexthop> ()
;
return tid;
}
Ipv4GlobalRoutingOneNexthop::Ipv4GlobalRoutingOneNexthop ()
{
}
void
Ipv4GlobalRoutingOneNexthop::AddRouteTo (Ipv4Address dest,
Ipv4Mask destMask,
Ipv4Address nextHop,
uint32_t interface,
uint32_t metric/*=0*/)
{
NS_LOG_FUNCTION (dest << nextHop << interface);
// First, make sure we don't try to add route to ourselves
int32_t iface = m_ipv4->GetInterfaceForPrefix (dest, destMask);
NS_LOG_LOGIC ("Iface " << iface << " for " << dest);
if (iface >= 0)
{
NS_LOG_LOGIC ("Do not add route to ourselves");
return;
}
// Second, there is no reason to add p2p route that equals to the next hop
if (destMask == Ipv4Mask::GetOnes () && dest == nextHop)
{
NS_LOG_LOGIC ("Ignore route to nexthop via nexhop");
return;
}
Ipv4AddressTrie<Ipv4RoutingTableEntry>::iterator route =
m_routes.find (dest.CombineMask (destMask));
if (route == m_routes.end ())
{
NS_LOG_LOGIC ("Adding new route");
m_routes[dest.CombineMask (destMask)] =
Ipv4RoutingTableEntry::CreateNetworkRouteTo (dest, destMask, nextHop, interface, metric);
}
else
if (route->second.GetMetric () > metric)
{
NS_LOG_LOGIC ("Replacing larger-metric route");
m_routes[dest.CombineMask (destMask)] =
Ipv4RoutingTableEntry::CreateNetworkRouteTo (dest, destMask, nextHop, interface, metric);
}
else
{
NS_LOG_LOGIC ("Don't update lower-metric route");
}
}
Ptr<Ipv4Route>
Ipv4GlobalRoutingOneNexthop::LookupGlobal (Ipv4Address dest, Ptr<NetDevice> oif)
{
NS_LOG_FUNCTION_NOARGS ();
NS_LOG_LOGIC ("Looking for route for destination " << dest);
// Cheating with lookups. Need to redesign Trie
Ipv4AddressTrieMap::const_iterator longest_prefix_map;
Ipv4Mask mask ("255.255.255.255");
do {
NS_LOG_DEBUG ("Try mask " << mask);
longest_prefix_map = m_routes.longest_prefix_match (dest.CombineMask (mask));
mask = Ipv4Mask (mask.Get () << 8);
} while (longest_prefix_map == m_routes.end () && !mask.IsEqual (Ipv4Mask::GetZero ()));
if (longest_prefix_map == m_routes.end ())
{
NS_LOG_LOGIC ("Route not found...");
return 0;
}
if (oif != 0 && oif == m_ipv4->GetNetDevice (longest_prefix_map->second.GetInterface ()))
{
NS_LOG_LOGIC ("Route points to the incoming interface. Return empty route");
return 0;
}
// create a Ipv4Route object from the selected routing table entry
Ptr<Ipv4Route> rtentry = Create<Ipv4Route> ();
rtentry->SetDestination (longest_prefix_map->second.GetDest ());
rtentry->SetSource (m_ipv4->GetAddress (longest_prefix_map->second.GetInterface (), 0).GetLocal ());
rtentry->SetGateway (longest_prefix_map->second.GetGateway ());
rtentry->SetOutputDevice (m_ipv4->GetNetDevice (longest_prefix_map->second.GetInterface ()));
return rtentry;
}
void
Ipv4GlobalRoutingOneNexthop::DeleteRoutes ()
{
m_routes.clear ();
}
// Formatted like output of "route -n" command
void
Ipv4GlobalRoutingOneNexthop::PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const
{
std::ostream* os = stream->GetStream ();
if (m_routes.size () > 0)
{
*os << "Destination Gateway Genmask Flags Metric Ref Use Iface" << std::endl;
for (Ipv4AddressTrieMap::const_iterator i=m_routes.begin (); i != m_routes.end (); i++)
{
std::ostringstream dest, gw, mask, flags;
const Ipv4RoutingTableEntry &route = i->second;
dest << route.GetDest ();
*os << std::setiosflags (std::ios::left) << std::setw (16) << dest.str ();
gw << route.GetGateway ();
*os << std::setiosflags (std::ios::left) << std::setw (16) << gw.str ();
mask << route.GetDestNetworkMask ();
*os << std::setiosflags (std::ios::left) << std::setw (16) << mask.str ();
flags << "U";
if (route.IsHost ())
{
flags << "H";
}
else if (route.IsGateway ())
{
flags << "G";
}
*os << std::setiosflags (std::ios::left) << std::setw (6) << flags.str ();
*os << std::setiosflags (std::ios::left) << std::setw (6) << route.GetMetric ();
// Ref ct not implemented
*os << "-" << " ";
// Use not implemented
*os << "-" << " ";
if (Names::FindName (m_ipv4->GetNetDevice (route.GetInterface ())) != "")
{
*os << Names::FindName (m_ipv4->GetNetDevice (route.GetInterface ()));
}
else
{
*os << route.GetInterface ();
}
*os << std::endl;
}
}
}
Ptr<Ipv4Route>
Ipv4GlobalRoutingOneNexthop::RouteOutput (Ptr<Packet> p, const Ipv4Header &header,
Ptr<NetDevice> oif, Socket::SocketErrno &sockerr)
{
//
// First, see if this is a multicast packet we have a route for. If we
// have a route, then send the packet down each of the specified interfaces.
//
if (header.GetDestination ().IsMulticast ())
{
NS_LOG_LOGIC ("Multicast destination-- returning false");
return 0; // Let other routing protocols try to handle this
}
//
// See if this is a unicast packet we have a route for.
//
NS_LOG_LOGIC ("Unicast destination- looking up");
Ptr<Ipv4Route> rtentry = LookupGlobal (header.GetDestination (), oif);
if (rtentry)
{
sockerr = Socket::ERROR_NOTERROR;
}
else
{
sockerr = Socket::ERROR_NOROUTETOHOST;
}
return rtentry;
}
bool
Ipv4GlobalRoutingOneNexthop::RouteInput (Ptr<const Packet> p, const Ipv4Header &header,
Ptr<const NetDevice> idev,
UnicastForwardCallback ucb, MulticastForwardCallback mcb,
LocalDeliverCallback lcb, ErrorCallback ecb)
{
NS_LOG_FUNCTION (this << p << header << header.GetSource () << header.GetDestination () << idev);
// Check if input device supports IP
NS_ASSERT (m_ipv4->GetInterfaceForDevice (idev) >= 0);
uint32_t iif = m_ipv4->GetInterfaceForDevice (idev);
if (header.GetDestination ().IsMulticast ())
{
NS_LOG_LOGIC ("Multicast destination-- returning false");
return false; // Let other routing protocols try to handle this
}
if (header.GetDestination ().IsBroadcast ())
{
NS_LOG_LOGIC ("For me (Ipv4Addr broadcast address)");
// TODO: Local Deliver for broadcast
// TODO: Forward broadcast
}
// TODO: Configurable option to enable RFC 1222 Strong End System Model
// Right now, we will be permissive and allow a source to send us
// a packet to one of our other interface addresses; that is, the
// destination unicast address does not match one of the iif addresses,
// but we check our other interfaces. This could be an option
// (to remove the outer loop immediately below and just check iif).
for (uint32_t j = 0; j < m_ipv4->GetNInterfaces (); j++)
{
for (uint32_t i = 0; i < m_ipv4->GetNAddresses (j); i++)
{
Ipv4InterfaceAddress iaddr = m_ipv4->GetAddress (j, i);
Ipv4Address addr = iaddr.GetLocal ();
if (addr.IsEqual (header.GetDestination ()))
{
if (j == iif)
{
NS_LOG_LOGIC ("For me (destination " << addr << " match)");
}
else
{
NS_LOG_LOGIC ("For me (destination " << addr << " match) on another interface " << header.GetDestination ());
}
lcb (p, header, iif);
return true;
}
if (header.GetDestination ().IsEqual (iaddr.GetBroadcast ()))
{
NS_LOG_LOGIC ("For me (interface broadcast address)");
lcb (p, header, iif);
return true;
}
NS_LOG_LOGIC ("Address "<< addr << " not a match");
}
}
// Check if input device supports IP forwarding
if (m_ipv4->IsForwarding (iif) == false)
{
NS_LOG_LOGIC ("Forwarding disabled for this interface");
ecb (p, header, Socket::ERROR_NOROUTETOHOST);
return false;
}
// Next, try to find a route
NS_LOG_LOGIC ("Unicast destination- looking up global route");
Ptr<Ipv4Route> rtentry = LookupGlobal (header.GetDestination ());
if (rtentry != 0)
{
NS_LOG_LOGIC ("Found unicast destination- calling unicast callback");
ucb (rtentry, p, header);
return true;
}
else
{
NS_LOG_LOGIC ("Did not find unicast destination- returning false");
return false; // Let other routing protocols try to handle this
// route request.
}
}
uint32_t
Ipv4GlobalRoutingOneNexthop::GetNRoutes () const
{
return m_routes.size ();
}
Ipv4RoutingTableEntry
Ipv4GlobalRoutingOneNexthop::GetRoute (uint32_t i) const
{
uint32_t index = 0;
for (Ipv4AddressTrieMap::const_iterator it = m_routes.begin ();
index <= i && it != m_routes.end ();
it++, index++)
{
if (index == i) return it->second;
}
NS_ASSERT (false);
return Ipv4RoutingTableEntry ();
}
} // namespace ns3
@@ -0,0 +1,83 @@
// -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*-
//
// Copyright (c) 2008 University of Washington
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation;
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
//
#ifndef IPV4_GLOBAL_ROUTING_ONE_NEXTHOP_H
#define IPV4_GLOBAL_ROUTING_ONE_NEXTHOP_H
#include "ns3/ipv4-global-routing.h"
#include "ns3/trie.h"
#include "ns3/ipv4-routing-table-entry.h"
namespace ns3 {
/**
* \brief Global routing protocol for IP version 4 stacks.
*
* Each prefix entry stores a list of ordered by metric next-hops
*
* This class deals with Ipv4 unicast routes only.
*
* \see Ipv4GlobalRouting
* \see Ipv4RoutingProtocol
* \see GlobalRouteManager
*/
class Ipv4GlobalRoutingOneNexthop : public Ipv4GlobalRouting
{
public:
static TypeId GetTypeId (void);
Ipv4GlobalRoutingOneNexthop ();
// These methods inherited from base class
// from Ipv4RoutingProtocol
virtual Ptr<Ipv4Route> RouteOutput (Ptr<Packet> p, const Ipv4Header &header,
Ptr<NetDevice> oif, Socket::SocketErrno &sockerr);
virtual bool RouteInput (Ptr<const Packet> p, const Ipv4Header &header, Ptr<const NetDevice> idev,
UnicastForwardCallback ucb, MulticastForwardCallback mcb,
LocalDeliverCallback lcb, ErrorCallback ecb);
virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const;
// from Ipv4GlobalRouting
virtual void AddRouteTo (Ipv4Address dest,
Ipv4Mask destMask,
Ipv4Address nextHop,
uint32_t interface,
uint32_t metric=0);
virtual void DeleteRoutes ();
uint32_t
GetNRoutes () const;
Ipv4RoutingTableEntry
GetRoute (uint32_t i) const;
protected:
virtual Ptr<Ipv4Route> LookupGlobal (Ipv4Address dest, Ptr<NetDevice> oif = 0);
private:
typedef Ipv4AddressTrie<Ipv4RoutingTableEntry> Ipv4AddressTrieMap;
Ipv4AddressTrieMap m_routes;
};
} // Namespace ns3
#endif /* IPV4_GLOBAL_ROUTING_ONE_NEXTHOP_H */
+6 -496
View File
@@ -16,19 +16,13 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#include <vector>
#include <iomanip>
#include "ns3/names.h"
#include "ns3/log.h"
#include "ns3/simulator.h"
#include "ns3/object.h"
#include "ns3/packet.h"
#include "ns3/net-device.h"
#include "ns3/ipv4-route.h"
#include "ns3/ipv4-routing-table-entry.h"
#include "ns3/global-route-manager.h"
#include "ns3/boolean.h"
#include "ipv4-global-routing.h"
#include "global-route-manager.h"
NS_LOG_COMPONENT_DEFINE ("Ipv4GlobalRouting");
@@ -40,14 +34,10 @@ TypeId
Ipv4GlobalRouting::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::Ipv4GlobalRouting")
.SetParent<Object> ()
.AddAttribute ("RandomEcmpRouting",
"Set to true if packets are randomly routed among ECMP; set to false for using only one route consistently",
BooleanValue (false),
MakeBooleanAccessor (&Ipv4GlobalRouting::m_randomEcmpRouting),
MakeBooleanChecker ())
.SetParent<Ipv4RoutingProtocol> ()
.AddAttribute ("RespondToInterfaceEvents",
"Set to true if you want to dynamically recompute the global routes upon Interface notification events (up/down, or add/remove address)",
"Set to true if you want to dynamically recompute the global routes "
"upon Interface notification events (up/down, or add/remove address)",
BooleanValue (false),
MakeBooleanAccessor (&Ipv4GlobalRouting::m_respondToInterfaceEvents),
MakeBooleanChecker ())
@@ -55,491 +45,11 @@ Ipv4GlobalRouting::GetTypeId (void)
return tid;
}
Ipv4GlobalRouting::Ipv4GlobalRouting ()
: m_randomEcmpRouting (false),
m_respondToInterfaceEvents (false)
Ipv4GlobalRouting::Ipv4GlobalRouting ()
: m_respondToInterfaceEvents (false)
{
NS_LOG_FUNCTION_NOARGS ();
}
Ipv4GlobalRouting::~Ipv4GlobalRouting ()
{
NS_LOG_FUNCTION_NOARGS ();
}
void
Ipv4GlobalRouting::AddHostRouteTo (Ipv4Address dest,
Ipv4Address nextHop,
uint32_t interface)
{
NS_LOG_FUNCTION (dest << nextHop << interface);
Ipv4RoutingTableEntry *route = new Ipv4RoutingTableEntry ();
*route = Ipv4RoutingTableEntry::CreateHostRouteTo (dest, nextHop, interface);
m_hostRoutes.push_back (route);
}
void
Ipv4GlobalRouting::AddHostRouteTo (Ipv4Address dest,
uint32_t interface)
{
NS_LOG_FUNCTION (dest << interface);
Ipv4RoutingTableEntry *route = new Ipv4RoutingTableEntry ();
*route = Ipv4RoutingTableEntry::CreateHostRouteTo (dest, interface);
m_hostRoutes.push_back (route);
}
void
Ipv4GlobalRouting::AddNetworkRouteTo (Ipv4Address network,
Ipv4Mask networkMask,
Ipv4Address nextHop,
uint32_t interface)
{
NS_LOG_FUNCTION (network << networkMask << nextHop << interface);
Ipv4RoutingTableEntry *route = new Ipv4RoutingTableEntry ();
*route = Ipv4RoutingTableEntry::CreateNetworkRouteTo (network,
networkMask,
nextHop,
interface);
m_networkRoutes.push_back (route);
}
void
Ipv4GlobalRouting::AddNetworkRouteTo (Ipv4Address network,
Ipv4Mask networkMask,
uint32_t interface)
{
NS_LOG_FUNCTION (network << networkMask << interface);
Ipv4RoutingTableEntry *route = new Ipv4RoutingTableEntry ();
*route = Ipv4RoutingTableEntry::CreateNetworkRouteTo (network,
networkMask,
interface);
m_networkRoutes.push_back (route);
}
void
Ipv4GlobalRouting::AddASExternalRouteTo (Ipv4Address network,
Ipv4Mask networkMask,
Ipv4Address nextHop,
uint32_t interface)
{
NS_LOG_FUNCTION (network << networkMask << nextHop);
Ipv4RoutingTableEntry *route = new Ipv4RoutingTableEntry ();
*route = Ipv4RoutingTableEntry::CreateNetworkRouteTo (network,
networkMask,
nextHop,
interface);
m_ASexternalRoutes.push_back (route);
}
Ptr<Ipv4Route>
Ipv4GlobalRouting::LookupGlobal (Ipv4Address dest, Ptr<NetDevice> oif)
{
NS_LOG_FUNCTION_NOARGS ();
NS_LOG_LOGIC ("Looking for route for destination " << dest);
Ptr<Ipv4Route> rtentry = 0;
// store all available routes that bring packets to their destination
typedef std::vector<Ipv4RoutingTableEntry*> RouteVec_t;
RouteVec_t allRoutes;
NS_LOG_LOGIC ("Number of m_hostRoutes = " << m_hostRoutes.size ());
for (HostRoutesCI i = m_hostRoutes.begin ();
i != m_hostRoutes.end ();
i++)
{
NS_ASSERT ((*i)->IsHost ());
if ((*i)->GetDest ().IsEqual (dest))
{
if (oif != 0)
{
if (oif != m_ipv4->GetNetDevice ((*i)->GetInterface ()))
{
NS_LOG_LOGIC ("Not on requested interface, skipping");
continue;
}
}
allRoutes.push_back (*i);
NS_LOG_LOGIC (allRoutes.size () << "Found global host route" << *i);
}
}
if (allRoutes.size () == 0) // if no host route is found
{
NS_LOG_LOGIC ("Number of m_networkRoutes" << m_networkRoutes.size ());
for (NetworkRoutesI j = m_networkRoutes.begin ();
j != m_networkRoutes.end ();
j++)
{
Ipv4Mask mask = (*j)->GetDestNetworkMask ();
Ipv4Address entry = (*j)->GetDestNetwork ();
if (mask.IsMatch (dest, entry))
{
if (oif != 0)
{
if (oif != m_ipv4->GetNetDevice ((*j)->GetInterface ()))
{
NS_LOG_LOGIC ("Not on requested interface, skipping");
continue;
}
}
allRoutes.push_back (*j);
NS_LOG_LOGIC (allRoutes.size () << "Found global network route" << *j);
}
}
}
if (allRoutes.size () == 0) // consider external if no host/network found
{
for (ASExternalRoutesI k = m_ASexternalRoutes.begin ();
k != m_ASexternalRoutes.end ();
k++)
{
Ipv4Mask mask = (*k)->GetDestNetworkMask ();
Ipv4Address entry = (*k)->GetDestNetwork ();
if (mask.IsMatch (dest, entry))
{
NS_LOG_LOGIC ("Found external route" << *k);
if (oif != 0)
{
if (oif != m_ipv4->GetNetDevice ((*k)->GetInterface ()))
{
NS_LOG_LOGIC ("Not on requested interface, skipping");
continue;
}
}
allRoutes.push_back (*k);
break;
}
}
}
if (allRoutes.size () > 0 ) // if route(s) is found
{
// pick up one of the routes uniformly at random if random
// ECMP routing is enabled, or always select the first route
// consistently if random ECMP routing is disabled
uint32_t selectIndex;
if (m_randomEcmpRouting)
{
selectIndex = m_rand.GetInteger (0, allRoutes.size ()-1);
}
else
{
selectIndex = 0;
}
Ipv4RoutingTableEntry* route = allRoutes.at (selectIndex);
// create a Ipv4Route object from the selected routing table entry
rtentry = Create<Ipv4Route> ();
rtentry->SetDestination (route->GetDest ());
// XXX handle multi-address case
rtentry->SetSource (m_ipv4->GetAddress (route->GetInterface (), 0).GetLocal ());
rtentry->SetGateway (route->GetGateway ());
uint32_t interfaceIdx = route->GetInterface ();
rtentry->SetOutputDevice (m_ipv4->GetNetDevice (interfaceIdx));
return rtentry;
}
else
{
return 0;
}
}
uint32_t
Ipv4GlobalRouting::GetNRoutes (void) const
{
NS_LOG_FUNCTION_NOARGS ();
uint32_t n = 0;
n += m_hostRoutes.size ();
n += m_networkRoutes.size ();
n += m_ASexternalRoutes.size ();
return n;
}
Ipv4RoutingTableEntry *
Ipv4GlobalRouting::GetRoute (uint32_t index) const
{
NS_LOG_FUNCTION (index);
if (index < m_hostRoutes.size ())
{
uint32_t tmp = 0;
for (HostRoutesCI i = m_hostRoutes.begin ();
i != m_hostRoutes.end ();
i++)
{
if (tmp == index)
{
return *i;
}
tmp++;
}
}
index -= m_hostRoutes.size ();
uint32_t tmp = 0;
if (index < m_networkRoutes.size ())
{
for (NetworkRoutesCI j = m_networkRoutes.begin ();
j != m_networkRoutes.end ();
j++)
{
if (tmp == index)
{
return *j;
}
tmp++;
}
}
index -= m_networkRoutes.size ();
tmp = 0;
for (ASExternalRoutesCI k = m_ASexternalRoutes.begin ();
k != m_ASexternalRoutes.end ();
k++)
{
if (tmp == index)
{
return *k;
}
tmp++;
}
NS_ASSERT (false);
// quiet compiler.
return 0;
}
void
Ipv4GlobalRouting::RemoveRoute (uint32_t index)
{
NS_LOG_FUNCTION (index);
if (index < m_hostRoutes.size ())
{
uint32_t tmp = 0;
for (HostRoutesI i = m_hostRoutes.begin ();
i != m_hostRoutes.end ();
i++)
{
if (tmp == index)
{
NS_LOG_LOGIC ("Removing route " << index << "; size = " << m_hostRoutes.size ());
delete *i;
m_hostRoutes.erase (i);
NS_LOG_LOGIC ("Done removing host route " << index << "; host route remaining size = " << m_hostRoutes.size ());
return;
}
tmp++;
}
}
index -= m_hostRoutes.size ();
uint32_t tmp = 0;
for (NetworkRoutesI j = m_networkRoutes.begin ();
j != m_networkRoutes.end ();
j++)
{
if (tmp == index)
{
NS_LOG_LOGIC ("Removing route " << index << "; size = " << m_networkRoutes.size ());
delete *j;
m_networkRoutes.erase (j);
NS_LOG_LOGIC ("Done removing network route " << index << "; network route remaining size = " << m_networkRoutes.size ());
return;
}
tmp++;
}
index -= m_networkRoutes.size ();
tmp = 0;
for (ASExternalRoutesI k = m_ASexternalRoutes.begin ();
k != m_ASexternalRoutes.end ();
k++)
{
if (tmp == index)
{
NS_LOG_LOGIC ("Removing route " << index << "; size = " << m_ASexternalRoutes.size ());
delete *k;
m_ASexternalRoutes.erase (k);
NS_LOG_LOGIC ("Done removing network route " << index << "; network route remaining size = " << m_networkRoutes.size ());
return;
}
tmp++;
}
NS_ASSERT (false);
}
void
Ipv4GlobalRouting::DoDispose (void)
{
NS_LOG_FUNCTION_NOARGS ();
for (HostRoutesI i = m_hostRoutes.begin ();
i != m_hostRoutes.end ();
i = m_hostRoutes.erase (i))
{
delete (*i);
}
for (NetworkRoutesI j = m_networkRoutes.begin ();
j != m_networkRoutes.end ();
j = m_networkRoutes.erase (j))
{
delete (*j);
}
for (ASExternalRoutesI l = m_ASexternalRoutes.begin ();
l != m_ASexternalRoutes.end ();
l = m_ASexternalRoutes.erase (l))
{
delete (*l);
}
Ipv4RoutingProtocol::DoDispose ();
}
// Formatted like output of "route -n" command
void
Ipv4GlobalRouting::PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const
{
std::ostream* os = stream->GetStream ();
if (GetNRoutes () > 0)
{
*os << "Destination Gateway Genmask Flags Metric Ref Use Iface" << std::endl;
for (uint32_t j = 0; j < GetNRoutes (); j++)
{
std::ostringstream dest, gw, mask, flags;
Ipv4RoutingTableEntry route = GetRoute (j);
dest << route.GetDest ();
*os << std::setiosflags (std::ios::left) << std::setw (16) << dest.str ();
gw << route.GetGateway ();
*os << std::setiosflags (std::ios::left) << std::setw (16) << gw.str ();
mask << route.GetDestNetworkMask ();
*os << std::setiosflags (std::ios::left) << std::setw (16) << mask.str ();
flags << "U";
if (route.IsHost ())
{
flags << "H";
}
else if (route.IsGateway ())
{
flags << "G";
}
*os << std::setiosflags (std::ios::left) << std::setw (6) << flags.str ();
// Metric not implemented
*os << "-" << " ";
// Ref ct not implemented
*os << "-" << " ";
// Use not implemented
*os << "-" << " ";
if (Names::FindName (m_ipv4->GetNetDevice (route.GetInterface ())) != "")
{
*os << Names::FindName (m_ipv4->GetNetDevice (route.GetInterface ()));
}
else
{
*os << route.GetInterface ();
}
*os << std::endl;
}
}
}
Ptr<Ipv4Route>
Ipv4GlobalRouting::RouteOutput (Ptr<Packet> p, const Ipv4Header &header, Ptr<NetDevice> oif, Socket::SocketErrno &sockerr)
{
//
// First, see if this is a multicast packet we have a route for. If we
// have a route, then send the packet down each of the specified interfaces.
//
if (header.GetDestination ().IsMulticast ())
{
NS_LOG_LOGIC ("Multicast destination-- returning false");
return 0; // Let other routing protocols try to handle this
}
//
// See if this is a unicast packet we have a route for.
//
NS_LOG_LOGIC ("Unicast destination- looking up");
Ptr<Ipv4Route> rtentry = LookupGlobal (header.GetDestination (), oif);
if (rtentry)
{
sockerr = Socket::ERROR_NOTERROR;
}
else
{
sockerr = Socket::ERROR_NOROUTETOHOST;
}
return rtentry;
}
bool
Ipv4GlobalRouting::RouteInput (Ptr<const Packet> p, const Ipv4Header &header, Ptr<const NetDevice> idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb,
LocalDeliverCallback lcb, ErrorCallback ecb)
{
NS_LOG_FUNCTION (this << p << header << header.GetSource () << header.GetDestination () << idev);
// Check if input device supports IP
NS_ASSERT (m_ipv4->GetInterfaceForDevice (idev) >= 0);
uint32_t iif = m_ipv4->GetInterfaceForDevice (idev);
if (header.GetDestination ().IsMulticast ())
{
NS_LOG_LOGIC ("Multicast destination-- returning false");
return false; // Let other routing protocols try to handle this
}
if (header.GetDestination ().IsBroadcast ())
{
NS_LOG_LOGIC ("For me (Ipv4Addr broadcast address)");
// TODO: Local Deliver for broadcast
// TODO: Forward broadcast
}
// TODO: Configurable option to enable RFC 1222 Strong End System Model
// Right now, we will be permissive and allow a source to send us
// a packet to one of our other interface addresses; that is, the
// destination unicast address does not match one of the iif addresses,
// but we check our other interfaces. This could be an option
// (to remove the outer loop immediately below and just check iif).
for (uint32_t j = 0; j < m_ipv4->GetNInterfaces (); j++)
{
for (uint32_t i = 0; i < m_ipv4->GetNAddresses (j); i++)
{
Ipv4InterfaceAddress iaddr = m_ipv4->GetAddress (j, i);
Ipv4Address addr = iaddr.GetLocal ();
if (addr.IsEqual (header.GetDestination ()))
{
if (j == iif)
{
NS_LOG_LOGIC ("For me (destination " << addr << " match)");
}
else
{
NS_LOG_LOGIC ("For me (destination " << addr << " match) on another interface " << header.GetDestination ());
}
lcb (p, header, iif);
return true;
}
if (header.GetDestination ().IsEqual (iaddr.GetBroadcast ()))
{
NS_LOG_LOGIC ("For me (interface broadcast address)");
lcb (p, header, iif);
return true;
}
NS_LOG_LOGIC ("Address "<< addr << " not a match");
}
}
// Check if input device supports IP forwarding
if (m_ipv4->IsForwarding (iif) == false)
{
NS_LOG_LOGIC ("Forwarding disabled for this interface");
ecb (p, header, Socket::ERROR_NOROUTETOHOST);
return false;
}
// Next, try to find a route
NS_LOG_LOGIC ("Unicast destination- looking up global route");
Ptr<Ipv4Route> rtentry = LookupGlobal (header.GetDestination ());
if (rtentry != 0)
{
NS_LOG_LOGIC ("Found unicast destination- calling unicast callback");
ucb (rtentry, p, header);
return true;
}
else
{
NS_LOG_LOGIC ("Did not find unicast destination- returning false");
return false; // Let other routing protocols try to handle this
// route request.
}
}
void
Ipv4GlobalRouting::NotifyInterfaceUp (uint32_t i)
{
+15 -155
View File
@@ -20,26 +20,16 @@
#ifndef IPV4_GLOBAL_ROUTING_H
#define IPV4_GLOBAL_ROUTING_H
#include <list>
#include <stdint.h>
#include "ns3/ipv4-address.h"
#include "ns3/ipv4-header.h"
#include "ns3/ptr.h"
#include "ns3/ipv4.h"
#include "ns3/ipv4-routing-protocol.h"
#include "ns3/random-variable.h"
namespace ns3 {
class Packet;
class NetDevice;
class Ipv4Interface;
class Ipv4Address;
class Ipv4Header;
class Ipv4RoutingTableEntry;
class Ipv4MulticastRoutingTableEntry;
class Node;
/**
* \brief Global routing protocol for IP version 4 stacks.
@@ -70,175 +60,45 @@ class Ipv4GlobalRouting : public Ipv4RoutingProtocol
{
public:
static TypeId GetTypeId (void);
/**
* \brief Construct an empty Ipv4GlobalRouting routing protocol,
*
* The Ipv4GlobalRouting class supports host and network unicast routes.
* This method initializes the lists containing these routes to empty.
*
* \see Ipv4GlobalRouting
*/
Ipv4GlobalRouting ();
virtual ~Ipv4GlobalRouting ();
// These methods inherited from base class
virtual Ptr<Ipv4Route> RouteOutput (Ptr<Packet> p, const Ipv4Header &header, Ptr<NetDevice> oif, Socket::SocketErrno &sockerr);
virtual bool RouteInput (Ptr<const Packet> p, const Ipv4Header &header, Ptr<const NetDevice> idev,
UnicastForwardCallback ucb, MulticastForwardCallback mcb,
LocalDeliverCallback lcb, ErrorCallback ecb);
virtual void NotifyInterfaceUp (uint32_t interface);
virtual void NotifyInterfaceDown (uint32_t interface);
virtual void NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress address);
virtual void NotifyRemoveAddress (uint32_t interface, Ipv4InterfaceAddress address);
virtual void SetIpv4 (Ptr<Ipv4> ipv4);
virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const;
/**
* \brief Add a host route to the global routing table.
* \brief Add a route to the global routing table.
*
* \param dest The Ipv4Address destination for this route.
* \param destMask The Ipv4Mask to extract the network.
* \param nextHop The Ipv4Address of the next hop in the route.
* \param interface The network interface index used to send packets to the
* destination.
*
* \see Ipv4Address
*/
void AddHostRouteTo (Ipv4Address dest,
Ipv4Address nextHop,
uint32_t interface);
/**
* \brief Add a host route to the global routing table.
*
* \param dest The Ipv4Address destination for this route.
* \param interface The network interface index used to send packets to the
* destination.
*
* \see Ipv4Address
*/
void AddHostRouteTo (Ipv4Address dest,
uint32_t interface);
virtual void AddRouteTo (Ipv4Address dest,
Ipv4Mask destMask,
Ipv4Address nextHop,
uint32_t interface,
uint32_t metric=0) = 0;
/**
* \brief Add a network route to the global routing table.
*
* \param network The Ipv4Address network for this route.
* \param networkMask The Ipv4Mask to extract the network.
* \param nextHop The next hop in the route to the destination network.
* \param interface The network interface index used to send packets to the
* destination.
*
* \see Ipv4Address
*/
void AddNetworkRouteTo (Ipv4Address network,
Ipv4Mask networkMask,
Ipv4Address nextHop,
uint32_t interface);
/**
* \brief Add a network route to the global routing table.
*
* \param network The Ipv4Address network for this route.
* \param networkMask The Ipv4Mask to extract the network.
* \param interface The network interface index used to send packets to the
* destination.
*
* \see Ipv4Address
*/
void AddNetworkRouteTo (Ipv4Address network,
Ipv4Mask networkMask,
uint32_t interface);
/**
* \brief Add an external route to the global routing table.
*
* \param network The Ipv4Address network for this route.
* \param networkMask The Ipv4Mask to extract the network.
* \param nextHop The next hop Ipv4Address
* \param interface The network interface index used to send packets to the
* destination.
*/
void AddASExternalRouteTo (Ipv4Address network,
Ipv4Mask networkMask,
Ipv4Address nextHop,
uint32_t interface);
/**
* \brief Get the number of individual unicast routes that have been added
* to the routing table.
*
* \warning The default route counts as one of the routes.
*/
uint32_t GetNRoutes (void) const;
/**
* \brief Get a route from the global unicast routing table.
*
* Externally, the unicast global routing table appears simply as a table with
* n entries. The one subtlety of note is that if a default route has been set
* it will appear as the zeroth entry in the table. This means that if you
* add only a default route, the table will have one entry that can be accessed
* either by explicitly calling GetDefaultRoute () or by calling GetRoute (0).
*
* Similarly, if the default route has been set, calling RemoveRoute (0) will
* remove the default route.
*
* \param i The index (into the routing table) of the route to retrieve. If
* the default route has been set, it will occupy index zero.
* \return If route is set, a pointer to that Ipv4RoutingTableEntry is returned, otherwise
* a zero pointer is returned.
*
* \see Ipv4RoutingTableEntry
* \see Ipv4GlobalRouting::RemoveRoute
*/
Ipv4RoutingTableEntry *GetRoute (uint32_t i) const;
/**
* \brief Remove a route from the global unicast routing table.
*
* Externally, the unicast global routing table appears simply as a table with
* n entries. The one subtlety of note is that if a default route has been set
* it will appear as the zeroth entry in the table. This means that if the
* default route has been set, calling RemoveRoute (0) will remove the
* default route.
*
* \param i The index (into the routing table) of the route to remove. If
* the default route has been set, it will occupy index zero.
*
* \see Ipv4RoutingTableEntry
* \see Ipv4GlobalRouting::GetRoute
* \see Ipv4GlobalRouting::AddRoute
*/
void RemoveRoute (uint32_t i);
/**
* \brief Function to remove all routes
*/
virtual void DeleteRoutes () = 0;
protected:
void DoDispose (void);
// virtual Ptr<Ipv4Route> LookupGlobal (Ipv4Address dest, Ptr<NetDevice> oif = 0) = 0;
Ptr<Ipv4> m_ipv4;
private:
/// Set to true if packets are randomly routed among ECMP; set to false for using only one route consistently
bool m_randomEcmpRouting;
/// Set to true if this interface should respond to interface events by globallly recomputing routes
bool m_respondToInterfaceEvents;
/// A uniform random number generator for randomly routing packets among ECMP
UniformVariable m_rand;
typedef std::list<Ipv4RoutingTableEntry *> HostRoutes;
typedef std::list<Ipv4RoutingTableEntry *>::const_iterator HostRoutesCI;
typedef std::list<Ipv4RoutingTableEntry *>::iterator HostRoutesI;
typedef std::list<Ipv4RoutingTableEntry *> NetworkRoutes;
typedef std::list<Ipv4RoutingTableEntry *>::const_iterator NetworkRoutesCI;
typedef std::list<Ipv4RoutingTableEntry *>::iterator NetworkRoutesI;
typedef std::list<Ipv4RoutingTableEntry *> ASExternalRoutes;
typedef std::list<Ipv4RoutingTableEntry *>::const_iterator ASExternalRoutesCI;
typedef std::list<Ipv4RoutingTableEntry *>::iterator ASExternalRoutesI;
Ptr<Ipv4Route> LookupGlobal (Ipv4Address dest, Ptr<NetDevice> oif = 0);
HostRoutes m_hostRoutes;
NetworkRoutes m_networkRoutes;
ASExternalRoutes m_ASexternalRoutes; // External routes imported
Ptr<Ipv4> m_ipv4;
};
} // Namespace ns3
+3 -4
View File
@@ -547,11 +547,10 @@ Ipv4L3Protocol::Send (Ptr<Packet> packet,
Ipv4Header ipHeader;
bool mayFragment = true;
uint8_t ttl = m_defaultTtl;
SocketIpTtlTag tag;
bool found = packet->RemovePacketTag (tag);
if (found)
Ptr<const SocketIpTtlTag> tag = packet->RemovePacketTag<SocketIpTtlTag> ();
if (tag != 0)
{
ttl = tag.GetTtl ();
ttl = tag->GetTtl ();
}
// Handle a few cases:
+4 -3
View File
@@ -320,9 +320,10 @@ Ipv4RawSocketImpl::ForwardUp (Ptr<const Packet> p, Ipv4Header ipHeader, Ptr<Ipv4
// Should check via getsockopt ()..
if (IsRecvPktInfo ())
{
Ipv4PacketInfoTag tag;
copy->RemovePacketTag (tag);
tag.SetRecvIf (incomingInterface->GetDevice ()->GetIfIndex ());
Ptr<const Ipv4PacketInfoTag> origTag = copy->RemovePacketTag<Ipv4PacketInfoTag> ();
NS_ASSERT (origTag != 0);
Ptr<Ipv4PacketInfoTag> tag = CreateObject<Ipv4PacketInfoTag> (*origTag);
tag->SetRecvIf (incomingInterface->GetDevice ()->GetIfIndex ());
copy->AddPacketTag (tag);
}
if (m_protocol == 1)
+50 -22
View File
@@ -35,7 +35,8 @@ Ipv4RoutingTableEntry::Ipv4RoutingTableEntry (Ipv4RoutingTableEntry const &route
: m_dest (route.m_dest),
m_destNetworkMask (route.m_destNetworkMask),
m_gateway (route.m_gateway),
m_interface (route.m_interface)
m_interface (route.m_interface),
m_metric (route.m_metric)
{
}
@@ -43,44 +44,53 @@ Ipv4RoutingTableEntry::Ipv4RoutingTableEntry (Ipv4RoutingTableEntry const *route
: m_dest (route->m_dest),
m_destNetworkMask (route->m_destNetworkMask),
m_gateway (route->m_gateway),
m_interface (route->m_interface)
m_interface (route->m_interface),
m_metric (route->m_metric)
{
}
Ipv4RoutingTableEntry::Ipv4RoutingTableEntry (Ipv4Address dest,
Ipv4Address gateway,
uint32_t interface)
uint32_t interface,
uint32_t metric/*=0*/)
: m_dest (dest),
m_destNetworkMask (Ipv4Mask::GetOnes ()),
m_gateway (gateway),
m_interface (interface)
m_interface (interface),
m_metric (metric)
{
}
Ipv4RoutingTableEntry::Ipv4RoutingTableEntry (Ipv4Address dest,
uint32_t interface)
uint32_t interface,
uint32_t metric/*=0*/)
: m_dest (dest),
m_destNetworkMask (Ipv4Mask::GetOnes ()),
m_gateway (Ipv4Address::GetZero ()),
m_interface (interface)
m_interface (interface),
m_metric (metric)
{
}
Ipv4RoutingTableEntry::Ipv4RoutingTableEntry (Ipv4Address network,
Ipv4Mask networkMask,
Ipv4Address gateway,
uint32_t interface)
uint32_t interface,
uint32_t metric/*=0*/)
: m_dest (network),
m_destNetworkMask (networkMask),
m_gateway (gateway),
m_interface (interface)
m_interface (interface),
m_metric (metric)
{
}
Ipv4RoutingTableEntry::Ipv4RoutingTableEntry (Ipv4Address network,
Ipv4Mask networkMask,
uint32_t interface)
uint32_t interface,
uint32_t metric/*=0*/)
: m_dest (network),
m_destNetworkMask (networkMask),
m_gateway (Ipv4Address::GetZero ()),
m_interface (interface)
m_interface (interface),
m_metric (metric)
{
}
@@ -151,41 +161,58 @@ Ipv4RoutingTableEntry::GetInterface (void) const
return m_interface;
}
uint32_t
Ipv4RoutingTableEntry::GetMetric () const
{
return m_metric;
}
void
Ipv4RoutingTableEntry::SetMetric (uint32_t metric)
{
m_metric = metric;
}
Ipv4RoutingTableEntry
Ipv4RoutingTableEntry::CreateHostRouteTo (Ipv4Address dest,
Ipv4Address nextHop,
uint32_t interface)
uint32_t interface,
uint32_t metric/*=0*/)
{
return Ipv4RoutingTableEntry (dest, nextHop, interface);
return Ipv4RoutingTableEntry (dest, nextHop, interface, metric);
}
Ipv4RoutingTableEntry
Ipv4RoutingTableEntry::CreateHostRouteTo (Ipv4Address dest,
uint32_t interface)
uint32_t interface,
uint32_t metric/*=0*/)
{
return Ipv4RoutingTableEntry (dest, interface);
return Ipv4RoutingTableEntry (dest, interface, metric);
}
Ipv4RoutingTableEntry
Ipv4RoutingTableEntry::CreateNetworkRouteTo (Ipv4Address network,
Ipv4Mask networkMask,
Ipv4Address nextHop,
uint32_t interface)
uint32_t interface,
uint32_t metric/*=0*/)
{
return Ipv4RoutingTableEntry (network, networkMask,
nextHop, interface);
nextHop, interface, metric);
}
Ipv4RoutingTableEntry
Ipv4RoutingTableEntry::CreateNetworkRouteTo (Ipv4Address network,
Ipv4Mask networkMask,
uint32_t interface)
uint32_t interface,
uint32_t metric/*=0*/)
{
return Ipv4RoutingTableEntry (network, networkMask,
interface);
interface, metric);
}
Ipv4RoutingTableEntry
Ipv4RoutingTableEntry::CreateDefaultRoute (Ipv4Address nextHop,
uint32_t interface)
uint32_t interface,
uint32_t metric/*=0*/)
{
return Ipv4RoutingTableEntry (Ipv4Address::GetZero (), nextHop, interface);
return Ipv4RoutingTableEntry (Ipv4Address::GetZero (), nextHop, interface, metric);
}
@@ -216,20 +243,21 @@ std::ostream& operator<< (std::ostream& os, Ipv4RoutingTableEntry const& route)
{
os << "network=" << route.GetDestNetwork () <<
", mask=" << route.GetDestNetworkMask () <<
",out=" << route.GetInterface () <<
", out=" << route.GetInterface () <<
", next hop=" << route.GetGateway ();
}
else
{
os << "network=" << route.GetDestNetwork () <<
", mask=" << route.GetDestNetworkMask () <<
",out=" << route.GetInterface ();
", out=" << route.GetInterface ();
}
}
else
{
NS_ASSERT (false);
}
os << ", metric=" << route.GetMetric ();
return os;
}
+28 -9
View File
@@ -88,6 +88,15 @@ public:
* \return The Ipv4 interface number used for sending outgoing packets
*/
uint32_t GetInterface (void) const;
/**
* \return Routing metric
*/
uint32_t GetMetric () const;
/**
* Set/Updates metric of the routing table entry
*/
void SetMetric (uint32_t metric);
/**
* \return An Ipv4RoutingTableEntry object corresponding to the input parameters.
* \param dest Ipv4Address of the destination
@@ -96,14 +105,16 @@ public:
*/
static Ipv4RoutingTableEntry CreateHostRouteTo (Ipv4Address dest,
Ipv4Address nextHop,
uint32_t interface);
uint32_t interface,
uint32_t metric=0);
/**
* \return An Ipv4RoutingTableEntry object corresponding to the input parameters.
* \param dest Ipv4Address of the destination
* \param interface Outgoing interface
*/
static Ipv4RoutingTableEntry CreateHostRouteTo (Ipv4Address dest,
uint32_t interface);
uint32_t interface,
uint32_t metric=0);
/**
* \return An Ipv4RoutingTableEntry object corresponding to the input parameters.
* \param network Ipv4Address of the destination network
@@ -114,7 +125,8 @@ public:
static Ipv4RoutingTableEntry CreateNetworkRouteTo (Ipv4Address network,
Ipv4Mask networkMask,
Ipv4Address nextHop,
uint32_t interface);
uint32_t interface,
uint32_t metric=0);
/**
* \return An Ipv4RoutingTableEntry object corresponding to the input parameters.
* \param network Ipv4Address of the destination network
@@ -123,7 +135,8 @@ public:
*/
static Ipv4RoutingTableEntry CreateNetworkRouteTo (Ipv4Address network,
Ipv4Mask networkMask,
uint32_t interface);
uint32_t interface,
uint32_t metric=0);
/**
* \return An Ipv4RoutingTableEntry object corresponding to the input
* parameters. This route is distinguished; it will match any
@@ -132,26 +145,32 @@ public:
* \param interface Outgoing interface
*/
static Ipv4RoutingTableEntry CreateDefaultRoute (Ipv4Address nextHop,
uint32_t interface);
uint32_t interface,
uint32_t metric=0);
private:
Ipv4RoutingTableEntry (Ipv4Address network,
Ipv4Mask mask,
Ipv4Address gateway,
uint32_t interface);
uint32_t interface,
uint32_t metric=0);
Ipv4RoutingTableEntry (Ipv4Address dest,
Ipv4Mask mask,
uint32_t interface);
uint32_t interface,
uint32_t metric=0);
Ipv4RoutingTableEntry (Ipv4Address dest,
Ipv4Address gateway,
uint32_t interface);
uint32_t interface,
uint32_t metric=0);
Ipv4RoutingTableEntry (Ipv4Address dest,
uint32_t interface);
uint32_t interface,
uint32_t metric=0);
Ipv4Address m_dest;
Ipv4Mask m_destNetworkMask;
Ipv4Address m_gateway;
uint32_t m_interface;
uint32_t m_metric;
};
std::ostream& operator<< (std::ostream& os, Ipv4RoutingTableEntry const& route);
+36 -33
View File
@@ -36,8 +36,6 @@
NS_LOG_COMPONENT_DEFINE ("Ipv4StaticRouting");
using std::make_pair;
namespace ns3 {
NS_OBJECT_ENSURE_REGISTERED (Ipv4StaticRouting);
@@ -70,8 +68,9 @@ Ipv4StaticRouting::AddNetworkRouteTo (Ipv4Address network,
*route = Ipv4RoutingTableEntry::CreateNetworkRouteTo (network,
networkMask,
nextHop,
interface);
m_networkRoutes.push_back (make_pair (route,metric));
interface,
metric);
m_networkRoutes.push_back (route);
}
void
@@ -84,8 +83,9 @@ Ipv4StaticRouting::AddNetworkRouteTo (Ipv4Address network,
Ipv4RoutingTableEntry *route = new Ipv4RoutingTableEntry ();
*route = Ipv4RoutingTableEntry::CreateNetworkRouteTo (network,
networkMask,
interface);
m_networkRoutes.push_back (make_pair (route,metric));
interface,
metric);
m_networkRoutes.push_back (route);
}
void
@@ -142,7 +142,7 @@ Ipv4StaticRouting::SetDefaultMulticastRoute (uint32_t outputInterface)
*route = Ipv4RoutingTableEntry::CreateNetworkRouteTo (network,
networkMask,
outputInterface);
m_networkRoutes.push_back (make_pair (route,0));
m_networkRoutes.push_back (route);
}
uint32_t
@@ -162,7 +162,7 @@ Ipv4StaticRouting::GetMulticastRoute (uint32_t index) const
if (index < m_multicastRoutes.size ())
{
uint32_t tmp = 0;
for (MulticastRoutesCI i = m_multicastRoutes.begin ();
for (MulticastRoutes::const_iterator i = m_multicastRoutes.begin ();
i != m_multicastRoutes.end ();
i++)
{
@@ -182,7 +182,7 @@ Ipv4StaticRouting::RemoveMulticastRoute (Ipv4Address origin,
uint32_t inputInterface)
{
NS_LOG_FUNCTION (this << origin << " " << group << " " << inputInterface);
for (MulticastRoutesI i = m_multicastRoutes.begin ();
for (MulticastRoutes::iterator i = m_multicastRoutes.begin ();
i != m_multicastRoutes.end ();
i++)
{
@@ -204,7 +204,7 @@ Ipv4StaticRouting::RemoveMulticastRoute (uint32_t index)
{
NS_LOG_FUNCTION (this << index);
uint32_t tmp = 0;
for (MulticastRoutesI i = m_multicastRoutes.begin ();
for (MulticastRoutes::iterator i = m_multicastRoutes.begin ();
i != m_multicastRoutes.end ();
i++)
{
@@ -239,12 +239,12 @@ Ipv4StaticRouting::LookupStatic (Ipv4Address dest, Ptr<NetDevice> oif)
}
for (NetworkRoutesI i = m_networkRoutes.begin ();
for (NetworkRoutes::iterator i = m_networkRoutes.begin ();
i != m_networkRoutes.end ();
i++)
{
Ipv4RoutingTableEntry *j=i->first;
uint32_t metric =i->second;
Ipv4RoutingTableEntry *j=*i;
uint32_t metric =j->GetMetric ();
Ipv4Mask mask = (j)->GetDestNetworkMask ();
uint16_t masklen = mask.GetPrefixLength ();
Ipv4Address entry = (j)->GetDestNetwork ();
@@ -305,7 +305,7 @@ Ipv4StaticRouting::LookupStatic (
NS_LOG_FUNCTION (this << origin << " " << group << " " << interface);
Ptr<Ipv4MulticastRoute> mrtentry = 0;
for (MulticastRoutesI i = m_multicastRoutes.begin ();
for (MulticastRoutes::iterator i = m_multicastRoutes.begin ();
i != m_multicastRoutes.end ();
i++)
{
@@ -363,13 +363,13 @@ Ipv4StaticRouting::GetDefaultRoute ()
Ipv4Address dest ("0.0.0.0");
uint32_t shortest_metric = 0xffffffff;
Ipv4RoutingTableEntry *result = 0;
for (NetworkRoutesI i = m_networkRoutes.begin ();
for (NetworkRoutes::iterator i = m_networkRoutes.begin ();
i != m_networkRoutes.end ();
i++)
{
Ipv4RoutingTableEntry *j = i->first;
uint32_t metric = i->second;
Ipv4Mask mask = (j)->GetDestNetworkMask ();
Ipv4RoutingTableEntry *j = *i;
uint32_t metric = j->GetMetric ();
Ipv4Mask mask = j->GetDestNetworkMask ();
uint16_t masklen = mask.GetPrefixLength ();
if (masklen != 0)
{
@@ -397,13 +397,13 @@ Ipv4StaticRouting::GetRoute (uint32_t index) const
{
NS_LOG_FUNCTION (this << index);
uint32_t tmp = 0;
for (NetworkRoutesCI j = m_networkRoutes.begin ();
for (NetworkRoutes::const_iterator j = m_networkRoutes.begin ();
j != m_networkRoutes.end ();
j++)
{
if (tmp == index)
{
return j->first;
return *j;
}
tmp++;
}
@@ -417,13 +417,13 @@ Ipv4StaticRouting::GetMetric (uint32_t index) const
{
NS_LOG_FUNCTION (this << index);
uint32_t tmp = 0;
for (NetworkRoutesCI j = m_networkRoutes.begin ();
for (NetworkRoutes::const_iterator j = m_networkRoutes.begin ();
j != m_networkRoutes.end ();
j++)
{
if (tmp == index)
{
return j->second;
return (*j)->GetMetric ();
}
tmp++;
}
@@ -436,13 +436,13 @@ Ipv4StaticRouting::RemoveRoute (uint32_t index)
{
NS_LOG_FUNCTION (this << index);
uint32_t tmp = 0;
for (NetworkRoutesI j = m_networkRoutes.begin ();
for (NetworkRoutes::iterator j = m_networkRoutes.begin ();
j != m_networkRoutes.end ();
j++)
{
if (tmp == index)
{
delete j->first;
delete *j;
m_networkRoutes.erase (j);
return;
}
@@ -584,13 +584,13 @@ Ipv4StaticRouting::~Ipv4StaticRouting ()
void
Ipv4StaticRouting::DoDispose (void)
{
for (NetworkRoutesI j = m_networkRoutes.begin ();
for (NetworkRoutes::iterator j = m_networkRoutes.begin ();
j != m_networkRoutes.end ();
j = m_networkRoutes.erase (j))
{
delete (j->first);
delete *j;
}
for (MulticastRoutesI i = m_multicastRoutes.begin ();
for (MulticastRoutes::iterator i = m_multicastRoutes.begin ();
i != m_multicastRoutes.end ();
i = m_multicastRoutes.erase (i))
{
@@ -708,15 +708,18 @@ Ipv4StaticRouting::PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const
if (GetNRoutes () > 0)
{
*os << "Destination Gateway Genmask Flags Metric Ref Use Iface" << std::endl;
for (uint32_t j = 0; j < GetNRoutes (); j++)
for (NetworkRoutes::const_iterator j = m_networkRoutes.begin ();
j != m_networkRoutes.end ();
j++)
{
std::ostringstream dest, gw, mask, flags;
Ipv4RoutingTableEntry route = GetRoute (j);
dest << route.GetDest ();
Ipv4RoutingTableEntry &route = *(*j);
dest << route.GetDest ();
*os << std::setiosflags (std::ios::left) << std::setw (16) << dest.str ();
gw << route.GetGateway ();
gw << route.GetGateway ();
*os << std::setiosflags (std::ios::left) << std::setw (16) << gw.str ();
mask << route.GetDestNetworkMask ();
mask << route.GetDestNetworkMask ();
*os << std::setiosflags (std::ios::left) << std::setw (16) << mask.str ();
flags << "U";
if (route.IsHost ())
@@ -728,7 +731,7 @@ Ipv4StaticRouting::PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const
flags << "GS";
}
*os << std::setiosflags (std::ios::left) << std::setw (6) << flags.str ();
*os << std::setiosflags (std::ios::left) << std::setw (7) << GetMetric (j);
*os << std::setiosflags (std::ios::left) << std::setw (6) << route.GetMetric ();
// Ref ct not implemented
*os << "-" << " ";
// Use not implemented
+5 -5
View File
@@ -375,13 +375,13 @@ protected:
virtual void DoDispose (void);
private:
typedef std::list<std::pair <Ipv4RoutingTableEntry *, uint32_t> > NetworkRoutes;
typedef std::list<std::pair <Ipv4RoutingTableEntry *, uint32_t> >::const_iterator NetworkRoutesCI;
typedef std::list<std::pair <Ipv4RoutingTableEntry *, uint32_t> >::iterator NetworkRoutesI;
typedef std::list<Ipv4RoutingTableEntry *> NetworkRoutes;
// typedef std::list<Ipv4RoutingTableEntry *>::const_iterator NetworkRoutesCI;
// typedef std::list<Ipv4RoutingTableEntry *>::iterator NetworkRoutesI;
typedef std::list<Ipv4MulticastRoutingTableEntry *> MulticastRoutes;
typedef std::list<Ipv4MulticastRoutingTableEntry *>::const_iterator MulticastRoutesCI;
typedef std::list<Ipv4MulticastRoutingTableEntry *>::iterator MulticastRoutesI;
// typedef std::list<Ipv4MulticastRoutingTableEntry *>::const_iterator MulticastRoutesCI;
// typedef std::list<Ipv4MulticastRoutingTableEntry *>::iterator MulticastRoutesI;
Ptr<Ipv4Route> LookupStatic (Ipv4Address dest, Ptr<NetDevice> oif = 0);
Ptr<Ipv4MulticastRoute> LookupStatic (Ipv4Address origin, Ipv4Address group,
+3 -4
View File
@@ -610,12 +610,11 @@ void Ipv6L3Protocol::Send (Ptr<Packet> packet, Ipv6Address source, Ipv6Address d
NS_LOG_FUNCTION (this << packet << source << destination << (uint32_t)protocol << route);
Ipv6Header hdr;
uint8_t ttl = m_defaultTtl;
SocketIpTtlTag tag;
bool found = packet->RemovePacketTag (tag);
Ptr<const SocketIpTtlTag> tag = packet->RemovePacketTag<SocketIpTtlTag> ();
if (found)
if (tag != 0)
{
ttl = tag.GetTtl ();
ttl = tag->GetTtl ();
}
/* Handle 3 cases:
+3 -3
View File
@@ -340,9 +340,9 @@ bool Ipv6RawSocketImpl::ForwardUp (Ptr<const Packet> p, Ipv6Header hdr, Ptr<NetD
// Should check via getsockopt ()..
if (IsRecvPktInfo ())
{
Ipv6PacketInfoTag tag;
copy->RemovePacketTag (tag);
tag.SetRecvIf (device->GetIfIndex ());
Ptr<const Ipv6PacketInfoTag> origTag = copy->RemovePacketTag<Ipv6PacketInfoTag> ();
Ptr<Ipv6PacketInfoTag> tag = CreateObject<Ipv6PacketInfoTag> (*origTag);
tag->SetRecvIf (device->GetIfIndex ());
copy->AddPacketTag (tag);
}
+55 -18
View File
@@ -61,6 +61,12 @@ RttEstimator::GetTypeId (void)
MakeTimeAccessor (&RttEstimator::SetMinRto,
&RttEstimator::GetMinRto),
MakeTimeChecker ())
.AddAttribute ("MaxRTO",
"Maximum retransmit timeout value",
TimeValue (Seconds (200.0)),
MakeTimeAccessor (&RttEstimator::SetMaxRto,
&RttEstimator::GetMaxRto),
MakeTimeChecker ())
;
return tid;
}
@@ -76,6 +82,19 @@ RttEstimator::GetMinRto (void) const
{
return m_minRto;
}
void
RttEstimator::SetMaxRto (Time maxRto)
{
NS_LOG_FUNCTION (this << maxRto);
m_maxRto = maxRto;
}
Time
RttEstimator::GetMaxRto (void) const
{
return m_maxRto;
}
void
RttEstimator::SetCurrentEstimate (Time estimate)
{
@@ -123,7 +142,7 @@ RttEstimator::RttEstimator (const RttEstimator& c)
: Object (c), m_next (c.m_next), m_history (c.m_history),
m_maxMultiplier (c.m_maxMultiplier),
m_initialEstimatedRtt (c.m_initialEstimatedRtt),
m_currentEstimatedRtt (c.m_currentEstimatedRtt), m_minRto (c.m_minRto),
m_currentEstimatedRtt (c.m_currentEstimatedRtt), m_minRto (c.m_minRto), m_maxRto (c.m_maxRto),
m_nSamples (c.m_nSamples), m_multiplier (c.m_multiplier)
{
NS_LOG_FUNCTION (this);
@@ -234,10 +253,15 @@ RttMeanDeviation::GetTypeId (void)
.SetParent<RttEstimator> ()
.AddConstructor<RttMeanDeviation> ()
.AddAttribute ("Gain",
"Gain used in estimating the RTT, must be 0 < Gain < 1",
DoubleValue (0.1),
"Gain used in estimating the RTT (smoothed RTT), must be 0 < Gain < 1",
DoubleValue (0.125),
MakeDoubleAccessor (&RttMeanDeviation::m_gain),
MakeDoubleChecker<double> ())
.AddAttribute ("Gain2",
"Gain2 used in estimating the RTT (variance), must be 0 < Gain2 < 1",
DoubleValue (0.25),
MakeDoubleAccessor (&RttMeanDeviation::m_gain2),
MakeDoubleChecker<double> ())
;
return tid;
}
@@ -249,7 +273,7 @@ RttMeanDeviation::RttMeanDeviation() :
}
RttMeanDeviation::RttMeanDeviation (const RttMeanDeviation& c)
: RttEstimator (c), m_gain (c.m_gain), m_variance (c.m_variance)
: RttEstimator (c), m_gain (c.m_gain), m_gain2 (c.m_gain2), m_variance (c.m_variance)
{
NS_LOG_FUNCTION (this);
}
@@ -263,14 +287,15 @@ void RttMeanDeviation::Measurement (Time m)
double gErr = err.ToDouble (Time::S) * m_gain;
m_currentEstimatedRtt += Time::FromDouble (gErr, Time::S);
Time difference = Abs (err) - m_variance;
NS_LOG_DEBUG ("m_variance += " << Time::FromDouble (difference.ToDouble (Time::S) * m_gain, Time::S));
m_variance += Time::FromDouble (difference.ToDouble (Time::S) * m_gain, Time::S);
NS_LOG_DEBUG ("m_variance += " << Time::FromDouble (difference.ToDouble (Time::S) * m_gain2, Time::S));
m_variance += Time::FromDouble (difference.ToDouble (Time::S) * m_gain2, Time::S);
}
else
{ // First sample
m_currentEstimatedRtt = m; // Set estimate to current
//variance = sample / 2; // And variance to current / 2
m_variance = m; // try this
// m_variance = m; // try this why????
m_variance = Seconds (m.ToDouble (Time::S) / 2);
NS_LOG_DEBUG ("(first sample) m_variance += " << m);
}
m_nSamples++;
@@ -279,17 +304,29 @@ void RttMeanDeviation::Measurement (Time m)
Time RttMeanDeviation::RetransmitTimeout ()
{
NS_LOG_FUNCTION (this);
NS_LOG_DEBUG ("RetransmitTimeout: var " << m_variance.GetSeconds () << " est " << m_currentEstimatedRtt.GetSeconds () << " multiplier " << m_multiplier);
// RTO = srtt + 4* rttvar
int64_t temp = m_currentEstimatedRtt.ToInteger (Time::MS) + 4 * m_variance.ToInteger (Time::MS);
if (temp < m_minRto.ToInteger (Time::MS))
{
temp = m_minRto.ToInteger (Time::MS);
}
temp = temp * m_multiplier; // Apply backoff
Time retval = Time::FromInteger (temp, Time::MS);
NS_LOG_DEBUG ("RetransmitTimeout: return " << retval.GetSeconds ());
return (retval);
// If not enough samples, just return 2 times estimate
//if (nSamples < 2) return est * 2;
double retval = std::min (m_maxRto.ToDouble (Time::S),
std::max (m_minRto.ToDouble (Time::S),
m_currentEstimatedRtt.ToDouble (Time::S) + 4 * m_variance.ToDouble (Time::S)));
// NS_LOG_DEBUG ("RetransmitTimeout: var " << var << " est " << m_currentEstimatedRtt.ToDouble (Time::S) << " multiplier " << m_multiplier);
// if (var < (m_currentEstimatedRtt.ToDouble (Time::S) / 4.0) )
// {
// for (uint16_t i = 0; i < 2* m_multiplier; i++)
// {
// retval += m_currentEstimatedRtt;
// }
// }
// else
// {
// int64_t temp = m_currentEstimatedRtt.ToInteger (Time::S) + 4 * m_variance.ToInteger (Time::S);
// retval = Time::FromInteger (temp, Time::S);
// }
NS_LOG_DEBUG ("RetransmitTimeout: return " << retval);
return Seconds (retval);
}
Ptr<RttEstimator> RttMeanDeviation::Copy () const
+14
View File
@@ -124,6 +124,18 @@ public:
*/
Time GetMinRto (void) const;
/**
* \brief Sets the Maximum RTO.
* \param minRto The maximum RTO returned by the estimator.
*/
void SetMaxRto (Time maxRto);
/**
* \brief Get the Maximum RTO.
* \return The maximum RTO returned by the estimator.
*/
Time GetMaxRto (void) const;
/**
* \brief Sets the current RTT estimate (forcefully).
* \param estimate The current RTT estimate.
@@ -145,6 +157,7 @@ private:
protected:
Time m_currentEstimatedRtt; // Current estimate
Time m_minRto; // minimum value of the timeout
Time m_maxRto; // maximum value of the timeout
uint32_t m_nSamples; // Number of samples
uint16_t m_multiplier; // RTO Multiplier
};
@@ -194,6 +207,7 @@ public:
private:
double m_gain; // Filter gain
double m_gain2; // Filter gain
Time m_variance; // Current variance
};
} // namespace ns3
+81 -80
View File
@@ -269,7 +269,7 @@ TcpSocketBase::Bind6 (void)
{
m_errno = ERROR_ADDRNOTAVAIL;
return -1;
}
}
m_tcp->m_sockets.push_back (this);
return SetupCallback ();
}
@@ -281,30 +281,30 @@ TcpSocketBase::Bind (const Address &address)
NS_LOG_FUNCTION (this << address);
if (InetSocketAddress::IsMatchingType (address))
{
InetSocketAddress transport = InetSocketAddress::ConvertFrom (address);
Ipv4Address ipv4 = transport.GetIpv4 ();
uint16_t port = transport.GetPort ();
if (ipv4 == Ipv4Address::GetAny () && port == 0)
{
m_endPoint = m_tcp->Allocate ();
}
else if (ipv4 == Ipv4Address::GetAny () && port != 0)
{
m_endPoint = m_tcp->Allocate (port);
}
else if (ipv4 != Ipv4Address::GetAny () && port == 0)
{
m_endPoint = m_tcp->Allocate (ipv4);
}
else if (ipv4 != Ipv4Address::GetAny () && port != 0)
{
m_endPoint = m_tcp->Allocate (ipv4, port);
}
if (0 == m_endPoint)
{
m_errno = port ? ERROR_ADDRINUSE : ERROR_ADDRNOTAVAIL;
return -1;
}
InetSocketAddress transport = InetSocketAddress::ConvertFrom (address);
Ipv4Address ipv4 = transport.GetIpv4 ();
uint16_t port = transport.GetPort ();
if (ipv4 == Ipv4Address::GetAny () && port == 0)
{
m_endPoint = m_tcp->Allocate ();
}
else if (ipv4 == Ipv4Address::GetAny () && port != 0)
{
m_endPoint = m_tcp->Allocate (port);
}
else if (ipv4 != Ipv4Address::GetAny () && port == 0)
{
m_endPoint = m_tcp->Allocate (ipv4);
}
else if (ipv4 != Ipv4Address::GetAny () && port != 0)
{
m_endPoint = m_tcp->Allocate (ipv4, port);
}
if (0 == m_endPoint)
{
m_errno = port ? ERROR_ADDRINUSE : ERROR_ADDRNOTAVAIL;
return -1;
}
}
else if (Inet6SocketAddress::IsMatchingType (address))
{
@@ -353,24 +353,24 @@ TcpSocketBase::Connect (const Address & address)
// If haven't do so, Bind() this socket first
if (InetSocketAddress::IsMatchingType (address) && m_endPoint6 == 0)
{
if (m_endPoint == 0)
if (m_endPoint == 0)
{
if (Bind () == -1)
{
if (Bind () == -1)
{
NS_ASSERT (m_endPoint == 0);
return -1; // Bind() failed
}
NS_ASSERT (m_endPoint != 0);
NS_ASSERT (m_endPoint == 0);
return -1; // Bind() failed
}
InetSocketAddress transport = InetSocketAddress::ConvertFrom (address);
m_endPoint->SetPeer (transport.GetIpv4 (), transport.GetPort ());
NS_ASSERT (m_endPoint != 0);
}
InetSocketAddress transport = InetSocketAddress::ConvertFrom (address);
m_endPoint->SetPeer (transport.GetIpv4 (), transport.GetPort ());
m_endPoint6 = 0;
// Get the appropriate local address and port number from the routing protocol and set up endpoint
if (SetupEndpoint () != 0)
{ // Route to destination does not exist
return -1;
}
// Get the appropriate local address and port number from the routing protocol and set up endpoint
if (SetupEndpoint () != 0)
{ // Route to destination does not exist
return -1;
}
}
else if (Inet6SocketAddress::IsMatchingType (address) && m_endPoint == 0)
{
@@ -381,7 +381,7 @@ TcpSocketBase::Connect (const Address & address)
if (v6Addr.IsIpv4MappedAddress () == true)
{
Ipv4Address v4Addr = v6Addr.GetIpv4MappedAddress ();
return Connect (InetSocketAddress (v4Addr, transport.GetPort ()));
return Connect(InetSocketAddress(v4Addr, transport.GetPort ()));
}
if (m_endPoint6 == 0)
@@ -526,15 +526,16 @@ TcpSocketBase::Recv (uint32_t maxSize, uint32_t flags)
Ptr<Packet> outPacket = m_rxBuffer.Extract (maxSize);
if (outPacket != 0 && outPacket->GetSize () != 0)
{
SocketAddressTag tag;
Ptr<SocketAddressTag> tag = CreateObject<SocketAddressTag> ();
if (m_endPoint != 0)
{
tag.SetAddress (InetSocketAddress (m_endPoint->GetPeerAddress (), m_endPoint->GetPeerPort ()));
tag->SetAddress (InetSocketAddress (m_endPoint->GetPeerAddress (), m_endPoint->GetPeerPort ()));
}
else if (m_endPoint6 != 0)
{
tag.SetAddress (Inet6SocketAddress (m_endPoint6->GetPeerAddress (), m_endPoint6->GetPeerPort ()));
tag->SetAddress (Inet6SocketAddress (m_endPoint6->GetPeerAddress (), m_endPoint6->GetPeerPort ()));
}
outPacket->AddPacketTag (tag);
}
return outPacket;
@@ -621,7 +622,7 @@ TcpSocketBase::BindToNetDevice (Ptr<NetDevice> netdevice)
if (m_endPoint != 0)
{
m_endPoint->BindToNetDevice (netdevice);
m_endPoint->BindToNetDevice (netdevice);
}
// No BindToNetDevice() for Ipv6EndPoint
return;
@@ -639,8 +640,8 @@ TcpSocketBase::SetupCallback (void)
}
if (m_endPoint != 0)
{
m_endPoint->SetRxCallback (MakeCallback (&TcpSocketBase::ForwardUp, Ptr<TcpSocketBase> (this)));
m_endPoint->SetDestroyCallback (MakeCallback (&TcpSocketBase::Destroy, Ptr<TcpSocketBase> (this)));
m_endPoint->SetRxCallback (MakeCallback (&TcpSocketBase::ForwardUp, Ptr<TcpSocketBase> (this)));
m_endPoint->SetDestroyCallback (MakeCallback (&TcpSocketBase::Destroy, Ptr<TcpSocketBase> (this)));
}
if (m_endPoint6 != 0)
{
@@ -791,7 +792,7 @@ TcpSocketBase::DoForwardUp (Ptr<Packet> packet, Ipv4Header header, uint16_t port
TcpHeader tcpHeader;
packet->RemoveHeader (tcpHeader);
if (tcpHeader.GetFlags () & TcpHeader::ACK)
{
{
EstimateRtt (tcpHeader);
}
ReadOptions (tcpHeader);
@@ -810,7 +811,7 @@ TcpSocketBase::DoForwardUp (Ptr<Packet> packet, Ipv4Header header, uint16_t port
{
NS_LOG_LOGIC ("At state " << TcpStateName[m_state] <<
" received packet of seq [" << tcpHeader.GetSequenceNumber () <<
":" << tcpHeader.GetSequenceNumber () + packet->GetSize () <<
":" << tcpHeader.GetSequenceNumber () + packet->GetSize() <<
") out of range [" << m_rxBuffer.NextRxSequence () << ":" <<
m_rxBuffer.MaxRxSequence () << ")");
// Acknowledgement should be sent for all unacceptable packets (RFC793, p.69)
@@ -905,7 +906,7 @@ TcpSocketBase::DoForwardUp (Ptr<Packet> packet, Ipv6Address saddr, Ipv6Address d
{
NS_LOG_LOGIC ("At state " << TcpStateName[m_state] <<
" received packet of seq [" << tcpHeader.GetSequenceNumber () <<
":" << tcpHeader.GetSequenceNumber () + packet->GetSize () <<
":" << tcpHeader.GetSequenceNumber () + packet->GetSize() <<
") out of range [" << m_rxBuffer.NextRxSequence () << ":" <<
m_rxBuffer.MaxRxSequence () << ")");
// Acknowledgement should be sent for all unacceptable packets (RFC793, p.69)
@@ -1130,7 +1131,7 @@ TcpSocketBase::ProcessSynSent (Ptr<Packet> packet, const TcpHeader& tcpHeader)
{ // Other in-sequence input
if (tcpflags != TcpHeader::RST)
{ // When (1) rx of FIN+ACK; (2) rx of FIN; (3) rx of bad flags
NS_LOG_LOGIC ("Illegal flag " << std::hex << static_cast<uint32_t> (tcpflags) << std::dec << " received. Reset packet is sent.");
NS_LOG_LOGIC ("Illegal flag " << std::hex << static_cast<uint32_t>(tcpflags) << std::dec << " received. Reset packet is sent.");
SendRST ();
}
CloseAndNotify ();
@@ -1149,7 +1150,7 @@ TcpSocketBase::ProcessSynRcvd (Ptr<Packet> packet, const TcpHeader& tcpHeader,
if (tcpflags == 0
|| (tcpflags == TcpHeader::ACK
&& m_nextTxSequence + SequenceNumber32 (1) == tcpHeader.GetAckNumber ()))
&& m_nextTxSequence + SequenceNumber32 (1) == tcpHeader.GetAckNumber ()))
{ // If it is bare data, accept it and move to ESTABLISHED state. This is
// possibly due to ACK lost in 3WHS. If in-sequence ACK is received, the
// handshake is completed nicely.
@@ -1161,8 +1162,8 @@ TcpSocketBase::ProcessSynRcvd (Ptr<Packet> packet, const TcpHeader& tcpHeader,
m_txBuffer.SetHeadSequence (m_nextTxSequence);
if (m_endPoint)
{
m_endPoint->SetPeer (InetSocketAddress::ConvertFrom (fromAddress).GetIpv4 (),
InetSocketAddress::ConvertFrom (fromAddress).GetPort ());
m_endPoint->SetPeer (InetSocketAddress::ConvertFrom (fromAddress).GetIpv4 (),
InetSocketAddress::ConvertFrom (fromAddress).GetPort ());
}
else if (m_endPoint6)
{
@@ -1195,8 +1196,8 @@ TcpSocketBase::ProcessSynRcvd (Ptr<Packet> packet, const TcpHeader& tcpHeader,
m_txBuffer.SetHeadSequence (m_nextTxSequence);
if (m_endPoint)
{
m_endPoint->SetPeer (InetSocketAddress::ConvertFrom (fromAddress).GetIpv4 (),
InetSocketAddress::ConvertFrom (fromAddress).GetPort ());
m_endPoint->SetPeer (InetSocketAddress::ConvertFrom (fromAddress).GetIpv4 (),
InetSocketAddress::ConvertFrom (fromAddress).GetPort ());
}
else if (m_endPoint6)
{
@@ -1213,8 +1214,8 @@ TcpSocketBase::ProcessSynRcvd (Ptr<Packet> packet, const TcpHeader& tcpHeader,
NS_LOG_LOGIC ("Illegal flag " << tcpflags << " received. Reset packet is sent.");
if (m_endPoint)
{
m_endPoint->SetPeer (InetSocketAddress::ConvertFrom (fromAddress).GetIpv4 (),
InetSocketAddress::ConvertFrom (fromAddress).GetPort ());
m_endPoint->SetPeer (InetSocketAddress::ConvertFrom (fromAddress).GetIpv4 (),
InetSocketAddress::ConvertFrom (fromAddress).GetPort ());
}
else if (m_endPoint6)
{
@@ -1294,9 +1295,9 @@ TcpSocketBase::ProcessWait (Ptr<Packet> packet, const TcpHeader& tcpHeader)
if (!m_shutdownRecv)
{
NotifyDataRecv ();
}
}
}
}
/** Received a packet upon CLOSING */
void
@@ -1450,12 +1451,12 @@ TcpSocketBase::Destroy (void)
m_endPoint = 0;
if (m_tcp != 0)
{
std::vector<Ptr<TcpSocketBase> >::iterator it
= std::find (m_tcp->m_sockets.begin (), m_tcp->m_sockets.end (), this);
if (it != m_tcp->m_sockets.end ())
{
m_tcp->m_sockets.erase (it);
}
std::vector<Ptr<TcpSocketBase> >::iterator it
= std::find (m_tcp->m_sockets.begin (), m_tcp->m_sockets.end (), this);
if (it != m_tcp->m_sockets.end ())
{
m_tcp->m_sockets.erase (it);
}
}
NS_LOG_LOGIC (this << " Cancelled ReTxTimeout event which was set to expire at " <<
(Simulator::Now () + Simulator::GetDelayLeft (m_retxEvent)).GetSeconds ());
@@ -1511,8 +1512,8 @@ TcpSocketBase::SendEmptyPacket (uint8_t flags)
header.SetAckNumber (m_rxBuffer.NextRxSequence ());
if (m_endPoint != 0)
{
header.SetSourcePort (m_endPoint->GetLocalPort ());
header.SetDestinationPort (m_endPoint->GetPeerPort ());
header.SetSourcePort (m_endPoint->GetLocalPort ());
header.SetDestinationPort (m_endPoint->GetPeerPort ());
}
else
{
@@ -1601,7 +1602,7 @@ TcpSocketBase::DeallocateEndPoint (void)
if (it != m_tcp->m_sockets.end ())
{
m_tcp->m_sockets.erase (it);
}
}
CancelAllTimers ();
}
}
@@ -1677,10 +1678,10 @@ TcpSocketBase::CompleteFork (Ptr<Packet> p, const TcpHeader& h,
// Get port and address from peer (connecting host)
if (InetSocketAddress::IsMatchingType (toAddress))
{
m_endPoint = m_tcp->Allocate (InetSocketAddress::ConvertFrom (toAddress).GetIpv4 (),
InetSocketAddress::ConvertFrom (toAddress).GetPort (),
InetSocketAddress::ConvertFrom (fromAddress).GetIpv4 (),
InetSocketAddress::ConvertFrom (fromAddress).GetPort ());
m_endPoint = m_tcp->Allocate (InetSocketAddress::ConvertFrom (toAddress).GetIpv4 (),
InetSocketAddress::ConvertFrom (toAddress).GetPort (),
InetSocketAddress::ConvertFrom (fromAddress).GetIpv4 (),
InetSocketAddress::ConvertFrom (fromAddress).GetPort ());
m_endPoint6 = 0;
}
else if (Inet6SocketAddress::IsMatchingType (toAddress))
@@ -1748,8 +1749,8 @@ TcpSocketBase::SendDataPacket (SequenceNumber32 seq, uint32_t maxSize, bool with
header.SetAckNumber (m_rxBuffer.NextRxSequence ());
if (m_endPoint)
{
header.SetSourcePort (m_endPoint->GetLocalPort ());
header.SetDestinationPort (m_endPoint->GetPeerPort ());
header.SetSourcePort (m_endPoint->GetLocalPort ());
header.SetDestinationPort (m_endPoint->GetPeerPort ());
}
else
{
@@ -1769,8 +1770,8 @@ TcpSocketBase::SendDataPacket (SequenceNumber32 seq, uint32_t maxSize, bool with
NS_LOG_LOGIC ("Send packet via TcpL4Protocol with flags 0x" << std::hex << static_cast<uint32_t> (flags) << std::dec);
if (m_endPoint)
{
m_tcp->SendPacket (p, header, m_endPoint->GetLocalAddress (),
m_endPoint->GetPeerAddress (), m_boundnetdevice);
m_tcp->SendPacket (p, header, m_endPoint->GetLocalAddress (),
m_endPoint->GetPeerAddress (), m_boundnetdevice);
}
else
{
@@ -2061,8 +2062,8 @@ TcpSocketBase::PersistTimeout ()
tcpHeader.SetWindowSize (AdvertisedWindowSize ());
if (m_endPoint != 0)
{
tcpHeader.SetSourcePort (m_endPoint->GetLocalPort ());
tcpHeader.SetDestinationPort (m_endPoint->GetPeerPort ());
tcpHeader.SetSourcePort (m_endPoint->GetLocalPort ());
tcpHeader.SetDestinationPort (m_endPoint->GetPeerPort ());
}
else
{
@@ -2073,8 +2074,8 @@ TcpSocketBase::PersistTimeout ()
if (m_endPoint != 0)
{
m_tcp->SendPacket (p, tcpHeader, m_endPoint->GetLocalAddress (),
m_endPoint->GetPeerAddress (), m_boundnetdevice);
m_tcp->SendPacket (p, tcpHeader, m_endPoint->GetLocalAddress (),
m_endPoint->GetPeerAddress (), m_boundnetdevice);
}
else
{
@@ -2149,7 +2150,7 @@ TcpSocketBase::TimeWait ()
CancelAllTimers ();
// Move from TIME_WAIT to CLOSED after 2*MSL. Max segment lifetime is 2 min
// according to RFC793, p.28
m_timewaitEvent = Simulator::Schedule (Seconds (2 * m_msl),
m_timewaitEvent = Simulator::Schedule (Seconds (2*m_msl),
&TcpSocketBase::CloseAndNotify, this);
}
+68 -69
View File
@@ -182,9 +182,9 @@ UdpSocketImpl::FinishBind (void)
bool done = false;
if (m_endPoint != 0)
{
m_endPoint->SetRxCallback (MakeCallback (&UdpSocketImpl::ForwardUp, Ptr<UdpSocketImpl> (this)));
m_endPoint->SetIcmpCallback (MakeCallback (&UdpSocketImpl::ForwardIcmp, Ptr<UdpSocketImpl> (this)));
m_endPoint->SetDestroyCallback (MakeCallback (&UdpSocketImpl::Destroy, Ptr<UdpSocketImpl> (this)));
m_endPoint->SetRxCallback (MakeCallback (&UdpSocketImpl::ForwardUp, Ptr<UdpSocketImpl> (this)));
m_endPoint->SetIcmpCallback (MakeCallback (&UdpSocketImpl::ForwardIcmp, Ptr<UdpSocketImpl> (this)));
m_endPoint->SetDestroyCallback (MakeCallback (&UdpSocketImpl::Destroy, Ptr<UdpSocketImpl> (this)));
done = true;
}
if (m_endPoint6 != 0)
@@ -196,8 +196,8 @@ UdpSocketImpl::FinishBind (void)
}
if (done)
{
return 0;
}
return 0;
}
return -1;
}
@@ -209,7 +209,7 @@ UdpSocketImpl::Bind (void)
return FinishBind ();
}
int
int
UdpSocketImpl::Bind6 (void)
{
NS_LOG_FUNCTION_NOARGS ();
@@ -224,25 +224,25 @@ UdpSocketImpl::Bind (const Address &address)
if (InetSocketAddress::IsMatchingType (address))
{
InetSocketAddress transport = InetSocketAddress::ConvertFrom (address);
Ipv4Address ipv4 = transport.GetIpv4 ();
uint16_t port = transport.GetPort ();
if (ipv4 == Ipv4Address::GetAny () && port == 0)
{
m_endPoint = m_udp->Allocate ();
}
else if (ipv4 == Ipv4Address::GetAny () && port != 0)
{
m_endPoint = m_udp->Allocate (port);
}
else if (ipv4 != Ipv4Address::GetAny () && port == 0)
{
m_endPoint = m_udp->Allocate (ipv4);
}
else if (ipv4 != Ipv4Address::GetAny () && port != 0)
{
m_endPoint = m_udp->Allocate (ipv4, port);
}
InetSocketAddress transport = InetSocketAddress::ConvertFrom (address);
Ipv4Address ipv4 = transport.GetIpv4 ();
uint16_t port = transport.GetPort ();
if (ipv4 == Ipv4Address::GetAny () && port == 0)
{
m_endPoint = m_udp->Allocate ();
}
else if (ipv4 == Ipv4Address::GetAny () && port != 0)
{
m_endPoint = m_udp->Allocate (port);
}
else if (ipv4 != Ipv4Address::GetAny () && port == 0)
{
m_endPoint = m_udp->Allocate (ipv4);
}
else if (ipv4 != Ipv4Address::GetAny () && port != 0)
{
m_endPoint = m_udp->Allocate (ipv4, port);
}
}
else if (Inet6SocketAddress::IsMatchingType (address))
{
@@ -312,11 +312,11 @@ UdpSocketImpl::Connect (const Address & address)
NS_LOG_FUNCTION (this << address);
if (InetSocketAddress::IsMatchingType(address) == true)
{
InetSocketAddress transport = InetSocketAddress::ConvertFrom (address);
InetSocketAddress transport = InetSocketAddress::ConvertFrom (address);
m_defaultAddress = Address(transport.GetIpv4 ());
m_defaultPort = transport.GetPort ();
m_connected = true;
NotifyConnectionSucceeded ();
m_defaultPort = transport.GetPort ();
m_connected = true;
NotifyConnectionSucceeded ();
}
else if (Inet6SocketAddress::IsMatchingType(address) == true)
{
@@ -395,11 +395,11 @@ UdpSocketImpl::DoSendTo (Ptr<Packet> p, const Address &address)
NS_LOG_LOGIC ("Not connected");
if (InetSocketAddress::IsMatchingType(address) == true)
{
InetSocketAddress transport = InetSocketAddress::ConvertFrom (address);
Ipv4Address ipv4 = transport.GetIpv4 ();
uint16_t port = transport.GetPort ();
return DoSendTo (p, ipv4, port);
}
InetSocketAddress transport = InetSocketAddress::ConvertFrom (address);
Ipv4Address ipv4 = transport.GetIpv4 ();
uint16_t port = transport.GetPort ();
return DoSendTo (p, ipv4, port);
}
else if (Inet6SocketAddress::IsMatchingType(address) == true)
{
Inet6SocketAddress transport = Inet6SocketAddress::ConvertFrom (address);
@@ -407,8 +407,8 @@ UdpSocketImpl::DoSendTo (Ptr<Packet> p, const Address &address)
uint16_t port = transport.GetPort ();
return DoSendTo (p, ipv6, port);
}
else
{
else
{
return -1;
}
}
@@ -419,11 +419,11 @@ UdpSocketImpl::DoSendTo (Ptr<Packet> p, const Address &address)
if (Ipv4Address::IsMatchingType(m_defaultAddress))
{
return DoSendTo (p, Ipv4Address::ConvertFrom(m_defaultAddress), m_defaultPort);
}
}
else if (Ipv6Address::IsMatchingType(m_defaultAddress))
{
return DoSendTo (p, Ipv6Address::ConvertFrom(m_defaultAddress), m_defaultPort);
}
}
}
m_errno = ERROR_AFNOSUPPORT;
return(-1);
@@ -470,28 +470,29 @@ UdpSocketImpl::DoSendTo (Ptr<Packet> p, Ipv4Address dest, uint16_t port)
// the same as a unicast, but it will be fixed further down the stack
if (m_ipMulticastTtl != 0 && dest.IsMulticast ())
{
SocketIpTtlTag tag;
tag.SetTtl (m_ipMulticastTtl);
Ptr<SocketIpTtlTag> tag = CreateObject<SocketIpTtlTag> ();
tag->SetTtl (m_ipMulticastTtl);
p->AddPacketTag (tag);
}
else if (m_ipTtl != 0 && !dest.IsMulticast () && !dest.IsBroadcast ())
{
SocketIpTtlTag tag;
tag.SetTtl (m_ipTtl);
Ptr<SocketIpTtlTag> tag = CreateObject<SocketIpTtlTag> ();
tag->SetTtl (m_ipTtl);
p->AddPacketTag (tag);
}
{
SocketSetDontFragmentTag tag;
bool found = p->RemovePacketTag (tag);
if (!found)
// !!! Previously, header was removed, checked, but never added back. Guess, this was wrong
if (p->PeekPacketTag<SocketSetDontFragmentTag> () == 0)
{
Ptr<SocketSetDontFragmentTag> tag = CreateObject<SocketSetDontFragmentTag> ();
if (m_mtuDiscover)
{
tag.Enable ();
tag->Enable ();
}
else
{
tag.Disable ();
tag->Disable ();
}
p->AddPacketTag (tag);
}
@@ -658,14 +659,14 @@ UdpSocketImpl::DoSendTo (Ptr<Packet> p, Ipv6Address dest, uint16_t port)
// the same as a unicast, but it will be fixed further down the stack
if (m_ipMulticastTtl != 0 && dest.IsMulticast ())
{
SocketIpTtlTag tag;
tag.SetTtl (m_ipMulticastTtl);
Ptr<SocketIpTtlTag> tag = CreateObject<SocketIpTtlTag> ();
tag->SetTtl (m_ipMulticastTtl);
p->AddPacketTag (tag);
}
else if (m_ipTtl != 0 && !dest.IsMulticast ())
{
SocketIpTtlTag tag;
tag.SetTtl (m_ipTtl);
Ptr<SocketIpTtlTag> tag = CreateObject<SocketIpTtlTag> ();
tag->SetTtl (m_ipTtl);
p->AddPacketTag (tag);
}
// There is no analgous to an IPv4 broadcast address in IPv6.
@@ -736,11 +737,11 @@ UdpSocketImpl::SendTo (Ptr<Packet> p, uint32_t flags, const Address &address)
NS_LOG_FUNCTION (this << p << flags << address);
if (InetSocketAddress::IsMatchingType (address))
{
InetSocketAddress transport = InetSocketAddress::ConvertFrom (address);
Ipv4Address ipv4 = transport.GetIpv4 ();
uint16_t port = transport.GetPort ();
return DoSendTo (p, ipv4, port);
}
InetSocketAddress transport = InetSocketAddress::ConvertFrom (address);
Ipv4Address ipv4 = transport.GetIpv4 ();
uint16_t port = transport.GetPort ();
return DoSendTo (p, ipv4, port);
}
else if (Inet6SocketAddress::IsMatchingType (address))
{
Inet6SocketAddress transport = Inet6SocketAddress::ConvertFrom (address);
@@ -790,11 +791,9 @@ UdpSocketImpl::RecvFrom (uint32_t maxSize, uint32_t flags,
Ptr<Packet> packet = Recv (maxSize, flags);
if (packet != 0)
{
SocketAddressTag tag;
bool found;
found = packet->PeekPacketTag (tag);
NS_ASSERT (found);
fromAddress = tag.GetAddress ();
Ptr<const SocketAddressTag> tag = packet->PeekPacketTag<SocketAddressTag> ();
NS_ASSERT (tag != 0);
fromAddress = tag->GetAddress ();
}
return packet;
}
@@ -876,17 +875,17 @@ UdpSocketImpl::ForwardUp (Ptr<Packet> packet, Ipv4Header header, uint16_t port,
// Should check via getsockopt ()..
if (IsRecvPktInfo ())
{
Ipv4PacketInfoTag tag;
packet->RemovePacketTag (tag);
tag.SetRecvIf (incomingInterface->GetDevice ()->GetIfIndex ());
Ptr<const Ipv4PacketInfoTag> origTag = packet->RemovePacketTag<Ipv4PacketInfoTag> ();
Ptr<Ipv4PacketInfoTag> tag = CreateObject<Ipv4PacketInfoTag> (*origTag);
tag->SetRecvIf (incomingInterface->GetDevice ()->GetIfIndex ());
packet->AddPacketTag (tag);
}
if ((m_rxAvailable + packet->GetSize ()) <= m_rcvBufSize)
{
Address address = InetSocketAddress (header.GetSource (), port);
SocketAddressTag tag;
tag.SetAddress (address);
Ptr<SocketAddressTag> tag = CreateObject<SocketAddressTag> ();
tag->SetAddress (address);
packet->AddPacketTag (tag);
m_deliveryQueue.push (packet);
m_rxAvailable += packet->GetSize ();
@@ -904,7 +903,7 @@ UdpSocketImpl::ForwardUp (Ptr<Packet> packet, Ipv4Header header, uint16_t port,
}
}
void
void
UdpSocketImpl::ForwardUp6 (Ptr<Packet> packet, Ipv6Address saddr, Ipv6Address daddr, uint16_t port)
{
NS_LOG_FUNCTION (this << packet << saddr << port);
@@ -917,8 +916,8 @@ UdpSocketImpl::ForwardUp6 (Ptr<Packet> packet, Ipv6Address saddr, Ipv6Address da
if ((m_rxAvailable + packet->GetSize ()) <= m_rcvBufSize)
{
Address address = Inet6SocketAddress (saddr, port);
SocketAddressTag tag;
tag.SetAddress (address);
Ptr<SocketAddressTag> tag = CreateObject<SocketAddressTag> ();
tag->SetAddress (address);
packet->AddPacketTag (tag);
m_deliveryQueue.push (packet);
m_rxAvailable += packet->GetSize ();
@@ -97,10 +97,8 @@ Ipv4PacketInfoTagTest::RxCb (Ptr<Socket> socket)
m_receivedPacket = socket->Recv (std::numeric_limits<uint32_t>::max (), 0);
NS_TEST_ASSERT_MSG_EQ (availableData, m_receivedPacket->GetSize (), "Did not read expected data");
Ipv4PacketInfoTag tag;
bool found;
found = m_receivedPacket->RemovePacketTag (tag);
NS_TEST_ASSERT_MSG_EQ (found, true, "Could not find tag");
Ptr<const Ipv4PacketInfoTag> tag = m_receivedPacket->RemovePacketTag<Ipv4PacketInfoTag> ();
NS_TEST_ASSERT_MSG_NE (tag, 0, "Could not find tag");
}
void
@@ -93,10 +93,8 @@ Ipv6PacketInfoTagTest::RxCb (Ptr<Socket> socket)
m_receivedPacket = socket->Recv (std::numeric_limits<uint32_t>::max (), 0);
NS_TEST_ASSERT_MSG_EQ (availableData, m_receivedPacket->GetSize (), "Did not read expected data");
Ipv6PacketInfoTag tag;
bool found;
found = m_receivedPacket->RemovePacketTag (tag);
NS_TEST_ASSERT_MSG_EQ (found, true, "Could not find tag");
Ptr<const Ipv6PacketInfoTag> tag = m_receivedPacket->RemovePacketTag<Ipv6PacketInfoTag> ();
NS_TEST_ASSERT_MSG_NE (tag, 0, "Could not find tag");
}
void
+4
View File
@@ -93,6 +93,7 @@ def configure(conf):
def build(bld):
# bridge and mpi dependencies are due to global routing
obj = bld.create_ns3_module('internet', ['bridge', 'mpi', 'network', 'core'])
obj.source = [
'model/ip-l4-protocol.cc',
'model/udp-header.cc',
@@ -173,6 +174,7 @@ def build(bld):
'model/global-route-manager-impl.cc',
'model/candidate-queue.cc',
'model/ipv4-global-routing.cc',
'model/ipv4-global-routing-one-nexthop.cc',
'helper/ipv4-global-routing-helper.cc',
'helper/internet-stack-helper.cc',
'helper/internet-trace-helper.cc',
@@ -270,6 +272,7 @@ def build(bld):
'model/global-route-manager-impl.h',
'model/candidate-queue.h',
'model/ipv4-global-routing.h',
'model/ipv4-global-routing-one-nexthop.h',
'helper/ipv4-global-routing-helper.h',
'helper/internet-stack-helper.h',
'helper/internet-trace-helper.h',
@@ -280,6 +283,7 @@ def build(bld):
'helper/ipv6-interface-container.h',
'helper/ipv6-routing-helper.h',
'model/ipv6-address-generator.h',
'model/rtt-estimator.h',
]
if bld.env['NSC_ENABLED']:
+9 -10
View File
@@ -55,8 +55,7 @@ HwmpProtocolMac::ReceiveData (Ptr<Packet> packet, const WifiMacHeader & header)
NS_ASSERT (header.IsData ());
MeshHeader meshHdr;
HwmpTag tag;
if (packet->PeekPacketTag (tag))
if (packet->PeekPacketTag<HwmpTag> () != 0)
{
NS_FATAL_ERROR ("HWMP tag is not supposed to be received by network");
}
@@ -78,8 +77,9 @@ HwmpProtocolMac::ReceiveData (Ptr<Packet> packet, const WifiMacHeader & header)
NS_FATAL_ERROR (
"6-address scheme is not yet supported and 4-address extension is not supposed to be used for data frames.");
}
tag.SetSeqno (meshHdr.GetMeshSeqno ());
tag.SetTtl (meshHdr.GetMeshTtl ());
Ptr<HwmpTag> tag = CreateObject<HwmpTag> ();
tag->SetSeqno (meshHdr.GetMeshSeqno ());
tag->SetTtl (meshHdr.GetMeshTtl ());
packet->AddPacketTag (tag);
if ((destination == Mac48Address::GetBroadcast ()) && (m_protocol->DropDataFrame (meshHdr.GetMeshSeqno (),
@@ -188,19 +188,18 @@ HwmpProtocolMac::UpdateOutcomingFrame (Ptr<Packet> packet, WifiMacHeader & heade
{
return true;
}
HwmpTag tag;
bool tagExists = packet->RemovePacketTag (tag);
if (!tagExists)
Ptr<const HwmpTag> tag = packet->RemovePacketTag<HwmpTag> ();
if (tag == 0)
{
NS_FATAL_ERROR ("HWMP tag must exist at this point");
}
m_stats.txData++;
m_stats.txDataBytes += packet->GetSize ();
MeshHeader meshHdr;
meshHdr.SetMeshSeqno (tag.GetSeqno ());
meshHdr.SetMeshTtl (tag.GetTtl ());
meshHdr.SetMeshSeqno (tag->GetSeqno ());
meshHdr.SetMeshTtl (tag->GetTtl ());
packet->AddHeader (meshHdr);
header.SetAddr1 (tag.GetAddress ());
header.SetAddr1 (tag->GetAddress ());
return true;
}
WifiActionHeader
+29 -21
View File
@@ -233,29 +233,32 @@ HwmpProtocol::RequestRoute (
)
{
Ptr <Packet> packet = constPacket->Copy ();
HwmpTag tag;
Ptr<HwmpTag> tag = 0;
if (sourceIface == GetMeshPoint ()->GetIfIndex ())
{
// packet from level 3
if (packet->PeekPacketTag (tag))
if (packet->PeekPacketTag<HwmpTag> () != 0)
{
NS_FATAL_ERROR ("HWMP tag has come with a packet from upper layer. This must not occur...");
}
tag = CreateObject<HwmpTag> ();
//Filling TAG:
if (destination == Mac48Address::GetBroadcast ())
{
tag.SetSeqno (m_dataSeqno++);
tag->SetSeqno (m_dataSeqno++);
}
tag.SetTtl (m_maxTtl);
tag->SetTtl (m_maxTtl);
}
else
{
if (!packet->RemovePacketTag (tag))
Ptr<const HwmpTag> origTag = packet->RemovePacketTag<HwmpTag> ();
if (!packet->RemovePacketTag<HwmpTag> ())
{
NS_FATAL_ERROR ("HWMP tag is supposed to be here at this point.");
}
tag.DecrementTtl ();
if (tag.GetTtl () == 0)
tag = CreateObject<HwmpTag> (*origTag);
tag->DecrementTtl ();
if (tag->GetTtl () == 0)
{
m_stats.droppedTtl++;
return false;
@@ -287,11 +290,11 @@ HwmpProtocol::RequestRoute (
{
Ptr<Packet> packetCopy = packet->Copy ();
//
// 64-bit Intel valgrind complains about tag.SetAddress (*i). It
// 64-bit Intel valgrind complains about tag->SetAddress (*i). It
// likes this just fine.
//
Mac48Address address = *i;
tag.SetAddress (address);
tag->SetAddress (address);
packetCopy->AddPacketTag (tag);
routeReply (true, packetCopy, source, destination, protocolType, plugin->first);
}
@@ -299,7 +302,7 @@ HwmpProtocol::RequestRoute (
}
else
{
return ForwardUnicast (sourceIface, source, destination, packet, protocolType, routeReply, tag.GetTtl ());
return ForwardUnicast (sourceIface, source, destination, packet, protocolType, routeReply, tag->GetTtl ());
}
return true;
}
@@ -307,8 +310,8 @@ bool
HwmpProtocol::RemoveRoutingStuff (uint32_t fromIface, const Mac48Address source,
const Mac48Address destination, Ptr<Packet> packet, uint16_t& protocolType)
{
HwmpTag tag;
if (!packet->RemovePacketTag (tag))
Ptr<const HwmpTag> tag = packet->RemovePacketTag<HwmpTag> ();
if (tag == 0)
{
NS_FATAL_ERROR ("HWMP tag must exist when packet received from the network");
}
@@ -325,9 +328,9 @@ HwmpProtocol::ForwardUnicast (uint32_t sourceIface, const Mac48Address source,
{
result = m_rtable->LookupProactive ();
}
HwmpTag tag;
tag.SetAddress (result.retransmitter);
tag.SetTtl (ttl);
Ptr<HwmpTag> tag = CreateObject<HwmpTag> ();
tag->SetAddress (result.retransmitter);
tag->SetTtl (ttl);
//seqno and metric is not used;
packet->AddPacketTag (tag);
if (result.retransmitter != Mac48Address::GetBroadcast ())
@@ -921,9 +924,13 @@ HwmpProtocol::ReactivePathResolved (Mac48Address dst)
while (packet.pkt != 0)
{
//set RA tag for retransmitter:
HwmpTag tag;
packet.pkt->RemovePacketTag (tag);
tag.SetAddress (result.retransmitter);
Ptr<const HwmpTag> origTag = packet.pkt->RemovePacketTag<HwmpTag> ();
if (origTag == 0)
{
NS_FATAL_ERROR ("HWMP tag must be present at this point");
}
Ptr<HwmpTag> tag = CreateObject<HwmpTag> (*origTag);
tag->SetAddress (result.retransmitter);
packet.pkt->AddPacketTag (tag);
m_stats.txUnicast++;
m_stats.txBytes += packet.pkt->GetSize ();
@@ -942,12 +949,13 @@ HwmpProtocol::ProactivePathResolved ()
while (packet.pkt != 0)
{
//set RA tag for retransmitter:
HwmpTag tag;
if (!packet.pkt->RemovePacketTag (tag))
Ptr<const HwmpTag> origTag = packet.pkt->RemovePacketTag<HwmpTag> ();
if (origTag == 0)
{
NS_FATAL_ERROR ("HWMP tag must be present at this point");
}
tag.SetAddress (result.retransmitter);
Ptr<HwmpTag> tag = CreateObject<HwmpTag> (*origTag);
tag->SetAddress (result.retransmitter);
packet.pkt->AddPacketTag (tag);
m_stats.txUnicast++;
m_stats.txBytes += packet.pkt->GetSize ();
+4 -4
View File
@@ -41,7 +41,7 @@ HwmpTag::SetAddress (Mac48Address retransmitter)
}
Mac48Address
HwmpTag::GetAddress ()
HwmpTag::GetAddress () const
{
return m_address;
}
@@ -53,7 +53,7 @@ HwmpTag::SetTtl (uint8_t ttl)
}
uint8_t
HwmpTag::GetTtl ()
HwmpTag::GetTtl () const
{
return m_ttl;
}
@@ -65,7 +65,7 @@ HwmpTag::SetMetric (uint32_t metric)
}
uint32_t
HwmpTag::GetMetric ()
HwmpTag::GetMetric () const
{
return m_metric;
}
@@ -77,7 +77,7 @@ HwmpTag::SetSeqno (uint32_t seqno)
}
uint32_t
HwmpTag::GetSeqno ()
HwmpTag::GetSeqno () const
{
return m_seqno;
}
+4 -4
View File
@@ -51,13 +51,13 @@ public:
HwmpTag ();
~HwmpTag ();
void SetAddress (Mac48Address retransmitter);
Mac48Address GetAddress ();
Mac48Address GetAddress () const;
void SetTtl (uint8_t ttl);
uint8_t GetTtl ();
uint8_t GetTtl () const;
void SetMetric (uint32_t metric);
uint32_t GetMetric ();
uint32_t GetMetric () const;
void SetSeqno (uint32_t seqno);
uint32_t GetSeqno ();
uint32_t GetSeqno () const;
void DecrementTtl ();
static TypeId GetTypeId ();
+9 -9
View File
@@ -47,14 +47,14 @@ FlameProtocolMac::Receive (Ptr<Packet> packet, const WifiMacHeader & header)
{
return true;
}
FlameTag tag;
if (packet->PeekPacketTag (tag))
if (packet->PeekPacketTag<FlameTag> () != 0)
{
NS_FATAL_ERROR ("FLAME tag is not supposed to be received by network");
}
tag.receiver = header.GetAddr1 ();
tag.transmitter = header.GetAddr2 ();
if (tag.receiver == Mac48Address::GetBroadcast ())
Ptr<FlameTag> tag = CreateObject<FlameTag> ();
tag->receiver = header.GetAddr1 ();
tag->transmitter = header.GetAddr2 ();
if (tag->receiver == Mac48Address::GetBroadcast ())
{
m_stats.rxBroadcast++;
}
@@ -74,13 +74,13 @@ FlameProtocolMac::UpdateOutcomingFrame (Ptr<Packet> packet, WifiMacHeader & head
{
return true;
}
FlameTag tag;
if (!packet->RemovePacketTag (tag))
Ptr<const FlameTag> tag = packet->RemovePacketTag<FlameTag> ();
if (tag == 0)
{
NS_FATAL_ERROR ("FLAME tag must exist here");
}
header.SetAddr1 (tag.receiver);
if (tag.receiver == Mac48Address::GetBroadcast ())
header.SetAddr1 (tag->receiver);
if (tag->receiver == Mac48Address::GetBroadcast ())
{
m_stats.txBroadcast++;
}
+18 -16
View File
@@ -150,8 +150,7 @@ FlameProtocol::RequestRoute (uint32_t sourceIface, const Mac48Address source, co
if (sourceIface == m_mp->GetIfIndex ())
{
//Packet from upper layer!
FlameTag tag;
if (packet->PeekPacketTag (tag))
if (packet->PeekPacketTag<FlameTag> () != 0)
{
NS_FATAL_ERROR ("FLAME tag is not supposed to be received from upper layers");
}
@@ -174,7 +173,8 @@ FlameProtocol::RequestRoute (uint32_t sourceIface, const Mac48Address source, co
flameHdr.SetOrigSrc (source);
m_stats.txBytes += packet->GetSize ();
packet->AddHeader (flameHdr);
tag.receiver = result.retransmitter;
Ptr<FlameTag> tag = CreateObject<FlameTag> ();
tag->receiver = result.retransmitter;
if (result.retransmitter == Mac48Address::GetBroadcast ())
{
m_stats.txBroadcast++;
@@ -183,7 +183,7 @@ FlameProtocol::RequestRoute (uint32_t sourceIface, const Mac48Address source, co
{
m_stats.txUnicast++;
}
NS_LOG_DEBUG ("Source: send packet with RA = " << tag.receiver);
NS_LOG_DEBUG ("Source: send packet with RA = " << tag->receiver);
packet->AddPacketTag (tag);
routeReply (true, packet, source, destination, FLAME_PROTOCOL, result.ifIndex);
}
@@ -191,17 +191,18 @@ FlameProtocol::RequestRoute (uint32_t sourceIface, const Mac48Address source, co
{
FlameHeader flameHdr;
packet->RemoveHeader (flameHdr);
FlameTag tag;
if (!packet->RemovePacketTag (tag))
Ptr<const FlameTag> origTag = packet->RemovePacketTag<FlameTag> ();
if (origTag == 0)
{
NS_FATAL_ERROR ("FLAME tag must exist here");
}
if (destination == Mac48Address::GetBroadcast ())
{
//Broadcast always is forwarded as broadcast!
NS_ASSERT (HandleDataFrame (flameHdr.GetSeqno (), source, flameHdr, tag.transmitter, sourceIface));
FlameTag tag (Mac48Address::GetBroadcast ());
NS_ASSERT (HandleDataFrame (flameHdr.GetSeqno (), source, flameHdr, origTag->transmitter, sourceIface));
Ptr<FlameTag> tag = CreateObject<FlameTag> (Mac48Address::GetBroadcast ());
flameHdr.AddCost (1);
m_stats.txBytes += packet->GetSize ();
packet->AddHeader (flameHdr);
@@ -212,27 +213,28 @@ FlameProtocol::RequestRoute (uint32_t sourceIface, const Mac48Address source, co
}
else
{
Ptr<FlameTag> tag = CreateObject<FlameTag> (*origTag);
// We check sequence only when forward unicast, because broadcast-checks were done
// inside remove routing stuff.
if (HandleDataFrame (flameHdr.GetSeqno (), source, flameHdr, tag.transmitter, sourceIface))
if (HandleDataFrame (flameHdr.GetSeqno (), source, flameHdr, tag->transmitter, sourceIface))
{
return false;
}
FlameRtable::LookupResult result = m_rtable->Lookup (destination);
if (tag.receiver != Mac48Address::GetBroadcast ())
if (origTag->receiver != Mac48Address::GetBroadcast ())
{
if (result.retransmitter == Mac48Address::GetBroadcast ())
{
NS_LOG_DEBUG ("unicast packet dropped, because no route! I am " << GetAddress ()
<< ", RA = " << tag.receiver << ", TA = " << tag.transmitter);
<< ", RA = " << origTag->receiver << ", TA = " << origTag->transmitter);
m_stats.totalDropped++;
return false;
}
tag.receiver = result.retransmitter;
tag->receiver = result.retransmitter;
}
else
{
tag.receiver = Mac48Address::GetBroadcast ();
tag->receiver = Mac48Address::GetBroadcast ();
}
if (result.retransmitter == Mac48Address::GetBroadcast ())
{
@@ -263,14 +265,14 @@ FlameProtocol::RemoveRoutingStuff (uint32_t fromIface, const Mac48Address source
NS_LOG_DEBUG ("Dropped my own frame!");
return false;
}
FlameTag tag;
if (!packet->RemovePacketTag (tag))
Ptr<const FlameTag> tag = packet->RemovePacketTag <FlameTag> ();
if (tag == 0)
{
NS_FATAL_ERROR ("FLAME tag must exist when packet is coming to protocol");
}
FlameHeader flameHdr;
packet->RemoveHeader (flameHdr);
if (HandleDataFrame (flameHdr.GetSeqno (), source, flameHdr, tag.transmitter, fromIface))
if (HandleDataFrame (flameHdr.GetSeqno (), source, flameHdr, tag->transmitter, fromIface))
{
return false;
}
+5 -5
View File
@@ -222,15 +222,15 @@ MeshWifiInterfaceMac::ForwardDown (Ptr<const Packet> const_packet, Mac48Address
//Classify: application sets a tag, which is removed here
// Get Qos tag:
AcIndex ac = AC_BE;
QosTag tag;
if (packet->RemovePacketTag (tag))
Ptr<const QosTag> tag = packet->RemovePacketTag<QosTag> ();
if (tag != 0)
{
hdr.SetType (WIFI_MAC_QOSDATA);
hdr.SetQosTid (tag.GetTid ());
hdr.SetQosTid (tag->GetTid ());
//Aftre setting type DsFrom and DsTo fields are reset.
hdr.SetDsFrom ();
hdr.SetDsTo ();
ac = QosUtilsMapTidToAc (tag.GetTid ());
ac = QosUtilsMapTidToAc (tag->GetTid ());
}
m_stats.sentFrames++;
m_stats.sentBytes += packet->GetSize ();
@@ -446,7 +446,7 @@ MeshWifiInterfaceMac::Receive (Ptr<Packet> packet, WifiMacHeader const *hdr)
// Check if QoS tag exists and add it:
if (hdr->IsQosData ())
{
packet->AddPacketTag (QosTag (hdr->GetQosTid ()));
packet->AddPacketTag (CreateObject<QosTag> (hdr->GetQosTid ()));
}
// Forward data up
if (hdr->IsData ())
+3 -1
View File
@@ -679,7 +679,9 @@ void AnimationInterface::WriteDummyPacket ()
}
void AnimationInterface::DevTxTrace (std::string context, Ptr<const Packet> p,
void AnimationInterface::DevTxTrace (std::string context,
uint32_t, // channel
Ptr<const Packet> p,
Ptr<NetDevice> tx, Ptr<NetDevice> rx,
Time txTime, Time rxTime)
{
+2 -1
View File
@@ -264,7 +264,8 @@ private:
std::string m_originalFileName;
void DevTxTrace (std::string context,
Ptr<const Packet> p,
uint32_t,
Ptr<const Packet> p,
Ptr<NetDevice> tx,
Ptr<NetDevice> rx,
Time txTime,
+4 -5
View File
@@ -96,8 +96,8 @@ MyTag::GetSimpleValue (void) const
int main (int argc, char *argv[])
{
// create a tag.
MyTag tag;
tag.SetSimpleValue (0x56);
Ptr<MyTag> tag = CreateObject<MyTag> ();
tag->SetSimpleValue (0x56);
// store the tag in a packet.
Ptr<Packet> p = Create<Packet> (100);
@@ -107,11 +107,10 @@ int main (int argc, char *argv[])
Ptr<Packet> aCopy = p->Copy ();
// read the tag from the packet copy
MyTag tagCopy;
p->PeekPacketTag (tagCopy);
Ptr<const MyTag> tagCopy = p->PeekPacketTag<MyTag> ();
// the copy and the original are the same !
NS_ASSERT (tagCopy.GetSimpleValue () == tag.GetSimpleValue ());
NS_ASSERT (tagCopy->GetSimpleValue () == tag->GetSimpleValue ());
aCopy->PrintPacketTags (std::cout);
std::cout << std::endl;
+36 -1
View File
@@ -248,6 +248,13 @@ public:
*/
void Write (Iterator start, Iterator end);
/**
* \return the byte read in the buffer.
*
* Read data, but do not advance the Iterator read.
*/
inline uint8_t PeekU8 (void);
/**
* \return the byte read in the buffer.
*
@@ -332,11 +339,21 @@ public:
* \param size number of bytes to copy
*
* Copy size bytes of data from the internal buffer to the
* input buffer and avance the Iterator by the number of
* input buffer and advance the Iterator by the number of
* bytes read.
*/
void Read (uint8_t *buffer, uint32_t size);
/**
* \param start start iterator of the buffer to copy data into
* \param size number of bytes to copy
*
* Copy size bytes of data from the internal buffer to the input buffer via
* the provided iterator and advance the Iterator by the number of bytes
* read.
*/
inline void Read (Iterator start, uint32_t size);
/**
* \brief Calculate the checksum.
* \param size size of the buffer.
@@ -813,6 +830,14 @@ Buffer::Iterator::ReadNtohU32 (void)
return retval;
}
uint8_t
Buffer::Iterator::PeekU8 (void)
{
uint8_t ret = ReadU8 ();
Prev ();
return ret;
}
uint8_t
Buffer::Iterator::ReadU8 (void)
{
@@ -851,6 +876,16 @@ Buffer::Iterator::ReadU16 (void)
return data;
}
void
Buffer::Iterator::Read (Buffer::Iterator start, uint32_t size)
{
Buffer::Iterator end = *this;
end.Next (size);
start.Write (*this, end);
}
Buffer::Buffer (Buffer const&o)
: m_data (o.m_data),
m_maxZeroAreaStart (o.m_zeroAreaStart),
+122 -126
View File
@@ -28,150 +28,146 @@ NS_LOG_COMPONENT_DEFINE ("PacketTagList");
namespace ns3 {
#ifdef USE_FREE_LIST
struct PacketTagList::TagData *PacketTagList::g_free = 0;
uint32_t PacketTagList::g_nfree = 0;
struct PacketTagList::TagData *
PacketTagList::AllocData (void) const
{
NS_LOG_FUNCTION (g_nfree);
struct PacketTagList::TagData *retval;
if (g_free != 0)
{
retval = g_free;
g_free = g_free->m_next;
g_nfree--;
}
else
{
retval = new struct PacketTagList::TagData ();
}
return retval;
}
void
PacketTagList::FreeData (struct TagData *data) const
PacketTagList::Add (Ptr<const Tag> tag)
{
NS_LOG_FUNCTION (g_nfree << data);
if (g_nfree > 1000)
{
delete data;
return;
}
g_nfree++;
data->next = g_free;
data->tid = TypeId ();
g_free = data;
}
#else
struct PacketTagList::TagData *
PacketTagList::AllocData (void) const
{
NS_LOG_FUNCTION_NOARGS ();
struct PacketTagList::TagData *retval;
retval = new struct PacketTagList::TagData ();
return retval;
NS_LOG_FUNCTION (this << tag->GetInstanceTypeId ());
NS_ASSERT_MSG (Peek (tag->GetInstanceTypeId ()) == 0,
"Only one tag type per packet is allowed");
push_back (tag);
}
void
PacketTagList::FreeData (struct TagData *data) const
Ptr<const Tag>
PacketTagList::Remove (TypeId tagType)
{
NS_LOG_FUNCTION (data);
delete data;
}
#endif
bool
PacketTagList::Remove (Tag &tag)
{
NS_LOG_FUNCTION (this << tag.GetInstanceTypeId ());
TypeId tid = tag.GetInstanceTypeId ();
bool found = false;
for (struct TagData *cur = m_next; cur != 0; cur = cur->next)
NS_LOG_FUNCTION (this << tagType);
for (iterator tag = begin (); tag != end (); tag++)
{
if (cur->tid == tid)
if ((*tag)->GetInstanceTypeId () == tagType)
{
found = true;
tag.Deserialize (TagBuffer (cur->data, cur->data+PACKET_TAG_MAX_SIZE));
Ptr<const Tag> retval = *tag;
erase (tag);
return retval;
}
}
if (!found)
{
return false;
}
struct TagData *start = 0;
struct TagData **prevNext = &start;
for (struct TagData *cur = m_next; cur != 0; cur = cur->next)
{
if (cur->tid == tid)
{
/**
* XXX
* Note: I believe that we could optimize this to
* avoid copying each TagData located after the target id
* and just link the already-copied list to the next tag.
*/
continue;
}
struct TagData *copy = AllocData ();
copy->tid = cur->tid;
copy->count = 1;
copy->next = 0;
memcpy (copy->data, cur->data, PACKET_TAG_MAX_SIZE);
*prevNext = copy;
prevNext = &copy->next;
}
*prevNext = 0;
RemoveAll ();
m_next = start;
return true;
return 0;
}
void
PacketTagList::Add (const Tag &tag) const
Ptr<const Tag>
PacketTagList::Peek (TypeId tagType) const
{
NS_LOG_FUNCTION (this << tag.GetInstanceTypeId ());
// ensure this id was not yet added
for (struct TagData *cur = m_next; cur != 0; cur = cur->next)
NS_LOG_FUNCTION (this << tagType);
for (const_iterator tag = begin (); tag != end (); tag++)
{
NS_ASSERT (cur->tid != tag.GetInstanceTypeId ());
if ((*tag)->GetInstanceTypeId () == tagType)
return *tag;
}
struct TagData *head = AllocData ();
head->count = 1;
head->next = 0;
head->tid = tag.GetInstanceTypeId ();
head->next = m_next;
NS_ASSERT (tag.GetSerializedSize () <= PACKET_TAG_MAX_SIZE);
tag.Serialize (TagBuffer (head->data, head->data+tag.GetSerializedSize ()));
const_cast<PacketTagList *> (this)->m_next = head;
return 0;
}
bool
PacketTagList::Peek (Tag &tag) const
{
NS_LOG_FUNCTION (this << tag.GetInstanceTypeId ());
TypeId tid = tag.GetInstanceTypeId ();
for (struct TagData *cur = m_next; cur != 0; cur = cur->next)
{
if (cur->tid == tid)
{
/* found tag */
tag.Deserialize (TagBuffer (cur->data, cur->data+PACKET_TAG_MAX_SIZE));
return true;
}
}
/* no tag found */
return false;
}
const struct PacketTagList::TagData *
PacketTagList::Head (void) const
{
return m_next;
}
// bool
// PacketTagList::Remove (Tag &tag)
// {
// NS_LOG_FUNCTION (this << tag.GetInstanceTypeId ());
// return false;
// // TypeId tid = tag.GetInstanceTypeId ();
// // bool found = false;
// // for (struct TagData *cur = m_next; cur != 0; cur = cur->next)
// // {
// // if (cur->tid == tid)
// // {
// // found = true;
// // tag.Deserialize (TagBuffer (cur->data, cur->data+PACKET_TAG_MAX_SIZE));
// // }
// // }
// // if (!found)
// // {
// // return false;
// // }
// // struct TagData *start = 0;
// // struct TagData **prevNext = &start;
// // for (struct TagData *cur = m_next; cur != 0; cur = cur->next)
// // {
// // if (cur->tid == tid)
// // {
// // /**
// // * XXX
// // * Note: I believe that we could optimize this to
// // * avoid copying each TagData located after the target id
// // * and just link the already-copied list to the next tag.
// // */
// // continue;
// // }
// // struct TagData *copy = AllocData ();
// // copy->tid = cur->tid;
// // copy->count = 1;
// // copy->next = 0;
// // memcpy (copy->data, cur->data, PACKET_TAG_MAX_SIZE);
// // *prevNext = copy;
// // prevNext = &copy->next;
// // }
// // *prevNext = 0;
// // RemoveAll ();
// // m_next = start;
// // return true;
// }
// void
// PacketTagList::Add (const Tag &tag) const
// {
// NS_LOG_FUNCTION (this << tag.GetInstanceTypeId ());
// // ensure this id was not yet added
// // for (struct TagData *cur = m_next; cur != 0; cur = cur->next)
// // {
// // NS_ASSERT (cur->tid != tag.GetInstanceTypeId ());
// // }
// // struct TagData *head = AllocData ();
// // head->count = 1;
// // head->next = 0;
// // head->tid = tag.GetInstanceTypeId ();
// // head->next = m_next;
// // NS_ASSERT (tag.GetSerializedSize () <= PACKET_TAG_MAX_SIZE);
// // tag.Serialize (TagBuffer (head->data, head->data+tag.GetSerializedSize ()));
// // const_cast<PacketTagList *> (this)->m_next = head;
// // m_tags.
// }
// bool
// PacketTagList::Peek (Tag &tag) const
// {
// NS_LOG_FUNCTION (this << tag.GetInstanceTypeId ());
// // TypeId tid = tag.GetInstanceTypeId ();
// // for (struct TagData *cur = m_next; cur != 0; cur = cur->next)
// // {
// // if (cur->tid == tid)
// // {
// // /* found tag */
// // tag.Deserialize (TagBuffer (cur->data, cur->data+PACKET_TAG_MAX_SIZE));
// // return true;
// // }
// // }
// /* no tag found */
// return false;
// }
// // const struct PacketTagList::TagData *
// // PacketTagList::Head (void) const
// // {
// // return m_next;
// // }
} // namespace ns3
+46 -83
View File
@@ -21,7 +21,7 @@
#define PACKET_TAG_LIST_H
#include <stdint.h>
#include <ostream>
#include <list>
#include "ns3/type-id.h"
namespace ns3 {
@@ -34,40 +34,30 @@ class Tag;
* The maximum size (in bytes) of a Tag is stored
* in this constant.
*/
#define PACKET_TAG_MAX_SIZE 20
// #define PACKET_TAG_MAX_SIZE 20
class PacketTagList
class PacketTagList : public std::list<Ptr<const Tag> >
{
public:
struct TagData {
uint8_t data[PACKET_TAG_MAX_SIZE];
struct TagData *next;
TypeId tid;
uint32_t count;
};
// struct TagData {
// std::vector<uint8_t> data;
// TypeId tid;
// uint32_t count;
// };
inline PacketTagList ();
inline PacketTagList (PacketTagList const &o);
inline PacketTagList &operator = (PacketTagList const &o);
inline ~PacketTagList ();
// inline PacketTagList ();
// inline PacketTagList (PacketTagList const &o);
// inline PacketTagList &operator = (PacketTagList const &o);
// inline ~PacketTagList ();
void Add (Tag const&tag) const;
bool Remove (Tag &tag);
bool Peek (Tag &tag) const;
inline void RemoveAll (void);
void
Add (Ptr<const Tag> tag);
const struct PacketTagList::TagData *Head (void) const;
Ptr<const Tag>
Remove (TypeId tagType);
private:
bool Remove (TypeId tid);
struct PacketTagList::TagData *AllocData (void) const;
void FreeData (struct TagData *data) const;
static struct PacketTagList::TagData *g_free;
static uint32_t g_nfree;
struct TagData *m_next;
Ptr<const Tag>
Peek (TypeId tagType) const;
};
} // namespace ns3
@@ -78,65 +68,38 @@ private:
namespace ns3 {
PacketTagList::PacketTagList ()
: m_next ()
{
}
// PacketTagList::PacketTagList ()
// {
// }
PacketTagList::PacketTagList (PacketTagList const &o)
: m_next (o.m_next)
{
if (m_next != 0)
{
m_next->count++;
}
}
// PacketTagList::PacketTagList (PacketTagList const &o)
// : m_tags (o.m_tags)
// {
// }
PacketTagList &
PacketTagList::operator = (PacketTagList const &o)
{
// self assignment
if (m_next == o.m_next)
{
return *this;
}
RemoveAll ();
m_next = o.m_next;
if (m_next != 0)
{
m_next->count++;
}
return *this;
}
// PacketTagList &
// PacketTagList::operator = (PacketTagList const &o)
// {
// // self assignment
// if (&o == this)
// {
// return *this;
// }
// // RemoveAll (); // ???
// m_tags = o.m_tags;
// return *this;
// }
PacketTagList::~PacketTagList ()
{
RemoveAll ();
}
// PacketTagList::~PacketTagList ()
// {
// RemoveAll ();
// }
void
PacketTagList::RemoveAll (void)
{
struct TagData *prev = 0;
for (struct TagData *cur = m_next; cur != 0; cur = cur->next)
{
cur->count--;
if (cur->count > 0)
{
break;
}
if (prev != 0)
{
FreeData (prev);
}
prev = cur;
}
if (prev != 0)
{
FreeData (prev);
}
m_next = 0;
}
// void
// PacketTagList::RemoveAll (void)
// {
// m_tags.clear ();
// }
} // namespace ns3
+93 -63
View File
@@ -81,39 +81,39 @@ ByteTagIterator::ByteTagIterator (ByteTagList::Iterator i)
}
PacketTagIterator::PacketTagIterator (const struct PacketTagList::TagData *head)
: m_current (head)
{
}
bool
PacketTagIterator::HasNext (void) const
{
return m_current != 0;
}
PacketTagIterator::Item
PacketTagIterator::Next (void)
{
NS_ASSERT (HasNext ());
const struct PacketTagList::TagData *prev = m_current;
m_current = m_current->next;
return PacketTagIterator::Item (prev);
}
// PacketTagIterator::PacketTagIterator (const struct PacketTagList::TagData *head)
// : m_current (head)
// {
// }
// bool
// PacketTagIterator::HasNext (void) const
// {
// return m_current != 0;
// }
// PacketTagIterator::Item
// PacketTagIterator::Next (void)
// {
// NS_ASSERT (HasNext ());
// const struct PacketTagList::TagData *prev = m_current;
// m_current = m_current->next;
// return PacketTagIterator::Item (prev);
// }
PacketTagIterator::Item::Item (const struct PacketTagList::TagData *data)
: m_data (data)
{
}
TypeId
PacketTagIterator::Item::GetTypeId (void) const
{
return m_data->tid;
}
void
PacketTagIterator::Item::GetTag (Tag &tag) const
{
NS_ASSERT (tag.GetInstanceTypeId () == m_data->tid);
tag.Deserialize (TagBuffer ((uint8_t*)m_data->data, (uint8_t*)m_data->data+PACKET_TAG_MAX_SIZE));
}
// PacketTagIterator::Item::Item (const struct PacketTagList::TagData *data)
// : m_data (data)
// {
// }
// TypeId
// PacketTagIterator::Item::GetTypeId (void) const
// {
// return m_data->tid;
// }
// void
// PacketTagIterator::Item::GetTag (Tag &tag) const
// {
// NS_ASSERT (tag.GetInstanceTypeId () == m_data->tid);
// tag.Deserialize (TagBuffer ((uint8_t*)m_data->data, (uint8_t*)m_data->data+PACKET_TAG_MAX_SIZE));
// }
Ptr<Packet>
@@ -835,60 +835,90 @@ Packet::FindFirstMatchingByteTag (Tag &tag) const
return false;
}
void
Packet::AddPacketTag (const Tag &tag) const
// void
// Packet::AddPacketTag (const Tag &tag) const
// {
// NS_LOG_FUNCTION (this << tag.GetInstanceTypeId ().GetName () << tag.GetSerializedSize ());
// m_packetTagList.Add (tag);
// }
// bool
// Packet::RemovePacketTag (Tag &tag)
// {
// NS_LOG_FUNCTION (this << tag.GetInstanceTypeId ().GetName () << tag.GetSerializedSize ());
// bool found = m_packetTagList.Remove (tag);
// return found;
// }
// bool
// Packet::PeekPacketTag (Tag &tag) const
// {
// bool found = m_packetTagList.Peek (tag);
// return found;
// }
void
Packet::AddPacketTag (Ptr<const Tag> tag)
{
NS_LOG_FUNCTION (this << tag.GetInstanceTypeId ().GetName () << tag.GetSerializedSize ());
m_packetTagList.Add (tag);
}
bool
Packet::RemovePacketTag (Tag &tag)
Ptr<const Tag>
Packet::RemovePacketTag (TypeId tagType)
{
NS_LOG_FUNCTION (this << tag.GetInstanceTypeId ().GetName () << tag.GetSerializedSize ());
bool found = m_packetTagList.Remove (tag);
return found;
return m_packetTagList.Remove (tagType);
}
bool
Packet::PeekPacketTag (Tag &tag) const
Ptr<const Tag>
Packet::PeekPacketTag (TypeId tagType) const
{
bool found = m_packetTagList.Peek (tag);
return found;
return m_packetTagList.Peek (tagType);
}
void
Packet::RemoveAllPacketTags (void)
{
NS_LOG_FUNCTION (this);
m_packetTagList.RemoveAll ();
m_packetTagList.clear ();
}
void
Packet::PrintPacketTags (std::ostream &os) const
{
PacketTagIterator i = GetPacketTagIterator ();
while (i.HasNext ())
for (PacketTagList::const_iterator tag = m_packetTagList.begin ();
tag != m_packetTagList.end ();
tag++)
{
PacketTagIterator::Item item = i.Next ();
NS_ASSERT (item.GetTypeId ().HasConstructor ());
Callback<ObjectBase *> constructor = item.GetTypeId ().GetConstructor ();
NS_ASSERT (!constructor.IsNull ());
ObjectBase *instance = constructor ();
Tag *tag = dynamic_cast<Tag *> (instance);
NS_ASSERT (tag != 0);
item.GetTag (*tag);
tag->Print (os);
delete tag;
if (i.HasNext ())
if (tag != m_packetTagList.begin ())
{
os << " ";
}
(*tag)->Print (os);
}
// PacketTagIterator i = GetPacketTagIterator ();
// while (i.HasNext ())
// {
// PacketTagIterator::Item item = i.Next ();
// NS_ASSERT (item.GetTypeId ().HasConstructor ());
// Callback<ObjectBase *> constructor = item.GetTypeId ().GetConstructor ();
// NS_ASSERT (!constructor.IsNull ());
// ObjectBase *instance = constructor ();
// Tag *tag = dynamic_cast<Tag *> (instance);
// NS_ASSERT (tag != 0);
// item.GetTag (*tag);
// tag->Print (os);
// delete tag;
// if (i.HasNext ())
// {
// os << " ";
// }
// }
}
PacketTagIterator
Packet::GetPacketTagIterator (void) const
{
return PacketTagIterator (m_packetTagList.Head ());
}
// PacketTagIterator
// Packet::GetPacketTagIterator (void) const
// {
// return PacketTagIterator (m_packetTagList.Head ());
// }
std::ostream& operator<< (std::ostream& os, const Packet &packet)
{
+47 -62
View File
@@ -104,53 +104,6 @@ private:
ByteTagList::Iterator m_current;
};
/**
* \ingroup packet
* \brief Iterator over the set of 'packet' tags in a packet
*
* This is a java-style iterator.
*/
class PacketTagIterator
{
public:
/**
* Identifies a tag within a packet.
*/
class Item
{
public:
/**
* \returns the ns3::TypeId associated to this tag.
*/
TypeId GetTypeId (void) const;
/**
* \param tag the user tag to which the data should be copied.
*
* Read the requested tag and store it in the user-provided
* tag instance. This method will crash if the type of the
* tag provided by the user does not match the type of
* the underlying tag.
*/
void GetTag (Tag &tag) const;
private:
friend class PacketTagIterator;
Item (const struct PacketTagList::TagData *data);
const struct PacketTagList::TagData *m_data;
};
/**
* \returns true if calling Next is safe, false otherwise.
*/
bool HasNext (void) const;
/**
* \returns the next item found and prepare for the next one.
*/
Item Next (void);
private:
friend class Packet;
PacketTagIterator (const struct PacketTagList::TagData *head);
const struct PacketTagList::TagData *m_current;
};
/**
* \ingroup packet
* \brief network packets
@@ -498,31 +451,63 @@ public:
/**
* \param tag the tag to store in this packet
*
* Add a tag to this packet. This method calls the
* Tag::GetSerializedSize and, then, Tag::Serialize.
*
* Note that this method is const, that is, it does not
* modify the state of this packet, which is fairly
* un-intuitive.
* Add a tag to this packet.
*/
void AddPacketTag (const Tag &tag) const;
void
AddPacketTag (Ptr<const Tag> tag);
/**
* \param tag the tag to remove from this packet
* \returns true if the requested tag is found, false
* otherwise.
* \returns smart pointer to a constant Tag object if the requested tag is found,
* 0 otherwise.
*
* Remove a tag from this packet. This method calls
* Tag::Deserialize if the tag is found.
* Remove a tag from this packet.
*/
bool RemovePacketTag (Tag &tag);
Ptr<const Tag>
RemovePacketTag (TypeId tagType);
/**
* \param tag the tag to remove from this packet
* \returns smart pointer to a constant Tag object if the requested tag is found,
* 0 otherwise.
*
* Templated version to remove a tag from this packet.
* In addition to non-templated version, there is a DynamicCast to
* the requested tag type
*/
template<class T>
Ptr<const T>
RemovePacketTag ()
{
return DynamicCast<const T> (RemovePacketTag (T::GetTypeId ()));
}
/**
* \param tag the tag to search in this packet
* \returns true if the requested tag is found, false
* otherwise.
*
* Search a matching tag and call Tag::Deserialize if it is found.
* Search a matching tag and return it if found
*/
bool PeekPacketTag (Tag &tag) const;
Ptr<const Tag>
PeekPacketTag (TypeId tagType) const;
/**
* \param tag the tag to search in this packet
* \returns true if the requested tag is found, false
* otherwise.
*
* Templated version of search for a matching tag and returning it if found
* In addition to non-templated version, there is a DynamicCast to
* the requested tag type
*/
template<class T>
Ptr<const T>
PeekPacketTag () const
{
return DynamicCast<const T> (PeekPacketTag (T::GetTypeId ()));
}
/**
* Remove all packet tags.
*/
@@ -542,7 +527,7 @@ public:
* \returns an object which can be used to iterate over the list of
* packet tags.
*/
PacketTagIterator GetPacketTagIterator (void) const;
// PacketTagIterator GetPacketTagIterator (void) const;
/* Note: These functions support a temporary solution
* to a specific problem in this generic class, i.e.
+9 -2
View File
@@ -20,7 +20,7 @@
#ifndef TAG_H
#define TAG_H
#include "ns3/object-base.h"
#include "ns3/object.h"
#include "tag-buffer.h"
#include <stdint.h>
@@ -33,7 +33,7 @@ namespace ns3 {
*
* New kinds of tags can be created by subclassing this base class.
*/
class Tag : public ObjectBase
class Tag : public Object
{
public:
static TypeId GetTypeId (void);
@@ -71,6 +71,13 @@ public:
virtual void Print (std::ostream &os) const = 0;
};
inline std::ostream &
operator << (std::ostream &os, const Tag &tag)
{
tag.Print (os);
return os;
}
} // namespace ns3
#endif /* TAG_H */
+22 -22
View File
@@ -391,33 +391,33 @@ PacketTest::DoRun (void)
{
Packet p;
ATestTag<10> a;
Ptr< ATestTag<10> > a = CreateObject< ATestTag<10> > ();
p.AddPacketTag (a);
NS_TEST_EXPECT_MSG_EQ (p.PeekPacketTag (a), true, "trivial");
ATestTag<11> b;
NS_TEST_EXPECT_MSG_NE (p.PeekPacketTag< ATestTag<10> > (), 0, "trivial");
Ptr< ATestTag<11> > b = CreateObject< ATestTag<11> > ();
p.AddPacketTag (b);
NS_TEST_EXPECT_MSG_EQ (p.PeekPacketTag (b), true, "trivial");
NS_TEST_EXPECT_MSG_EQ (p.PeekPacketTag (a), true, "trivial");
NS_TEST_EXPECT_MSG_NE (p.PeekPacketTag< ATestTag<11> > (), 0, "trivial");
NS_TEST_EXPECT_MSG_NE (p.PeekPacketTag< ATestTag<10> > (), 0, "trivial");
Packet copy = p;
NS_TEST_EXPECT_MSG_EQ (copy.PeekPacketTag (b), true, "trivial");
NS_TEST_EXPECT_MSG_EQ (copy.PeekPacketTag (a), true, "trivial");
ATestTag<12> c;
NS_TEST_EXPECT_MSG_EQ (copy.PeekPacketTag (c), false, "trivial");
NS_TEST_EXPECT_MSG_NE (copy.PeekPacketTag< ATestTag<11> > (), 0, "trivial");
NS_TEST_EXPECT_MSG_NE (copy.PeekPacketTag< ATestTag<10> > (), 0, "trivial");
Ptr< ATestTag<12> > c = CreateObject< ATestTag<12> > ();
NS_TEST_EXPECT_MSG_EQ (copy.PeekPacketTag< ATestTag<12> > (), 0, "trivial");
copy.AddPacketTag (c);
NS_TEST_EXPECT_MSG_EQ (copy.PeekPacketTag (c), true, "trivial");
NS_TEST_EXPECT_MSG_EQ (copy.PeekPacketTag (b), true, "trivial");
NS_TEST_EXPECT_MSG_EQ (copy.PeekPacketTag (a), true, "trivial");
NS_TEST_EXPECT_MSG_EQ (p.PeekPacketTag (c), false, "trivial");
copy.RemovePacketTag (b);
NS_TEST_EXPECT_MSG_EQ (copy.PeekPacketTag (b), false, "trivial");
NS_TEST_EXPECT_MSG_EQ (p.PeekPacketTag (b), true, "trivial");
p.RemovePacketTag (a);
NS_TEST_EXPECT_MSG_EQ (p.PeekPacketTag (a), false, "trivial");
NS_TEST_EXPECT_MSG_EQ (copy.PeekPacketTag (a), true, "trivial");
NS_TEST_EXPECT_MSG_EQ (p.PeekPacketTag (c), false, "trivial");
NS_TEST_EXPECT_MSG_EQ (copy.PeekPacketTag (c), true, "trivial");
NS_TEST_EXPECT_MSG_NE (copy.PeekPacketTag< ATestTag<12> > (), 0, "trivial");
NS_TEST_EXPECT_MSG_NE (copy.PeekPacketTag< ATestTag<11> > (), 0, "trivial");
NS_TEST_EXPECT_MSG_NE (copy.PeekPacketTag< ATestTag<10> > (), 0, "trivial");
NS_TEST_EXPECT_MSG_EQ (p.PeekPacketTag< ATestTag<12> > (), 0, "trivial");
copy.RemovePacketTag< ATestTag<11> > ();
NS_TEST_EXPECT_MSG_EQ (copy.PeekPacketTag< ATestTag<11> > (), 0, "trivial");
NS_TEST_EXPECT_MSG_NE (p.PeekPacketTag< ATestTag<11> > (), 0, "trivial");
p.RemovePacketTag< ATestTag<10> > ();
NS_TEST_EXPECT_MSG_EQ (p.PeekPacketTag< ATestTag<10> > (), 0, "trivial");
NS_TEST_EXPECT_MSG_NE (copy.PeekPacketTag< ATestTag<10> > (), 0, "trivial");
NS_TEST_EXPECT_MSG_EQ (p.PeekPacketTag< ATestTag<12> > (), 0, "trivial");
NS_TEST_EXPECT_MSG_NE (copy.PeekPacketTag< ATestTag<12> > (), 0, "trivial");
p.RemoveAllPacketTags ();
NS_TEST_EXPECT_MSG_EQ (p.PeekPacketTag (b), false, "trivial");
NS_TEST_EXPECT_MSG_EQ (p.PeekPacketTag< ATestTag<11> > (), 0, "trivial");
}
{
+5 -5
View File
@@ -130,10 +130,10 @@ Ipv4Mask::GetInverse (void) const
void
Ipv4Mask::Print (std::ostream &os) const
{
os << ((m_mask >> 24) & 0xff) << "."
<< ((m_mask >> 16) & 0xff) << "."
<< ((m_mask >> 8) & 0xff) << "."
<< ((m_mask >> 0) & 0xff);
os << (int)((m_mask >> 24) & 0xff) << "."
<< (int)((m_mask >> 16) & 0xff) << "."
<< (int)((m_mask >> 8) & 0xff) << "."
<< (int)((m_mask >> 0) & 0xff);
}
@@ -183,7 +183,7 @@ Ipv4Address::Ipv4Address (char const *address)
m_address = AsciiToIpv4Host (address);
}
uint32_t
const uint32_t &
Ipv4Address::Get (void) const
{
return m_address;
+2 -1
View File
@@ -57,7 +57,8 @@ public:
* Get the host-order 32-bit IP address
* \return the host-order 32-bit IP address
*/
uint32_t Get (void) const;
const uint32_t &
Get (void) const;
/**
* input address is in host order.
* \param address The host order 32-bit address
+5 -7
View File
@@ -386,8 +386,8 @@ PacketSocket::ForwardUp (Ptr<NetDevice> device, Ptr<const Packet> packet,
if ((m_rxAvailable + packet->GetSize ()) <= m_rcvBufSize)
{
Ptr<Packet> copy = packet->Copy ();
SocketAddressTag tag;
tag.SetAddress (address);
Ptr<SocketAddressTag> tag = Create<SocketAddressTag> ();
tag->SetAddress (address);
copy->AddPacketTag (tag);
m_deliveryQueue.push (copy);
m_rxAvailable += packet->GetSize ();
@@ -443,11 +443,9 @@ PacketSocket::RecvFrom (uint32_t maxSize, uint32_t flags, Address &fromAddress)
Ptr<Packet> packet = Recv (maxSize, flags);
if (packet != 0)
{
SocketAddressTag tag;
bool found;
found = packet->PeekPacketTag (tag);
NS_ASSERT (found);
fromAddress = tag.GetAddress ();
Ptr<const SocketAddressTag> tag = packet->PeekPacketTag<SocketAddressTag> ();
NS_ASSERT (tag != 0);
fromAddress = tag->GetAddress ();
}
return packet;
}
+20
View File
@@ -0,0 +1,20 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2011 University of California, Los Angeles
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
+267
View File
@@ -0,0 +1,267 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2011 University of California, Los Angeles
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
#ifndef _TRIE_H_
#define _TRIE_H_
#ifndef __GNUC__
#error "gcc is required to compile this code"
#else
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#include <ext/pb_ds/tag_and_trait.hpp>
#if __GNUC__ < 4 || (__GNUC__==4 && __GNUC_MINOR__<=1)
#error "gcc version at least 4.1 is required to compile this code"
#elif (__GNUC__==4 && __GNUC_MINOR__<3)
#define PB_DS pb_ds
#else
#define PB_DS __gnu_pbds
#endif
#endif // __GNUC__
/**
* At least for now, trie implementation is based on gcc policy-based data containers
*
* Important!!! This trie simplifies/optimizes work with IPv4 prefixes.
* There is an assumption that nobody will use IP netmasks other than 255.255.255.0, 255.255.0.0, 255.0.0.0, or 0.0.0.0.
* As a result, branching happens on a byte level, not on bit a level.
*/
namespace ns3 {
/**
* \brief IPv4 version of element-access traits for patricia trie
*
* Refer to http://gcc.gnu.org/onlinedocs/libstdc++/ext/pb_ds/trie_based_containers.html
*/
class Ipv4AddressTrieEAccessTraits
{
public:
// Size type.
typedef size_t size_type;
// Key type.
typedef Ipv4Address key_type;
// Const key reference type.
typedef const Ipv4Address & const_key_reference;
// Element const iterator type.
typedef const uint8_t * const_iterator;
// Element type.
typedef uint8_t e_type;
enum
{
min_e_val = 0,
max_e_val = 255,
max_size = max_e_val - min_e_val + 1
};
public:
// Returns a const_iterator to the first element of r_key.
inline static const_iterator
begin (const_key_reference r_key);
// Returns a const_iterator to the after-last element of r_key.
inline static const_iterator
end (const_key_reference r_key);
// Maps an element to a position.
inline static size_type
e_pos (e_type e);
};
Ipv4AddressTrieEAccessTraits::const_iterator
Ipv4AddressTrieEAccessTraits::begin (Ipv4AddressTrieEAccessTraits::const_key_reference r_key)
{
return reinterpret_cast<Ipv4AddressTrieEAccessTraits::const_iterator> (&r_key.Get ());
}
Ipv4AddressTrieEAccessTraits::const_iterator
Ipv4AddressTrieEAccessTraits::end (Ipv4AddressTrieEAccessTraits::const_key_reference r_key)
{
return sizeof (r_key.Get ()) + reinterpret_cast<Ipv4AddressTrieEAccessTraits::const_iterator> (&r_key.Get ());
}
Ipv4AddressTrieEAccessTraits::size_type
Ipv4AddressTrieEAccessTraits::e_pos (Ipv4AddressTrieEAccessTraits::e_type e)
{
return e;
}
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
#include <ext/pb_ds/detail/trie_policy/trie_policy_base.hpp>
#define PB_DS_BASE_C_DEC \
PB_DS::detail::trie_policy_base<Const_Node_Iterator,Node_Iterator,E_Access_Traits,Allocator>
template<typename Const_Node_Iterator,
class Node_Iterator,
class E_Access_Traits,
class Allocator>
class TrieLongestPrefixMatch : private PB_DS_BASE_C_DEC
{
private:
typedef PB_DS_BASE_C_DEC base_type;
public:
typedef typename base_type::key_type key_type;
typedef typename base_type::const_key_reference const_key_reference;
// Element access traits.
typedef E_Access_Traits e_access_traits;
// Const element iterator.
typedef typename e_access_traits::const_iterator const_e_iterator;
// Allocator type.
typedef Allocator allocator;
// Size type.
typedef typename allocator::size_type size_type;
typedef PB_DS::detail::null_node_metadata metadata_type;
typedef Const_Node_Iterator const_node_iterator;
typedef Node_Iterator node_iterator;
typedef typename const_node_iterator::value_type const_iterator;
typedef typename node_iterator::value_type iterator;
inline const_iterator
longest_prefix_match (const_key_reference r_key)
{
return longest_prefix_match (
get_e_access_traits().begin (r_key),
get_e_access_traits().end (r_key));
}
inline const_iterator
longest_prefix_match (typename e_access_traits::const_iterator b, typename e_access_traits::const_iterator e)
{
if (empty())
return (end());
node_iterator nd_it = node_begin ();
node_iterator end_nd_it = node_end ();
const e_access_traits& r_traits = get_e_access_traits ();
const size_type given_range_length = std::distance (b, e);
while (true)
{
if (nd_it == end_nd_it) return end ();
const size_type common_range_length =
base_type::common_prefix_len (nd_it, b, e, r_traits);
if (common_range_length >= given_range_length) // not sure what this condition is for...
{
return rightmost_it (nd_it);
}
nd_it = next_child (nd_it, b, e, end_nd_it, r_traits);
}
}
protected:
inline void
operator()(node_iterator node_it, const_node_iterator end_nd_it) const
{
}
private:
// Returns true if the container is empty.
virtual bool
empty() const = 0;
// Returns the const iterator associated with the just-after last element.
virtual const_iterator
end() const = 0;
// Returns the iterator associated with the just-after last element.
virtual iterator
end() = 0;
// Returns the const_node_iterator associated with the trie's root node.
virtual const_node_iterator
node_begin() const = 0;
// Returns the node_iterator associated with the trie's root node.
virtual node_iterator
node_begin() = 0;
// Returns the const_node_iterator associated with a just-after leaf node.
virtual const_node_iterator
node_end() const = 0;
// Returns the node_iterator associated with a just-after leaf node.
virtual node_iterator
node_end() = 0;
// Access to the cmp_fn object.
virtual const e_access_traits&
get_e_access_traits() const = 0;
node_iterator
next_child(node_iterator nd_it, const_e_iterator b, const_e_iterator e,
node_iterator end_nd_it, const e_access_traits &r_traits)
{
const size_type num_children = nd_it.num_children();
node_iterator ret = end_nd_it;
size_type max_length = 0;
for (size_type i = 0; i < num_children; ++i)
{
node_iterator pot = nd_it.get_child (i);
const size_type common_range_length =
PB_DS_BASE_C_DEC::common_prefix_len (pot, b, e, r_traits);
if (common_range_length > max_length)
{
ret = pot;
max_length = common_range_length;
}
}
return (ret);
}
};
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
template<class MappedValue>
class Ipv4AddressTrie : public PB_DS::trie<Ipv4Address,MappedValue,Ipv4AddressTrieEAccessTraits,
PB_DS::pat_trie_tag,TrieLongestPrefixMatch>
{
};
} // namespace ns3
#endif // _TRIE_H_
+1
View File
@@ -124,6 +124,7 @@ def build(bld):
'utils/simple-channel.h',
'utils/simple-net-device.h',
'utils/pcap-test.h',
'utils/trie.h',
'helper/application-container.h',
'helper/net-device-container.h',
'helper/node-container.h',
+1 -9
View File
@@ -2,23 +2,15 @@
import os
import Options
import Logs
from waflib.Errors import WafError
def options(opt):
opt.add_option('--with-openflow',
help=('Path to OFSID source for NS-3 OpenFlow Integration support'),
default='', dest='with_openflow')
opt.tool_options('boost', tooldir=["waf-tools"])
def configure(conf):
try:
conf.check_tool('boost')
conf.check_boost(lib='signals filesystem')
if not conf.env.LIB_BOOST:
conf.check_boost(lib='signals filesystem', libpath="/usr/lib64")
except WafError:
conf.env['LIB_BOOST'] = []
if not conf.env.LIB_BOOST:
conf.report_optional_feature("openflow", "NS-3 OpenFlow Integration", False,
"Required boost libraries not found")
@@ -19,12 +19,16 @@
#include "point-to-point-channel.h"
#include "point-to-point-net-device.h"
#include "ns3/trace-source-accessor.h"
#include "ns3/point-to-point-loss-model.h"
#include "ns3/packet.h"
#include "ns3/simulator.h"
#include "ns3/log.h"
#include "ns3/pointer.h"
NS_LOG_COMPONENT_DEFINE ("PointToPointChannel");
#include "type-tag.h"
namespace ns3 {
NS_OBJECT_ENSURE_REGISTERED (PointToPointChannel);
@@ -39,9 +43,16 @@ PointToPointChannel::GetTypeId (void)
TimeValue (Seconds (0)),
MakeTimeAccessor (&PointToPointChannel::m_delay),
MakeTimeChecker ())
.AddAttribute ("LossModel", "Loss model",
PointerValue (0),
MakePointerAccessor (&PointToPointChannel::m_loss),
MakePointerChecker<PointToPointLossModel> ())
.AddTraceSource ("TxRxPointToPoint",
"Trace source indicating transmission of packet from the PointToPointChannel, used by the Animation interface.",
MakeTraceSourceAccessor (&PointToPointChannel::m_txrxPointToPoint))
.AddTraceSource ("DropPointToPoint",
"Trace source indicating dropping of packets in the PointToPointChannel.",
MakeTraceSourceAccessor (&PointToPointChannel::m_dropPointToPoint))
;
return tid;
}
@@ -58,6 +69,10 @@ PointToPointChannel::PointToPointChannel()
NS_LOG_FUNCTION_NOARGS ();
}
PointToPointChannel::~PointToPointChannel ()
{
}
void
PointToPointChannel::Attach (Ptr<PointToPointNetDevice> device)
{
@@ -93,12 +108,27 @@ PointToPointChannel::TransmitStart (
uint32_t wire = src == m_link[0].m_src ? 0 : 1;
// Ptr<const TypeTag> tag = p->PeekPacketTag<TypeTag> ();
// NS_LOG_DEBUG ("Packet tag is: " << tag);
// if (tag != 0 && tag->GetType () == TypeTag::DATA)
// {
if (m_loss != 0 && m_loss->IsLoss (p))
{
// drop packet
m_dropPointToPoint (GetId (), p, src, m_link[wire].m_dst, txTime, txTime + m_delay);
return false;
}
// }
// continue normal operations
Simulator::ScheduleWithContext (m_link[wire].m_dst->GetNode ()->GetId (),
txTime + m_delay, &PointToPointNetDevice::Receive,
m_link[wire].m_dst, p);
// Call the tx anim callback on the net device
m_txrxPointToPoint (p, src, m_link[wire].m_dst, txTime, txTime + m_delay);
m_txrxPointToPoint (GetId (), p, src, m_link[wire].m_dst, txTime, txTime + m_delay);
return true;
}
@@ -30,6 +30,7 @@ namespace ns3 {
class PointToPointNetDevice;
class Packet;
class PointToPointLossModel;
/**
* \ingroup point-to-point
@@ -57,6 +58,11 @@ public:
*/
PointToPointChannel ();
/**
* \brief Destructor
*/
~PointToPointChannel ();
/**
* \brief Attach a given netdevice to this channel
* \param device pointer to the netdevice to attach to the channel
@@ -128,6 +134,7 @@ private:
Time m_delay;
int32_t m_nDevices;
Ptr<PointToPointLossModel> m_loss;
/**
* The trace source for the packet transmission animation events that the
* device can fire.
@@ -137,13 +144,22 @@ private:
*
* @see class CallBackTraceSource
*/
TracedCallback<Ptr<const Packet>, // Packet being transmitted
TracedCallback<uint32_t, // channel ID
Ptr<const Packet>, // Packet being transmitted
Ptr<NetDevice>, // Transmitting NetDevice
Ptr<NetDevice>, // Receiving NetDevice
Time, // Amount of time to transmit the pkt
Time // Last bit receive time (relative to now)
> m_txrxPointToPoint;
TracedCallback<uint32_t, // channel ID
Ptr<const Packet>, // Packet being transmitted
Ptr<NetDevice>, // Transmitting NetDevice
Ptr<NetDevice>, // Receiving NetDevice
Time, // Amount of time to transmit the pkt
Time // Last bit receive time (relative to now)
> m_dropPointToPoint;
enum WireState
{
INITIALIZING,
@@ -0,0 +1,114 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2005,2006,2007 INRIA
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
#include "point-to-point-loss-model.h"
#include "ns3/log.h"
#include "ns3/boolean.h"
#include "ns3/double.h"
#include "ns3/pointer.h"
#include "ns3/packet.h"
#include <math.h>
NS_LOG_COMPONENT_DEFINE ("PointToPointLossModel");
namespace ns3 {
// ------------------------------------------------------------------------- //
NS_OBJECT_ENSURE_REGISTERED (PointToPointLossModel);
TypeId
PointToPointLossModel::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::PointToPointLossModel")
.SetParent<Object> ()
;
return tid;
}
PointToPointLossModel::PointToPointLossModel ()
: m_next (0)
{
}
PointToPointLossModel::~PointToPointLossModel ()
{
}
void
PointToPointLossModel::SetNext (Ptr<PointToPointLossModel> next)
{
m_next = next;
}
bool
PointToPointLossModel::IsLoss (Ptr<const Packet> pkt)
{
bool loss = DoIsLoss (pkt);
if (!loss && m_next != 0)
{
loss = m_next->IsLoss (pkt);
}
return loss;
}
// ------------------------------------------------------------------------- //
NS_OBJECT_ENSURE_REGISTERED (RandomPointToPointLossModel);
TypeId
RandomPointToPointLossModel::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::RandomPointToPointLossModel")
.SetParent<PointToPointLossModel> ()
.AddConstructor<RandomPointToPointLossModel> ()
.AddAttribute ("Variable", "The random variable used to pick a random los",
RandomVariableValue (UniformVariable ()),
MakeRandomVariableAccessor (&RandomPointToPointLossModel::m_variable),
MakeRandomVariableChecker ())
.AddAttribute ("Probability", "Loss probability",
DoubleValue (-1), // impossible
MakeDoubleAccessor (&RandomPointToPointLossModel::m_probability),
MakeDoubleChecker<double> ())
;
return tid;
}
RandomPointToPointLossModel::RandomPointToPointLossModel ()
: PointToPointLossModel ()
{
}
RandomPointToPointLossModel::~RandomPointToPointLossModel ()
{
}
bool
RandomPointToPointLossModel::DoIsLoss (Ptr<const Packet> pkt)
{
bool loss = (m_variable.GetValue () <= m_probability);
NS_LOG_DEBUG ("Loss: " << loss);
return loss;
}
// ------------------------------------------------------------------------- //
} // namespace ns3
@@ -0,0 +1,101 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2005,2006,2007 INRIA
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
#ifndef POINT_TO_POINT_LOSS_MODEL_H
#define POINT_TO_POINT_LOSS_MODEL_H
#include "ns3/object.h"
#include "ns3/random-variable.h"
#include "ns3/ptr.h"
namespace ns3 {
class Packet;
/**
* \defgroup point-to-point Loss Models
*
*/
/**
* \ingroup point-to-point
*
* \brief Model losses in point-to-point links
*/
class PointToPointLossModel : public Object
{
public:
static TypeId GetTypeId (void);
PointToPointLossModel ();
virtual ~PointToPointLossModel ();
/**
* \brief Enables a chain of loss models to act on the signal
* \param next The next PointToPointLossModel to add to the chain
*/
void
SetNext (Ptr<PointToPointLossModel> next);
/**
* \brief Decide whether or not packet should be lost
*/
bool
IsLoss (Ptr<const Packet> pkt);
private:
PointToPointLossModel (const PointToPointLossModel &o);
PointToPointLossModel &operator = (const PointToPointLossModel &o);
virtual bool
DoIsLoss (Ptr<const Packet> pkt) = 0;
Ptr<PointToPointLossModel> m_next;
};
/**
* \ingroup propagation
*
* \brief The propagation loss follows a random distribution.
*/
class RandomPointToPointLossModel : public PointToPointLossModel
{
public:
static TypeId GetTypeId (void);
RandomPointToPointLossModel ();
virtual ~RandomPointToPointLossModel ();
private:
RandomPointToPointLossModel (const RandomPointToPointLossModel &o);
RandomPointToPointLossModel & operator = (const RandomPointToPointLossModel &o);
virtual bool
DoIsLoss (Ptr<const Packet> pkt);
private:
RandomVariable m_variable;
double m_probability;
};
} // namespace ns3
#endif /* POINT_TO_POINT_LOSS_MODEL_H */
@@ -607,6 +607,7 @@ PointToPointNetDevice::PppToEther (uint16_t proto)
{
case 0x0021: return 0x0800; //IPv4
case 0x0057: return 0x86DD; //IPv6
case 0x0077: return 0x7777; //CCNx
default: NS_ASSERT_MSG (false, "PPP Protocol number not defined!");
}
return 0;
@@ -619,6 +620,7 @@ PointToPointNetDevice::EtherToPpp (uint16_t proto)
{
case 0x0800: return 0x0021; //IPv4
case 0x86DD: return 0x0057; //IPv6
case 0x7777: return 0x0077; //CCNx
default: NS_ASSERT_MSG (false, "PPP Protocol number not defined!");
}
return 0;
+3
View File
@@ -66,6 +66,9 @@ PppHeader::Print (std::ostream &os) const
case 0x0057: /* IPv6 */
proto = "IPv6 (0x0057)";
break;
case 0x0077: /* CCNx */
proto = "CCNx (0x0077)";
break;
default:
NS_ASSERT_MSG (false, "PPP Protocol number not defined!");
}
+92
View File
@@ -0,0 +1,92 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2011 University of California, Los Angeles
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
#ifndef TYPE_TAG_H
#define TYPE_TAG_H
#include <ns3/tag.h>
#include <ns3/type-id.h>
using namespace ns3;
class TypeTag : public Tag
{
public:
static TypeId GetTypeId (void)
{
static TypeId tid = TypeId ("TypeTag")
.SetParent<Tag> ()
;
return tid;
}
enum Type
{
DATA,
INTEREST,
DATA2,
INTEREST2
};
TypeTag (Type type)
: m_type (type)
{
}
Type GetType () const
{
return m_type;
}
virtual uint32_t GetSerializedSize (void) const
{
return 0;
}
virtual void Serialize (TagBuffer i) const
{
return;
}
virtual void Deserialize (TagBuffer i)
{
return;
}
virtual void Print (std::ostream &os) const
{
switch (m_type)
{
case DATA:
case DATA2:
os << "DATA";
break;
case INTEREST:
case INTEREST2:
os << "INTEREST";
break;
}
}
private:
Type m_type;
};
#endif // TYPE_TAG_H
+2
View File
@@ -7,6 +7,7 @@ def build(bld):
'model/point-to-point-net-device.cc',
'model/point-to-point-channel.cc',
'model/point-to-point-remote-channel.cc',
'model/point-to-point-loss-model.cc',
'model/ppp-header.cc',
'helper/point-to-point-helper.cc',
]
@@ -22,6 +23,7 @@ def build(bld):
'model/point-to-point-net-device.h',
'model/point-to-point-channel.h',
'model/point-to-point-remote-channel.h',
'model/point-to-point-loss-model.h',
'model/ppp-header.h',
'helper/point-to-point-helper.h',
]
+6 -10
View File
@@ -76,11 +76,9 @@ DynamicGlobalRoutingTestCase::~DynamicGlobalRoutingTestCase ()
void
DynamicGlobalRoutingTestCase::SinkRx (std::string path, Ptr<const Packet> p, const Address& address)
{
Ipv4PacketInfoTag tag;
bool found;
found = p->PeekPacketTag (tag);
Ptr<const Ipv4PacketInfoTag> tag = p->PeekPacketTag<Ipv4PacketInfoTag> ();
uint8_t now = static_cast<uint8_t> (Simulator::Now ().GetSeconds ());
if (found)
if (tag != 0)
{
;
}
@@ -99,17 +97,15 @@ DynamicGlobalRoutingTestCase::HandleRead (Ptr<Socket> socket)
{ //EOF
break;
}
Ipv4PacketInfoTag tag;
bool found;
found = packet->PeekPacketTag (tag);
Ptr<const Ipv4PacketInfoTag> tag = packet->PeekPacketTag<Ipv4PacketInfoTag> ();
uint8_t now = static_cast<uint8_t> (Simulator::Now ().GetSeconds ());
if (found)
if (tag != 0)
{
if (tag.GetRecvIf () == 1)
if (tag->GetRecvIf () == 1)
{
m_firstInterface[now]++;
}
if (tag.GetRecvIf () == 2)
if (tag->GetRecvIf () == 2)
{
m_secondInterface[now]++;
}
@@ -47,7 +47,6 @@ TopologyReaderHelper::SetFileType (const std::string fileType)
m_fileType = fileType;
}
Ptr<TopologyReader>
TopologyReaderHelper::GetTopologyReader ()
{
@@ -59,17 +58,17 @@ TopologyReaderHelper::GetTopologyReader ()
if (m_fileType == "Orbis")
{
NS_LOG_INFO ("Creating Orbis formatted data input.");
m_inFile = CreateObject<OrbisTopologyReader> ();
m_inFile = Create<OrbisTopologyReader> ();
}
else if (m_fileType == "Inet")
{
NS_LOG_INFO ("Creating Inet formatted data input.");
m_inFile = CreateObject<InetTopologyReader> ();
m_inFile = Create<InetTopologyReader> ();
}
else if (m_fileType == "Rocketfuel")
{
NS_LOG_INFO ("Creating Rocketfuel formatted data input.");
m_inFile = CreateObject<RocketfuelTopologyReader> ();
m_inFile = Create<RocketfuelTopologyReader> ();
}
else
{
@@ -22,11 +22,10 @@
#ifndef TOPOLOGY_READER_HELPER_H
#define TOPOLOGY_READER_HELPER_H
#include "ns3/topology-reader.h"
#include <string>
namespace ns3 {
class TopologyReader;
/**
* \ingroup topology
*
+10 -10
View File
@@ -28,19 +28,19 @@
using namespace std;
namespace ns3 {
NS_LOG_COMPONENT_DEFINE ("InetTopologyReader");
NS_OBJECT_ENSURE_REGISTERED (InetTopologyReader);
namespace ns3 {
TypeId InetTopologyReader::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::InetTopologyReader")
.SetParent<Object> ()
;
return tid;
}
// NS_OBJECT_ENSURE_REGISTERED (InetTopologyReader);
// TypeId InetTopologyReader::GetTypeId (void)
// {
// static TypeId tid = TypeId ("ns3::InetTopologyReader")
// .SetParent<Object> ()
// ;
// return tid;
// }
InetTopologyReader::InetTopologyReader ()
{
@@ -47,7 +47,7 @@ namespace ns3 {
class InetTopologyReader : public TopologyReader
{
public:
static TypeId GetTypeId (void);
// static TypeId GetTypeId (void);
InetTopologyReader ();
virtual ~InetTopologyReader ();
@@ -29,19 +29,19 @@
using namespace std;
namespace ns3 {
NS_LOG_COMPONENT_DEFINE ("OrbisTopologyReader");
NS_OBJECT_ENSURE_REGISTERED (OrbisTopologyReader);
namespace ns3 {
TypeId OrbisTopologyReader::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::OrbisTopologyReader")
.SetParent<Object> ()
;
return tid;
}
// NS_OBJECT_ENSURE_REGISTERED (OrbisTopologyReader);
// TypeId OrbisTopologyReader::GetTypeId (void)
// {
// static TypeId tid = TypeId ("ns3::OrbisTopologyReader")
// .SetParent<Object> ()
// ;
// return tid;
// }
OrbisTopologyReader::OrbisTopologyReader ()
{
@@ -44,7 +44,7 @@ namespace ns3 {
class OrbisTopologyReader : public TopologyReader
{
public:
static TypeId GetTypeId (void);
// static TypeId GetTypeId (void);
OrbisTopologyReader ();
virtual ~OrbisTopologyReader ();
@@ -28,19 +28,19 @@
#include "ns3/unused.h"
#include "rocketfuel-topology-reader.h"
namespace ns3 {
NS_LOG_COMPONENT_DEFINE ("RocketfuelTopologyReader");
NS_OBJECT_ENSURE_REGISTERED (RocketfuelTopologyReader);
namespace ns3 {
TypeId RocketfuelTopologyReader::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::RocketfuelTopologyReader")
.SetParent<Object> ()
;
return tid;
}
// NS_OBJECT_ENSURE_REGISTERED (RocketfuelTopologyReader);
// TypeId RocketfuelTopologyReader::GetTypeId (void)
// {
// static TypeId tid = TypeId ("ns3::RocketfuelTopologyReader")
// .SetParent<Object> ()
// ;
// return tid;
// }
RocketfuelTopologyReader::RocketfuelTopologyReader ()
{
@@ -21,7 +21,6 @@
#ifndef ROCKETFUEL_TOPOLOGY_READER_H
#define ROCKETFUEL_TOPOLOGY_READER_H
#include "ns3/nstime.h"
#include "topology-reader.h"
namespace ns3 {
@@ -43,7 +42,7 @@ namespace ns3 {
class RocketfuelTopologyReader : public TopologyReader
{
public:
static TypeId GetTypeId (void);
// static TypeId GetTypeId (void);
RocketfuelTopologyReader ();
virtual ~RocketfuelTopologyReader ();
+26 -10
View File
@@ -19,24 +19,23 @@
* Author: Valerio Sartini (valesar@gmail.com)
*/
#include "ns3/log.h"
#include "topology-reader.h"
#include "ns3/log.h"
namespace ns3 {
NS_LOG_COMPONENT_DEFINE ("TopologyReader");
NS_OBJECT_ENSURE_REGISTERED (TopologyReader);
// NS_OBJECT_ENSURE_REGISTERED (TopologyReader);
TypeId TopologyReader::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::TopologyReader")
.SetParent<Object> ()
;
return tid;
}
// TypeId TopologyReader::GetTypeId (void)
// {
// static TypeId tid = TypeId ("ns3::TopologyReader")
// .SetParent<Object> ()
// ;
// return tid;
// }
TopologyReader::TopologyReader ()
{
@@ -106,12 +105,23 @@ TopologyReader::Link::Link ()
{
}
void
TopologyReader::Link::SetNetDevices (Ptr<NetDevice> from, Ptr<NetDevice> to)
{
m_fromNetDevice = from;
m_toNetDevice = to;
}
Ptr<Node> TopologyReader::Link::GetFromNode (void) const
{
return m_fromPtr;
}
Ptr<NetDevice> TopologyReader::Link::GetFromNetDevice (void) const
{
return m_fromNetDevice;
}
std::string
TopologyReader::Link::GetFromNodeName (void) const
{
@@ -124,6 +134,12 @@ TopologyReader::Link::GetToNode (void) const
return m_toPtr;
}
Ptr<NetDevice>
TopologyReader::Link::GetToNetDevice (void) const
{
return m_toNetDevice;
}
std::string
TopologyReader::Link::GetToNodeName (void) const
{
+34 -12
View File
@@ -22,16 +22,16 @@
#ifndef TOPOLOGY_READER_H
#define TOPOLOGY_READER_H
#include <string>
#include <map>
#include <list>
#include "ns3/object.h"
#include "ns3/node-container.h"
#include "ns3/simple-ref-count.h"
namespace ns3 {
class NetDevice;
/**
* \ingroup topology
*
@@ -40,7 +40,7 @@ namespace ns3 {
* This interface perform the shared tasks among all possible input file readers.
* Each different file format is handled by its own topology reader.
*/
class TopologyReader : public Object
class TopologyReader : public SimpleRefCount<TopologyReader>
{
public:
@@ -53,12 +53,14 @@ public:
*/
class Link
{
public:
public:
/**
* \brief Constant iterator to scan the map of link attributes.
*/
typedef std::map<std::string, std::string>::const_iterator ConstAttributesIterator;
Link (); // default constructor
/**
* \brief Constructor
* \param fromPtr Ptr to the node the link is orginating from
@@ -66,13 +68,26 @@ public:
* \param toPtr Ptr to the node the link is directed to
* \param toName name of the node the link is directed to
*/
Link ( Ptr<Node> fromPtr, const std::string &fromName, Ptr<Node> toPtr, const std::string &toName );
Link (Ptr<Node> fromPtr, const std::string &fromName, Ptr<Node> toPtr, const std::string &toName);
/**
* \brief Set netdevices associated with the link
* \param from NetDevice associated with From node
* \param to NetDevice associated with To node
*/
void
SetNetDevices (Ptr<NetDevice> from, Ptr<NetDevice> to);
/**
* \brief Returns a Ptr<Node> to the "from" node of the link
* \return a Ptr<Node> to the "from" node of the link
*/
Ptr<Node> GetFromNode (void) const;
/**
* \brief Returns a Ptr<NetDevice> of the "from" node of the link
* \return a Ptr<NetDevice> of the "from" node of the link
*/
Ptr<NetDevice> GetFromNetDevice (void) const;
/**
* \brief Returns the name of the "from" node of the link
* \return the name of the "from" node of the link
@@ -83,6 +98,11 @@ public:
* \return a Ptr<Node> to the "to" node of the link
*/
Ptr<Node> GetToNode (void) const;
/**
* \brief Returns a Ptr<NetDevice> of the "to" node of the link
* \return a Ptr<NetDevice> of the "to" node of the link
*/
Ptr<NetDevice> GetToNetDevice (void) const;
/**
* \brief Returns the name of the "to" node of the link
* \return the name of the "to" node of the link
@@ -122,12 +142,13 @@ public:
ConstAttributesIterator AttributesEnd (void);
private:
Link ();
std::string m_fromName;
Ptr< Node > m_fromPtr;
std::string m_toName;
Ptr< Node > m_toPtr;
std::map<std::string, std::string> m_linkAttr;
Ptr< NetDevice > m_fromNetDevice;
Ptr< NetDevice > m_toNetDevice;
std::map<std::string, std::string > m_linkAttr;
};
/**
@@ -135,7 +156,7 @@ private:
*/
typedef std::list< Link >::const_iterator ConstLinksIterator;
static TypeId GetTypeId (void);
// static TypeId GetTypeId (void);
TopologyReader ();
virtual ~TopologyReader ();
@@ -195,13 +216,14 @@ private:
*/
void AddLink (Link link);
protected:
std::string m_fileName;
std::list<Link> m_linksList;
private:
TopologyReader (const TopologyReader&);
TopologyReader& operator= (const TopologyReader&);
std::string m_fileName;
std::list<Link> m_linksList;
// end class TopologyReader
};
@@ -55,7 +55,7 @@ RocketfuelTopologyReaderTest::DoRun (void)
std::string input ("./src/topology-read/examples/RocketFuel_toposample_1239_weights.txt");
inFile = CreateObject<RocketfuelTopologyReader> ();
inFile = Create<RocketfuelTopologyReader> ();
inFile->SetFileName (input);
if (inFile != 0)
@@ -113,8 +113,7 @@ class Tunnel
{
Ptr<Packet> packet = socket->Recv (65535, 0);
NS_LOG_DEBUG ("N3SocketRecv: " << *packet);
SocketAddressTag socketAddressTag;
packet->RemovePacketTag (socketAddressTag);
packet->RemovePacketTag<SocketAddressTag> ();
m_n3Tap->Receive (packet, 0x0800, m_n3Tap->GetAddress (), m_n3Tap->GetAddress (), NetDevice::PACKET_HOST);
}
@@ -122,8 +121,7 @@ class Tunnel
{
Ptr<Packet> packet = socket->Recv (65535, 0);
NS_LOG_DEBUG ("N0SocketRecv: " << *packet);
SocketAddressTag socketAddressTag;
packet->RemovePacketTag (socketAddressTag);
packet->RemovePacketTag<SocketAddressTag> ();
m_n0Tap->Receive (packet, 0x0800, m_n0Tap->GetAddress (), m_n0Tap->GetAddress (), NetDevice::PACKET_HOST);
}
@@ -131,8 +129,7 @@ class Tunnel
{
Ptr<Packet> packet = socket->Recv (65535, 0);
NS_LOG_DEBUG ("N1SocketRecv: " << *packet);
SocketAddressTag socketAddressTag;
packet->RemovePacketTag (socketAddressTag);
packet->RemovePacketTag<SocketAddressTag> ();
m_n1Tap->Receive (packet, 0x0800, m_n1Tap->GetAddress (), m_n1Tap->GetAddress (), NetDevice::PACKET_HOST);
}
+3 -2
View File
@@ -317,8 +317,9 @@ PyViz::SimulatorRunUntil (Time time)
// events just appear to "jump" big chunks of time.
NS_LOG_LOGIC ("Schedule dummy callback to be called in " << (time - Simulator::Now ()));
m_stop = false;
Simulator::Cancel (m_stopCallbackEvent);
m_stopCallbackEvent = Simulator::Schedule (time - Simulator::Now (), &PyViz::CallbackStopSimulation, this);
// Simulator::Cancel (m_stopCallbackEvent);
// m_stopCallbackEvent =
Simulator::ScheduleWithContext (-1, time - Simulator::Now (), &PyViz::CallbackStopSimulation, this);
Ptr<SimulatorImpl> impl = Simulator::GetImplementation ();
Ptr<VisualSimulatorImpl> visualImpl = DynamicCast<VisualSimulatorImpl> (impl);
+9 -3
View File
@@ -6,7 +6,10 @@ import ns.internet
import ns.mesh
import ns.wimax
import ns.wimax
import ns.lte
try:
import ns.lte
except:
pass
import gobject
import os.path
@@ -43,9 +46,12 @@ netdevice_traits = {
ns.mesh.MeshPointDevice: NetDeviceTraits(is_virtual=True),
ns.wimax.SubscriberStationNetDevice: NetDeviceTraits(is_wireless=True),
ns.wimax.BaseStationNetDevice: NetDeviceTraits(is_wireless=True),
ns.lte.UeNetDevice: NetDeviceTraits(is_wireless=True),
ns.lte.EnbNetDevice: NetDeviceTraits(is_wireless=True),
}
try:
netdevice_traits[ns.lte.UeNetDevice] = NetDeviceTraits(is_wireless=True)
netdevice_traits[ns.lte.EnbNetDevice] = NetDeviceTraits(is_wireless=True)
except:
pass
def lookup_netdevice_traits(class_type):
try:
+19 -4
View File
@@ -463,6 +463,8 @@ class Visualizer(gobject.GObject):
self.node_drag_state = None
self.follow_node = None
self.shell_window = None
self._topology_scan_timeout_id = None
self.last_discoverd_node = 0
self.create_gui()
@@ -749,10 +751,13 @@ class Visualizer(gobject.GObject):
self.window.show()
def scan_topology(self):
print "scanning topology: %i nodes..." % (ns.network.NodeList.GetNNodes(),)
if (self.last_discoverd_node >= ns.network.NodeList.GetNNodes()):
return True
print "scanning topology: [%i, %i) nodes..." % (self.last_discoverd_node, ns.network.NodeList.GetNNodes(),)
graph = pygraphviz.AGraph()
seen_nodes = 0
for nodeI in range(ns.network.NodeList.GetNNodes()):
for nodeI in range(self.last_discoverd_node, ns.network.NodeList.GetNNodes()):
seen_nodes += 1
if seen_nodes == 100:
print "scan topology... %i nodes visited (%.1f%%)" % (nodeI, 100*nodeI/ns.network.NodeList.GetNNodes())
@@ -762,6 +767,7 @@ class Visualizer(gobject.GObject):
node_view = self.get_node(nodeI)
mobility = node.GetObject(ns.mobility.MobilityModel.GetTypeId())
# print "Mobility type: " + mobility.GetInstanceTypeId().GetName()
if mobility is not None:
node_view.set_color("red")
pos = mobility.GetPosition()
@@ -808,7 +814,7 @@ class Visualizer(gobject.GObject):
graph.add_edge(node_name, other_node_name)
self.create_link(self.get_node(nodeI), otherNodeView)
print "scanning topology: calling graphviz layout"
# print "scanning topology: calling graphviz layout"
graph.layout(LAYOUT_ALGORITHM)
for node in graph.iternodes():
#print node, "=>", node.attr['pos']
@@ -820,8 +826,11 @@ class Visualizer(gobject.GObject):
obj = self.channels[int(node_id)]
obj.set_position(pos_x, pos_y)
print "scanning topology: all done."
# print "scanning topology: all done."
self.emit("topology-scanned")
self.last_discoverd_node = ns.network.NodeList.GetNNodes();
return True
def get_node(self, index):
try:
@@ -1093,6 +1102,11 @@ class Visualizer(gobject.GObject):
#print "view: done."
return True
def _start_topology_scan(self):
if self._topology_scan_timeout_id is not None:
gobject.source_remove(self._topology_scan_timeout_id)
self._topology_scan_timeout_id = gobject.timeout_add (1000, self.scan_topology, priority=PRIORITY_UPDATE_VIEW)
def _start_update_timer(self):
if self._update_timeout_id is not None:
gobject.source_remove(self._update_timeout_id)
@@ -1171,6 +1185,7 @@ class Visualizer(gobject.GObject):
def start(self):
self.scan_topology()
self._start_topology_scan()
self.window.connect("delete-event", self._quit)
#self._start_update_timer()
gobject.timeout_add(200, self.autoscale_view)
@@ -0,0 +1,89 @@
import gtk
import ns.core
import ns.network
import ns.internet
import ns.NDNabstraction
from visualizer.base import InformationWindow
class ShowCcnxFib(InformationWindow):
(
COLUMN_PREFIX,
COLUMN_FACE
) = range(2)
def __init__(self, visualizer, node_index):
InformationWindow.__init__(self)
self.win = gtk.Dialog(parent=visualizer.window,
flags=gtk.DIALOG_DESTROY_WITH_PARENT|gtk.DIALOG_NO_SEPARATOR,
buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE))
self.win.connect("response", self._response_cb)
self.node = ns.network.NodeList.GetNode (node_index)
node_name = ns.core.Names.FindName (self.node)
title = "CCNx FIB for node %i" % node_index
if len(node_name) != 0:
title += " (" + str(node_name) + ")"
self.win.set_title (title)
self.visualizer = visualizer
self.node_index = node_index
self.table_model = gtk.ListStore(str, str, int)
treeview = gtk.TreeView(self.table_model)
treeview.show()
sw = gtk.ScrolledWindow()
sw.set_properties(hscrollbar_policy=gtk.POLICY_AUTOMATIC,
vscrollbar_policy=gtk.POLICY_AUTOMATIC)
sw.show()
sw.add(treeview)
self.win.vbox.add(sw)
self.win.set_default_size(600, 300)
# Dest.
column = gtk.TreeViewColumn('Destination', gtk.CellRendererText(),
text=self.COLUMN_PREFIX)
treeview.append_column(column)
# Interface
column = gtk.TreeViewColumn('faceType[nodeId](routingCost,status,metric)', gtk.CellRendererText(),
text=self.COLUMN_FACE)
treeview.append_column(column)
self.visualizer.add_information_window(self)
self.win.show()
def _response_cb(self, win, response):
self.win.destroy()
self.visualizer.remove_information_window(self)
def update(self):
ccnxFib = self.node.GetObject(ns.NDNabstraction.CcnxFib.GetTypeId())
if ccnxFib is None:
return
self.table_model.clear()
for fibI in range(ccnxFib.GetCcnxFibEntryCount()):
entry = ccnxFib.GetCcnxFibEntry(fibI)
tree_iter = self.table_model.append()
self.table_model.set(tree_iter,
self.COLUMN_PREFIX, str(entry.GetPrefix()),
self.COLUMN_FACE, str(entry))
def populate_node_menu(viz, node, menu):
menu_item = gtk.MenuItem("Show CCNx FIB")
menu_item.show()
def _show_ccnx_fib(dummy_menu_item):
ShowCcnxFib(viz, node.node_index)
menu_item.connect("activate", _show_ccnx_fib)
menu.add(menu_item)
def register(viz):
viz.connect("populate-node-menu", populate_node_menu)
+8 -10
View File
@@ -709,12 +709,11 @@ MacLow::ReceiveOk (Ptr<Packet> packet, double rxSnr, WifiMode txMode, WifiPreamb
&& m_currentPacket != 0)
{
NS_LOG_DEBUG ("receive cts from=" << m_currentHdr.GetAddr1 ());
SnrTag tag;
packet->RemovePacketTag (tag);
Ptr<const SnrTag> tag = packet->RemovePacketTag<SnrTag> ();
m_stationManager->ReportRxOk (m_currentHdr.GetAddr1 (), &m_currentHdr,
rxSnr, txMode);
m_stationManager->ReportRtsOk (m_currentHdr.GetAddr1 (), &m_currentHdr,
rxSnr, txMode, tag.Get ());
rxSnr, txMode, tag->Get ());
m_ctsTimeoutEvent.Cancel ();
NotifyCtsTimeoutResetNow ();
@@ -734,12 +733,11 @@ MacLow::ReceiveOk (Ptr<Packet> packet, double rxSnr, WifiMode txMode, WifiPreamb
&& m_txParams.MustWaitAck ())
{
NS_LOG_DEBUG ("receive ack from=" << m_currentHdr.GetAddr1 ());
SnrTag tag;
packet->RemovePacketTag (tag);
Ptr<const SnrTag> tag = packet->RemovePacketTag<SnrTag> ();
m_stationManager->ReportRxOk (m_currentHdr.GetAddr1 (), &m_currentHdr,
rxSnr, txMode);
m_stationManager->ReportDataOk (m_currentHdr.GetAddr1 (), &m_currentHdr,
rxSnr, txMode, tag.Get ());
rxSnr, txMode, tag->Get ());
bool gotAck = false;
if (m_txParams.MustWaitNormalAck ()
&& m_normalAckTimeoutEvent.IsRunning ())
@@ -1446,8 +1444,8 @@ MacLow::SendCtsAfterRts (Mac48Address source, Time duration, WifiMode rtsTxMode,
WifiMacTrailer fcs;
packet->AddTrailer (fcs);
SnrTag tag;
tag.Set (rtsSnr);
Ptr<SnrTag> tag = CreateObject<SnrTag> ();
tag->Set (rtsSnr);
packet->AddPacketTag (tag);
ForwardDown (packet, &cts, ctsTxMode);
@@ -1525,8 +1523,8 @@ MacLow::SendAckAfterData (Mac48Address source, Time duration, WifiMode dataTxMod
WifiMacTrailer fcs;
packet->AddTrailer (fcs);
SnrTag tag;
tag.Set (dataSnr);
Ptr<SnrTag> tag = CreateObject<SnrTag> ();
tag->Set (dataSnr);
packet->AddPacketTag (tag);
ForwardDown (packet, &ack, ackTxMode);
+4 -4
View File
@@ -59,13 +59,13 @@ QosUtilsMapTidToAc (uint8_t tid)
uint8_t
QosUtilsGetTidForPacket (Ptr<const Packet> packet)
{
QosTag qos;
Ptr<const QosTag> qos = packet->PeekPacketTag<QosTag> ();
uint8_t tid = 8;
if (packet->PeekPacketTag (qos))
if (qos != 0)
{
if (qos.GetTid () < 8)
if (qos->GetTid () < 8)
{
tid = qos.GetTid ();
tid = qos->GetTid ();
}
}
return tid;
+10 -14
View File
@@ -347,12 +347,12 @@ WifiRemoteStationManager::PrepareForQueue (Mac48Address address, const WifiMacHe
WifiRemoteStation *station = Lookup (address, header);
WifiMode rts = DoGetRtsMode (station);
WifiMode data = DoGetDataMode (station, fullPacketSize);
TxModeTag tag;
// first, make sure that the tag is not here anymore.
ConstCast<Packet> (packet)->RemovePacketTag (tag);
tag = TxModeTag (rts, data);
ConstCast<Packet> (packet)->RemovePacketTag<TxModeTag> ();
Ptr<TxModeTag> tag = CreateObject<TxModeTag> (rts, data);
// and then, add it back
packet->AddPacketTag (tag);
ConstCast<Packet> (packet)->AddPacketTag (tag);
}
WifiMode
WifiRemoteStationManager::GetDataMode (Mac48Address address, const WifiMacHeader *header,
@@ -364,11 +364,9 @@ WifiRemoteStationManager::GetDataMode (Mac48Address address, const WifiMacHeader
}
if (!IsLowLatency ())
{
TxModeTag tag;
bool found;
found = ConstCast<Packet> (packet)->PeekPacketTag (tag);
NS_ASSERT (found);
return tag.GetDataMode ();
Ptr<const TxModeTag> tag = packet->PeekPacketTag<TxModeTag> ();
NS_ASSERT (tag != 0);
return tag->GetDataMode ();
}
return DoGetDataMode (Lookup (address, header), fullPacketSize);
}
@@ -379,11 +377,9 @@ WifiRemoteStationManager::GetRtsMode (Mac48Address address, const WifiMacHeader
NS_ASSERT (!address.IsGroup ());
if (!IsLowLatency ())
{
TxModeTag tag;
bool found;
found = ConstCast<Packet> (packet)->PeekPacketTag (tag);
NS_ASSERT (found);
return tag.GetRtsMode ();
Ptr<const TxModeTag> tag = packet->PeekPacketTag<TxModeTag> ();
NS_ASSERT (tag != 0);
return tag->GetRtsMode ();
}
return DoGetRtsMode (Lookup (address, header));
}
+6 -6
View File
@@ -163,19 +163,19 @@ benchD (uint32_t n)
{
BenchHeader<25> ipv4;
BenchHeader<8> udp;
BenchTag<16> tag1;
BenchTag<17> tag2;
for (uint32_t i = 0; i < n; i++) {
Ptr<Packet> p = Create<Packet> (2000);
p->AddPacketTag (tag1);
p->AddPacketTag (CreateObject<BenchTag<16> > ());
p->AddHeader (udp);
p->RemovePacketTag (tag1);
p->AddPacketTag (tag2);
p->RemovePacketTag (BenchTag<16>::GetTypeId ());
p->AddPacketTag (CreateObject<BenchTag<17> > ());
p->AddHeader (ipv4);
Ptr<Packet> o = p->Copy ();
o->RemoveHeader (ipv4);
p->RemovePacketTag (tag2);
p->RemovePacketTag (BenchTag<17>::GetTypeId ());
o->RemoveHeader (udp);
}
}
+9
View File
@@ -125,6 +125,7 @@ def options(opt):
opt.load('compiler_cxx')
opt.load('cflags')
opt.load('gnu_dirs')
opt.tool_options('boost', tooldir=["waf-tools"])
opt.add_option('--cwd',
help=('Set the working directory for a program.'),
@@ -364,6 +365,14 @@ def configure(conf):
conf.report_optional_feature("static", "Static build", False,
"Link flag -Wl,--whole-archive,-Bstatic does not work")
try:
conf.check_tool('boost')
conf.check_boost(lib='signals filesystem iostreams regex')
if not conf.env.LIB_BOOST:
conf.check_boost(lib='signals filesystem iostreams regex', libpath="/usr/lib64")
except WafError:
conf.env['LIB_BOOST'] = []
# Set this so that the lists won't be printed at the end of this
# configure command.
conf.env['PRINT_BUILT_MODULES_AT_END'] = False