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
261 InternetStackHelper::SetTcp (std::string tid, std::string n0, const AttributeValue &v0)
262 {
263  m_tcpFactory.SetTypeId (tid);
264  m_tcpFactory.Set (n0,v0);
265 }
266 
267 void
269 {
270  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
271  {
272  Install (*i);
273  }
274 }
275 
276 void
278 {
280 }
281 
282 void
284 {
285  ObjectFactory factory;
286  factory.SetTypeId (typeId);
287  Ptr<Object> protocol = factory.Create <Object> ();
288  node->AggregateObject (protocol);
289 }
290 
291 void
293 {
294  if (m_ipv4Enabled)
295  {
296  if (node->GetObject<Ipv4> () != 0)
297  {
298  NS_FATAL_ERROR ("InternetStackHelper::Install (): Aggregating "
299  "an InternetStack to a node with an existing Ipv4 object");
300  return;
301  }
302 
303  CreateAndAggregateObjectFromTypeId (node, "ns3::ArpL3Protocol");
304  CreateAndAggregateObjectFromTypeId (node, "ns3::Ipv4L3Protocol");
305  CreateAndAggregateObjectFromTypeId (node, "ns3::Icmpv4L4Protocol");
306  if (m_ipv4ArpJitterEnabled == false)
307  {
309  NS_ASSERT (arp);
310  arp->SetAttribute ("RequestJitter", StringValue ("ns3::ConstantRandomVariable[Constant=0.0]"));
311  }
312  // Set routing
313  Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> ();
314  Ptr<Ipv4RoutingProtocol> ipv4Routing = m_routing->Create (node);
315  ipv4->SetRoutingProtocol (ipv4Routing);
316  }
317 
318  if (m_ipv6Enabled)
319  {
320  /* IPv6 stack */
321  if (node->GetObject<Ipv6> () != 0)
322  {
323  NS_FATAL_ERROR ("InternetStackHelper::Install (): Aggregating "
324  "an InternetStack to a node with an existing Ipv6 object");
325  return;
326  }
327 
328  CreateAndAggregateObjectFromTypeId (node, "ns3::Ipv6L3Protocol");
329  CreateAndAggregateObjectFromTypeId (node, "ns3::Icmpv6L4Protocol");
330  if (m_ipv6NsRsJitterEnabled == false)
331  {
332  Ptr<Icmpv6L4Protocol> icmpv6l4 = node->GetObject<Icmpv6L4Protocol> ();
333  NS_ASSERT (icmpv6l4);
334  icmpv6l4->SetAttribute ("SolicitationJitter", StringValue ("ns3::ConstantRandomVariable[Constant=0.0]"));
335  }
336  // Set routing
337  Ptr<Ipv6> ipv6 = node->GetObject<Ipv6> ();
338  Ptr<Ipv6RoutingProtocol> ipv6Routing = m_routingv6->Create (node);
339  ipv6->SetRoutingProtocol (ipv6Routing);
340 
341  /* register IPv6 extensions and options */
342  ipv6->RegisterExtensions ();
343  ipv6->RegisterOptions ();
344  }
345 
347  {
348  CreateAndAggregateObjectFromTypeId (node, "ns3::TrafficControlLayer");
349  CreateAndAggregateObjectFromTypeId (node, "ns3::UdpL4Protocol");
351  Ptr<PacketSocketFactory> factory = CreateObject<PacketSocketFactory> ();
352  node->AggregateObject (factory);
353  }
354 
355  if (m_ipv4Enabled)
356  {
359  NS_ASSERT (arp);
360  NS_ASSERT (tc);
361  arp->SetTrafficControl (tc);
362  }
363 }
364 
365 void
366 InternetStackHelper::Install (std::string nodeName) const
367 {
368  Ptr<Node> node = Names::Find<Node> (nodeName);
369  Install (node);
370 }
371 
378 static void
380 {
381  NS_LOG_FUNCTION (p << ipv4 << interface);
382 
383  //
384  // Since trace sources are independent of interface, if we hook a source
385  // on a particular protocol we will get traces for all of its interfaces.
386  // We need to filter this to only report interfaces for which the user
387  // has expressed interest.
388  //
389  InterfacePairIpv4 pair = std::make_pair (ipv4, interface);
390  if (g_interfaceFileMapIpv4.find (pair) == g_interfaceFileMapIpv4.end ())
391  {
392  NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
393  return;
394  }
395 
397  file->Write (Simulator::Now (), p);
398 }
399 
400 bool
402 {
403  for ( InterfaceFileMapIpv4::const_iterator i = g_interfaceFileMapIpv4.begin ();
404  i != g_interfaceFileMapIpv4.end ();
405  ++i)
406  {
407  if ((*i).first.first == ipv4)
408  {
409  return true;
410  }
411  }
412  return false;
413 }
414 
415 void
416 InternetStackHelper::EnablePcapIpv4Internal (std::string prefix, Ptr<Ipv4> ipv4, uint32_t interface, bool explicitFilename)
417 {
418  NS_LOG_FUNCTION (prefix << ipv4 << interface);
419 
420  if (!m_ipv4Enabled)
421  {
422  NS_LOG_INFO ("Call to enable Ipv4 pcap tracing but Ipv4 not enabled");
423  return;
424  }
425 
426  //
427  // We have to create a file and a mapping from protocol/interface to file
428  // irrespective of how many times we want to trace a particular protocol.
429  //
430  PcapHelper pcapHelper;
431 
432  std::string filename;
433  if (explicitFilename)
434  {
435  filename = prefix;
436  }
437  else
438  {
439  filename = pcapHelper.GetFilenameFromInterfacePair (prefix, ipv4, interface);
440  }
441 
442  Ptr<PcapFileWrapper> file = pcapHelper.CreateFile (filename, std::ios::out, PcapHelper::DLT_RAW);
443 
444  //
445  // However, we only hook the trace source once to avoid multiple trace sink
446  // calls per event (connect is independent of interface).
447  //
448  if (!PcapHooked (ipv4))
449  {
450  //
451  // Ptr<Ipv4> is aggregated to node and Ipv4L3Protocol is aggregated to
452  // node so we can get to Ipv4L3Protocol through Ipv4.
453  //
454  Ptr<Ipv4L3Protocol> ipv4L3Protocol = ipv4->GetObject<Ipv4L3Protocol> ();
455  NS_ASSERT_MSG (ipv4L3Protocol, "InternetStackHelper::EnablePcapIpv4Internal(): "
456  "m_ipv4Enabled and ipv4L3Protocol inconsistent");
457 
458  bool result = ipv4L3Protocol->TraceConnectWithoutContext ("Tx", MakeCallback (&Ipv4L3ProtocolRxTxSink));
459  NS_ASSERT_MSG (result == true, "InternetStackHelper::EnablePcapIpv4Internal(): "
460  "Unable to connect ipv4L3Protocol \"Tx\"");
461 
462  result = ipv4L3Protocol->TraceConnectWithoutContext ("Rx", MakeCallback (&Ipv4L3ProtocolRxTxSink));
463  NS_ASSERT_MSG (result == true, "InternetStackHelper::EnablePcapIpv4Internal(): "
464  "Unable to connect ipv4L3Protocol \"Rx\"");
465  }
466 
467  g_interfaceFileMapIpv4[std::make_pair (ipv4, interface)] = file;
468 }
469 
476 static void
478 {
479  NS_LOG_FUNCTION (p << ipv6 << interface);
480 
481  //
482  // Since trace sources are independent of interface, if we hook a source
483  // on a particular protocol we will get traces for all of its interfaces.
484  // We need to filter this to only report interfaces for which the user
485  // has expressed interest.
486  //
487  InterfacePairIpv6 pair = std::make_pair (ipv6, interface);
488  if (g_interfaceFileMapIpv6.find (pair) == g_interfaceFileMapIpv6.end ())
489  {
490  NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
491  return;
492  }
493 
495  file->Write (Simulator::Now (), p);
496 }
497 
498 bool
500 {
501  for ( InterfaceFileMapIpv6::const_iterator i = g_interfaceFileMapIpv6.begin ();
502  i != g_interfaceFileMapIpv6.end ();
503  ++i)
504  {
505  if ((*i).first.first == ipv6)
506  {
507  return true;
508  }
509  }
510  return false;
511 }
512 
513 void
514 InternetStackHelper::EnablePcapIpv6Internal (std::string prefix, Ptr<Ipv6> ipv6, uint32_t interface, bool explicitFilename)
515 {
516  NS_LOG_FUNCTION (prefix << ipv6 << interface);
517 
518  if (!m_ipv6Enabled)
519  {
520  NS_LOG_INFO ("Call to enable Ipv6 pcap tracing but Ipv6 not enabled");
521  return;
522  }
523 
524  //
525  // We have to create a file and a mapping from protocol/interface to file
526  // irrespective of how many times we want to trace a particular protocol.
527  //
528  PcapHelper pcapHelper;
529 
530  std::string filename;
531  if (explicitFilename)
532  {
533  filename = prefix;
534  }
535  else
536  {
537  filename = pcapHelper.GetFilenameFromInterfacePair (prefix, ipv6, interface);
538  }
539 
540  Ptr<PcapFileWrapper> file = pcapHelper.CreateFile (filename, std::ios::out, PcapHelper::DLT_RAW);
541 
542  //
543  // However, we only hook the trace source once to avoid multiple trace sink
544  // calls per event (connect is independent of interface).
545  //
546  if (!PcapHooked (ipv6))
547  {
548  //
549  // Ptr<Ipv6> is aggregated to node and Ipv6L3Protocol is aggregated to
550  // node so we can get to Ipv6L3Protocol through Ipv6.
551  //
552  Ptr<Ipv6L3Protocol> ipv6L3Protocol = ipv6->GetObject<Ipv6L3Protocol> ();
553  NS_ASSERT_MSG (ipv6L3Protocol, "InternetStackHelper::EnablePcapIpv6Internal(): "
554  "m_ipv6Enabled and ipv6L3Protocol inconsistent");
555 
556  bool result = ipv6L3Protocol->TraceConnectWithoutContext ("Tx", MakeCallback (&Ipv6L3ProtocolRxTxSink));
557  NS_ASSERT_MSG (result == true, "InternetStackHelper::EnablePcapIpv6Internal(): "
558  "Unable to connect ipv6L3Protocol \"Tx\"");
559 
560  result = ipv6L3Protocol->TraceConnectWithoutContext ("Rx", MakeCallback (&Ipv6L3ProtocolRxTxSink));
561  NS_ASSERT_MSG (result == true, "InternetStackHelper::EnablePcapIpv6Internal(): "
562  "Unable to connect ipv6L3Protocol \"Rx\"");
563  }
564 
565  g_interfaceFileMapIpv6[std::make_pair (ipv6, interface)] = file;
566 }
567 
577 static void
580  Ipv4Header const &header,
581  Ptr<const Packet> packet,
583  Ptr<Ipv4> ipv4,
584  uint32_t interface)
585 {
586  //
587  // Since trace sources are independent of interface, if we hook a source
588  // on a particular protocol we will get traces for all of its interfaces.
589  // We need to filter this to only report interfaces for which the user
590  // has expressed interest.
591  //
592  InterfacePairIpv4 pair = std::make_pair (ipv4, interface);
593  if (g_interfaceStreamMapIpv4.find (pair) == g_interfaceStreamMapIpv4.end ())
594  {
595  NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
596  return;
597  }
598 
599  Ptr<Packet> p = packet->Copy ();
600  p->AddHeader (header);
601  *stream->GetStream () << "d " << Simulator::Now ().GetSeconds () << " " << *p << std::endl;
602 }
603 
611 static void
614  Ptr<const Packet> packet,
615  Ptr<Ipv4> ipv4,
616  uint32_t interface)
617 {
618  InterfacePairIpv4 pair = std::make_pair (ipv4, interface);
619  if (g_interfaceStreamMapIpv4.find (pair) == g_interfaceStreamMapIpv4.end ())
620  {
621  NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
622  return;
623  }
624 
625  *stream->GetStream () << "t " << Simulator::Now ().GetSeconds () << " " << *packet << std::endl;
626 }
627 
635 static void
638  Ptr<const Packet> packet,
639  Ptr<Ipv4> ipv4,
640  uint32_t interface)
641 {
642  InterfacePairIpv4 pair = std::make_pair (ipv4, interface);
643  if (g_interfaceStreamMapIpv4.find (pair) == g_interfaceStreamMapIpv4.end ())
644  {
645  NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
646  return;
647  }
648 
649  *stream->GetStream () << "r " << Simulator::Now ().GetSeconds () << " " << *packet << std::endl;
650 }
651 
662 static void
665  std::string context,
666  Ipv4Header const &header,
667  Ptr<const Packet> packet,
669  Ptr<Ipv4> ipv4,
670  uint32_t interface)
671 {
672  //
673  // Since trace sources are independent of interface, if we hook a source
674  // on a particular protocol we will get traces for all of its interfaces.
675  // We need to filter this to only report interfaces for which the user
676  // has expressed interest.
677  //
678  InterfacePairIpv4 pair = std::make_pair (ipv4, interface);
679  if (g_interfaceStreamMapIpv4.find (pair) == g_interfaceStreamMapIpv4.end ())
680  {
681  NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
682  return;
683  }
684 
685  Ptr<Packet> p = packet->Copy ();
686  p->AddHeader (header);
687 #ifdef INTERFACE_CONTEXT
688  *stream->GetStream () << "d " << Simulator::Now ().GetSeconds () << " " << context << "(" << interface << ") "
689  << *p << std::endl;
690 #else
691  *stream->GetStream () << "d " << Simulator::Now ().GetSeconds () << " " << context << " " << *p << std::endl;
692 #endif
693 }
694 
703 static void
706  std::string context,
707  Ptr<const Packet> packet,
708  Ptr<Ipv4> ipv4,
709  uint32_t interface)
710 {
711  InterfacePairIpv4 pair = std::make_pair (ipv4, interface);
712  if (g_interfaceStreamMapIpv4.find (pair) == g_interfaceStreamMapIpv4.end ())
713  {
714  NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
715  return;
716  }
717 
718 #ifdef INTERFACE_CONTEXT
719  *stream->GetStream () << "t " << Simulator::Now ().GetSeconds () << " " << context << "(" << interface << ") "
720  << *packet << std::endl;
721 #else
722  *stream->GetStream () << "t " << Simulator::Now ().GetSeconds () << " " << context << " " << *packet << std::endl;
723 #endif
724 }
725 
734 static void
737  std::string context,
738  Ptr<const Packet> packet,
739  Ptr<Ipv4> ipv4,
740  uint32_t interface)
741 {
742  InterfacePairIpv4 pair = std::make_pair (ipv4, interface);
743  if (g_interfaceStreamMapIpv4.find (pair) == g_interfaceStreamMapIpv4.end ())
744  {
745  NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
746  return;
747  }
748 
749 #ifdef INTERFACE_CONTEXT
750  *stream->GetStream () << "r " << Simulator::Now ().GetSeconds () << " " << context << "(" << interface << ") "
751  << *packet << std::endl;
752 #else
753  *stream->GetStream () << "r " << Simulator::Now ().GetSeconds () << " " << context << " " << *packet << std::endl;
754 #endif
755 }
756 
757 bool
759 {
760  for ( InterfaceStreamMapIpv4::const_iterator i = g_interfaceStreamMapIpv4.begin ();
761  i != g_interfaceStreamMapIpv4.end ();
762  ++i)
763  {
764  if ((*i).first.first == ipv4)
765  {
766  return true;
767  }
768  }
769  return false;
770 }
771 
772 void
774  Ptr<OutputStreamWrapper> stream,
775  std::string prefix,
776  Ptr<Ipv4> ipv4,
777  uint32_t interface,
778  bool explicitFilename)
779 {
780  if (!m_ipv4Enabled)
781  {
782  NS_LOG_INFO ("Call to enable Ipv4 ascii tracing but Ipv4 not enabled");
783  return;
784  }
785 
786  //
787  // Our trace sinks are going to use packet printing, so we have to
788  // make sure that is turned on.
789  //
791 
792  //
793  // If we are not provided an OutputStreamWrapper, we are expected to create
794  // one using the usual trace filename conventions and hook WithoutContext
795  // since there will be one file per context and therefore the context would
796  // be redundant.
797  //
798  if (stream == 0)
799  {
800  //
801  // Set up an output stream object to deal with private ofstream copy
802  // constructor and lifetime issues. Let the helper decide the actual
803  // name of the file given the prefix.
804  //
805  // We have to create a stream and a mapping from protocol/interface to
806  // stream irrespective of how many times we want to trace a particular
807  // protocol.
808  //
809  AsciiTraceHelper asciiTraceHelper;
810 
811  std::string filename;
812  if (explicitFilename)
813  {
814  filename = prefix;
815  }
816  else
817  {
818  filename = asciiTraceHelper.GetFilenameFromInterfacePair (prefix, ipv4, interface);
819  }
820 
821  Ptr<OutputStreamWrapper> theStream = asciiTraceHelper.CreateFileStream (filename);
822 
823  //
824  // However, we only hook the trace sources once to avoid multiple trace sink
825  // calls per event (connect is independent of interface).
826  //
827  if (!AsciiHooked (ipv4))
828  {
829  //
830  // We can use the default drop sink for the ArpL3Protocol since it has
831  // the usual signature. We can get to the Ptr<ArpL3Protocol> through
832  // our Ptr<Ipv4> since they must both be aggregated to the same node.
833  //
834  Ptr<ArpL3Protocol> arpL3Protocol = ipv4->GetObject<ArpL3Protocol> ();
835  asciiTraceHelper.HookDefaultDropSinkWithoutContext<ArpL3Protocol> (arpL3Protocol, "Drop", theStream);
836 
837  //
838  // The drop sink for the Ipv4L3Protocol uses a different signature than
839  // the default sink, so we have to cook one up for ourselves. We can get
840  // to the Ptr<Ipv4L3Protocol> through our Ptr<Ipv4> since they must both
841  // be aggregated to the same node.
842  //
843  Ptr<Ipv4L3Protocol> ipv4L3Protocol = ipv4->GetObject<Ipv4L3Protocol> ();
844  bool result = ipv4L3Protocol->TraceConnectWithoutContext ("Drop",
846  NS_ASSERT_MSG (result == true, "InternetStackHelper::EnableAsciiIpv4Internal(): "
847  "Unable to connect ipv4L3Protocol \"Drop\"");
848  result = ipv4L3Protocol->TraceConnectWithoutContext ("Tx",
850  NS_ASSERT_MSG (result == true, "InternetStackHelper::EnableAsciiIpv4Internal(): "
851  "Unable to connect ipv4L3Protocol \"Tx\"");
852  result = ipv4L3Protocol->TraceConnectWithoutContext ("Rx",
854  NS_ASSERT_MSG (result == true, "InternetStackHelper::EnableAsciiIpv4Internal(): "
855  "Unable to connect ipv4L3Protocol \"Rx\"");
856  }
857 
858  g_interfaceStreamMapIpv4[std::make_pair (ipv4, interface)] = theStream;
859  return;
860  }
861 
862  //
863  // If we are provided an OutputStreamWrapper, we are expected to use it, and
864  // to provide a context. We are free to come up with our own context if we
865  // want, and use the AsciiTraceHelper Hook*WithContext functions, but for
866  // compatibility and simplicity, we just use Config::Connect and let it deal
867  // with the context.
868  //
869  // We need to associate the ipv4/interface with a stream to express interest
870  // in tracing events on that pair, however, we only hook the trace sources
871  // once to avoid multiple trace sink calls per event (connect is independent
872  // of interface).
873  //
874  if (!AsciiHooked (ipv4))
875  {
876  Ptr<Node> node = ipv4->GetObject<Node> ();
877  std::ostringstream oss;
878 
879  //
880  // For the ARP Drop, we are going to use the default trace sink provided by
881  // the ascii trace helper. There is actually no AsciiTraceHelper in sight
882  // here, but the default trace sinks are actually publicly available static
883  // functions that are always there waiting for just such a case.
884  //
885  oss << "/NodeList/" << node->GetId () << "/$ns3::ArpL3Protocol/Drop";
887 
888  //
889  // This has all kinds of parameters coming with, so we have to cook up our
890  // own sink.
891  //
892  oss.str ("");
893  oss << "/NodeList/" << node->GetId () << "/$ns3::Ipv4L3Protocol/Drop";
895  oss.str ("");
896  oss << "/NodeList/" << node->GetId () << "/$ns3::Ipv4L3Protocol/Tx";
898  oss.str ("");
899  oss << "/NodeList/" << node->GetId () << "/$ns3::Ipv4L3Protocol/Rx";
901  }
902 
903  g_interfaceStreamMapIpv4[std::make_pair (ipv4, interface)] = stream;
904 }
905 
915 static void
918  Ipv6Header const &header,
919  Ptr<const Packet> packet,
921  Ptr<Ipv6> ipv6,
922  uint32_t interface)
923 {
924  //
925  // Since trace sources are independent of interface, if we hook a source
926  // on a particular protocol we will get traces for all of its interfaces.
927  // We need to filter this to only report interfaces for which the user
928  // has expressed interest.
929  //
930  InterfacePairIpv6 pair = std::make_pair (ipv6, interface);
931  if (g_interfaceStreamMapIpv6.find (pair) == g_interfaceStreamMapIpv6.end ())
932  {
933  NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
934  return;
935  }
936 
937  Ptr<Packet> p = packet->Copy ();
938  p->AddHeader (header);
939  *stream->GetStream () << "d " << Simulator::Now ().GetSeconds () << " " << *p << std::endl;
940 }
941 
949 static void
952  Ptr<const Packet> packet,
953  Ptr<Ipv6> ipv6,
954  uint32_t interface)
955 {
956  InterfacePairIpv6 pair = std::make_pair (ipv6, interface);
957  if (g_interfaceStreamMapIpv6.find (pair) == g_interfaceStreamMapIpv6.end ())
958  {
959  NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
960  return;
961  }
962 
963  *stream->GetStream () << "t " << Simulator::Now ().GetSeconds () << " " << *packet << std::endl;
964 }
965 
973 static void
976  Ptr<const Packet> packet,
977  Ptr<Ipv6> ipv6,
978  uint32_t interface)
979 {
980  InterfacePairIpv6 pair = std::make_pair (ipv6, interface);
981  if (g_interfaceStreamMapIpv6.find (pair) == g_interfaceStreamMapIpv6.end ())
982  {
983  NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
984  return;
985  }
986 
987  *stream->GetStream () << "r " << Simulator::Now ().GetSeconds () << " " << *packet << std::endl;
988 }
989 
1000 static void
1002  Ptr<OutputStreamWrapper> stream,
1003  std::string context,
1004  Ipv6Header const &header,
1005  Ptr<const Packet> packet,
1007  Ptr<Ipv6> ipv6,
1008  uint32_t interface)
1009 {
1010  //
1011  // Since trace sources are independent of interface, if we hook a source
1012  // on a particular protocol we will get traces for all of its interfaces.
1013  // We need to filter this to only report interfaces for which the user
1014  // has expressed interest.
1015  //
1016  InterfacePairIpv6 pair = std::make_pair (ipv6, interface);
1017  if (g_interfaceStreamMapIpv6.find (pair) == g_interfaceStreamMapIpv6.end ())
1018  {
1019  NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
1020  return;
1021  }
1022 
1023  Ptr<Packet> p = packet->Copy ();
1024  p->AddHeader (header);
1025 #ifdef INTERFACE_CONTEXT
1026  *stream->GetStream () << "d " << Simulator::Now ().GetSeconds () << " " << context << "(" << interface << ") "
1027  << *p << std::endl;
1028 #else
1029  *stream->GetStream () << "d " << Simulator::Now ().GetSeconds () << " " << context << " " << *p << std::endl;
1030 #endif
1031 }
1032 
1041 static void
1043  Ptr<OutputStreamWrapper> stream,
1044  std::string context,
1045  Ptr<const Packet> packet,
1046  Ptr<Ipv6> ipv6,
1047  uint32_t interface)
1048 {
1049  InterfacePairIpv6 pair = std::make_pair (ipv6, interface);
1050  if (g_interfaceStreamMapIpv6.find (pair) == g_interfaceStreamMapIpv6.end ())
1051  {
1052  NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
1053  return;
1054  }
1055 
1056 #ifdef INTERFACE_CONTEXT
1057  *stream->GetStream () << "t " << Simulator::Now ().GetSeconds () << " " << context << "(" << interface << ") "
1058  << *packet << std::endl;
1059 #else
1060  *stream->GetStream () << "t " << Simulator::Now ().GetSeconds () << " " << context << " " << *packet << std::endl;
1061 #endif
1062 }
1063 
1072 static void
1074  Ptr<OutputStreamWrapper> stream,
1075  std::string context,
1076  Ptr<const Packet> packet,
1077  Ptr<Ipv6> ipv6,
1078  uint32_t interface)
1079 {
1080  InterfacePairIpv6 pair = std::make_pair (ipv6, interface);
1081  if (g_interfaceStreamMapIpv6.find (pair) == g_interfaceStreamMapIpv6.end ())
1082  {
1083  NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
1084  return;
1085  }
1086 
1087 #ifdef INTERFACE_CONTEXT
1088  *stream->GetStream () << "r " << Simulator::Now ().GetSeconds () << " " << context << "(" << interface << ") "
1089  << *packet << std::endl;
1090 #else
1091  *stream->GetStream () << "r " << Simulator::Now ().GetSeconds () << " " << context << " " << *packet << std::endl;
1092 #endif
1093 }
1094 
1095 bool
1097 {
1098  for ( InterfaceStreamMapIpv6::const_iterator i = g_interfaceStreamMapIpv6.begin ();
1099  i != g_interfaceStreamMapIpv6.end ();
1100  ++i)
1101  {
1102  if ((*i).first.first == ipv6)
1103  {
1104  return true;
1105  }
1106  }
1107  return false;
1108 }
1109 
1110 void
1112  Ptr<OutputStreamWrapper> stream,
1113  std::string prefix,
1114  Ptr<Ipv6> ipv6,
1115  uint32_t interface,
1116  bool explicitFilename)
1117 {
1118  if (!m_ipv6Enabled)
1119  {
1120  NS_LOG_INFO ("Call to enable Ipv6 ascii tracing but Ipv6 not enabled");
1121  return;
1122  }
1123 
1124  //
1125  // Our trace sinks are going to use packet printing, so we have to
1126  // make sure that is turned on.
1127  //
1129 
1130  //
1131  // If we are not provided an OutputStreamWrapper, we are expected to create
1132  // one using the usual trace filename conventions and do a hook WithoutContext
1133  // since there will be one file per context and therefore the context would
1134  // be redundant.
1135  //
1136  if (stream == 0)
1137  {
1138  //
1139  // Set up an output stream object to deal with private ofstream copy
1140  // constructor and lifetime issues. Let the helper decide the actual
1141  // name of the file given the prefix.
1142  //
1143  // We have to create a stream and a mapping from protocol/interface to
1144  // stream irrespective of how many times we want to trace a particular
1145  // protocol.
1146  //
1147  AsciiTraceHelper asciiTraceHelper;
1148 
1149  std::string filename;
1150  if (explicitFilename)
1151  {
1152  filename = prefix;
1153  }
1154  else
1155  {
1156  filename = asciiTraceHelper.GetFilenameFromInterfacePair (prefix, ipv6, interface);
1157  }
1158 
1159  Ptr<OutputStreamWrapper> theStream = asciiTraceHelper.CreateFileStream (filename);
1160 
1161  //
1162  // However, we only hook the trace sources once to avoid multiple trace sink
1163  // calls per event (connect is independent of interface).
1164  //
1165  if (!AsciiHooked (ipv6))
1166  {
1167  //
1168  // The drop sink for the Ipv6L3Protocol uses a different signature than
1169  // the default sink, so we have to cook one up for ourselves. We can get
1170  // to the Ptr<Ipv6L3Protocol> through our Ptr<Ipv6> since they must both
1171  // be aggregated to the same node.
1172  //
1173  Ptr<Ipv6L3Protocol> ipv6L3Protocol = ipv6->GetObject<Ipv6L3Protocol> ();
1174  bool result = ipv6L3Protocol->TraceConnectWithoutContext ("Drop",
1176  NS_ASSERT_MSG (result == true, "InternetStackHelper::EnableAsciiIpv6Internal(): "
1177  "Unable to connect ipv6L3Protocol \"Drop\"");
1178  result = ipv6L3Protocol->TraceConnectWithoutContext ("Tx",
1180  NS_ASSERT_MSG (result == true, "InternetStackHelper::EnableAsciiIpv6Internal(): "
1181  "Unable to connect ipv6L3Protocol \"Tx\"");
1182  result = ipv6L3Protocol->TraceConnectWithoutContext ("Rx",
1184  NS_ASSERT_MSG (result == true, "InternetStackHelper::EnableAsciiIpv6Internal(): "
1185  "Unable to connect ipv6L3Protocol \"Rx\"");
1186  }
1187 
1188  g_interfaceStreamMapIpv6[std::make_pair (ipv6, interface)] = theStream;
1189  return;
1190  }
1191 
1192  //
1193  // If we are provided an OutputStreamWrapper, we are expected to use it, and
1194  // to provide a context. We are free to come up with our own context if we
1195  // want, and use the AsciiTraceHelper Hook*WithContext functions, but for
1196  // compatibility and simplicity, we just use Config::Connect and let it deal
1197  // with the context.
1198  //
1199  // We need to associate the ipv4/interface with a stream to express interest
1200  // in tracing events on that pair, however, we only hook the trace sources
1201  // once to avoid multiple trace sink calls per event (connect is independent
1202  // of interface).
1203  //
1204  if (!AsciiHooked (ipv6))
1205  {
1206  Ptr<Node> node = ipv6->GetObject<Node> ();
1207  std::ostringstream oss;
1208 
1209  oss.str ("");
1210  oss << "/NodeList/" << node->GetId () << "/$ns3::Ipv6L3Protocol/Drop";
1212  oss.str ("");
1213  oss << "/NodeList/" << node->GetId () << "/$ns3::Ipv6L3Protocol/Tx";
1215  oss.str ("");
1216  oss << "/NodeList/" << node->GetId () << "/$ns3::Ipv6L3Protocol/Rx";
1218  }
1219 
1220  g_interfaceStreamMapIpv6[std::make_pair (ipv6, interface)] = stream;
1221 }
1222 
1223 } // namespace ns3
bool m_ipv4ArpJitterEnabled
IPv4 ARP Jitter state (enabled/disabled) ?
bool m_ipv6NsRsJitterEnabled
IPv6 IPv6 NS and RS Jitter state (enabled/disabled) ?
void InstallAll(void) const
Aggregate IPv4, IPv6, UDP, and TCP stacks to all nodes in the simulation.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
Manage ASCII trace files for device models.
Definition: trace-helper.h:161
Packet header for IPv6.
Definition: ipv6-header.h:34
virtual void EnablePcapIpv6Internal(std::string prefix, Ptr< Ipv6 > ipv6, uint32_t interface, bool explicitFilename)
Enable pcap output the indicated Ipv6 and interface pair.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
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.
uint32_t GetId(void) const
Definition: node.cc:107
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:483
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
NS_ASSERT_MSG(false, "Ipv4AddressGenerator::MaskToIndex(): Impossible")
Access to the IPv6 forwarding table, interfaces, and configuration.
Definition: ipv6.h:81
Hold variables of type string.
Definition: string.h:41
Introspection did not find any typical Config paths.
static const uint8_t EXT_NUMBER
Fragmentation extension number.
Hold a value for an Attribute.
Definition: attribute.h:68
void SetIpv4ArpJitter(bool enable)
Enable/disable IPv4 ARP Jitter.
Manage pcap files for device models.
Definition: trace-helper.h:38
IPv6 layer implementation.
Demultiplexes IPv6 extensions.
virtual Ipv4RoutingHelper * Copy(void) const =0
virtual constructor
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument.
Definition: callback.h:1686
static InterfaceFileMapIpv4 g_interfaceFileMapIpv4
A mapping of Ipv4/interface pairs to pcap files.
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
Definition: object.cc:252
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:355
ObjectFactory m_tcpFactory
TCP objects factory.
virtual Ipv6RoutingHelper * Copy(void) const =0
virtual constructor
#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
static void DefaultDropSinkWithContext(Ptr< OutputStreamWrapper > file, std::string context, Ptr< const Packet > p)
Basic Drop default trace sink.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:204
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
aggregate IP/TCP/UDP functionality to existing Nodes.
std::map< InterfacePairIpv6, Ptr< PcapFileWrapper > > InterfaceFileMapIpv6
Ipv6/interface and Pcap file wrapper container.
static void Ipv4L3ProtocolRxSinkWithoutContext(Ptr< OutputStreamWrapper > stream, Ptr< const Packet > packet, Ptr< Ipv4 > ipv4, uint32_t interface)
Sync function for IPv4 received packet - Ascii output.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:280
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.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:162
Ptr< OutputStreamWrapper > CreateFileStream(std::string filename, std::ios::openmode filemode=std::ios::out)
Create and initialize an output stream object we&#39;ll use to write the traced bits. ...
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container.
std::map< InterfacePairIpv6, Ptr< OutputStreamWrapper > > InterfaceStreamMapIpv6
Ipv6/interface and output stream container.
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
static InterfaceStreamMapIpv4 g_interfaceStreamMapIpv4
A mapping of Ipv4/interface pairs to ascii streams.
std::map< InterfacePairIpv4, Ptr< OutputStreamWrapper > > InterfaceStreamMapIpv4
Ipv4/interface and output stream container.
static void Ipv4L3ProtocolTxSinkWithoutContext(Ptr< OutputStreamWrapper > stream, Ptr< const Packet > packet, Ptr< Ipv4 > ipv4, uint32_t interface)
Sync function for IPv4 transmitted packet - Ascii output.
InternetStackHelper & operator=(const InternetStackHelper &o)
Copy constructor.
static void CreateAndAggregateObjectFromTypeId(Ptr< Node > node, const std::string typeId)
create an object from its TypeId and aggregates it to the node
DropReason
Reason why a packet has been dropped.
Packet header for IPv4.
Definition: ipv4-header.h:33
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.
virtual void EnablePcapIpv4Internal(std::string prefix, Ptr< Ipv4 > ipv4, uint32_t interface, bool explicitFilename)
Enable pcap output the indicated Ipv4 and interface pair.
static void EnablePrinting(void)
Enable printing packets metadata.
Definition: packet.cc:572
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
void SetIpv4StackInstall(bool enable)
Enable/disable IPv4 stack install.
static InterfaceFileMapIpv6 g_interfaceFileMapIpv6
A mapping of Ipv6/interface pairs to pcap files.
std::pair< Ptr< Ipv6 >, uint32_t > InterfacePairIpv6
Ipv6/interface pair.
A factory to create ns3::Ipv6RoutingProtocol objects.
void Reset(void)
Return helper internal state to that of a newly constructed one.
An implementation of the ICMPv6 protocol.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:1489
bool PcapHooked(Ptr< Ipv4 > ipv4)
checks if there is an hook to a Pcap wrapper
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...
bool m_ipv6Enabled
IPv6 install state (enabled/disabled) ?
a factory to create ns3::Ipv4RoutingProtocol objects
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:871
static void Ipv6L3ProtocolTxSinkWithoutContext(Ptr< OutputStreamWrapper > stream, Ptr< const Packet > packet, Ptr< Ipv6 > ipv6, uint32_t interface)
Sync function for IPv6 transmitted 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.
Access to the IPv4 forwarding table, interfaces, and configuration.
Definition: ipv4.h:76
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:459
virtual Ptr< Ipv6RoutingProtocol > Create(Ptr< Node > node) const =0
static void Ipv6L3ProtocolRxSinkWithoutContext(Ptr< OutputStreamWrapper > stream, Ptr< const Packet > packet, Ptr< Ipv6 > ipv6, uint32_t interface)
Sync function for IPv6 received packet - Ascii output.
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
Definition: object-base.cc:293
Implement the IPv4 layer.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
Helper class that adds ns3::Ipv6StaticRouting objects.
void Initialize(void)
Initialize the helper to its default values.
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
Definition: packet.cc:121
void SetTcp(std::string tid)
set the Tcp stack which will not need any other parameter.
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.
void Set(std::string name, const AttributeValue &value)
Set an attribute to be set during construction.
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:193
void Add(const Ipv4RoutingHelper &routing, int16_t priority)
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.
virtual ~InternetStackHelper(void)
Destroy the InternetStackHelper.
An interface aggregated to a node to provide global routing info.
static NodeContainer GetGlobal(void)
Create a NodeContainer that contains a list of all nodes created through NodeContainer::Create() and ...
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
std::pair< Ptr< Ipv4 >, uint32_t > InterfacePairIpv4
Ipv4/interface pair.
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.
Instantiate subclasses of ns3::Object.
const Ipv6RoutingHelper * m_routingv6
IPv6 routing helper.
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 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.
Helper class that adds ns3::Ipv4StaticRouting objects.
A network Node.
Definition: node.h:56
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...
virtual Ptr< Ipv4RoutingProtocol > Create(Ptr< Node > node) const =0
An implementation of the ARP protocol.
Helper class that adds ns3::Ipv4GlobalRouting objects.
Helper class that adds ns3::Ipv4ListRouting objects.
bool AsciiHooked(Ptr< Ipv4 > ipv4)
checks if there is an hook to an ascii output stream
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.
InternetStackHelper(void)
Create a new InternetStackHelper which uses a mix of static routing and global routing by default...
A base class which provides memory management and object aggregation.
Definition: object.h:87
std::map< InterfacePairIpv4, Ptr< PcapFileWrapper > > InterfaceFileMapIpv4
Ipv4/interface and Pcap file wrapper container.
const Ipv4RoutingHelper * m_routing
IPv4 routing helper.
void SetIpv6NsRsJitter(bool enable)
Enable/disable IPv6 NS and RS Jitter.
static InterfaceStreamMapIpv6 g_interfaceStreamMapIpv6
A mapping of Ipv6/interface pairs to pcap files.
void SetRoutingHelper(const Ipv4RoutingHelper &routing)
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
bool m_ipv4Enabled
IPv4 install state (enabled/disabled) ?
Iterator Begin(void) const
Get an iterator which refers to the first Node in the container.
static void Ipv6L3ProtocolRxTxSink(Ptr< const Packet > p, Ptr< Ipv6 > ipv6, uint32_t interface)
Sync function for IPv6 packet - Pcap output.
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.
void SetIpv6StackInstall(bool enable)
Enable/disable IPv6 stack install.
DropReason
Reason why a packet has been dropped.
static void Ipv4L3ProtocolRxTxSink(Ptr< const Packet > p, Ptr< Ipv4 > ipv4, uint32_t interface)
Sync function for IPv4 packet - Pcap output.