clean up internet stack helper tracing

This commit is contained in:
Craig Dowell
2010-01-25 14:25:08 -08:00
parent a58a79f06e
commit 1d072582fa
3 changed files with 120 additions and 260 deletions

View File

@@ -162,22 +162,39 @@
#include "ns3/callback.h"
#include "ns3/node.h"
#include "ns3/core-config.h"
#include "ns3/pcap-writer.h"
#include "ns3/ascii-writer.h"
#include "ns3/arp-l3-protocol.h"
#include "internet-stack-helper.h"
#include "ipv4-list-routing-helper.h"
#include "ipv4-static-routing-helper.h"
#include "ipv4-global-routing-helper.h"
#include "ipv6-list-routing-helper.h"
#include "ipv6-static-routing-helper.h"
#include "pcap-helper.h"
#include "ascii-trace-helper.h"
#include <limits>
#include <map>
NS_LOG_COMPONENT_DEFINE ("InternetStackHelper");
namespace ns3 {
#if 0
std::vector<InternetStackHelper::Trace> InternetStackHelper::m_traces;
std::string InternetStackHelper::m_pcapBaseFilename;
#endif
//
// Things are going to work differently here with respect to trace file handling
// than in most places because the Tx and Rx trace sources we are interested in
// are going to multiplex receive and transmit callbacks for all Ipv4 and
// interface pairs through one callback. We want packets to or from each
// distinct pair to go to an individual file, so we have got to demultiplex the
// Ipv4 and interface pair into a corresponding Ptr<PcapFileObject> at the
// callback.
//
// This has got to continue to work properly after the helper has been
// destroyed; but must be cleaned up at the end of time to avoid leaks. A
// global map of interface pairs to pcap file objects seems to fit the bill.
//
typedef std::pair<Ptr<Ipv4>, uint32_t> InterfacePair;
typedef std::map<InterfacePair, Ptr<PcapFileObject> > InterfaceFileMap;
static InterfaceFileMap g_interfaceFileMap;
InternetStackHelper::InternetStackHelper ()
: m_routing (0),
@@ -269,23 +286,6 @@ void InternetStackHelper::SetIpv6StackInstall (bool enable)
m_ipv6Enabled = enable;
}
void
InternetStackHelper::Cleanup (void)
{
#if 0
uint32_t illegal = std::numeric_limits<uint32_t>::max ();
for (std::vector<Trace>::iterator i = m_traces.begin ();
i != m_traces.end (); i++)
{
i->nodeId = illegal;
i->interfaceId = illegal;
i->writer = 0;
}
m_traces.clear ();
#endif
}
void
InternetStackHelper::SetTcp (const std::string tid)
{
@@ -378,100 +378,77 @@ InternetStackHelper::Install (std::string nodeName) const
Install (node);
}
static void
Ipv4L3ProtocolRxTxSink (Ptr<const Packet> p, Ptr<Ipv4> ipv4, uint32_t interface)
{
NS_LOG_FUNCTION (p << ipv4 << interface);
InterfacePair pair = std::make_pair (ipv4, interface);
if (g_interfaceFileMap.find (pair) == g_interfaceFileMap.end ())
{
NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
return;
}
Ptr<PcapFileObject> file = g_interfaceFileMap[pair];
file->Write(Simulator::Now(), p);
}
void
InternetStackHelper::EnablePcapInternal (std::string prefix, Ptr<Ipv4> ipv4, uint32_t interface)
{
#if 0
//
// We would normally create the pcap file here, but we need to create a file
// for each interface. This is because when the trace sink for Rx and Tx are
// called, we get the packet and an interface ID. We want to group packets
// to/from a given interface id into a pcap file, but we have no knowledge
// here about what interfaces are created. So we have to go with the flow.
// Look for the file creation to happen in the
//
PcapHelper pcapHelper;
std::string filename = pcapHelper.GetFilenameFromNode (prefix, node);
Ptr<PcapFileObject> file = pcapHelper.CreateFile (filename, "w", PcapHelper::DLT_RAW);
NS_LOG_FUNCTION (prefix << ipv4 << interface);
PcapHelper pcapHelper;
std::string filename = pcapHelper.GetFilenameFromInterfacePair (prefix, ipv4, interface);
Ptr<PcapFileObject> file = pcapHelper.CreateFile (filename, "w", PcapHelper::DLT_RAW);
g_interfaceFileMap[std::make_pair (ipv4, interface)] = file;
//
// We want to enable Tx and Rx traces on Ipv4L3Protocol if m_ipv4Enabled; and
// we want to enable Tx and Rx traces on Ipv6L3Protocol if m_ipv6Enabled. The
// simple way to do that is to let Config::Connect wander through the global
// node list looking for <node> and then the appropriate protocols and trace
// sources. Since we have the node handy, we can be quicker about it, but it
// takes slightly more work here.
//
if (m_ipv4Enabled)
{
Ptr<Ipv4L3Protocol> ipv4L3Protocol = node->GetObject<Ipv4L3Protocol> ();
//
// Ptr<Ipv4> is aggregated to node and Ipv4L3Protocol is aggregated to
// node so we can get to Ipv4L3Protocol through Ipv4.
//
Ptr<Ipv4L3Protocol> ipv4L3Protocol = ipv4->GetObject<Ipv4L3Protocol> ();
NS_ASSERT_MSG (ipv4L3Protocol, "InternetStackHelper::EnablePcapInternal(): "
"m_ipv4Enabled and ipv4L3Protocol inconsistent");
bool result = ipv4L3Protocol->TraceConnectWithoutContext ("Tx", MakeBoundCallback (&DefaultSink, file));
bool result = ipv4L3Protocol->TraceConnectWithoutContext ("Tx", MakeCallback (&Ipv4L3ProtocolRxTxSink));
NS_ASSERT_MSG (result == true, "InternetStackHelper::EnablePcapInternal(): Unable to connect ipv4L3Protocol \"Tx\"");
result = ipv4L3Protocol->TraceConnectWithoutContext ("Rx", MakeBoundCallback (&DefaultSink, file));
result = ipv4L3Protocol->TraceConnectWithoutContext ("Rx", MakeCallback (&Ipv4L3ProtocolRxTxSink));
NS_ASSERT_MSG (result == true, "InternetStackHelper::EnablePcapInternal(): Unable to connect ipv4L3Protocol \"Rx\"");
}
if (m_ipv6Enabled)
{
Ptr<Ipv6L3Protocol> ipv6L3Protocol = node->GetObject<Ipv6L3Protocol> ();
NS_FATAL_ERROR_UNLESS (ipv6L3Protocol, "InternetStackHelper::EnablePcapInternal(): "
"m_ipv6Enabled and ipv6L3Protocol inconsistent");
bool result = ipv6L3Protocol->TraceConnectWithoutContext ("Tx", MakeBoundCallback (&DefaultSink, file));
NS_ASSERT_MSG (result == true, "InternetStackHelper::EnablePcapInternal(): Unable to connect ipv6L3Protocol \"Tx\"");
result = ipv6L3Protocol->TraceConnectWithoutContext ("Rx", MakeBoundCallback (&DefaultSink, file));
NS_ASSERT_MSG (result == true, "InternetStackHelper::EnablePcapInternal(): Unable to connect ipv6L3Protocol \"Rx\"");
}
#endif
}
static void
Ipv4L3ProtocolDropSinkWithoutContext (
Ptr<OutputStreamObject> stream,
Ipv4Header const &header,
Ptr<const Packet> packet,
Ipv4L3Protocol::DropReason reason,
uint32_t interface)
{
Ptr<Packet> p = packet->Copy ();
p->AddHeader (header);
*stream->GetStream () << "d " << Simulator::Now ().GetSeconds () << " " << *p << std::endl;
}
#if 0
//
// We want to enable drop traces on Ipv4L3Protocol and ArpL3Protocol if
// m_ipv4Enabled; and we want to enable the drop trace on Ipv6L3Protocol
// if enabled. The simple way to do that is to let Config::Connect wander
// through the global node list looking for <node> and then the appropriate
// protocols and trace sources. Since we have the node handy, we can be
// quicker about it, but it takes slightly more work here.
//
if (m_ipv4Enabled)
{
Ptr<Ipv4L3Protocol> ipv4L3Protocol = node->GetObject<Ipv4L3Protocol> ();
NS_ASSERT_MSG (ipv4L3Protocol, "InternetStackHelper::EnablePcapInternal(): "
"m_ipv4Enabled and ipv4L3Protocol inconsistent");
bool result = ipv4L3Protocol->TraceConnectWithoutContext ("Drop", MakeBoundCallback (&DefaultSink, file));
NS_ASSERT_MSG (result == true, "InternetStackHelper::EnablePcapInternal(): Unable to connect ipv4L3Protocol \"Drop\"");
Ptr<ArpL3Protocol> arpL3Protocol = node->GetObject<ArpL3Protocol> ();
NS_ASSERT_MSG (arpL3Protocol, "InternetStackHelper::EnablePcapInternal(): "
"m_ipv4Enabled and arpL3Protocol inconsistent");
result = arpL3Protocol->TraceConnectWithoutContext ("Drop", MakeBoundCallback (&DefaultSink, file));
NS_ASSERT_MSG (result == true, "InternetStackHelper::EnablePcapInternal(): Unable to connect arpL3Protocol \"Drop\"");
}
if (m_ipv6Enabled)
{
Ptr<Ipv6L3Protocol> ipv6L3Protocol = node->GetObject<Ipv6L3Protocol> ();
NS_FATAL_ERROR_UNLESS (ipv6L3Protocol, "InternetStackHelper::EnablePcapInternal(): "
"m_ipv6Enabled and ipv6L3Protocol inconsistent");
bool result = ipv6L3Protocol->TraceConnectWithoutContext ("Drop", MakeBoundCallback (&DefaultSink, file));
NS_ASSERT_MSG (result == true, "InternetStackHelper::EnablePcapInternal(): Unable to connect ipv6L3Protocol \"Drop\"");
}
#endif
static void
Ipv4L3ProtocolDropSinkWithContext (
Ptr<OutputStreamObject> stream,
std::string context,
Ipv4Header const &header,
Ptr<const Packet> packet,
Ipv4L3Protocol::DropReason reason,
uint32_t interface)
{
Ptr<Packet> p = packet->Copy ();
p->AddHeader (header);
*stream->GetStream () << "d " << Simulator::Now ().GetSeconds () << " " << context << " " << *p << std::endl;
}
void
InternetStackHelper::EnableAsciiInternal (
@@ -480,21 +457,8 @@ InternetStackHelper::EnableAsciiInternal (
Ptr<Ipv4> ipv4,
uint32_t interface)
{
#if 0
//
// All of the ascii enable functions vector through here including the ones
// that are wandering through all of devices on perhaps all of the nodes in
// the system. We can only deal with devices of type CsmaNetDevice.
//
Ptr<CsmaNetDevice> device = nd->GetObject<CsmaNetDevice> ();
if (device == 0)
{
NS_LOG_INFO ("CsmaHelper::EnableAsciiInternal(): Device " << device << " not of type ns3::CsmaNetDevice");
return;
}
//
// Our default trace sinks are going to use packet printing, so we have to
// Our trace sinks are going to use packet printing, so we have to
// make sure that is turned on.
//
Packet::EnablePrinting ();
@@ -513,23 +477,27 @@ InternetStackHelper::EnableAsciiInternal (
// name of the file given the prefix.
//
AsciiTraceHelper asciiTraceHelper;
std::string filename = asciiTraceHelper.GetFilenameFromDevice (prefix, device);
std::string filename = asciiTraceHelper.GetFilenameFromInterfacePair (prefix, ipv4, interface);
Ptr<OutputStreamObject> theStream = asciiTraceHelper.CreateFileStream (filename, "w");
//
// The MacRx trace source provides our "r" event.
// We can use the default drop sink for the ArpL3Protocol since it has
// the usual signature. We can get to the Ptr<ArpL3Protocol> through
// our Ptr<Ipv4> since they must both be aggregated to the same node.
//
asciiTraceHelper.HookDefaultReceiveSinkWithoutContext<CsmaNetDevice> (device, "MacRx", theStream);
Ptr<ArpL3Protocol> arpL3Protocol = ipv4->GetObject<ArpL3Protocol> ();
asciiTraceHelper.HookDefaultDropSinkWithoutContext<ArpL3Protocol> (arpL3Protocol, "Drop", theStream);
//
// The "+", '-', and 'd' events are driven by trace sources actually in the
// transmit queue.
// The drop sink for the Ipv4L3Protocol uses a different signature than
// the default sink, so we have to cook one up for ourselves. We can get
// to the Ptr<Ipv4L3Protocol> through our Ptr<Ipv4> since they must both
// be aggregated to the same node.
//
Ptr<Queue> queue = device->GetQueue ();
asciiTraceHelper.HookDefaultEnqueueSinkWithoutContext<Queue> (queue, "Enqueue", theStream);
asciiTraceHelper.HookDefaultDropSinkWithoutContext<Queue> (queue, "Drop", theStream);
asciiTraceHelper.HookDefaultDequeueSinkWithoutContext<Queue> (queue, "Dequeue", theStream);
Ptr<Ipv4L3Protocol> ipv4L3Protocol = ipv4->GetObject<Ipv4L3Protocol> ();
bool result = ipv4L3Protocol->TraceConnectWithoutContext ("Drop",
MakeBoundCallback (&Ipv4L3ProtocolDropSinkWithoutContext, theStream));
NS_ASSERT_MSG (result == true, "InternetStackHelper::EnableAsciiInternal(): Unable to connect ipv4L3Protocol \"Drop\"");
return;
}
@@ -540,34 +508,21 @@ InternetStackHelper::EnableAsciiInternal (
// compatibility and simplicity, we just use Config::Connect and let it deal
// with the context.
//
// Note that we are going to use the default trace sinks provided by the
// ascii trace helper. There is actually no AsciiTraceHelper in sight here,
// but the default trace sinks are actually publicly available static
// functions that are always there waiting for just such a case.
//
uint32_t nodeid = nd->GetNode ()->GetId ();
uint32_t deviceid = nd->GetIfIndex ();
Ptr<Node> node = ipv4->GetObject<Node> ();
std::ostringstream oss;
oss << "/NodeList/" << nd->GetNode ()->GetId () << "/DeviceList/" << deviceid << "/$ns3::CsmaNetDevice/MacRx";
Config::Connect (oss.str (), MakeBoundCallback (&AsciiTraceHelper::DefaultReceiveSinkWithContext, stream));
oss.str ("");
oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::CsmaNetDevice/TxQueue/Enqueue";
Config::Connect (oss.str (), MakeBoundCallback (&AsciiTraceHelper::DefaultEnqueueSinkWithContext, stream));
oss.str ("");
oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::CsmaNetDevice/TxQueue/Dequeue";
Config::Connect (oss.str (), MakeBoundCallback (&AsciiTraceHelper::DefaultDequeueSinkWithContext, stream));
oss.str ("");
oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::CsmaNetDevice/TxQueue/Drop";
// We are going to use the default trace sink provided by the ascii trace
// helper. There is actually no AsciiTraceHelper in sight here, but the
// default trace sinks are actually publicly available static functions
// that are always there waiting for just such a case.
//
oss << "/NodeList/" << node->GetId () << "/$ns3::ArpL3Protocol/Drop";
Config::Connect (oss.str (), MakeBoundCallback (&AsciiTraceHelper::DefaultDropSinkWithContext, stream));
#endif
oss << "/NodeList/" << node->GetId () << "/$ns3::Ipv4L3Protocol/Drop";
Config::Connect (oss.str (), MakeBoundCallback (&Ipv4L3ProtocolDropSinkWithContext, stream));
}
#if 0
void
InternetStackHelper::EnableAscii (std::ostream &os, NodeContainer n)
@@ -590,100 +545,6 @@ InternetStackHelper::EnableAscii (std::ostream &os, NodeContainer n)
}
}
void
InternetStackHelper::EnableAsciiAll (std::ostream &os)
{
EnableAscii (os, NodeContainer::GetGlobal ());
}
void
InternetStackHelper::EnablePcapAll (std::string filename)
{
Simulator::ScheduleDestroy (&InternetStackHelper::Cleanup);
InternetStackHelper::m_pcapBaseFilename = filename;
Config::Connect ("/NodeList/*/$ns3::Ipv4L3Protocol/Tx",
MakeCallback (&InternetStackHelper::LogTxIp));
Config::Connect ("/NodeList/*/$ns3::Ipv4L3Protocol/Rx",
MakeCallback (&InternetStackHelper::LogRxIp));
/* IPv6 */
Config::Connect ("/NodeList/*/$ns3::Ipv6L3Protocol/Tx",
MakeCallback (&InternetStackHelper::LogTxIp));
Config::Connect ("/NodeList/*/$ns3::Ipv6L3Protocol/Rx",
MakeCallback (&InternetStackHelper::LogRxIp));
}
uint32_t
InternetStackHelper::GetNodeIndex (std::string context)
{
std::string::size_type pos;
pos = context.find ("/NodeList/");
NS_ASSERT (pos == 0);
std::string::size_type afterNodeIndex = context.find ("/", 11);
NS_ASSERT (afterNodeIndex != std::string::npos);
std::string index = context.substr (10, afterNodeIndex - 10);
std::istringstream iss;
iss.str (index);
uint32_t nodeIndex;
iss >> nodeIndex;
return nodeIndex;
}
void
InternetStackHelper::LogTxIp (std::string context, Ptr<const Packet> packet, uint32_t interfaceIndex)
{
Ptr<PcapWriter> writer = InternetStackHelper::GetStream (GetNodeIndex (context), interfaceIndex);
writer->WritePacket (packet);
}
void
InternetStackHelper::LogRxIp (std::string context, Ptr<const Packet> packet, uint32_t interfaceIndex)
{
Ptr<PcapWriter> writer = InternetStackHelper::GetStream (GetNodeIndex (context), interfaceIndex);
writer->WritePacket (packet);
}
Ptr<PcapWriter>
InternetStackHelper::GetStream (uint32_t nodeId, uint32_t interfaceId)
{
for (std::vector<Trace>::iterator i = m_traces.begin ();
i != m_traces.end (); i++)
{
if (i->nodeId == nodeId &&
i->interfaceId == interfaceId)
{
return i->writer;
}
}
InternetStackHelper::Trace trace;
trace.nodeId = nodeId;
trace.interfaceId = interfaceId;
trace.writer = CreateObject<PcapWriter> ();
std::ostringstream oss;
oss << m_pcapBaseFilename << "-" << nodeId << "-" << interfaceId << ".pcap";
trace.writer->Open (oss.str ());
trace.writer->WriteIpHeader ();
m_traces.push_back (trace);
return trace.writer;
}
void
InternetStackHelper::AsciiDropEventArp (Ptr<AsciiWriter> writer, std::string path, Ptr<const Packet> packet)
{
writer->WritePacket (AsciiWriter::DROP, path, packet);
}
void
InternetStackHelper::AsciiDropEventIpv4 (Ptr<AsciiWriter> writer, std::string path,
Ipv4Header const &header, Ptr<const Packet> packet,
Ipv4L3Protocol::DropReason reason, uint32_t interface)
{
Ptr<Packet> p = packet->Copy ();
p->AddHeader (header);
writer->WritePacket (AsciiWriter::DROP, path, p);
}
void
InternetStackHelper::AsciiDropEventIpv6 (Ptr<AsciiWriter> writer, std::string path,
Ipv6Header const &header, Ptr<const Packet> packet,

View File

@@ -442,7 +442,7 @@ Ipv4L3Protocol::Receive( Ptr<NetDevice> device, Ptr<const Packet> p, uint16_t pr
{
if (ipv4Interface->IsUp ())
{
m_rxTrace (packet, interface);
m_rxTrace (packet, m_node->GetObject<Ipv4> (), interface);
break;
}
else
@@ -450,7 +450,7 @@ Ipv4L3Protocol::Receive( Ptr<NetDevice> device, Ptr<const Packet> p, uint16_t pr
NS_LOG_LOGIC ("Dropping received packet-- interface is down");
Ipv4Header ipHeader;
packet->RemoveHeader (ipHeader);
m_dropTrace (ipHeader, packet, DROP_INTERFACE_DOWN, interface);
m_dropTrace (ipHeader, packet, DROP_INTERFACE_DOWN, m_node->GetObject<Ipv4> (), interface);
return;
}
}
@@ -465,7 +465,7 @@ Ipv4L3Protocol::Receive( Ptr<NetDevice> device, Ptr<const Packet> p, uint16_t pr
if (!ipHeader.IsChecksumOk ())
{
m_dropTrace (ipHeader, packet, DROP_BAD_CHECKSUM, interface);
m_dropTrace (ipHeader, packet, DROP_BAD_CHECKSUM, m_node->GetObject<Ipv4> (), interface);
return;
}
@@ -547,7 +547,7 @@ Ipv4L3Protocol::Send (Ptr<Packet> packet,
m_sendOutgoingTrace (ipHeader, packetCopy, ifaceIndex);
packetCopy->AddHeader (ipHeader);
m_txTrace (packetCopy, ifaceIndex);
m_txTrace (packetCopy, m_node->GetObject<Ipv4> (), ifaceIndex);
outInterface->Send (packetCopy, destination);
}
return;
@@ -571,7 +571,7 @@ Ipv4L3Protocol::Send (Ptr<Packet> packet,
Ptr<Packet> packetCopy = packet->Copy ();
m_sendOutgoingTrace (ipHeader, packetCopy, ifaceIndex);
packetCopy->AddHeader (ipHeader);
m_txTrace (packetCopy, ifaceIndex);
m_txTrace (packetCopy, m_node->GetObject<Ipv4> (), ifaceIndex);
outInterface->Send (packetCopy, destination);
return;
}
@@ -613,7 +613,7 @@ Ipv4L3Protocol::Send (Ptr<Packet> packet,
else
{
NS_LOG_WARN ("No route to host. Drop.");
m_dropTrace (ipHeader, packet, DROP_NO_ROUTE, 0);
m_dropTrace (ipHeader, packet, DROP_NO_ROUTE, m_node->GetObject<Ipv4> (), 0);
}
}
@@ -666,7 +666,7 @@ Ipv4L3Protocol::SendRealOut (Ptr<Ipv4Route> route,
if (route == 0)
{
NS_LOG_WARN ("No route to host. Drop.");
m_dropTrace (ipHeader, packet, DROP_NO_ROUTE, 0);
m_dropTrace (ipHeader, packet, DROP_NO_ROUTE, m_node->GetObject<Ipv4> (), 0);
return;
}
packet->AddHeader (ipHeader);
@@ -682,7 +682,7 @@ Ipv4L3Protocol::SendRealOut (Ptr<Ipv4Route> route,
if (outInterface->IsUp ())
{
NS_LOG_LOGIC ("Send to gateway " << route->GetGateway ());
m_txTrace (packet, interface);
m_txTrace (packet, m_node->GetObject<Ipv4> (), interface);
outInterface->Send (packet, route->GetGateway ());
}
else
@@ -690,7 +690,7 @@ Ipv4L3Protocol::SendRealOut (Ptr<Ipv4Route> route,
NS_LOG_LOGIC ("Dropping-- outgoing interface is down: " << route->GetGateway ());
Ipv4Header ipHeader;
packet->RemoveHeader (ipHeader);
m_dropTrace (ipHeader, packet, DROP_INTERFACE_DOWN, interface);
m_dropTrace (ipHeader, packet, DROP_INTERFACE_DOWN, m_node->GetObject<Ipv4> (), interface);
}
}
else
@@ -698,7 +698,7 @@ Ipv4L3Protocol::SendRealOut (Ptr<Ipv4Route> route,
if (outInterface->IsUp ())
{
NS_LOG_LOGIC ("Send to destination " << ipHeader.GetDestination ());
m_txTrace (packet, interface);
m_txTrace (packet, m_node->GetObject<Ipv4> (), interface);
outInterface->Send (packet, ipHeader.GetDestination ());
}
else
@@ -706,7 +706,7 @@ Ipv4L3Protocol::SendRealOut (Ptr<Ipv4Route> route,
NS_LOG_LOGIC ("Dropping-- outgoing interface is down: " << ipHeader.GetDestination ());
Ipv4Header ipHeader;
packet->RemoveHeader (ipHeader);
m_dropTrace (ipHeader, packet, DROP_INTERFACE_DOWN, interface);
m_dropTrace (ipHeader, packet, DROP_INTERFACE_DOWN, m_node->GetObject<Ipv4> (), interface);
}
}
}
@@ -729,7 +729,7 @@ Ipv4L3Protocol::IpMulticastForward (Ptr<Ipv4MulticastRoute> mrtentry, Ptr<const
if (h.GetTtl () == 0)
{
NS_LOG_WARN ("TTL exceeded. Drop.");
m_dropTrace (header, packet, DROP_TTL_EXPIRED, i);
m_dropTrace (header, packet, DROP_TTL_EXPIRED, m_node->GetObject<Ipv4> (), i);
return;
}
NS_LOG_LOGIC ("Forward multicast via interface " << i);
@@ -766,7 +766,7 @@ Ipv4L3Protocol::IpForward (Ptr<Ipv4Route> rtentry, Ptr<const Packet> p, const Ip
icmp->SendTimeExceededTtl (ipHeader, packet);
}
NS_LOG_WARN ("TTL exceeded. Drop.");
m_dropTrace (header, packet, DROP_TTL_EXPIRED, interface);
m_dropTrace (header, packet, DROP_TTL_EXPIRED, m_node->GetObject<Ipv4> (), interface);
return;
}
m_unicastForwardTrace (ipHeader, packet, interface);
@@ -1036,8 +1036,7 @@ Ipv4L3Protocol::RouteInputError (Ptr<const Packet> p, const Ipv4Header & ipHeade
{
NS_LOG_FUNCTION (this << p << ipHeader << sockErrno);
NS_LOG_LOGIC ("Route input failure-- dropping packet to " << ipHeader << " with errno " << sockErrno);
m_dropTrace (ipHeader, p, DROP_ROUTE_ERROR, 0);
m_dropTrace (ipHeader, p, DROP_ROUTE_ERROR, m_node->GetObject<Ipv4> (), 0);
}
}//namespace ns3

View File

@@ -258,10 +258,10 @@ private:
TracedCallback<const Ipv4Header &, Ptr<const Packet>, uint32_t> m_localDeliverTrace;
// The following two traces pass a packet with an IP header
TracedCallback<Ptr<const Packet>, uint32_t> m_txTrace;
TracedCallback<Ptr<const Packet>, uint32_t> m_rxTrace;
TracedCallback<Ptr<const Packet>, Ptr<Ipv4>, uint32_t> m_txTrace;
TracedCallback<Ptr<const Packet>, Ptr<Ipv4>, uint32_t> m_rxTrace;
// <ip-header, payload, reason, ifindex> (ifindex not valid if reason is DROP_NO_ROUTE)
TracedCallback<const Ipv4Header &, Ptr<const Packet>, DropReason, uint32_t> m_dropTrace;
TracedCallback<const Ipv4Header &, Ptr<const Packet>, DropReason, Ptr<Ipv4>, uint32_t> m_dropTrace;
Ptr<Ipv4RoutingProtocol> m_routingProtocol;