A Discrete-Event Network Simulator
API
internet-stack-helper.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2008 INRIA
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  * Author: Faker Moatamri <faker.moatamri@sophia.inria.fr>
20  */
21 
22 #include "ns3/assert.h"
23 #include "ns3/log.h"
24 #include "ns3/object.h"
25 #include "ns3/names.h"
26 #include "ns3/ipv4.h"
27 #include "ns3/ipv6.h"
28 #include "ns3/packet-socket-factory.h"
29 #include "ns3/config.h"
30 #include "ns3/simulator.h"
31 #include "ns3/string.h"
32 #include "ns3/net-device.h"
33 #include "ns3/callback.h"
34 #include "ns3/node.h"
35 #include "ns3/node-list.h"
36 #include "ns3/core-config.h"
37 #include "ns3/arp-l3-protocol.h"
38 #include "internet-stack-helper.h"
39 #include "ns3/ipv4-global-routing.h"
40 #include "ns3/ipv4-list-routing-helper.h"
41 #include "ns3/ipv4-static-routing-helper.h"
42 #include "ns3/ipv4-global-routing-helper.h"
43 #include "ns3/ipv6-static-routing-helper.h"
44 #include "ns3/ipv6-extension.h"
45 #include "ns3/ipv6-extension-demux.h"
46 #include "ns3/ipv6-extension-header.h"
47 #include "ns3/icmpv6-l4-protocol.h"
48 #include "ns3/global-router-interface.h"
49 #include "ns3/traffic-control-layer.h"
50 #include <limits>
51 #include <map>
52 
53 namespace ns3 {
54 
55 NS_LOG_COMPONENT_DEFINE ("InternetStackHelper");
56 
57 //
58 // Historically, the only context written to ascii traces was the protocol.
59 // Traces from the protocols include the interface, though. It is not
60 // possible to really determine where an event originated without including
61 // this. If you want the additional context information, define
62 // INTERFACE_CONTEXT. If you want compatibility with the old-style traces
63 // comment it out.
64 //
65 #define INTERFACE_CONTEXT
66 
67 //
68 // Things are going to work differently here with respect to trace file handling
69 // than in most places because the Tx and Rx trace sources we are interested in
70 // are going to multiplex receive and transmit callbacks for all Ipv4 and
71 // interface pairs through one callback. We want packets to or from each
72 // distinct pair to go to an individual file, so we have got to demultiplex the
73 // Ipv4 and interface pair into a corresponding Ptr<PcapFileWrapper> at the
74 // callback.
75 //
76 // A complication in this situation is that the trace sources are hooked on
77 // a protocol basis. There is no trace source hooked by an Ipv4 and interface
78 // pair. This means that if we naively proceed to hook, say, a drop trace
79 // for a given Ipv4 with interface 0, and then hook for Ipv4 with interface 1
80 // we will hook the drop trace twice and get two callbacks per event. What
81 // we need to do is to hook the event once, and that will result in a single
82 // callback per drop event, and the trace source will provide the interface
83 // which we filter on in the trace sink.
84 //
85 // This has got to continue to work properly after the helper has been
86 // destroyed; but must be cleaned up at the end of time to avoid leaks.
87 // Global maps of protocol/interface pairs to file objects seems to fit the
88 // bill.
89 //
90 typedef std::pair<Ptr<Ipv4>, uint32_t> InterfacePairIpv4;
91 typedef std::map<InterfacePairIpv4, Ptr<PcapFileWrapper> > InterfaceFileMapIpv4;
92 typedef std::map<InterfacePairIpv4, Ptr<OutputStreamWrapper> > InterfaceStreamMapIpv4;
97 typedef std::pair<Ptr<Ipv6>, uint32_t> InterfacePairIpv6;
98 typedef std::map<InterfacePairIpv6, Ptr<PcapFileWrapper> > InterfaceFileMapIpv6;
99 typedef std::map<InterfacePairIpv6, Ptr<OutputStreamWrapper> > InterfaceStreamMapIpv6;
105  : m_routing (0),
106  m_routingv6 (0),
107  m_ipv4Enabled (true),
108  m_ipv6Enabled (true),
109  m_ipv4ArpJitterEnabled (true),
110  m_ipv6NsRsJitterEnabled (true)
111 
112 {
113  Initialize ();
114 }
115 
116 // private method called by both constructor and Reset ()
117 void
119 {
120  SetTcp ("ns3::TcpL4Protocol");
121  Ipv4StaticRoutingHelper staticRouting;
122  Ipv4GlobalRoutingHelper globalRouting;
123  Ipv4ListRoutingHelper listRouting;
124  Ipv6StaticRoutingHelper staticRoutingv6;
125  listRouting.Add (staticRouting, 0);
126  listRouting.Add (globalRouting, -10);
127  SetRoutingHelper (listRouting);
128  SetRoutingHelper (staticRoutingv6);
129 }
130 
132 {
133  delete m_routing;
134  delete m_routingv6;
135 }
136 
138 {
139  m_routing = o.m_routing->Copy ();
140  m_routingv6 = o.m_routingv6->Copy ();
146 }
147 
150 {
151  if (this == &o)
152  {
153  return *this;
154  }
155  m_routing = o.m_routing->Copy ();
156  m_routingv6 = o.m_routingv6->Copy ();
157  return *this;
158 }
159 
160 void
162 {
163  delete m_routing;
164  m_routing = 0;
165  delete m_routingv6;
166  m_routingv6 = 0;
167  m_ipv4Enabled = true;
168  m_ipv6Enabled = true;
169  m_ipv4ArpJitterEnabled = true;
171  Initialize ();
172 }
173 
174 void
176 {
177  delete m_routing;
178  m_routing = routing.Copy ();
179 }
180 
181 void
183 {
184  delete m_routingv6;
185  m_routingv6 = routing.Copy ();
186 }
187 
188 void
190 {
191  m_ipv4Enabled = enable;
192 }
193 
195 {
196  m_ipv6Enabled = enable;
197 }
198 
200 {
201  m_ipv4ArpJitterEnabled = enable;
202 }
203 
205 {
206  m_ipv6NsRsJitterEnabled = enable;
207 }
208 
209 int64_t
211 {
212  int64_t currentStream = stream;
213  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
214  {
215  Ptr<Node> node = *i;
216  Ptr<GlobalRouter> router = node->GetObject<GlobalRouter> ();
217  if (router != 0)
218  {
219  Ptr<Ipv4GlobalRouting> gr = router->GetRoutingProtocol ();
220  if (gr != 0)
221  {
222  currentStream += gr->AssignStreams (currentStream);
223  }
224  }
226  if (demux != 0)
227  {
228  Ptr<Ipv6Extension> fe = demux->GetExtension (Ipv6ExtensionFragment::EXT_NUMBER);
229  NS_ASSERT (fe); // should always exist in the demux
230  currentStream += fe->AssignStreams (currentStream);
231  }
232  Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> ();
233  if (ipv4 != 0)
234  {
235  Ptr<ArpL3Protocol> arpL3Protocol = ipv4->GetObject<ArpL3Protocol> ();
236  if (arpL3Protocol != 0)
237  {
238  currentStream += arpL3Protocol->AssignStreams (currentStream);
239  }
240  }
241  Ptr<Ipv6> ipv6 = node->GetObject<Ipv6> ();
242  if (ipv6 != 0)
243  {
244  Ptr<Icmpv6L4Protocol> icmpv6L4Protocol = ipv6->GetObject<Icmpv6L4Protocol> ();
245  if (icmpv6L4Protocol != 0)
246  {
247  currentStream += icmpv6L4Protocol->AssignStreams (currentStream);
248  }
249  }
250  }
251  return (currentStream - stream);
252 }
253 
254 void
255 InternetStackHelper::SetTcp (const std::string tid)
256 {
257  m_tcpFactory.SetTypeId (tid);
258 }
259 
260 void
262 {
263  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
264  {
265  Install (*i);
266  }
267 }
268 
269 void
271 {
273 }
274 
275 void
277 {
278  ObjectFactory factory;
279  factory.SetTypeId (typeId);
280  Ptr<Object> protocol = factory.Create <Object> ();
281  node->AggregateObject (protocol);
282 }
283 
284 void
286 {
287  if (m_ipv4Enabled)
288  {
289  if (node->GetObject<Ipv4> () != 0)
290  {
291  NS_FATAL_ERROR ("InternetStackHelper::Install (): Aggregating "
292  "an InternetStack to a node with an existing Ipv4 object");
293  return;
294  }
295 
296  CreateAndAggregateObjectFromTypeId (node, "ns3::ArpL3Protocol");
297  CreateAndAggregateObjectFromTypeId (node, "ns3::Ipv4L3Protocol");
298  CreateAndAggregateObjectFromTypeId (node, "ns3::Icmpv4L4Protocol");
299  if (m_ipv4ArpJitterEnabled == false)
300  {
302  NS_ASSERT (arp);
303  arp->SetAttribute ("RequestJitter", StringValue ("ns3::ConstantRandomVariable[Constant=0.0]"));
304  }
305  // Set routing
306  Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> ();
307  Ptr<Ipv4RoutingProtocol> ipv4Routing = m_routing->Create (node);
308  ipv4->SetRoutingProtocol (ipv4Routing);
309  }
310 
311  if (m_ipv6Enabled)
312  {
313  /* IPv6 stack */
314  if (node->GetObject<Ipv6> () != 0)
315  {
316  NS_FATAL_ERROR ("InternetStackHelper::Install (): Aggregating "
317  "an InternetStack to a node with an existing Ipv6 object");
318  return;
319  }
320 
321  CreateAndAggregateObjectFromTypeId (node, "ns3::Ipv6L3Protocol");
322  CreateAndAggregateObjectFromTypeId (node, "ns3::Icmpv6L4Protocol");
323  if (m_ipv6NsRsJitterEnabled == false)
324  {
325  Ptr<Icmpv6L4Protocol> icmpv6l4 = node->GetObject<Icmpv6L4Protocol> ();
326  NS_ASSERT (icmpv6l4);
327  icmpv6l4->SetAttribute ("SolicitationJitter", StringValue ("ns3::ConstantRandomVariable[Constant=0.0]"));
328  }
329  // Set routing
330  Ptr<Ipv6> ipv6 = node->GetObject<Ipv6> ();
331  Ptr<Ipv6RoutingProtocol> ipv6Routing = m_routingv6->Create (node);
332  ipv6->SetRoutingProtocol (ipv6Routing);
333 
334  /* register IPv6 extensions and options */
335  ipv6->RegisterExtensions ();
336  ipv6->RegisterOptions ();
337  }
338 
340  {
341  CreateAndAggregateObjectFromTypeId (node, "ns3::TrafficControlLayer");
342  CreateAndAggregateObjectFromTypeId (node, "ns3::UdpL4Protocol");
344  Ptr<PacketSocketFactory> factory = CreateObject<PacketSocketFactory> ();
345  node->AggregateObject (factory);
346  }
347 
348  if (m_ipv4Enabled)
349  {
352  NS_ASSERT (arp);
353  NS_ASSERT (tc);
354  arp->SetTrafficControl (tc);
355  }
356 }
357 
358 void
359 InternetStackHelper::Install (std::string nodeName) const
360 {
361  Ptr<Node> node = Names::Find<Node> (nodeName);
362  Install (node);
363 }
364 
371 static void
373 {
374  NS_LOG_FUNCTION (p << ipv4 << interface);
375 
376  //
377  // Since trace sources are independent of interface, if we hook a source
378  // on a particular protocol we will get traces for all of its interfaces.
379  // We need to filter this to only report interfaces for which the user
380  // has expressed interest.
381  //
382  InterfacePairIpv4 pair = std::make_pair (ipv4, interface);
383  if (g_interfaceFileMapIpv4.find (pair) == g_interfaceFileMapIpv4.end ())
384  {
385  NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
386  return;
387  }
388 
390  file->Write (Simulator::Now (), p);
391 }
392 
393 bool
395 {
396  for ( InterfaceFileMapIpv4::const_iterator i = g_interfaceFileMapIpv4.begin ();
397  i != g_interfaceFileMapIpv4.end ();
398  ++i)
399  {
400  if ((*i).first.first == ipv4)
401  {
402  return true;
403  }
404  }
405  return false;
406 }
407 
408 void
409 InternetStackHelper::EnablePcapIpv4Internal (std::string prefix, Ptr<Ipv4> ipv4, uint32_t interface, bool explicitFilename)
410 {
411  NS_LOG_FUNCTION (prefix << ipv4 << interface);
412 
413  if (!m_ipv4Enabled)
414  {
415  NS_LOG_INFO ("Call to enable Ipv4 pcap tracing but Ipv4 not enabled");
416  return;
417  }
418 
419  //
420  // We have to create a file and a mapping from protocol/interface to file
421  // irrespective of how many times we want to trace a particular protocol.
422  //
423  PcapHelper pcapHelper;
424 
425  std::string filename;
426  if (explicitFilename)
427  {
428  filename = prefix;
429  }
430  else
431  {
432  filename = pcapHelper.GetFilenameFromInterfacePair (prefix, ipv4, interface);
433  }
434 
435  Ptr<PcapFileWrapper> file = pcapHelper.CreateFile (filename, std::ios::out, PcapHelper::DLT_RAW);
436 
437  //
438  // However, we only hook the trace source once to avoid multiple trace sink
439  // calls per event (connect is independent of interface).
440  //
441  if (!PcapHooked (ipv4))
442  {
443  //
444  // Ptr<Ipv4> is aggregated to node and Ipv4L3Protocol is aggregated to
445  // node so we can get to Ipv4L3Protocol through Ipv4.
446  //
447  Ptr<Ipv4L3Protocol> ipv4L3Protocol = ipv4->GetObject<Ipv4L3Protocol> ();
448  NS_ASSERT_MSG (ipv4L3Protocol, "InternetStackHelper::EnablePcapIpv4Internal(): "
449  "m_ipv4Enabled and ipv4L3Protocol inconsistent");
450 
451  bool result = ipv4L3Protocol->TraceConnectWithoutContext ("Tx", MakeCallback (&Ipv4L3ProtocolRxTxSink));
452  NS_ASSERT_MSG (result == true, "InternetStackHelper::EnablePcapIpv4Internal(): "
453  "Unable to connect ipv4L3Protocol \"Tx\"");
454 
455  result = ipv4L3Protocol->TraceConnectWithoutContext ("Rx", MakeCallback (&Ipv4L3ProtocolRxTxSink));
456  NS_ASSERT_MSG (result == true, "InternetStackHelper::EnablePcapIpv4Internal(): "
457  "Unable to connect ipv4L3Protocol \"Rx\"");
458  }
459 
460  g_interfaceFileMapIpv4[std::make_pair (ipv4, interface)] = file;
461 }
462 
469 static void
471 {
472  NS_LOG_FUNCTION (p << ipv6 << interface);
473 
474  //
475  // Since trace sources are independent of interface, if we hook a source
476  // on a particular protocol we will get traces for all of its interfaces.
477  // We need to filter this to only report interfaces for which the user
478  // has expressed interest.
479  //
480  InterfacePairIpv6 pair = std::make_pair (ipv6, interface);
481  if (g_interfaceFileMapIpv6.find (pair) == g_interfaceFileMapIpv6.end ())
482  {
483  NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
484  return;
485  }
486 
488  file->Write (Simulator::Now (), p);
489 }
490 
491 bool
493 {
494  for ( InterfaceFileMapIpv6::const_iterator i = g_interfaceFileMapIpv6.begin ();
495  i != g_interfaceFileMapIpv6.end ();
496  ++i)
497  {
498  if ((*i).first.first == ipv6)
499  {
500  return true;
501  }
502  }
503  return false;
504 }
505 
506 void
507 InternetStackHelper::EnablePcapIpv6Internal (std::string prefix, Ptr<Ipv6> ipv6, uint32_t interface, bool explicitFilename)
508 {
509  NS_LOG_FUNCTION (prefix << ipv6 << interface);
510 
511  if (!m_ipv6Enabled)
512  {
513  NS_LOG_INFO ("Call to enable Ipv6 pcap tracing but Ipv6 not enabled");
514  return;
515  }
516 
517  //
518  // We have to create a file and a mapping from protocol/interface to file
519  // irrespective of how many times we want to trace a particular protocol.
520  //
521  PcapHelper pcapHelper;
522 
523  std::string filename;
524  if (explicitFilename)
525  {
526  filename = prefix;
527  }
528  else
529  {
530  filename = pcapHelper.GetFilenameFromInterfacePair (prefix, ipv6, interface);
531  }
532 
533  Ptr<PcapFileWrapper> file = pcapHelper.CreateFile (filename, std::ios::out, PcapHelper::DLT_RAW);
534 
535  //
536  // However, we only hook the trace source once to avoid multiple trace sink
537  // calls per event (connect is independent of interface).
538  //
539  if (!PcapHooked (ipv6))
540  {
541  //
542  // Ptr<Ipv6> is aggregated to node and Ipv6L3Protocol is aggregated to
543  // node so we can get to Ipv6L3Protocol through Ipv6.
544  //
545  Ptr<Ipv6L3Protocol> ipv6L3Protocol = ipv6->GetObject<Ipv6L3Protocol> ();
546  NS_ASSERT_MSG (ipv6L3Protocol, "InternetStackHelper::EnablePcapIpv6Internal(): "
547  "m_ipv6Enabled and ipv6L3Protocol inconsistent");
548 
549  bool result = ipv6L3Protocol->TraceConnectWithoutContext ("Tx", MakeCallback (&Ipv6L3ProtocolRxTxSink));
550  NS_ASSERT_MSG (result == true, "InternetStackHelper::EnablePcapIpv6Internal(): "
551  "Unable to connect ipv6L3Protocol \"Tx\"");
552 
553  result = ipv6L3Protocol->TraceConnectWithoutContext ("Rx", MakeCallback (&Ipv6L3ProtocolRxTxSink));
554  NS_ASSERT_MSG (result == true, "InternetStackHelper::EnablePcapIpv6Internal(): "
555  "Unable to connect ipv6L3Protocol \"Rx\"");
556  }
557 
558  g_interfaceFileMapIpv6[std::make_pair (ipv6, interface)] = file;
559 }
560 
570 static void
573  Ipv4Header const &header,
574  Ptr<const Packet> packet,
576  Ptr<Ipv4> ipv4,
577  uint32_t interface)
578 {
579  //
580  // Since trace sources are independent of interface, if we hook a source
581  // on a particular protocol we will get traces for all of its interfaces.
582  // We need to filter this to only report interfaces for which the user
583  // has expressed interest.
584  //
585  InterfacePairIpv4 pair = std::make_pair (ipv4, interface);
586  if (g_interfaceStreamMapIpv4.find (pair) == g_interfaceStreamMapIpv4.end ())
587  {
588  NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
589  return;
590  }
591 
592  Ptr<Packet> p = packet->Copy ();
593  p->AddHeader (header);
594  *stream->GetStream () << "d " << Simulator::Now ().GetSeconds () << " " << *p << std::endl;
595 }
596 
604 static void
607  Ptr<const Packet> packet,
608  Ptr<Ipv4> ipv4,
609  uint32_t interface)
610 {
611  InterfacePairIpv4 pair = std::make_pair (ipv4, interface);
612  if (g_interfaceStreamMapIpv4.find (pair) == g_interfaceStreamMapIpv4.end ())
613  {
614  NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
615  return;
616  }
617 
618  *stream->GetStream () << "t " << Simulator::Now ().GetSeconds () << " " << *packet << std::endl;
619 }
620 
628 static void
631  Ptr<const Packet> packet,
632  Ptr<Ipv4> ipv4,
633  uint32_t interface)
634 {
635  InterfacePairIpv4 pair = std::make_pair (ipv4, interface);
636  if (g_interfaceStreamMapIpv4.find (pair) == g_interfaceStreamMapIpv4.end ())
637  {
638  NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
639  return;
640  }
641 
642  *stream->GetStream () << "r " << Simulator::Now ().GetSeconds () << " " << *packet << std::endl;
643 }
644 
655 static void
658  std::string context,
659  Ipv4Header const &header,
660  Ptr<const Packet> packet,
662  Ptr<Ipv4> ipv4,
663  uint32_t interface)
664 {
665  //
666  // Since trace sources are independent of interface, if we hook a source
667  // on a particular protocol we will get traces for all of its interfaces.
668  // We need to filter this to only report interfaces for which the user
669  // has expressed interest.
670  //
671  InterfacePairIpv4 pair = std::make_pair (ipv4, interface);
672  if (g_interfaceStreamMapIpv4.find (pair) == g_interfaceStreamMapIpv4.end ())
673  {
674  NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
675  return;
676  }
677 
678  Ptr<Packet> p = packet->Copy ();
679  p->AddHeader (header);
680 #ifdef INTERFACE_CONTEXT
681  *stream->GetStream () << "d " << Simulator::Now ().GetSeconds () << " " << context << "(" << interface << ") "
682  << *p << std::endl;
683 #else
684  *stream->GetStream () << "d " << Simulator::Now ().GetSeconds () << " " << context << " " << *p << std::endl;
685 #endif
686 }
687 
696 static void
699  std::string context,
700  Ptr<const Packet> packet,
701  Ptr<Ipv4> ipv4,
702  uint32_t interface)
703 {
704  InterfacePairIpv4 pair = std::make_pair (ipv4, interface);
705  if (g_interfaceStreamMapIpv4.find (pair) == g_interfaceStreamMapIpv4.end ())
706  {
707  NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
708  return;
709  }
710 
711 #ifdef INTERFACE_CONTEXT
712  *stream->GetStream () << "t " << Simulator::Now ().GetSeconds () << " " << context << "(" << interface << ") "
713  << *packet << std::endl;
714 #else
715  *stream->GetStream () << "t " << Simulator::Now ().GetSeconds () << " " << context << " " << *packet << std::endl;
716 #endif
717 }
718 
727 static void
730  std::string context,
731  Ptr<const Packet> packet,
732  Ptr<Ipv4> ipv4,
733  uint32_t interface)
734 {
735  InterfacePairIpv4 pair = std::make_pair (ipv4, interface);
736  if (g_interfaceStreamMapIpv4.find (pair) == g_interfaceStreamMapIpv4.end ())
737  {
738  NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
739  return;
740  }
741 
742 #ifdef INTERFACE_CONTEXT
743  *stream->GetStream () << "r " << Simulator::Now ().GetSeconds () << " " << context << "(" << interface << ") "
744  << *packet << std::endl;
745 #else
746  *stream->GetStream () << "r " << Simulator::Now ().GetSeconds () << " " << context << " " << *packet << std::endl;
747 #endif
748 }
749 
750 bool
752 {
753  for ( InterfaceStreamMapIpv4::const_iterator i = g_interfaceStreamMapIpv4.begin ();
754  i != g_interfaceStreamMapIpv4.end ();
755  ++i)
756  {
757  if ((*i).first.first == ipv4)
758  {
759  return true;
760  }
761  }
762  return false;
763 }
764 
765 void
767  Ptr<OutputStreamWrapper> stream,
768  std::string prefix,
769  Ptr<Ipv4> ipv4,
770  uint32_t interface,
771  bool explicitFilename)
772 {
773  if (!m_ipv4Enabled)
774  {
775  NS_LOG_INFO ("Call to enable Ipv4 ascii tracing but Ipv4 not enabled");
776  return;
777  }
778 
779  //
780  // Our trace sinks are going to use packet printing, so we have to
781  // make sure that is turned on.
782  //
784 
785  //
786  // If we are not provided an OutputStreamWrapper, we are expected to create
787  // one using the usual trace filename conventions and hook WithoutContext
788  // since there will be one file per context and therefore the context would
789  // be redundant.
790  //
791  if (stream == 0)
792  {
793  //
794  // Set up an output stream object to deal with private ofstream copy
795  // constructor and lifetime issues. Let the helper decide the actual
796  // name of the file given the prefix.
797  //
798  // We have to create a stream and a mapping from protocol/interface to
799  // stream irrespective of how many times we want to trace a particular
800  // protocol.
801  //
802  AsciiTraceHelper asciiTraceHelper;
803 
804  std::string filename;
805  if (explicitFilename)
806  {
807  filename = prefix;
808  }
809  else
810  {
811  filename = asciiTraceHelper.GetFilenameFromInterfacePair (prefix, ipv4, interface);
812  }
813 
814  Ptr<OutputStreamWrapper> theStream = asciiTraceHelper.CreateFileStream (filename);
815 
816  //
817  // However, we only hook the trace sources once to avoid multiple trace sink
818  // calls per event (connect is independent of interface).
819  //
820  if (!AsciiHooked (ipv4))
821  {
822  //
823  // We can use the default drop sink for the ArpL3Protocol since it has
824  // the usual signature. We can get to the Ptr<ArpL3Protocol> through
825  // our Ptr<Ipv4> since they must both be aggregated to the same node.
826  //
827  Ptr<ArpL3Protocol> arpL3Protocol = ipv4->GetObject<ArpL3Protocol> ();
828  asciiTraceHelper.HookDefaultDropSinkWithoutContext<ArpL3Protocol> (arpL3Protocol, "Drop", theStream);
829 
830  //
831  // The drop sink for the Ipv4L3Protocol uses a different signature than
832  // the default sink, so we have to cook one up for ourselves. We can get
833  // to the Ptr<Ipv4L3Protocol> through our Ptr<Ipv4> since they must both
834  // be aggregated to the same node.
835  //
836  Ptr<Ipv4L3Protocol> ipv4L3Protocol = ipv4->GetObject<Ipv4L3Protocol> ();
837  bool result = ipv4L3Protocol->TraceConnectWithoutContext ("Drop",
839  NS_ASSERT_MSG (result == true, "InternetStackHelper::EnableAsciiIpv4Internal(): "
840  "Unable to connect ipv4L3Protocol \"Drop\"");
841  result = ipv4L3Protocol->TraceConnectWithoutContext ("Tx",
843  NS_ASSERT_MSG (result == true, "InternetStackHelper::EnableAsciiIpv4Internal(): "
844  "Unable to connect ipv4L3Protocol \"Tx\"");
845  result = ipv4L3Protocol->TraceConnectWithoutContext ("Rx",
847  NS_ASSERT_MSG (result == true, "InternetStackHelper::EnableAsciiIpv4Internal(): "
848  "Unable to connect ipv4L3Protocol \"Rx\"");
849  }
850 
851  g_interfaceStreamMapIpv4[std::make_pair (ipv4, interface)] = theStream;
852  return;
853  }
854 
855  //
856  // If we are provided an OutputStreamWrapper, we are expected to use it, and
857  // to provide a context. We are free to come up with our own context if we
858  // want, and use the AsciiTraceHelper Hook*WithContext functions, but for
859  // compatibility and simplicity, we just use Config::Connect and let it deal
860  // with the context.
861  //
862  // We need to associate the ipv4/interface with a stream to express interest
863  // in tracing events on that pair, however, we only hook the trace sources
864  // once to avoid multiple trace sink calls per event (connect is independent
865  // of interface).
866  //
867  if (!AsciiHooked (ipv4))
868  {
869  Ptr<Node> node = ipv4->GetObject<Node> ();
870  std::ostringstream oss;
871 
872  //
873  // For the ARP Drop, we are going to use the default trace sink provided by
874  // the ascii trace helper. There is actually no AsciiTraceHelper in sight
875  // here, but the default trace sinks are actually publicly available static
876  // functions that are always there waiting for just such a case.
877  //
878  oss << "/NodeList/" << node->GetId () << "/$ns3::ArpL3Protocol/Drop";
880 
881  //
882  // This has all kinds of parameters coming with, so we have to cook up our
883  // own sink.
884  //
885  oss.str ("");
886  oss << "/NodeList/" << node->GetId () << "/$ns3::Ipv4L3Protocol/Drop";
888  oss.str ("");
889  oss << "/NodeList/" << node->GetId () << "/$ns3::Ipv4L3Protocol/Tx";
891  oss.str ("");
892  oss << "/NodeList/" << node->GetId () << "/$ns3::Ipv4L3Protocol/Rx";
894  }
895 
896  g_interfaceStreamMapIpv4[std::make_pair (ipv4, interface)] = stream;
897 }
898 
908 static void
911  Ipv6Header const &header,
912  Ptr<const Packet> packet,
914  Ptr<Ipv6> ipv6,
915  uint32_t interface)
916 {
917  //
918  // Since trace sources are independent of interface, if we hook a source
919  // on a particular protocol we will get traces for all of its interfaces.
920  // We need to filter this to only report interfaces for which the user
921  // has expressed interest.
922  //
923  InterfacePairIpv6 pair = std::make_pair (ipv6, interface);
924  if (g_interfaceStreamMapIpv6.find (pair) == g_interfaceStreamMapIpv6.end ())
925  {
926  NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
927  return;
928  }
929 
930  Ptr<Packet> p = packet->Copy ();
931  p->AddHeader (header);
932  *stream->GetStream () << "d " << Simulator::Now ().GetSeconds () << " " << *p << std::endl;
933 }
934 
942 static void
945  Ptr<const Packet> packet,
946  Ptr<Ipv6> ipv6,
947  uint32_t interface)
948 {
949  InterfacePairIpv6 pair = std::make_pair (ipv6, interface);
950  if (g_interfaceStreamMapIpv6.find (pair) == g_interfaceStreamMapIpv6.end ())
951  {
952  NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
953  return;
954  }
955 
956  *stream->GetStream () << "t " << Simulator::Now ().GetSeconds () << " " << *packet << std::endl;
957 }
958 
966 static void
969  Ptr<const Packet> packet,
970  Ptr<Ipv6> ipv6,
971  uint32_t interface)
972 {
973  InterfacePairIpv6 pair = std::make_pair (ipv6, interface);
974  if (g_interfaceStreamMapIpv6.find (pair) == g_interfaceStreamMapIpv6.end ())
975  {
976  NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
977  return;
978  }
979 
980  *stream->GetStream () << "r " << Simulator::Now ().GetSeconds () << " " << *packet << std::endl;
981 }
982 
993 static void
996  std::string context,
997  Ipv6Header const &header,
998  Ptr<const Packet> packet,
1000  Ptr<Ipv6> ipv6,
1001  uint32_t interface)
1002 {
1003  //
1004  // Since trace sources are independent of interface, if we hook a source
1005  // on a particular protocol we will get traces for all of its interfaces.
1006  // We need to filter this to only report interfaces for which the user
1007  // has expressed interest.
1008  //
1009  InterfacePairIpv6 pair = std::make_pair (ipv6, interface);
1010  if (g_interfaceStreamMapIpv6.find (pair) == g_interfaceStreamMapIpv6.end ())
1011  {
1012  NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
1013  return;
1014  }
1015 
1016  Ptr<Packet> p = packet->Copy ();
1017  p->AddHeader (header);
1018 #ifdef INTERFACE_CONTEXT
1019  *stream->GetStream () << "d " << Simulator::Now ().GetSeconds () << " " << context << "(" << interface << ") "
1020  << *p << std::endl;
1021 #else
1022  *stream->GetStream () << "d " << Simulator::Now ().GetSeconds () << " " << context << " " << *p << std::endl;
1023 #endif
1024 }
1025 
1034 static void
1036  Ptr<OutputStreamWrapper> stream,
1037  std::string context,
1038  Ptr<const Packet> packet,
1039  Ptr<Ipv6> ipv6,
1040  uint32_t interface)
1041 {
1042  InterfacePairIpv6 pair = std::make_pair (ipv6, interface);
1043  if (g_interfaceStreamMapIpv6.find (pair) == g_interfaceStreamMapIpv6.end ())
1044  {
1045  NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
1046  return;
1047  }
1048 
1049 #ifdef INTERFACE_CONTEXT
1050  *stream->GetStream () << "t " << Simulator::Now ().GetSeconds () << " " << context << "(" << interface << ") "
1051  << *packet << std::endl;
1052 #else
1053  *stream->GetStream () << "t " << Simulator::Now ().GetSeconds () << " " << context << " " << *packet << std::endl;
1054 #endif
1055 }
1056 
1065 static void
1067  Ptr<OutputStreamWrapper> stream,
1068  std::string context,
1069  Ptr<const Packet> packet,
1070  Ptr<Ipv6> ipv6,
1071  uint32_t interface)
1072 {
1073  InterfacePairIpv6 pair = std::make_pair (ipv6, interface);
1074  if (g_interfaceStreamMapIpv6.find (pair) == g_interfaceStreamMapIpv6.end ())
1075  {
1076  NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
1077  return;
1078  }
1079 
1080 #ifdef INTERFACE_CONTEXT
1081  *stream->GetStream () << "r " << Simulator::Now ().GetSeconds () << " " << context << "(" << interface << ") "
1082  << *packet << std::endl;
1083 #else
1084  *stream->GetStream () << "r " << Simulator::Now ().GetSeconds () << " " << context << " " << *packet << std::endl;
1085 #endif
1086 }
1087 
1088 bool
1090 {
1091  for ( InterfaceStreamMapIpv6::const_iterator i = g_interfaceStreamMapIpv6.begin ();
1092  i != g_interfaceStreamMapIpv6.end ();
1093  ++i)
1094  {
1095  if ((*i).first.first == ipv6)
1096  {
1097  return true;
1098  }
1099  }
1100  return false;
1101 }
1102 
1103 void
1105  Ptr<OutputStreamWrapper> stream,
1106  std::string prefix,
1107  Ptr<Ipv6> ipv6,
1108  uint32_t interface,
1109  bool explicitFilename)
1110 {
1111  if (!m_ipv6Enabled)
1112  {
1113  NS_LOG_INFO ("Call to enable Ipv6 ascii tracing but Ipv6 not enabled");
1114  return;
1115  }
1116 
1117  //
1118  // Our trace sinks are going to use packet printing, so we have to
1119  // make sure that is turned on.
1120  //
1122 
1123  //
1124  // If we are not provided an OutputStreamWrapper, we are expected to create
1125  // one using the usual trace filename conventions and do a hook WithoutContext
1126  // since there will be one file per context and therefore the context would
1127  // be redundant.
1128  //
1129  if (stream == 0)
1130  {
1131  //
1132  // Set up an output stream object to deal with private ofstream copy
1133  // constructor and lifetime issues. Let the helper decide the actual
1134  // name of the file given the prefix.
1135  //
1136  // We have to create a stream and a mapping from protocol/interface to
1137  // stream irrespective of how many times we want to trace a particular
1138  // protocol.
1139  //
1140  AsciiTraceHelper asciiTraceHelper;
1141 
1142  std::string filename;
1143  if (explicitFilename)
1144  {
1145  filename = prefix;
1146  }
1147  else
1148  {
1149  filename = asciiTraceHelper.GetFilenameFromInterfacePair (prefix, ipv6, interface);
1150  }
1151 
1152  Ptr<OutputStreamWrapper> theStream = asciiTraceHelper.CreateFileStream (filename);
1153 
1154  //
1155  // However, we only hook the trace sources once to avoid multiple trace sink
1156  // calls per event (connect is independent of interface).
1157  //
1158  if (!AsciiHooked (ipv6))
1159  {
1160  //
1161  // The drop sink for the Ipv6L3Protocol uses a different signature than
1162  // the default sink, so we have to cook one up for ourselves. We can get
1163  // to the Ptr<Ipv6L3Protocol> through our Ptr<Ipv6> since they must both
1164  // be aggregated to the same node.
1165  //
1166  Ptr<Ipv6L3Protocol> ipv6L3Protocol = ipv6->GetObject<Ipv6L3Protocol> ();
1167  bool result = ipv6L3Protocol->TraceConnectWithoutContext ("Drop",
1169  NS_ASSERT_MSG (result == true, "InternetStackHelper::EnableAsciiIpv6Internal(): "
1170  "Unable to connect ipv6L3Protocol \"Drop\"");
1171  result = ipv6L3Protocol->TraceConnectWithoutContext ("Tx",
1173  NS_ASSERT_MSG (result == true, "InternetStackHelper::EnableAsciiIpv6Internal(): "
1174  "Unable to connect ipv6L3Protocol \"Tx\"");
1175  result = ipv6L3Protocol->TraceConnectWithoutContext ("Rx",
1177  NS_ASSERT_MSG (result == true, "InternetStackHelper::EnableAsciiIpv6Internal(): "
1178  "Unable to connect ipv6L3Protocol \"Rx\"");
1179  }
1180 
1181  g_interfaceStreamMapIpv6[std::make_pair (ipv6, interface)] = theStream;
1182  return;
1183  }
1184 
1185  //
1186  // If we are provided an OutputStreamWrapper, we are expected to use it, and
1187  // to provide a context. We are free to come up with our own context if we
1188  // want, and use the AsciiTraceHelper Hook*WithContext functions, but for
1189  // compatibility and simplicity, we just use Config::Connect and let it deal
1190  // with the context.
1191  //
1192  // We need to associate the ipv4/interface with a stream to express interest
1193  // in tracing events on that pair, however, we only hook the trace sources
1194  // once to avoid multiple trace sink calls per event (connect is independent
1195  // of interface).
1196  //
1197  if (!AsciiHooked (ipv6))
1198  {
1199  Ptr<Node> node = ipv6->GetObject<Node> ();
1200  std::ostringstream oss;
1201 
1202  oss.str ("");
1203  oss << "/NodeList/" << node->GetId () << "/$ns3::Ipv6L3Protocol/Drop";
1205  oss.str ("");
1206  oss << "/NodeList/" << node->GetId () << "/$ns3::Ipv6L3Protocol/Tx";
1208  oss.str ("");
1209  oss << "/NodeList/" << node->GetId () << "/$ns3::Ipv6L3Protocol/Rx";
1211  }
1212 
1213  g_interfaceStreamMapIpv6[std::make_pair (ipv6, interface)] = stream;
1214 }
1215 
1216 } // namespace ns3
An implementation of the ARP protocol.
Manage ASCII trace files for device models.
Definition: trace-helper.h:163
void HookDefaultDropSinkWithoutContext(Ptr< T > object, std::string traceName, Ptr< OutputStreamWrapper > stream)
Hook a trace source to the default drop operation trace sink that does not accept nor log a trace con...
Definition: trace-helper.h:484
static void DefaultDropSinkWithContext(Ptr< OutputStreamWrapper > file, std::string context, Ptr< const Packet > p)
Basic Drop default trace sink.
std::string GetFilenameFromInterfacePair(std::string prefix, Ptr< Object > object, uint32_t interface, bool useObjectNames=true)
Let the ascii trace helper figure out a reasonable filename to use for an ascii trace file associated...
Ptr< OutputStreamWrapper > CreateFileStream(std::string filename, std::ios::openmode filemode=std::ios::out)
Create and initialize an output stream object we'll use to write the traced bits.
An interface aggregated to a node to provide global routing info.
An implementation of the ICMPv6 protocol.
aggregate IP/TCP/UDP functionality to existing Nodes.
void SetIpv4StackInstall(bool enable)
Enable/disable IPv4 stack install.
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
void SetIpv4ArpJitter(bool enable)
Enable/disable IPv4 ARP Jitter.
void Reset(void)
Return helper internal state to that of a newly constructed one.
virtual void EnablePcapIpv6Internal(std::string prefix, Ptr< Ipv6 > ipv6, uint32_t interface, bool explicitFilename)
Enable pcap output the indicated Ipv6 and interface pair.
bool m_ipv6Enabled
IPv6 install state (enabled/disabled) ?
void SetRoutingHelper(const Ipv4RoutingHelper &routing)
bool m_ipv6NsRsJitterEnabled
IPv6 IPv6 NS and RS Jitter state (enabled/disabled) ?
bool AsciiHooked(Ptr< Ipv4 > ipv4)
checks if there is an hook to an ascii output stream
void Initialize(void)
Initialize the helper to its default values.
bool m_ipv4Enabled
IPv4 install state (enabled/disabled) ?
const Ipv4RoutingHelper * m_routing
IPv4 routing helper.
void InstallAll(void) const
Aggregate IPv4, IPv6, UDP, and TCP stacks to all nodes in the simulation.
void SetIpv6StackInstall(bool enable)
Enable/disable IPv6 stack install.
int64_t AssignStreams(NodeContainer c, int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
static void CreateAndAggregateObjectFromTypeId(Ptr< Node > node, const std::string typeId)
create an object from its TypeId and aggregates it to the node
ObjectFactory m_tcpFactory
TCP objects factory.
virtual void EnableAsciiIpv6Internal(Ptr< OutputStreamWrapper > stream, std::string prefix, Ptr< Ipv6 > ipv6, uint32_t interface, bool explicitFilename)
Enable ascii trace output on the indicated Ipv6 and interface pair.
void SetIpv6NsRsJitter(bool enable)
Enable/disable IPv6 NS and RS Jitter.
bool PcapHooked(Ptr< Ipv4 > ipv4)
checks if there is an hook to a Pcap wrapper
bool m_ipv4ArpJitterEnabled
IPv4 ARP Jitter state (enabled/disabled) ?
InternetStackHelper(void)
Create a new InternetStackHelper which uses a mix of static routing and global routing by default.
const Ipv6RoutingHelper * m_routingv6
IPv6 routing helper.
virtual void EnableAsciiIpv4Internal(Ptr< OutputStreamWrapper > stream, std::string prefix, Ptr< Ipv4 > ipv4, uint32_t interface, bool explicitFilename)
Enable ascii trace output on the indicated Ipv4 and interface pair.
InternetStackHelper & operator=(const InternetStackHelper &o)
Copy constructor.
void SetTcp(std::string tid)
set the Tcp stack which will not need any other parameter.
virtual ~InternetStackHelper(void)
Destroy the InternetStackHelper.
virtual void EnablePcapIpv4Internal(std::string prefix, Ptr< Ipv4 > ipv4, uint32_t interface, bool explicitFilename)
Enable pcap output the indicated Ipv4 and interface pair.
Helper class that adds ns3::Ipv4GlobalRouting objects.
Packet header for IPv4.
Definition: ipv4-header.h:34
Access to the IPv4 forwarding table, interfaces, and configuration.
Definition: ipv4.h:77
Implement the IPv4 layer.
DropReason
Reason why a packet has been dropped.
Helper class that adds ns3::Ipv4ListRouting objects.
void Add(const Ipv4RoutingHelper &routing, int16_t priority)
a factory to create ns3::Ipv4RoutingProtocol objects
virtual Ptr< Ipv4RoutingProtocol > Create(Ptr< Node > node) const =0
virtual Ipv4RoutingHelper * Copy(void) const =0
virtual constructor
Helper class that adds ns3::Ipv4StaticRouting objects.
Demultiplexes IPv6 extensions.
static const uint8_t EXT_NUMBER
Fragmentation extension number.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Packet header for IPv6.
Definition: ipv6-header.h:36
Access to the IPv6 forwarding table, interfaces, and configuration.
Definition: ipv6.h:82
IPv6 layer implementation.
DropReason
Reason why a packet has been dropped.
A factory to create ns3::Ipv6RoutingProtocol objects.
virtual Ipv6RoutingHelper * Copy(void) const =0
virtual constructor
virtual Ptr< Ipv6RoutingProtocol > Create(Ptr< Node > node) const =0
Helper class that adds ns3::Ipv6StaticRouting objects.
keep track of a set of node pointers.
Iterator Begin(void) const
Get an iterator which refers to the first Node in the container.
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container.
static NodeContainer GetGlobal(void)
Create a NodeContainer that contains a list of all nodes created through NodeContainer::Create() and ...
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
A network Node.
Definition: node.h:57
uint32_t GetId(void) const
Definition: node.cc:109
Instantiate subclasses of ns3::Object.
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
A base class which provides memory management and object aggregation.
Definition: object.h:88
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:470
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
Definition: object.cc:252
std::ostream * GetStream(void)
Return a pointer to an ostream previously set in the wrapper.
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:256
static void EnablePrinting(void)
Enable printing packets metadata.
Definition: packet.cc:572
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
Definition: packet.cc:121
Manage pcap files for device models.
Definition: trace-helper.h:39
Ptr< PcapFileWrapper > CreateFile(std::string filename, std::ios::openmode filemode, DataLinkType dataLinkType, uint32_t snapLen=std::numeric_limits< uint32_t >::max(), int32_t tzCorrection=0)
Create and initialize a pcap file.
Definition: trace-helper.cc:49
std::string GetFilenameFromInterfacePair(std::string prefix, Ptr< Object > object, uint32_t interface, bool useObjectNames=true)
Let the pcap helper figure out a reasonable filename to use for the pcap file associated with a node.
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:195
Hold variables of type string.
Definition: string.h:41
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:379
Introspection did not find any typical Config paths.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:67
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:88
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:920
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:165
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:281
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument.
Definition: callback.h:1709
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::pair< Ptr< Ipv6 >, uint32_t > InterfacePairIpv6
Ipv6/interface pair.
static void Ipv6L3ProtocolRxTxSink(Ptr< const Packet > p, Ptr< Ipv6 > ipv6, uint32_t interface)
Sync function for IPv6 packet - Pcap output.
static void Ipv6L3ProtocolDropSinkWithContext(Ptr< OutputStreamWrapper > stream, std::string context, Ipv6Header const &header, Ptr< const Packet > packet, Ipv6L3Protocol::DropReason reason, Ptr< Ipv6 > ipv6, uint32_t interface)
Sync function for IPv6 dropped packet - Ascii output.
std::map< InterfacePairIpv4, Ptr< OutputStreamWrapper > > InterfaceStreamMapIpv4
Ipv4/interface and output stream container.
static void Ipv4L3ProtocolRxTxSink(Ptr< const Packet > p, Ptr< Ipv4 > ipv4, uint32_t interface)
Sync function for IPv4 packet - Pcap output.
static void Ipv6L3ProtocolRxSinkWithContext(Ptr< OutputStreamWrapper > stream, std::string context, Ptr< const Packet > packet, Ptr< Ipv6 > ipv6, uint32_t interface)
Sync function for IPv6 received packet - Ascii output.
std::map< InterfacePairIpv6, Ptr< OutputStreamWrapper > > InterfaceStreamMapIpv6
Ipv6/interface and output stream container.
static InterfaceStreamMapIpv6 g_interfaceStreamMapIpv6
A mapping of Ipv6/interface pairs to pcap files.
static void Ipv6L3ProtocolDropSinkWithoutContext(Ptr< OutputStreamWrapper > stream, Ipv6Header const &header, Ptr< const Packet > packet, Ipv6L3Protocol::DropReason reason, Ptr< Ipv6 > ipv6, uint32_t interface)
Sync function for IPv6 dropped packet - Ascii output.
std::map< InterfacePairIpv6, Ptr< PcapFileWrapper > > InterfaceFileMapIpv6
Ipv6/interface and Pcap file wrapper container.
std::pair< Ptr< Ipv4 >, uint32_t > InterfacePairIpv4
Ipv4/interface pair.
static void Ipv4L3ProtocolRxSinkWithContext(Ptr< OutputStreamWrapper > stream, std::string context, Ptr< const Packet > packet, Ptr< Ipv4 > ipv4, uint32_t interface)
Sync function for IPv4 received packet - Ascii output.
static void Ipv4L3ProtocolDropSinkWithoutContext(Ptr< OutputStreamWrapper > stream, Ipv4Header const &header, Ptr< const Packet > packet, Ipv4L3Protocol::DropReason reason, Ptr< Ipv4 > ipv4, uint32_t interface)
Sync function for IPv4 dropped packet - Ascii output.
static void Ipv6L3ProtocolTxSinkWithContext(Ptr< OutputStreamWrapper > stream, std::string context, Ptr< const Packet > packet, Ptr< Ipv6 > ipv6, uint32_t interface)
Sync function for IPv6 transmitted packet - Ascii output.
std::map< InterfacePairIpv4, Ptr< PcapFileWrapper > > InterfaceFileMapIpv4
Ipv4/interface and Pcap file wrapper container.
static void Ipv4L3ProtocolDropSinkWithContext(Ptr< OutputStreamWrapper > stream, std::string context, Ipv4Header const &header, Ptr< const Packet > packet, Ipv4L3Protocol::DropReason reason, Ptr< Ipv4 > ipv4, uint32_t interface)
Sync function for IPv4 dropped packet - Ascii output.
static void Ipv4L3ProtocolRxSinkWithoutContext(Ptr< OutputStreamWrapper > stream, Ptr< const Packet > packet, Ptr< Ipv4 > ipv4, uint32_t interface)
Sync function for IPv4 received packet - Ascii output.
static InterfaceFileMapIpv4 g_interfaceFileMapIpv4
A mapping of Ipv4/interface pairs to pcap files.
static InterfaceStreamMapIpv4 g_interfaceStreamMapIpv4
A mapping of Ipv4/interface pairs to ascii streams.
static void Ipv4L3ProtocolTxSinkWithoutContext(Ptr< OutputStreamWrapper > stream, Ptr< const Packet > packet, Ptr< Ipv4 > ipv4, uint32_t interface)
Sync function for IPv4 transmitted packet - Ascii output.
static InterfaceFileMapIpv6 g_interfaceFileMapIpv6
A mapping of Ipv6/interface pairs to pcap files.
static void Ipv4L3ProtocolTxSinkWithContext(Ptr< OutputStreamWrapper > stream, std::string context, Ptr< const Packet > packet, Ptr< Ipv4 > ipv4, uint32_t interface)
Sync function for IPv4 transmitted packet - Ascii output.
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition: callback.h:1648
static void Ipv6L3ProtocolRxSinkWithoutContext(Ptr< OutputStreamWrapper > stream, Ptr< const Packet > packet, Ptr< Ipv6 > ipv6, uint32_t interface)
Sync function for IPv6 received packet - Ascii output.
static void Ipv6L3ProtocolTxSinkWithoutContext(Ptr< OutputStreamWrapper > stream, Ptr< const Packet > packet, Ptr< Ipv6 > ipv6, uint32_t interface)
Sync function for IPv6 transmitted packet - Ascii output.