merge with trunk again
This commit is contained in:
commit
d0fcfb2c2e
94 files changed
+5690
-14546
No files matched your search
@@ -19,16 +19,16 @@
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
#include "ns3/assert.h"
|
||||
|
||||
#include "ns3/packet.h"
|
||||
#include "ns3/simulator.h"
|
||||
|
||||
#include "arp-cache.h"
|
||||
#include "arp-header.h"
|
||||
#include "ipv4-interface.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
ArpCache::ArpCache (Ptr<NetDevice> device, Ipv4Interface *interface)
|
||||
ArpCache::ArpCache (Ptr<NetDevice> device, Ptr<Ipv4Interface> interface)
|
||||
: m_device (device),
|
||||
m_interface (interface),
|
||||
m_aliveTimeout (Seconds (120)),
|
||||
@@ -47,7 +47,7 @@ ArpCache::GetDevice (void) const
|
||||
return m_device;
|
||||
}
|
||||
|
||||
Ipv4Interface *
|
||||
Ptr<Ipv4Interface>
|
||||
ArpCache::GetInterface (void) const
|
||||
{
|
||||
return m_interface;
|
||||
|
||||
@@ -48,7 +48,7 @@ public:
|
||||
* \param device The hardware NetDevice associated with this ARP chache
|
||||
* \param interface the Ipv4Interface associated with this ARP chache
|
||||
*/
|
||||
ArpCache (Ptr<NetDevice> device, Ipv4Interface *interface);
|
||||
ArpCache (Ptr<NetDevice> device, Ptr<Ipv4Interface> interface);
|
||||
~ArpCache ();
|
||||
/**
|
||||
* \return The NetDevice that this ARP cache is associated with
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
/**
|
||||
* \return the Ipv4Interface that this ARP cache is associated with
|
||||
*/
|
||||
Ipv4Interface *GetInterface (void) const;
|
||||
Ptr<Ipv4Interface> GetInterface (void) const;
|
||||
|
||||
void SetAliveTimeout (Time aliveTimeout);
|
||||
void SetDeadTimeout (Time deadTimeout);
|
||||
@@ -152,7 +152,7 @@ private:
|
||||
typedef sgi::hash_map<Ipv4Address, ArpCache::Entry *, Ipv4AddressHash>::iterator CacheI;
|
||||
|
||||
Ptr<NetDevice> m_device;
|
||||
Ipv4Interface *m_interface;
|
||||
Ptr<Ipv4Interface> m_interface;
|
||||
Time m_aliveTimeout;
|
||||
Time m_deadTimeout;
|
||||
Time m_waitReplyTimeout;
|
||||
|
||||
@@ -47,17 +47,16 @@ ArpIpv4Interface::~ArpIpv4Interface ()
|
||||
NS_DEBUG ("ArpIpv4Interface::~ArpIpv4Interface ()");
|
||||
}
|
||||
|
||||
TraceResolver *
|
||||
ArpIpv4Interface::DoCreateTraceResolver (TraceContext const &context)
|
||||
Ptr<TraceResolver>
|
||||
ArpIpv4Interface::GetTraceResolver (void) const
|
||||
{
|
||||
NS_DEBUG ("ArpIpv4Interface::DoCreateTraceResolver ()");
|
||||
CompositeTraceResolver *resolver = new CompositeTraceResolver (context);
|
||||
Ptr<CompositeTraceResolver> resolver = Create<CompositeTraceResolver> ();
|
||||
if (GetDevice () != 0)
|
||||
{
|
||||
resolver->Add ("netdevice",
|
||||
MakeCallback (&NetDevice::CreateTraceResolver, PeekPointer (GetDevice ())));
|
||||
resolver->AddComposite ("netdevice", GetDevice ());
|
||||
}
|
||||
|
||||
resolver->SetParentResolver (Ipv4Interface::GetTraceResolver ());
|
||||
return resolver;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,9 +43,10 @@ class ArpIpv4Interface : public Ipv4Interface
|
||||
ArpIpv4Interface (Ptr<Node> node, Ptr<NetDevice> device);
|
||||
virtual ~ArpIpv4Interface ();
|
||||
|
||||
private:
|
||||
protected:
|
||||
virtual Ptr<TraceResolver> GetTraceResolver (void) const;
|
||||
private:
|
||||
virtual void SendTo (Packet p, Ipv4Address dest);
|
||||
virtual TraceResolver *DoCreateTraceResolver (TraceContext const &context);
|
||||
Ptr<Node> m_node;
|
||||
};
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
*/
|
||||
#include "ns3/packet.h"
|
||||
#include "ns3/debug.h"
|
||||
#include "ns3/empty-trace-resolver.h"
|
||||
#include "ns3/node.h"
|
||||
#include "ns3/net-device.h"
|
||||
|
||||
@@ -58,12 +57,6 @@ ArpL3Protocol::DoDispose (void)
|
||||
Object::DoDispose ();
|
||||
}
|
||||
|
||||
TraceResolver *
|
||||
ArpL3Protocol::CreateTraceResolver (TraceContext const &context)
|
||||
{
|
||||
return new EmptyTraceResolver (context);
|
||||
}
|
||||
|
||||
ArpCache *
|
||||
ArpL3Protocol::FindCache (Ptr<NetDevice> device)
|
||||
{
|
||||
@@ -75,7 +68,7 @@ ArpL3Protocol::FindCache (Ptr<NetDevice> device)
|
||||
}
|
||||
}
|
||||
Ptr<Ipv4L3Protocol> ipv4 = m_node->QueryInterface<Ipv4L3Protocol> (Ipv4L3Protocol::iid);
|
||||
Ipv4Interface *interface = ipv4->FindInterfaceForDevice (device);
|
||||
Ptr<Ipv4Interface> interface = ipv4->FindInterfaceForDevice (device);
|
||||
ArpCache * cache = new ArpCache (device, interface);
|
||||
NS_ASSERT (device->IsBroadcast ());
|
||||
device->SetLinkChangeCallback (MakeCallback (&ArpCache::Flush, cache));
|
||||
|
||||
@@ -48,8 +48,6 @@ public:
|
||||
*/
|
||||
ArpL3Protocol (Ptr<Node> node);
|
||||
virtual ~ArpL3Protocol ();
|
||||
|
||||
virtual TraceResolver *CreateTraceResolver (TraceContext const &context);
|
||||
/**
|
||||
* \brief Recieve a packet
|
||||
*/
|
||||
|
||||
@@ -21,9 +21,9 @@
|
||||
#include "ascii-trace.h"
|
||||
|
||||
#include "ns3/trace-context.h"
|
||||
#include "ns3/trace-root.h"
|
||||
#include "ns3/simulator.h"
|
||||
#include "ns3/node.h"
|
||||
#include "ns3/node-list.h"
|
||||
#include "ns3/packet.h"
|
||||
#include "ns3/queue.h"
|
||||
|
||||
@@ -41,19 +41,19 @@ void
|
||||
AsciiTrace::TraceAllQueues (void)
|
||||
{
|
||||
Packet::EnableMetadata ();
|
||||
TraceRoot::Connect ("/nodes/*/devices/*/queue/enqueue",
|
||||
NodeList::Connect ("/nodes/*/devices/*/queue/enqueue",
|
||||
MakeCallback (&AsciiTrace::LogDevQueueEnqueue, this));
|
||||
TraceRoot::Connect ("/nodes/*/devices/*/queue/dequeue",
|
||||
NodeList::Connect ("/nodes/*/devices/*/queue/dequeue",
|
||||
MakeCallback (&AsciiTrace::LogDevQueueDequeue, this));
|
||||
TraceRoot::Connect ("/nodes/*/devices/*/queue/drop",
|
||||
NodeList::Connect ("/nodes/*/devices/*/queue/drop",
|
||||
MakeCallback (&AsciiTrace::LogDevQueueDrop, this));
|
||||
}
|
||||
void
|
||||
AsciiTrace::TraceAllNetDeviceRx (void)
|
||||
{
|
||||
Packet::EnableMetadata ();
|
||||
TraceRoot::Connect ("/nodes/*/devices/*/rx",
|
||||
MakeCallback (&AsciiTrace::LogDevRx, this));
|
||||
NodeList::Connect ("/nodes/*/devices/*/rx",
|
||||
MakeCallback (&AsciiTrace::LogDevRx, this));
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -74,13 +74,14 @@ InternetNode::Construct (void)
|
||||
Object::AddInterface (ipv4L4Demux);
|
||||
}
|
||||
|
||||
void
|
||||
InternetNode::DoFillTraceResolver (CompositeTraceResolver &resolver)
|
||||
Ptr<TraceResolver>
|
||||
InternetNode::GetTraceResolver () const
|
||||
{
|
||||
Node::DoFillTraceResolver (resolver);
|
||||
Ptr<CompositeTraceResolver> resolver = Create<CompositeTraceResolver> ();
|
||||
Ptr<Ipv4L3Protocol> ipv4 = QueryInterface<Ipv4L3Protocol> (Ipv4L3Protocol::iid);
|
||||
resolver.Add ("ipv4",
|
||||
MakeCallback (&Ipv4L3Protocol::CreateTraceResolver, PeekPointer (ipv4)));
|
||||
resolver->AddComposite ("ipv4", ipv4);
|
||||
resolver->SetParentResolver (Node::GetTraceResolver ());
|
||||
return resolver;
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -42,8 +42,8 @@ public:
|
||||
|
||||
protected:
|
||||
virtual void DoDispose(void);
|
||||
virtual Ptr<TraceResolver> GetTraceResolver (void) const;
|
||||
private:
|
||||
virtual void DoFillTraceResolver (CompositeTraceResolver &resolver);
|
||||
bool ReceiveFromDevice (Ptr<NetDevice> device, const Packet &p, uint16_t protocolNumber) const;
|
||||
void Construct (void);
|
||||
};
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "ipv4-interface.h"
|
||||
#include "ns3/ipv4-address.h"
|
||||
#include "ns3/net-device.h"
|
||||
#include "ns3/trace-resolver.h"
|
||||
#include "ns3/debug.h"
|
||||
|
||||
NS_DEBUG_COMPONENT_DEFINE ("Ipv4Interface");
|
||||
@@ -46,6 +47,13 @@ Ipv4Interface::~Ipv4Interface ()
|
||||
NS_DEBUG ("Ipv4Interface::~Ipv4Interface ()");
|
||||
}
|
||||
|
||||
void
|
||||
Ipv4Interface::DoDispose (void)
|
||||
{
|
||||
m_netdevice = 0;
|
||||
Object::DoDispose ();
|
||||
}
|
||||
|
||||
Ptr<NetDevice>
|
||||
Ipv4Interface::GetDevice (void) const
|
||||
{
|
||||
@@ -53,13 +61,6 @@ Ipv4Interface::GetDevice (void) const
|
||||
return m_netdevice;
|
||||
}
|
||||
|
||||
TraceResolver *
|
||||
Ipv4Interface::CreateTraceResolver (TraceContext const &context)
|
||||
{
|
||||
NS_DEBUG ("Ipv4Interface::CreateTraceResolver (" << &context << ")");
|
||||
return DoCreateTraceResolver (context);
|
||||
}
|
||||
|
||||
void
|
||||
Ipv4Interface::SetAddress (Ipv4Address a)
|
||||
{
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <list>
|
||||
#include "ns3/ipv4-address.h"
|
||||
#include "ns3/ptr.h"
|
||||
#include "ns3/object.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
@@ -60,9 +61,8 @@ class TraceContext;
|
||||
*
|
||||
* Subclasses must implement the two methods:
|
||||
* - Ipv4Interface::SendTo
|
||||
* - Ipv4Interface::DoCreateTraceResolver
|
||||
*/
|
||||
class Ipv4Interface
|
||||
class Ipv4Interface : public Object
|
||||
{
|
||||
public:
|
||||
/**
|
||||
@@ -73,17 +73,6 @@ public:
|
||||
Ipv4Interface (Ptr<NetDevice> nd);
|
||||
virtual ~Ipv4Interface();
|
||||
|
||||
/**
|
||||
* \param context the trace context to use to construct the
|
||||
* TraceResolver to return
|
||||
* \returns a TraceResolver which can resolve all traces
|
||||
* performed in this object. The caller must
|
||||
* delete the returned object.
|
||||
*
|
||||
* This method will delegate the work to the private DoCreateTraceResolver
|
||||
* method which is supposed to be implemented by subclasses.
|
||||
*/
|
||||
TraceResolver *CreateTraceResolver (TraceContext const &context);
|
||||
/**
|
||||
* \returns the underlying NetDevice. This method can return
|
||||
* zero if this interface has no associated NetDevice.
|
||||
@@ -150,10 +139,10 @@ public:
|
||||
*/
|
||||
void Send(Packet p, Ipv4Address dest);
|
||||
|
||||
|
||||
private:
|
||||
protected:
|
||||
virtual void DoDispose (void);
|
||||
private:
|
||||
virtual void SendTo (Packet p, Ipv4Address dest) = 0;
|
||||
virtual TraceResolver *DoCreateTraceResolver (TraceContext const &context) = 0;
|
||||
Ptr<NetDevice> m_netdevice;
|
||||
bool m_ifup;
|
||||
Ipv4Address m_address;
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#include "ns3/packet.h"
|
||||
#include "ns3/debug.h"
|
||||
#include "ns3/composite-trace-resolver.h"
|
||||
#include "ns3/array-trace-resolver.h"
|
||||
#include "ns3/callback.h"
|
||||
#include "ns3/ipv4-address.h"
|
||||
#include "ns3/ipv4-route.h"
|
||||
@@ -88,30 +87,40 @@ Ipv4L3ProtocolTraceContextElement::GetUid (void)
|
||||
static uint16_t uid = AllocateUid<Ipv4L3ProtocolTraceContextElement> ("Ipv4L3ProtocolTraceContextElement");
|
||||
return uid;
|
||||
}
|
||||
std::string
|
||||
Ipv4L3ProtocolTraceContextElement::GetTypeName (void) const
|
||||
{
|
||||
return "ns3::Ipv4L3ProtocolTraceContextElement";
|
||||
}
|
||||
|
||||
|
||||
Ipv4l3ProtocolInterfaceIndex::Ipv4l3ProtocolInterfaceIndex ()
|
||||
Ipv4L3ProtocolInterfaceIndex::Ipv4L3ProtocolInterfaceIndex ()
|
||||
: m_index (0)
|
||||
{}
|
||||
Ipv4l3ProtocolInterfaceIndex::Ipv4l3ProtocolInterfaceIndex (uint32_t index)
|
||||
Ipv4L3ProtocolInterfaceIndex::Ipv4L3ProtocolInterfaceIndex (uint32_t index)
|
||||
: m_index (index)
|
||||
{}
|
||||
uint32_t
|
||||
Ipv4l3ProtocolInterfaceIndex::Get (void) const
|
||||
Ipv4L3ProtocolInterfaceIndex::Get (void) const
|
||||
{
|
||||
return m_index;
|
||||
}
|
||||
void
|
||||
Ipv4l3ProtocolInterfaceIndex::Print (std::ostream &os) const
|
||||
Ipv4L3ProtocolInterfaceIndex::Print (std::ostream &os) const
|
||||
{
|
||||
os << "ipv4-interface=" << m_index;
|
||||
}
|
||||
uint16_t
|
||||
Ipv4l3ProtocolInterfaceIndex::GetUid (void)
|
||||
Ipv4L3ProtocolInterfaceIndex::GetUid (void)
|
||||
{
|
||||
static uint16_t uid = AllocateUid<Ipv4l3ProtocolInterfaceIndex> ("Ipv4l3ProtocolInterfaceIndex");
|
||||
static uint16_t uid = AllocateUid<Ipv4L3ProtocolInterfaceIndex> ("Ipv4L3ProtocolInterfaceIndex");
|
||||
return uid;
|
||||
}
|
||||
std::string
|
||||
Ipv4L3ProtocolInterfaceIndex::GetTypeName (void) const
|
||||
{
|
||||
return "ns3::Ipv4L3ProtocolInterfaceIndex";
|
||||
}
|
||||
|
||||
|
||||
Ipv4L3Protocol::Ipv4L3Protocol(Ptr<Node> node)
|
||||
@@ -138,11 +147,6 @@ Ipv4L3Protocol::DoDispose (void)
|
||||
{
|
||||
NS_DEBUG("Ipv4L3Protocol::DoDispose ()");
|
||||
|
||||
for (Ipv4InterfaceList::iterator i = m_interfaces.begin ();
|
||||
i != m_interfaces.end (); i++)
|
||||
{
|
||||
delete (*i);
|
||||
}
|
||||
m_interfaces.clear ();
|
||||
m_node = 0;
|
||||
m_staticRouting->Dispose ();
|
||||
@@ -155,7 +159,7 @@ Ipv4L3Protocol::SetupLoopback (void)
|
||||
{
|
||||
NS_DEBUG("Ipv4L3Protocol::SetupLoopback ()");
|
||||
|
||||
Ipv4LoopbackInterface * interface = new Ipv4LoopbackInterface (m_node);
|
||||
Ptr<Ipv4LoopbackInterface> interface = Create<Ipv4LoopbackInterface> (m_node);
|
||||
interface->SetAddress (Ipv4Address::GetLoopback ());
|
||||
interface->SetNetworkMask (Ipv4Mask::GetLoopback ());
|
||||
uint32_t index = AddIpv4Interface (interface);
|
||||
@@ -163,30 +167,29 @@ Ipv4L3Protocol::SetupLoopback (void)
|
||||
interface->SetUp ();
|
||||
}
|
||||
|
||||
TraceResolver *
|
||||
Ipv4L3Protocol::CreateTraceResolver (TraceContext const &context)
|
||||
Ptr<TraceResolver>
|
||||
Ipv4L3Protocol::GetTraceResolver (void) const
|
||||
{
|
||||
NS_DEBUG("Ipv4L3Protocol::CreateTraceResolver ()");
|
||||
NS_DEBUG("Ipv4L3Protocol::GetTraceResolver ()");
|
||||
|
||||
CompositeTraceResolver *resolver = new CompositeTraceResolver (context);
|
||||
resolver->Add ("tx", m_txTrace, Ipv4L3ProtocolTraceContextElement(Ipv4L3ProtocolTraceContextElement::TX));
|
||||
resolver->Add ("rx", m_rxTrace, Ipv4L3ProtocolTraceContextElement(Ipv4L3ProtocolTraceContextElement::RX));
|
||||
resolver->Add ("drop", m_dropTrace, Ipv4L3ProtocolTraceContextElement (Ipv4L3ProtocolTraceContextElement::DROP));
|
||||
resolver->Add ("interfaces",
|
||||
MakeCallback (&Ipv4L3Protocol::InterfacesCreateTraceResolver, this));
|
||||
return resolver;
|
||||
}
|
||||
|
||||
TraceResolver *
|
||||
Ipv4L3Protocol::InterfacesCreateTraceResolver (TraceContext const &context) const
|
||||
{
|
||||
NS_DEBUG("Ipv4L3Protocol::InterfacesCreateTraceResolver ()");
|
||||
|
||||
ArrayTraceResolver<Ipv4Interface *, Ipv4l3ProtocolInterfaceIndex> *resolver =
|
||||
new ArrayTraceResolver<Ipv4Interface *,Ipv4l3ProtocolInterfaceIndex>
|
||||
(context,
|
||||
MakeCallback (&Ipv4L3Protocol::GetNInterfaces, this),
|
||||
MakeCallback (&Ipv4L3Protocol::GetInterface, this));
|
||||
Ptr<CompositeTraceResolver> resolver = Create<CompositeTraceResolver> ();
|
||||
resolver->AddSource ("tx",
|
||||
TraceDoc ("send ipv4 packet to outgoing interface",
|
||||
"const Packet &", "packet sent",
|
||||
"uint32_t", "index of output ipv4 interface"),
|
||||
m_txTrace, Ipv4L3ProtocolTraceContextElement(Ipv4L3ProtocolTraceContextElement::TX));
|
||||
resolver->AddSource ("rx",
|
||||
TraceDoc ("receive ipv4 packet from incoming interface",
|
||||
"const Packet &", "packet received",
|
||||
"uint32_t", "index of input ipv4 interface"),
|
||||
m_rxTrace, Ipv4L3ProtocolTraceContextElement(Ipv4L3ProtocolTraceContextElement::RX));
|
||||
resolver->AddSource ("drop",
|
||||
TraceDoc ("drop ipv4 packet",
|
||||
"const Packet &", "packet dropped"),
|
||||
m_dropTrace, Ipv4L3ProtocolTraceContextElement (Ipv4L3ProtocolTraceContextElement::DROP));
|
||||
resolver->AddArray ("interfaces",
|
||||
m_interfaces.begin (), m_interfaces.end (),
|
||||
Ipv4L3ProtocolInterfaceIndex ());
|
||||
return resolver;
|
||||
}
|
||||
|
||||
@@ -399,12 +402,12 @@ uint32_t
|
||||
Ipv4L3Protocol::AddInterface (Ptr<NetDevice> device)
|
||||
{
|
||||
NS_DEBUG("Ipv4L3Protocol::AddInterface (" << &device << ")");
|
||||
Ipv4Interface *interface = new ArpIpv4Interface (m_node, device);
|
||||
Ptr<Ipv4Interface> interface = Create<ArpIpv4Interface> (m_node, device);
|
||||
return AddIpv4Interface (interface);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
Ipv4L3Protocol::AddIpv4Interface (Ipv4Interface *interface)
|
||||
Ipv4L3Protocol::AddIpv4Interface (Ptr<Ipv4Interface>interface)
|
||||
{
|
||||
NS_DEBUG("Ipv4L3Protocol::AddIpv4Interface (" << interface << ")");
|
||||
uint32_t index = m_nInterfaces;
|
||||
@@ -413,7 +416,7 @@ Ipv4L3Protocol::AddIpv4Interface (Ipv4Interface *interface)
|
||||
return index;
|
||||
}
|
||||
|
||||
Ipv4Interface *
|
||||
Ptr<Ipv4Interface>
|
||||
Ipv4L3Protocol::GetInterface (uint32_t index) const
|
||||
{
|
||||
NS_DEBUG("Ipv4L3Protocol::GetInterface (" << index << ")");
|
||||
@@ -479,7 +482,7 @@ Ipv4L3Protocol::FindInterfaceForAddr (Ipv4Address addr, Ipv4Mask mask) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
Ipv4Interface *
|
||||
Ptr<Ipv4Interface>
|
||||
Ipv4L3Protocol::FindInterfaceForDevice (Ptr<const NetDevice> device)
|
||||
{
|
||||
NS_DEBUG("Ipv4L3Protocol::FindInterfaceForDevice (" << &device << ")");
|
||||
@@ -558,7 +561,7 @@ Ipv4L3Protocol::Send (Packet const &packet,
|
||||
for (Ipv4InterfaceList::iterator ifaceIter = m_interfaces.begin ();
|
||||
ifaceIter != m_interfaces.end (); ifaceIter++, ifaceIndex++)
|
||||
{
|
||||
Ipv4Interface *outInterface = *ifaceIter;
|
||||
Ptr<Ipv4Interface> outInterface = *ifaceIter;
|
||||
Packet packetCopy = packet;
|
||||
|
||||
NS_ASSERT (packetCopy.GetSize () <= outInterface->GetMtu ());
|
||||
@@ -602,7 +605,7 @@ Ipv4L3Protocol::SendRealOut (bool found,
|
||||
route.GetInterface ());
|
||||
|
||||
packet.AddHeader (ipHeader);
|
||||
Ipv4Interface *outInterface = GetInterface (route.GetInterface ());
|
||||
Ptr<Ipv4Interface> outInterface = GetInterface (route.GetInterface ());
|
||||
NS_ASSERT (packet.GetSize () <= outInterface->GetMtu ());
|
||||
m_txTrace (packet, route.GetInterface ());
|
||||
if (route.IsGateway ())
|
||||
@@ -643,7 +646,7 @@ Ipv4L3Protocol::Forwarding (
|
||||
for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin ();
|
||||
i != m_interfaces.end (); i++)
|
||||
{
|
||||
Ipv4Interface *interface = *i;
|
||||
Ptr<Ipv4Interface> interface = *i;
|
||||
if (interface->GetDevice () == device)
|
||||
{
|
||||
if (ipHeader.GetDestination ().IsEqual (interface->GetBroadcast ()))
|
||||
@@ -745,7 +748,7 @@ void
|
||||
Ipv4L3Protocol::SetAddress (uint32_t i, Ipv4Address address)
|
||||
{
|
||||
NS_DEBUG("Ipv4L3Protocol::SetAddress (" << i << ", " << address << ")");
|
||||
Ipv4Interface *interface = GetInterface (i);
|
||||
Ptr<Ipv4Interface> interface = GetInterface (i);
|
||||
interface->SetAddress (address);
|
||||
}
|
||||
|
||||
@@ -753,7 +756,7 @@ void
|
||||
Ipv4L3Protocol::SetNetworkMask (uint32_t i, Ipv4Mask mask)
|
||||
{
|
||||
NS_DEBUG("Ipv4L3Protocol::SetNetworkMask (" << i << ", " << mask << ")");
|
||||
Ipv4Interface *interface = GetInterface (i);
|
||||
Ptr<Ipv4Interface> interface = GetInterface (i);
|
||||
interface->SetNetworkMask (mask);
|
||||
}
|
||||
|
||||
@@ -761,7 +764,7 @@ Ipv4Mask
|
||||
Ipv4L3Protocol::GetNetworkMask (uint32_t i) const
|
||||
{
|
||||
NS_DEBUG("Ipv4L3Protocol::GetNetworkMask (" << i << ")");
|
||||
Ipv4Interface *interface = GetInterface (i);
|
||||
Ptr<Ipv4Interface> interface = GetInterface (i);
|
||||
return interface->GetNetworkMask ();
|
||||
}
|
||||
|
||||
@@ -769,7 +772,7 @@ Ipv4Address
|
||||
Ipv4L3Protocol::GetAddress (uint32_t i) const
|
||||
{
|
||||
NS_DEBUG("Ipv4L3Protocol::GetAddress (" << i << ")");
|
||||
Ipv4Interface *interface = GetInterface (i);
|
||||
Ptr<Ipv4Interface> interface = GetInterface (i);
|
||||
return interface->GetAddress ();
|
||||
}
|
||||
|
||||
@@ -849,7 +852,7 @@ uint16_t
|
||||
Ipv4L3Protocol::GetMtu (uint32_t i) const
|
||||
{
|
||||
NS_DEBUG("Ipv4L3Protocol::GetMtu (" << i << ")");
|
||||
Ipv4Interface *interface = GetInterface (i);
|
||||
Ptr<Ipv4Interface> interface = GetInterface (i);
|
||||
return interface->GetMtu ();
|
||||
}
|
||||
|
||||
@@ -857,7 +860,7 @@ bool
|
||||
Ipv4L3Protocol::IsUp (uint32_t i) const
|
||||
{
|
||||
NS_DEBUG("Ipv4L3Protocol::IsUp (" << i << ")");
|
||||
Ipv4Interface *interface = GetInterface (i);
|
||||
Ptr<Ipv4Interface> interface = GetInterface (i);
|
||||
return interface->IsUp ();
|
||||
}
|
||||
|
||||
@@ -865,7 +868,7 @@ void
|
||||
Ipv4L3Protocol::SetUp (uint32_t i)
|
||||
{
|
||||
NS_DEBUG("Ipv4L3Protocol::SetUp (" << i << ")");
|
||||
Ipv4Interface *interface = GetInterface (i);
|
||||
Ptr<Ipv4Interface> interface = GetInterface (i);
|
||||
interface->SetUp ();
|
||||
|
||||
// If interface address and network mask have been set, add a route
|
||||
@@ -883,7 +886,7 @@ void
|
||||
Ipv4L3Protocol::SetDown (uint32_t ifaceIndex)
|
||||
{
|
||||
NS_DEBUG("Ipv4L3Protocol::SetDown (" << ifaceIndex << ")");
|
||||
Ipv4Interface *interface = GetInterface (ifaceIndex);
|
||||
Ptr<Ipv4Interface> interface = GetInterface (ifaceIndex);
|
||||
interface->SetDown ();
|
||||
|
||||
// Remove all routes that are going through this interface
|
||||
|
||||
@@ -44,6 +44,9 @@ class Node;
|
||||
class TraceResolver;
|
||||
class TraceContext;
|
||||
|
||||
/**
|
||||
* \brief hold in a TraceContext the type of trace source used by this Ipv4L3Protocol
|
||||
*/
|
||||
class Ipv4L3ProtocolTraceContextElement : public TraceContextElement
|
||||
{
|
||||
public:
|
||||
@@ -54,23 +57,40 @@ public:
|
||||
};
|
||||
Ipv4L3ProtocolTraceContextElement ();
|
||||
Ipv4L3ProtocolTraceContextElement (enum Type type);
|
||||
/**
|
||||
* \returns true if this is a tx event, false otherwise.
|
||||
*/
|
||||
bool IsTx (void) const;
|
||||
/**
|
||||
* \returns true if this is a rx event, false otherwise.
|
||||
*/
|
||||
bool IsRx (void) const;
|
||||
/**
|
||||
* \returns true if this is a drop event, false otherwise.
|
||||
*/
|
||||
bool IsDrop (void) const;
|
||||
void Print (std::ostream &os) const;
|
||||
static uint16_t GetUid (void);
|
||||
std::string GetTypeName (void) const;
|
||||
private:
|
||||
enum Type m_type;
|
||||
};
|
||||
|
||||
class Ipv4l3ProtocolInterfaceIndex : public TraceContextElement
|
||||
/**
|
||||
* \brief hold in a TraceContext the index of an Ipv4Interface within the ipv4 stack of a Node
|
||||
*/
|
||||
class Ipv4L3ProtocolInterfaceIndex : public TraceContextElement
|
||||
{
|
||||
public:
|
||||
Ipv4l3ProtocolInterfaceIndex ();
|
||||
Ipv4l3ProtocolInterfaceIndex (uint32_t index);
|
||||
Ipv4L3ProtocolInterfaceIndex ();
|
||||
Ipv4L3ProtocolInterfaceIndex (uint32_t index);
|
||||
/**
|
||||
* \returns the index of the Ipv4Interface within a Node.
|
||||
*/
|
||||
uint32_t Get (void) const;
|
||||
void Print (std::ostream &os) const;
|
||||
static uint16_t GetUid (void);
|
||||
std::string GetTypeName (void) const;
|
||||
private:
|
||||
uint32_t m_index;
|
||||
};
|
||||
@@ -85,15 +105,6 @@ public:
|
||||
Ipv4L3Protocol(Ptr<Node> node);
|
||||
virtual ~Ipv4L3Protocol ();
|
||||
|
||||
/**
|
||||
* \param context the trace context to use to construct the
|
||||
* TraceResolver to return
|
||||
* \returns a TraceResolver which can resolve all traces
|
||||
* performed in this object. The caller must
|
||||
* delete the returned object.
|
||||
*/
|
||||
virtual TraceResolver *CreateTraceResolver (TraceContext const &context);
|
||||
|
||||
/**
|
||||
* \param ttl default ttl to use
|
||||
*
|
||||
@@ -109,7 +120,7 @@ public:
|
||||
* Try to find an Ipv4Interface whose NetDevice is equal to
|
||||
* the input NetDevice.
|
||||
*/
|
||||
Ipv4Interface *FindInterfaceForDevice (Ptr<const NetDevice> device);
|
||||
Ptr<Ipv4Interface> FindInterfaceForDevice (Ptr<const NetDevice> device);
|
||||
|
||||
/**
|
||||
* Lower layer calls this method after calling L3Demux::Lookup
|
||||
@@ -174,7 +185,7 @@ public:
|
||||
void RemoveMulticastRoute (uint32_t i);
|
||||
|
||||
uint32_t AddInterface (Ptr<NetDevice> device);
|
||||
Ipv4Interface * GetInterface (uint32_t i) const;
|
||||
Ptr<Ipv4Interface> GetInterface (uint32_t i) const;
|
||||
uint32_t GetNInterfaces (void) const;
|
||||
|
||||
uint32_t FindInterfaceForAddr (Ipv4Address addr) const;
|
||||
@@ -200,6 +211,7 @@ public:
|
||||
protected:
|
||||
|
||||
virtual void DoDispose (void);
|
||||
virtual Ptr<TraceResolver> GetTraceResolver (void) const;
|
||||
|
||||
private:
|
||||
void Lookup (uint32_t ifIndex,
|
||||
@@ -216,15 +228,13 @@ private:
|
||||
Ipv4Header &ipHeader,
|
||||
Ptr<NetDevice> device);
|
||||
void ForwardUp (Packet p, Ipv4Header const&ip);
|
||||
uint32_t AddIpv4Interface (Ipv4Interface *interface);
|
||||
uint32_t AddIpv4Interface (Ptr<Ipv4Interface> interface);
|
||||
void SetupLoopback (void);
|
||||
TraceResolver *InterfacesCreateTraceResolver (TraceContext const &context) const;
|
||||
|
||||
typedef std::list<Ipv4Interface*> Ipv4InterfaceList;
|
||||
typedef std::list<Ptr<Ipv4Interface> > Ipv4InterfaceList;
|
||||
typedef std::list<std::pair<Ipv4Address, Ipv4Address> >
|
||||
Ipv4MulticastGroupList;
|
||||
typedef std::list<std::pair< int, Ptr<Ipv4RoutingProtocol> > >
|
||||
Ipv4RoutingProtocolList;
|
||||
typedef std::list< std::pair< int, Ptr<Ipv4RoutingProtocol> > > Ipv4RoutingProtocolList;
|
||||
|
||||
Ipv4InterfaceList m_interfaces;
|
||||
uint32_t m_nInterfaces;
|
||||
|
||||
@@ -54,6 +54,11 @@ Ipv4L4ProtocolTraceContextElement::GetUid (void)
|
||||
static uint16_t uid = AllocateUid<Ipv4L4ProtocolTraceContextElement> ("Ipv4L4ProtocolTraceContextElement");
|
||||
return uid;
|
||||
}
|
||||
std::string
|
||||
Ipv4L4ProtocolTraceContextElement::GetTypeName (void) const
|
||||
{
|
||||
return "ns3::Ipv4L4ProtocolTraceContextElement";
|
||||
}
|
||||
|
||||
|
||||
Ipv4L4Demux::Ipv4L4Demux (Ptr<Node> node)
|
||||
@@ -78,21 +83,19 @@ Ipv4L4Demux::DoDispose (void)
|
||||
Object::DoDispose ();
|
||||
}
|
||||
|
||||
TraceResolver *
|
||||
Ipv4L4Demux::CreateTraceResolver (TraceContext const &context)
|
||||
Ptr<TraceResolver>
|
||||
Ipv4L4Demux::GetTraceResolver (void) const
|
||||
{
|
||||
CompositeTraceResolver *resolver = new CompositeTraceResolver (context);
|
||||
Ptr<CompositeTraceResolver> resolver = Create<CompositeTraceResolver> ();
|
||||
for (L4List_t::const_iterator i = m_protocols.begin(); i != m_protocols.end(); ++i)
|
||||
{
|
||||
Ptr<Ipv4L4Protocol> protocol = *i;
|
||||
std::string protValue;
|
||||
std::ostringstream oss (protValue);
|
||||
oss << (*i)->GetProtocolNumber ();
|
||||
std::ostringstream oss;
|
||||
oss << (unsigned int) (*i)->GetProtocolNumber ();
|
||||
Ipv4L4ProtocolTraceContextElement protocolNumber = (*i)->GetProtocolNumber ();
|
||||
resolver->Add (protValue,
|
||||
MakeCallback (&Ipv4L4Protocol::CreateTraceResolver, PeekPointer (protocol)),
|
||||
protocolNumber);
|
||||
resolver->AddComposite (oss.str (), protocol, protocolNumber);
|
||||
}
|
||||
resolver->SetParentResolver (Object::GetTraceResolver ());
|
||||
return resolver;
|
||||
}
|
||||
void
|
||||
|
||||
@@ -37,14 +37,21 @@ class Node;
|
||||
class TraceResolver;
|
||||
class TraceContext;
|
||||
|
||||
/**
|
||||
* \brief hold in a TraceContext the protocol number of a L4 Protocol
|
||||
*/
|
||||
class Ipv4L4ProtocolTraceContextElement : public TraceContextElement
|
||||
{
|
||||
public:
|
||||
Ipv4L4ProtocolTraceContextElement ();
|
||||
Ipv4L4ProtocolTraceContextElement (int protocolNumber);
|
||||
/**
|
||||
* \returns the protocol number as registered in the Ipv4L4Demux.
|
||||
*/
|
||||
int Get (void) const;
|
||||
void Print (std::ostream &os) const;
|
||||
static uint16_t GetUid (void);
|
||||
std::string GetTypeName (void) const;
|
||||
private:
|
||||
int m_protocolNumber;
|
||||
};
|
||||
@@ -59,14 +66,6 @@ public:
|
||||
Ipv4L4Demux (Ptr<Node> node);
|
||||
virtual ~Ipv4L4Demux();
|
||||
|
||||
/**
|
||||
* \param context the trace context to use to construct the
|
||||
* TraceResolver to return
|
||||
* \returns a TraceResolver which can resolve all traces
|
||||
* performed in this object. The caller must
|
||||
* delete the returned object.
|
||||
*/
|
||||
TraceResolver *CreateTraceResolver (TraceContext const &context);
|
||||
/**
|
||||
* \param protocol a template for the protocol to add to this L4 Demux.
|
||||
* \returns the L4Protocol effectively added.
|
||||
@@ -95,8 +94,10 @@ public:
|
||||
* returned from the Ipv4L4Protocol::Insert method.
|
||||
*/
|
||||
void Remove (Ptr<Ipv4L4Protocol> protocol);
|
||||
private:
|
||||
protected:
|
||||
Ptr<TraceResolver> GetTraceResolver (void) const;
|
||||
virtual void DoDispose (void);
|
||||
private:
|
||||
typedef std::list<Ptr<Ipv4L4Protocol> > L4List_t;
|
||||
L4List_t m_protocols;
|
||||
Ptr<Node> m_node;
|
||||
|
||||
@@ -37,10 +37,6 @@ class TraceContext;
|
||||
/**
|
||||
* \brief L4 Protocol base class
|
||||
*
|
||||
* All subclasses must implement:
|
||||
* - Ipv4L4Protocol::Copy
|
||||
* - Ipv4L4Protocol::CreateTraceResolver
|
||||
*
|
||||
* If you want to implement a new L4 protocol, all you have to do is
|
||||
* implement a subclass of this base class and add it to an L4Demux.
|
||||
*/
|
||||
@@ -59,8 +55,6 @@ public:
|
||||
*/
|
||||
int GetVersion() const;
|
||||
|
||||
virtual TraceResolver *CreateTraceResolver (TraceContext const &context) = 0;
|
||||
|
||||
/**
|
||||
* \param p packet to forward up
|
||||
* \param source source address of packet received
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
*/
|
||||
|
||||
#include "ns3/debug.h"
|
||||
#include "ns3/empty-trace-resolver.h"
|
||||
#include "ns3/net-device.h"
|
||||
#include "ns3/node.h"
|
||||
#include "ns3/eui48-address.h"
|
||||
@@ -44,13 +43,6 @@ Ipv4LoopbackInterface::~Ipv4LoopbackInterface ()
|
||||
NS_DEBUG("Ipv4LoopbackInterface::~Ipv4LoopbackInterface ()");
|
||||
}
|
||||
|
||||
TraceResolver *
|
||||
Ipv4LoopbackInterface::DoCreateTraceResolver (TraceContext const &context)
|
||||
{
|
||||
NS_DEBUG("Ipv4LoopbackInterface::DoCreateTraceResolver ()");
|
||||
return new EmptyTraceResolver (context);
|
||||
}
|
||||
|
||||
void
|
||||
Ipv4LoopbackInterface::SendTo (Packet packet, Ipv4Address dest)
|
||||
{
|
||||
|
||||
@@ -43,7 +43,6 @@ class Ipv4LoopbackInterface : public Ipv4Interface
|
||||
|
||||
private:
|
||||
virtual void SendTo (Packet p, Ipv4Address dest);
|
||||
virtual TraceResolver *DoCreateTraceResolver (TraceContext const &context);
|
||||
|
||||
Ptr<Node> m_node;
|
||||
};
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "ns3/trace-root.h"
|
||||
#include "ns3/node-list.h"
|
||||
#include "ns3/trace-context.h"
|
||||
#include "ns3/callback.h"
|
||||
#include "ns3/pcap-writer.h"
|
||||
@@ -50,8 +50,8 @@ PcapTrace::~PcapTrace ()
|
||||
void
|
||||
PcapTrace::TraceAllIp (void)
|
||||
{
|
||||
TraceRoot::Connect ("/nodes/*/ipv4/(tx|rx)",
|
||||
MakeCallback (&PcapTrace::LogIp, this));
|
||||
NodeList::Connect ("/nodes/*/ipv4/(tx|rx)",
|
||||
MakeCallback (&PcapTrace::LogIp, this));
|
||||
}
|
||||
|
||||
PcapWriter *
|
||||
@@ -83,7 +83,7 @@ void
|
||||
PcapTrace::LogIp (TraceContext const &context, Packet const &p, uint32_t interfaceIndex)
|
||||
{
|
||||
NodeListIndex nodeIndex;
|
||||
context.Get (nodeIndex);
|
||||
context.GetElement (nodeIndex);
|
||||
PcapWriter *writer = GetStream (nodeIndex.Get (), interfaceIndex);
|
||||
writer->WritePacket (p);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#include "ns3/debug.h"
|
||||
#include "ns3/assert.h"
|
||||
#include "ns3/packet.h"
|
||||
#include "ns3/empty-trace-resolver.h"
|
||||
#include "ns3/node.h"
|
||||
|
||||
#include "udp-l4-protocol.h"
|
||||
@@ -52,13 +51,6 @@ UdpL4Protocol::~UdpL4Protocol ()
|
||||
NS_DEBUG("UdpL4Protocol::~UdpL4Protocol ()");
|
||||
}
|
||||
|
||||
TraceResolver *
|
||||
UdpL4Protocol::CreateTraceResolver (TraceContext const &context)
|
||||
{
|
||||
NS_DEBUG("UdpL4Protocol::CreateTraceResolver ()");
|
||||
return new EmptyTraceResolver (context);
|
||||
}
|
||||
|
||||
void
|
||||
UdpL4Protocol::DoDispose (void)
|
||||
{
|
||||
|
||||
@@ -49,7 +49,6 @@ public:
|
||||
UdpL4Protocol (Ptr<Node> node);
|
||||
virtual ~UdpL4Protocol ();
|
||||
|
||||
virtual TraceResolver *CreateTraceResolver (TraceContext const &context);
|
||||
/**
|
||||
* \return A smart Socket pointer to a UdpSocket, allocated by this instance
|
||||
* of the UDP protocol
|
||||
|
||||
Reference in new issue
Block a user