A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
151 #include "ns3/assert.h"
152 #include "ns3/log.h"
153 #include "ns3/object.h"
154 #include "ns3/names.h"
155 #include "ns3/ipv4.h"
156 #include "ns3/ipv6.h"
157 #include "ns3/packet-socket-factory.h"
158 #include "ns3/config.h"
159 #include "ns3/simulator.h"
160 #include "ns3/string.h"
161 #include "ns3/net-device.h"
162 #include "ns3/callback.h"
163 #include "ns3/node.h"
164 #include "ns3/node-list.h"
165 #include "ns3/core-config.h"
166 #include "ns3/arp-l3-protocol.h"
167 #include "internet-stack-helper.h"
168 #include "ns3/ipv4-global-routing.h"
169 #include "ns3/ipv4-list-routing-helper.h"
170 #include "ns3/ipv4-static-routing-helper.h"
171 #include "ns3/ipv4-global-routing-helper.h"
172 #include "ns3/ipv6-list-routing-helper.h"
173 #include "ns3/ipv6-static-routing-helper.h"
174 #include "ns3/ipv6-extension.h"
175 #include "ns3/ipv6-extension-demux.h"
176 #include "ns3/ipv6-extension-header.h"
177 #include "ns3/icmpv6-l4-protocol.h"
178 #include "ns3/global-router-interface.h"
179 #include <limits>
180 #include <map>
181 
182 NS_LOG_COMPONENT_DEFINE ("InternetStackHelper");
183 
184 namespace ns3 {
185 
186 //
187 // Historically, the only context written to ascii traces was the protocol.
188 // Traces from the protocols include the interface, though. It is not
189 // possible to really determine where an event originated without including
190 // this. If you want the additional context information, define
191 // INTERFACE_CONTEXT. If you want compatibility with the old-style traces
192 // comment it out.
193 //
194 #define INTERFACE_CONTEXT
195 
196 //
197 // Things are going to work differently here with respect to trace file handling
198 // than in most places because the Tx and Rx trace sources we are interested in
199 // are going to multiplex receive and transmit callbacks for all Ipv4 and
200 // interface pairs through one callback. We want packets to or from each
201 // distinct pair to go to an individual file, so we have got to demultiplex the
202 // Ipv4 and interface pair into a corresponding Ptr<PcapFileWrapper> at the
203 // callback.
204 //
205 // A complication in this situation is that the trace sources are hooked on
206 // a protocol basis. There is no trace source hooked by an Ipv4 and interface
207 // pair. This means that if we naively proceed to hook, say, a drop trace
208 // for a given Ipv4 with interface 0, and then hook for Ipv4 with interface 1
209 // we will hook the drop trace twice and get two callbacks per event. What
210 // we need to do is to hook the event once, and that will result in a single
211 // callback per drop event, and the trace source will provide the interface
212 // which we filter on in the trace sink.
213 //
214 // This has got to continue to work properly after the helper has been
215 // destroyed; but must be cleaned up at the end of time to avoid leaks.
216 // Global maps of protocol/interface pairs to file objects seems to fit the
217 // bill.
218 //
219 typedef std::pair<Ptr<Ipv4>, uint32_t> InterfacePairIpv4;
220 typedef std::map<InterfacePairIpv4, Ptr<PcapFileWrapper> > InterfaceFileMapIpv4;
221 typedef std::map<InterfacePairIpv4, Ptr<OutputStreamWrapper> > InterfaceStreamMapIpv4;
222 
226 typedef std::pair<Ptr<Ipv6>, uint32_t> InterfacePairIpv6;
227 typedef std::map<InterfacePairIpv6, Ptr<PcapFileWrapper> > InterfaceFileMapIpv6;
228 typedef std::map<InterfacePairIpv6, Ptr<OutputStreamWrapper> > InterfaceStreamMapIpv6;
229 
234  : m_routing (0),
235  m_routingv6 (0),
236  m_ipv4Enabled (true),
237  m_ipv6Enabled (true),
238  m_ipv4ArpJitterEnabled (true),
239  m_ipv6NsRsJitterEnabled (true)
240 
241 {
242  Initialize ();
243 }
244 
245 // private method called by both constructor and Reset ()
246 void
248 {
249  SetTcp ("ns3::TcpL4Protocol");
250  Ipv4StaticRoutingHelper staticRouting;
251  Ipv4GlobalRoutingHelper globalRouting;
252  Ipv4ListRoutingHelper listRouting;
253  Ipv6ListRoutingHelper listRoutingv6;
254  Ipv6StaticRoutingHelper staticRoutingv6;
255  listRouting.Add (staticRouting, 0);
256  listRouting.Add (globalRouting, -10);
257  listRoutingv6.Add (staticRoutingv6, 0);
258  SetRoutingHelper (listRouting);
259  SetRoutingHelper (listRoutingv6);
260 }
261 
263 {
264  delete m_routing;
265  delete m_routingv6;
266 }
267 
269 {
270  m_routing = o.m_routing->Copy ();
271  m_routingv6 = o.m_routingv6->Copy ();
277 }
278 
281 {
282  if (this == &o)
283  {
284  return *this;
285  }
286  m_routing = o.m_routing->Copy ();
287  m_routingv6 = o.m_routingv6->Copy ();
288  return *this;
289 }
290 
291 void
293 {
294  delete m_routing;
295  m_routing = 0;
296  delete m_routingv6;
297  m_routingv6 = 0;
298  m_ipv4Enabled = true;
299  m_ipv6Enabled = true;
300  m_ipv4ArpJitterEnabled = true;
302  Initialize ();
303 }
304 
305 void
307 {
308  delete m_routing;
309  m_routing = routing.Copy ();
310 }
311 
312 void
314 {
315  delete m_routingv6;
316  m_routingv6 = routing.Copy ();
317 }
318 
319 void
321 {
322  m_ipv4Enabled = enable;
323 }
324 
326 {
327  m_ipv6Enabled = enable;
328 }
329 
331 {
332  m_ipv4ArpJitterEnabled = enable;
333 }
334 
336 {
337  m_ipv6NsRsJitterEnabled = enable;
338 }
339 
340 int64_t
342 {
343  int64_t currentStream = stream;
344  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
345  {
346  Ptr<Node> node = *i;
347  Ptr<GlobalRouter> router = node->GetObject<GlobalRouter> ();
348  if (router != 0)
349  {
350  Ptr<Ipv4GlobalRouting> gr = router->GetRoutingProtocol ();
351  if (gr != 0)
352  {
353  currentStream += gr->AssignStreams (currentStream);
354  }
355  }
357  if (demux != 0)
358  {
359  Ptr<Ipv6Extension> fe = demux->GetExtension (Ipv6ExtensionFragment::EXT_NUMBER);
360  NS_ASSERT (fe); // should always exist in the demux
361  currentStream += fe->AssignStreams (currentStream);
362  }
363  Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> ();
364  if (ipv4 != 0)
365  {
366  Ptr<ArpL3Protocol> arpL3Protocol = ipv4->GetObject<ArpL3Protocol> ();
367  if (arpL3Protocol != 0)
368  {
369  currentStream += arpL3Protocol->AssignStreams (currentStream);
370  }
371  }
372  Ptr<Ipv6> ipv6 = node->GetObject<Ipv6> ();
373  if (ipv6 != 0)
374  {
375  Ptr<Icmpv6L4Protocol> icmpv6L4Protocol = ipv6->GetObject<Icmpv6L4Protocol> ();
376  if (icmpv6L4Protocol != 0)
377  {
378  currentStream += icmpv6L4Protocol->AssignStreams (currentStream);
379  }
380  }
381  }
382  return (currentStream - stream);
383 }
384 
385 void
386 InternetStackHelper::SetTcp (const std::string tid)
387 {
388  m_tcpFactory.SetTypeId (tid);
389 }
390 
391 void
392 InternetStackHelper::SetTcp (std::string tid, std::string n0, const AttributeValue &v0)
393 {
394  m_tcpFactory.SetTypeId (tid);
395  m_tcpFactory.Set (n0,v0);
396 }
397 
398 void
400 {
401  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
402  {
403  Install (*i);
404  }
405 }
406 
407 void
409 {
411 }
412 
413 void
415 {
416  ObjectFactory factory;
417  factory.SetTypeId (typeId);
418  Ptr<Object> protocol = factory.Create <Object> ();
419  node->AggregateObject (protocol);
420 }
421 
422 void
424 {
425  if (m_ipv4Enabled)
426  {
427  if (node->GetObject<Ipv4> () != 0)
428  {
429  NS_FATAL_ERROR ("InternetStackHelper::Install (): Aggregating "
430  "an InternetStack to a node with an existing Ipv4 object");
431  return;
432  }
433 
434  CreateAndAggregateObjectFromTypeId (node, "ns3::ArpL3Protocol");
435  CreateAndAggregateObjectFromTypeId (node, "ns3::Ipv4L3Protocol");
436  CreateAndAggregateObjectFromTypeId (node, "ns3::Icmpv4L4Protocol");
437  if (m_ipv4ArpJitterEnabled == false)
438  {
440  NS_ASSERT (arp);
441  arp->SetAttribute ("RequestJitter", StringValue ("ns3::ConstantRandomVariable[Constant=0.0]"));
442  }
443  // Set routing
444  Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> ();
445  Ptr<Ipv4RoutingProtocol> ipv4Routing = m_routing->Create (node);
446  ipv4->SetRoutingProtocol (ipv4Routing);
447  }
448 
449  if (m_ipv6Enabled)
450  {
451  /* IPv6 stack */
452  if (node->GetObject<Ipv6> () != 0)
453  {
454  NS_FATAL_ERROR ("InternetStackHelper::Install (): Aggregating "
455  "an InternetStack to a node with an existing Ipv6 object");
456  return;
457  }
458 
459  CreateAndAggregateObjectFromTypeId (node, "ns3::Ipv6L3Protocol");
460  CreateAndAggregateObjectFromTypeId (node, "ns3::Icmpv6L4Protocol");
461  if (m_ipv6NsRsJitterEnabled == false)
462  {
463  Ptr<Icmpv6L4Protocol> icmpv6l4 = node->GetObject<Icmpv6L4Protocol> ();
464  NS_ASSERT (icmpv6l4);
465  icmpv6l4->SetAttribute ("SolicitationJitter", StringValue ("ns3::ConstantRandomVariable[Constant=0.0]"));
466  }
467  // Set routing
468  Ptr<Ipv6> ipv6 = node->GetObject<Ipv6> ();
469  Ptr<Ipv6RoutingProtocol> ipv6Routing = m_routingv6->Create (node);
470  ipv6->SetRoutingProtocol (ipv6Routing);
471 
472  /* register IPv6 extensions and options */
473  ipv6->RegisterExtensions ();
474  ipv6->RegisterOptions ();
475  }
476 
478  {
479  CreateAndAggregateObjectFromTypeId (node, "ns3::UdpL4Protocol");
481  Ptr<PacketSocketFactory> factory = CreateObject<PacketSocketFactory> ();
482  node->AggregateObject (factory);
483  }
484 }
485 
486 void
487 InternetStackHelper::Install (std::string nodeName) const
488 {
489  Ptr<Node> node = Names::Find<Node> (nodeName);
490  Install (node);
491 }
492 
493 static void
495 {
496  NS_LOG_FUNCTION (p << ipv4 << interface);
497 
498  //
499  // Since trace sources are independent of interface, if we hook a source
500  // on a particular protocol we will get traces for all of its interfaces.
501  // We need to filter this to only report interfaces for which the user
502  // has expressed interest.
503  //
504  InterfacePairIpv4 pair = std::make_pair (ipv4, interface);
505  if (g_interfaceFileMapIpv4.find (pair) == g_interfaceFileMapIpv4.end ())
506  {
507  NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
508  return;
509  }
510 
512  file->Write (Simulator::Now (), p);
513 }
514 
515 bool
517 {
518  for ( InterfaceFileMapIpv4::const_iterator i = g_interfaceFileMapIpv4.begin ();
519  i != g_interfaceFileMapIpv4.end ();
520  ++i)
521  {
522  if ((*i).first.first == ipv4)
523  {
524  return true;
525  }
526  }
527  return false;
528 }
529 
530 void
531 InternetStackHelper::EnablePcapIpv4Internal (std::string prefix, Ptr<Ipv4> ipv4, uint32_t interface, bool explicitFilename)
532 {
533  NS_LOG_FUNCTION (prefix << ipv4 << interface);
534 
535  if (!m_ipv4Enabled)
536  {
537  NS_LOG_INFO ("Call to enable Ipv4 pcap tracing but Ipv4 not enabled");
538  return;
539  }
540 
541  //
542  // We have to create a file and a mapping from protocol/interface to file
543  // irrespective of how many times we want to trace a particular protocol.
544  //
545  PcapHelper pcapHelper;
546 
547  std::string filename;
548  if (explicitFilename)
549  {
550  filename = prefix;
551  }
552  else
553  {
554  filename = pcapHelper.GetFilenameFromInterfacePair (prefix, ipv4, interface);
555  }
556 
557  Ptr<PcapFileWrapper> file = pcapHelper.CreateFile (filename, std::ios::out, PcapHelper::DLT_RAW);
558 
559  //
560  // However, we only hook the trace source once to avoid multiple trace sink
561  // calls per event (connect is independent of interface).
562  //
563  if (!PcapHooked (ipv4))
564  {
565  //
566  // Ptr<Ipv4> is aggregated to node and Ipv4L3Protocol is aggregated to
567  // node so we can get to Ipv4L3Protocol through Ipv4.
568  //
569  Ptr<Ipv4L3Protocol> ipv4L3Protocol = ipv4->GetObject<Ipv4L3Protocol> ();
570  NS_ASSERT_MSG (ipv4L3Protocol, "InternetStackHelper::EnablePcapIpv4Internal(): "
571  "m_ipv4Enabled and ipv4L3Protocol inconsistent");
572 
573  bool result = ipv4L3Protocol->TraceConnectWithoutContext ("Tx", MakeCallback (&Ipv4L3ProtocolRxTxSink));
574  NS_ASSERT_MSG (result == true, "InternetStackHelper::EnablePcapIpv4Internal(): "
575  "Unable to connect ipv4L3Protocol \"Tx\"");
576 
577  result = ipv4L3Protocol->TraceConnectWithoutContext ("Rx", MakeCallback (&Ipv4L3ProtocolRxTxSink));
578  NS_ASSERT_MSG (result == true, "InternetStackHelper::EnablePcapIpv4Internal(): "
579  "Unable to connect ipv4L3Protocol \"Rx\"");
580  }
581 
582  g_interfaceFileMapIpv4[std::make_pair (ipv4, interface)] = file;
583 }
584 
585 static void
587 {
588  NS_LOG_FUNCTION (p << ipv6 << interface);
589 
590  //
591  // Since trace sources are independent of interface, if we hook a source
592  // on a particular protocol we will get traces for all of its interfaces.
593  // We need to filter this to only report interfaces for which the user
594  // has expressed interest.
595  //
596  InterfacePairIpv6 pair = std::make_pair (ipv6, interface);
597  if (g_interfaceFileMapIpv6.find (pair) == g_interfaceFileMapIpv6.end ())
598  {
599  NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
600  return;
601  }
602 
604  file->Write (Simulator::Now (), p);
605 }
606 
607 bool
609 {
610  for ( InterfaceFileMapIpv6::const_iterator i = g_interfaceFileMapIpv6.begin ();
611  i != g_interfaceFileMapIpv6.end ();
612  ++i)
613  {
614  if ((*i).first.first == ipv6)
615  {
616  return true;
617  }
618  }
619  return false;
620 }
621 
622 void
623 InternetStackHelper::EnablePcapIpv6Internal (std::string prefix, Ptr<Ipv6> ipv6, uint32_t interface, bool explicitFilename)
624 {
625  NS_LOG_FUNCTION (prefix << ipv6 << interface);
626 
627  if (!m_ipv6Enabled)
628  {
629  NS_LOG_INFO ("Call to enable Ipv6 pcap tracing but Ipv6 not enabled");
630  return;
631  }
632 
633  //
634  // We have to create a file and a mapping from protocol/interface to file
635  // irrespective of how many times we want to trace a particular protocol.
636  //
637  PcapHelper pcapHelper;
638 
639  std::string filename;
640  if (explicitFilename)
641  {
642  filename = prefix;
643  }
644  else
645  {
646  filename = pcapHelper.GetFilenameFromInterfacePair (prefix, ipv6, interface);
647  }
648 
649  Ptr<PcapFileWrapper> file = pcapHelper.CreateFile (filename, std::ios::out, PcapHelper::DLT_RAW);
650 
651  //
652  // However, we only hook the trace source once to avoid multiple trace sink
653  // calls per event (connect is independent of interface).
654  //
655  if (!PcapHooked (ipv6))
656  {
657  //
658  // Ptr<Ipv6> is aggregated to node and Ipv6L3Protocol is aggregated to
659  // node so we can get to Ipv6L3Protocol through Ipv6.
660  //
661  Ptr<Ipv6L3Protocol> ipv6L3Protocol = ipv6->GetObject<Ipv6L3Protocol> ();
662  NS_ASSERT_MSG (ipv6L3Protocol, "InternetStackHelper::EnablePcapIpv6Internal(): "
663  "m_ipv6Enabled and ipv6L3Protocol inconsistent");
664 
665  bool result = ipv6L3Protocol->TraceConnectWithoutContext ("Tx", MakeCallback (&Ipv6L3ProtocolRxTxSink));
666  NS_ASSERT_MSG (result == true, "InternetStackHelper::EnablePcapIpv6Internal(): "
667  "Unable to connect ipv6L3Protocol \"Tx\"");
668 
669  result = ipv6L3Protocol->TraceConnectWithoutContext ("Rx", MakeCallback (&Ipv6L3ProtocolRxTxSink));
670  NS_ASSERT_MSG (result == true, "InternetStackHelper::EnablePcapIpv6Internal(): "
671  "Unable to connect ipv6L3Protocol \"Rx\"");
672  }
673 
674  g_interfaceFileMapIpv6[std::make_pair (ipv6, interface)] = file;
675 }
676 
677 static void
680  Ipv4Header const &header,
681  Ptr<const Packet> packet,
683  Ptr<Ipv4> ipv4,
684  uint32_t interface)
685 {
686  //
687  // Since trace sources are independent of interface, if we hook a source
688  // on a particular protocol we will get traces for all of its interfaces.
689  // We need to filter this to only report interfaces for which the user
690  // has expressed interest.
691  //
692  InterfacePairIpv4 pair = std::make_pair (ipv4, interface);
693  if (g_interfaceStreamMapIpv4.find (pair) == g_interfaceStreamMapIpv4.end ())
694  {
695  NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
696  return;
697  }
698 
699  Ptr<Packet> p = packet->Copy ();
700  p->AddHeader (header);
701  *stream->GetStream () << "d " << Simulator::Now ().GetSeconds () << " " << *p << std::endl;
702 }
703 
704 static void
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  *stream->GetStream () << "t " << Simulator::Now ().GetSeconds () << " " << *packet << std::endl;
719 }
720 
721 static void
724  Ptr<const Packet> packet,
725  Ptr<Ipv4> ipv4,
726  uint32_t interface)
727 {
728  InterfacePairIpv4 pair = std::make_pair (ipv4, interface);
729  if (g_interfaceStreamMapIpv4.find (pair) == g_interfaceStreamMapIpv4.end ())
730  {
731  NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
732  return;
733  }
734 
735  *stream->GetStream () << "r " << Simulator::Now ().GetSeconds () << " " << *packet << std::endl;
736 }
737 
738 static void
741  std::string context,
742  Ipv4Header const &header,
743  Ptr<const Packet> packet,
745  Ptr<Ipv4> ipv4,
746  uint32_t interface)
747 {
748  //
749  // Since trace sources are independent of interface, if we hook a source
750  // on a particular protocol we will get traces for all of its interfaces.
751  // We need to filter this to only report interfaces for which the user
752  // has expressed interest.
753  //
754  InterfacePairIpv4 pair = std::make_pair (ipv4, interface);
755  if (g_interfaceStreamMapIpv4.find (pair) == g_interfaceStreamMapIpv4.end ())
756  {
757  NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
758  return;
759  }
760 
761  Ptr<Packet> p = packet->Copy ();
762  p->AddHeader (header);
763 #ifdef INTERFACE_CONTEXT
764  *stream->GetStream () << "d " << Simulator::Now ().GetSeconds () << " " << context << "(" << interface << ") "
765  << *p << std::endl;
766 #else
767  *stream->GetStream () << "d " << Simulator::Now ().GetSeconds () << " " << context << " " << *p << std::endl;
768 #endif
769 }
770 
771 static void
774  std::string context,
775  Ptr<const Packet> packet,
776  Ptr<Ipv4> ipv4,
777  uint32_t interface)
778 {
779  InterfacePairIpv4 pair = std::make_pair (ipv4, interface);
780  if (g_interfaceStreamMapIpv4.find (pair) == g_interfaceStreamMapIpv4.end ())
781  {
782  NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
783  return;
784  }
785 
786 #ifdef INTERFACE_CONTEXT
787  *stream->GetStream () << "t " << Simulator::Now ().GetSeconds () << " " << context << "(" << interface << ") "
788  << *packet << std::endl;
789 #else
790  *stream->GetStream () << "t " << Simulator::Now ().GetSeconds () << " " << context << " " << *packet << std::endl;
791 #endif
792 }
793 
794 static void
797  std::string context,
798  Ptr<const Packet> packet,
799  Ptr<Ipv4> ipv4,
800  uint32_t interface)
801 {
802  InterfacePairIpv4 pair = std::make_pair (ipv4, interface);
803  if (g_interfaceStreamMapIpv4.find (pair) == g_interfaceStreamMapIpv4.end ())
804  {
805  NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
806  return;
807  }
808 
809 #ifdef INTERFACE_CONTEXT
810  *stream->GetStream () << "r " << Simulator::Now ().GetSeconds () << " " << context << "(" << interface << ") "
811  << *packet << std::endl;
812 #else
813  *stream->GetStream () << "r " << Simulator::Now ().GetSeconds () << " " << context << " " << *packet << std::endl;
814 #endif
815 }
816 
817 bool
819 {
820  for ( InterfaceStreamMapIpv4::const_iterator i = g_interfaceStreamMapIpv4.begin ();
821  i != g_interfaceStreamMapIpv4.end ();
822  ++i)
823  {
824  if ((*i).first.first == ipv4)
825  {
826  return true;
827  }
828  }
829  return false;
830 }
831 
832 void
834  Ptr<OutputStreamWrapper> stream,
835  std::string prefix,
836  Ptr<Ipv4> ipv4,
837  uint32_t interface,
838  bool explicitFilename)
839 {
840  if (!m_ipv4Enabled)
841  {
842  NS_LOG_INFO ("Call to enable Ipv4 ascii tracing but Ipv4 not enabled");
843  return;
844  }
845 
846  //
847  // Our trace sinks are going to use packet printing, so we have to
848  // make sure that is turned on.
849  //
851 
852  //
853  // If we are not provided an OutputStreamWrapper, we are expected to create
854  // one using the usual trace filename conventions and hook WithoutContext
855  // since there will be one file per context and therefore the context would
856  // be redundant.
857  //
858  if (stream == 0)
859  {
860  //
861  // Set up an output stream object to deal with private ofstream copy
862  // constructor and lifetime issues. Let the helper decide the actual
863  // name of the file given the prefix.
864  //
865  // We have to create a stream and a mapping from protocol/interface to
866  // stream irrespective of how many times we want to trace a particular
867  // protocol.
868  //
869  AsciiTraceHelper asciiTraceHelper;
870 
871  std::string filename;
872  if (explicitFilename)
873  {
874  filename = prefix;
875  }
876  else
877  {
878  filename = asciiTraceHelper.GetFilenameFromInterfacePair (prefix, ipv4, interface);
879  }
880 
881  Ptr<OutputStreamWrapper> theStream = asciiTraceHelper.CreateFileStream (filename);
882 
883  //
884  // However, we only hook the trace sources once to avoid multiple trace sink
885  // calls per event (connect is independent of interface).
886  //
887  if (!AsciiHooked (ipv4))
888  {
889  //
890  // We can use the default drop sink for the ArpL3Protocol since it has
891  // the usual signature. We can get to the Ptr<ArpL3Protocol> through
892  // our Ptr<Ipv4> since they must both be aggregated to the same node.
893  //
894  Ptr<ArpL3Protocol> arpL3Protocol = ipv4->GetObject<ArpL3Protocol> ();
895  asciiTraceHelper.HookDefaultDropSinkWithoutContext<ArpL3Protocol> (arpL3Protocol, "Drop", theStream);
896 
897  //
898  // The drop sink for the Ipv4L3Protocol uses a different signature than
899  // the default sink, so we have to cook one up for ourselves. We can get
900  // to the Ptr<Ipv4L3Protocol> through our Ptr<Ipv4> since they must both
901  // be aggregated to the same node.
902  //
903  Ptr<Ipv4L3Protocol> ipv4L3Protocol = ipv4->GetObject<Ipv4L3Protocol> ();
904  bool result = ipv4L3Protocol->TraceConnectWithoutContext ("Drop",
906  NS_ASSERT_MSG (result == true, "InternetStackHelper::EnableAsciiIpv4Internal(): "
907  "Unable to connect ipv4L3Protocol \"Drop\"");
908  result = ipv4L3Protocol->TraceConnectWithoutContext ("Tx",
910  NS_ASSERT_MSG (result == true, "InternetStackHelper::EnableAsciiIpv4Internal(): "
911  "Unable to connect ipv4L3Protocol \"Tx\"");
912  result = ipv4L3Protocol->TraceConnectWithoutContext ("Rx",
914  NS_ASSERT_MSG (result == true, "InternetStackHelper::EnableAsciiIpv4Internal(): "
915  "Unable to connect ipv4L3Protocol \"Rx\"");
916  }
917 
918  g_interfaceStreamMapIpv4[std::make_pair (ipv4, interface)] = theStream;
919  return;
920  }
921 
922  //
923  // If we are provided an OutputStreamWrapper, we are expected to use it, and
924  // to provide a context. We are free to come up with our own context if we
925  // want, and use the AsciiTraceHelper Hook*WithContext functions, but for
926  // compatibility and simplicity, we just use Config::Connect and let it deal
927  // with the context.
928  //
929  // We need to associate the ipv4/interface with a stream to express interest
930  // in tracing events on that pair, however, we only hook the trace sources
931  // once to avoid multiple trace sink calls per event (connect is independent
932  // of interface).
933  //
934  if (!AsciiHooked (ipv4))
935  {
936  Ptr<Node> node = ipv4->GetObject<Node> ();
937  std::ostringstream oss;
938 
939  //
940  // For the ARP Drop, we are going to use the default trace sink provided by
941  // the ascii trace helper. There is actually no AsciiTraceHelper in sight
942  // here, but the default trace sinks are actually publicly available static
943  // functions that are always there waiting for just such a case.
944  //
945  oss << "/NodeList/" << node->GetId () << "/$ns3::ArpL3Protocol/Drop";
947 
948  //
949  // This has all kinds of parameters coming with, so we have to cook up our
950  // own sink.
951  //
952  oss.str ("");
953  oss << "/NodeList/" << node->GetId () << "/$ns3::Ipv4L3Protocol/Drop";
955  oss.str ("");
956  oss << "/NodeList/" << node->GetId () << "/$ns3::Ipv4L3Protocol/Tx";
958  oss.str ("");
959  oss << "/NodeList/" << node->GetId () << "/$ns3::Ipv4L3Protocol/Rx";
961  }
962 
963  g_interfaceStreamMapIpv4[std::make_pair (ipv4, interface)] = stream;
964 }
965 
966 static void
969  Ipv6Header const &header,
970  Ptr<const Packet> packet,
972  Ptr<Ipv6> ipv6,
973  uint32_t interface)
974 {
975  //
976  // Since trace sources are independent of interface, if we hook a source
977  // on a particular protocol we will get traces for all of its interfaces.
978  // We need to filter this to only report interfaces for which the user
979  // has expressed interest.
980  //
981  InterfacePairIpv6 pair = std::make_pair (ipv6, interface);
982  if (g_interfaceStreamMapIpv6.find (pair) == g_interfaceStreamMapIpv6.end ())
983  {
984  NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
985  return;
986  }
987 
988  Ptr<Packet> p = packet->Copy ();
989  p->AddHeader (header);
990  *stream->GetStream () << "d " << Simulator::Now ().GetSeconds () << " " << *p << std::endl;
991 }
992 
993 static void
996  Ptr<const Packet> packet,
997  Ptr<Ipv6> ipv6,
998  uint32_t interface)
999 {
1000  InterfacePairIpv6 pair = std::make_pair (ipv6, interface);
1001  if (g_interfaceStreamMapIpv6.find (pair) == g_interfaceStreamMapIpv6.end ())
1002  {
1003  NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
1004  return;
1005  }
1006 
1007  *stream->GetStream () << "t " << Simulator::Now ().GetSeconds () << " " << *packet << std::endl;
1008 }
1009 
1010 static void
1012  Ptr<OutputStreamWrapper> stream,
1013  Ptr<const Packet> packet,
1014  Ptr<Ipv6> ipv6,
1015  uint32_t interface)
1016 {
1017  InterfacePairIpv6 pair = std::make_pair (ipv6, interface);
1018  if (g_interfaceStreamMapIpv6.find (pair) == g_interfaceStreamMapIpv6.end ())
1019  {
1020  NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
1021  return;
1022  }
1023 
1024  *stream->GetStream () << "r " << Simulator::Now ().GetSeconds () << " " << *packet << std::endl;
1025 }
1026 
1027 static void
1029  Ptr<OutputStreamWrapper> stream,
1030  std::string context,
1031  Ipv6Header const &header,
1032  Ptr<const Packet> packet,
1034  Ptr<Ipv6> ipv6,
1035  uint32_t interface)
1036 {
1037  //
1038  // Since trace sources are independent of interface, if we hook a source
1039  // on a particular protocol we will get traces for all of its interfaces.
1040  // We need to filter this to only report interfaces for which the user
1041  // has expressed interest.
1042  //
1043  InterfacePairIpv6 pair = std::make_pair (ipv6, interface);
1044  if (g_interfaceStreamMapIpv6.find (pair) == g_interfaceStreamMapIpv6.end ())
1045  {
1046  NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
1047  return;
1048  }
1049 
1050  Ptr<Packet> p = packet->Copy ();
1051  p->AddHeader (header);
1052 #ifdef INTERFACE_CONTEXT
1053  *stream->GetStream () << "d " << Simulator::Now ().GetSeconds () << " " << context << "(" << interface << ") "
1054  << *p << std::endl;
1055 #else
1056  *stream->GetStream () << "d " << Simulator::Now ().GetSeconds () << " " << context << " " << *p << std::endl;
1057 #endif
1058 }
1059 
1060 static void
1062  Ptr<OutputStreamWrapper> stream,
1063  std::string context,
1064  Ptr<const Packet> packet,
1065  Ptr<Ipv6> ipv6,
1066  uint32_t interface)
1067 {
1068  InterfacePairIpv6 pair = std::make_pair (ipv6, interface);
1069  if (g_interfaceStreamMapIpv6.find (pair) == g_interfaceStreamMapIpv6.end ())
1070  {
1071  NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
1072  return;
1073  }
1074 
1075 #ifdef INTERFACE_CONTEXT
1076  *stream->GetStream () << "t " << Simulator::Now ().GetSeconds () << " " << context << "(" << interface << ") "
1077  << *packet << std::endl;
1078 #else
1079  *stream->GetStream () << "t " << Simulator::Now ().GetSeconds () << " " << context << " " << *packet << std::endl;
1080 #endif
1081 }
1082 
1083 static void
1085  Ptr<OutputStreamWrapper> stream,
1086  std::string context,
1087  Ptr<const Packet> packet,
1088  Ptr<Ipv6> ipv6,
1089  uint32_t interface)
1090 {
1091  InterfacePairIpv6 pair = std::make_pair (ipv6, interface);
1092  if (g_interfaceStreamMapIpv6.find (pair) == g_interfaceStreamMapIpv6.end ())
1093  {
1094  NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
1095  return;
1096  }
1097 
1098 #ifdef INTERFACE_CONTEXT
1099  *stream->GetStream () << "r " << Simulator::Now ().GetSeconds () << " " << context << "(" << interface << ") "
1100  << *packet << std::endl;
1101 #else
1102  *stream->GetStream () << "r " << Simulator::Now ().GetSeconds () << " " << context << " " << *packet << std::endl;
1103 #endif
1104 }
1105 
1106 bool
1108 {
1109  for ( InterfaceStreamMapIpv6::const_iterator i = g_interfaceStreamMapIpv6.begin ();
1110  i != g_interfaceStreamMapIpv6.end ();
1111  ++i)
1112  {
1113  if ((*i).first.first == ipv6)
1114  {
1115  return true;
1116  }
1117  }
1118  return false;
1119 }
1120 
1121 void
1123  Ptr<OutputStreamWrapper> stream,
1124  std::string prefix,
1125  Ptr<Ipv6> ipv6,
1126  uint32_t interface,
1127  bool explicitFilename)
1128 {
1129  if (!m_ipv6Enabled)
1130  {
1131  NS_LOG_INFO ("Call to enable Ipv6 ascii tracing but Ipv6 not enabled");
1132  return;
1133  }
1134 
1135  //
1136  // Our trace sinks are going to use packet printing, so we have to
1137  // make sure that is turned on.
1138  //
1140 
1141  //
1142  // If we are not provided an OutputStreamWrapper, we are expected to create
1143  // one using the usual trace filename conventions and do a hook WithoutContext
1144  // since there will be one file per context and therefore the context would
1145  // be redundant.
1146  //
1147  if (stream == 0)
1148  {
1149  //
1150  // Set up an output stream object to deal with private ofstream copy
1151  // constructor and lifetime issues. Let the helper decide the actual
1152  // name of the file given the prefix.
1153  //
1154  // We have to create a stream and a mapping from protocol/interface to
1155  // stream irrespective of how many times we want to trace a particular
1156  // protocol.
1157  //
1158  AsciiTraceHelper asciiTraceHelper;
1159 
1160  std::string filename;
1161  if (explicitFilename)
1162  {
1163  filename = prefix;
1164  }
1165  else
1166  {
1167  filename = asciiTraceHelper.GetFilenameFromInterfacePair (prefix, ipv6, interface);
1168  }
1169 
1170  Ptr<OutputStreamWrapper> theStream = asciiTraceHelper.CreateFileStream (filename);
1171 
1172  //
1173  // However, we only hook the trace sources once to avoid multiple trace sink
1174  // calls per event (connect is independent of interface).
1175  //
1176  if (!AsciiHooked (ipv6))
1177  {
1178  //
1179  // The drop sink for the Ipv6L3Protocol uses a different signature than
1180  // the default sink, so we have to cook one up for ourselves. We can get
1181  // to the Ptr<Ipv6L3Protocol> through our Ptr<Ipv6> since they must both
1182  // be aggregated to the same node.
1183  //
1184  Ptr<Ipv6L3Protocol> ipv6L3Protocol = ipv6->GetObject<Ipv6L3Protocol> ();
1185  bool result = ipv6L3Protocol->TraceConnectWithoutContext ("Drop",
1187  NS_ASSERT_MSG (result == true, "InternetStackHelper::EnableAsciiIpv6Internal(): "
1188  "Unable to connect ipv6L3Protocol \"Drop\"");
1189  result = ipv6L3Protocol->TraceConnectWithoutContext ("Tx",
1191  NS_ASSERT_MSG (result == true, "InternetStackHelper::EnableAsciiIpv6Internal(): "
1192  "Unable to connect ipv6L3Protocol \"Tx\"");
1193  result = ipv6L3Protocol->TraceConnectWithoutContext ("Rx",
1195  NS_ASSERT_MSG (result == true, "InternetStackHelper::EnableAsciiIpv6Internal(): "
1196  "Unable to connect ipv6L3Protocol \"Rx\"");
1197  }
1198 
1199  g_interfaceStreamMapIpv6[std::make_pair (ipv6, interface)] = theStream;
1200  return;
1201  }
1202 
1203  //
1204  // If we are provided an OutputStreamWrapper, we are expected to use it, and
1205  // to provide a context. We are free to come up with our own context if we
1206  // want, and use the AsciiTraceHelper Hook*WithContext functions, but for
1207  // compatibility and simplicity, we just use Config::Connect and let it deal
1208  // with the context.
1209  //
1210  // We need to associate the ipv4/interface with a stream to express interest
1211  // in tracing events on that pair, however, we only hook the trace sources
1212  // once to avoid multiple trace sink calls per event (connect is independent
1213  // of interface).
1214  //
1215  if (!AsciiHooked (ipv6))
1216  {
1217  Ptr<Node> node = ipv6->GetObject<Node> ();
1218  std::ostringstream oss;
1219 
1220  oss.str ("");
1221  oss << "/NodeList/" << node->GetId () << "/$ns3::Ipv6L3Protocol/Drop";
1223  oss.str ("");
1224  oss << "/NodeList/" << node->GetId () << "/$ns3::Ipv6L3Protocol/Tx";
1226  oss.str ("");
1227  oss << "/NodeList/" << node->GetId () << "/$ns3::Ipv6L3Protocol/Rx";
1229  }
1230 
1231  g_interfaceStreamMapIpv6[std::make_pair (ipv6, interface)] = stream;
1232 }
1233 
1234 } // namespace ns3
bool m_ipv4ArpJitterEnabled
IPv4 ARP Jitter state (enabled/disabled) ?
bool m_ipv6NsRsJitterEnabled
IPv6 IPv6 NS and RS Jitter state (enabled/disabled) ?
int64_t AssignStreams(int64_t stream)
Manage ASCII trace files for device models.
Definition: trace-helper.h:109
Packet header for IPv6.
Definition: ipv6-header.h:33
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)
Definition: log.h:311
Ptr< PcapFileWrapper > CreateFile(std::string filename, std::ios::openmode filemode, uint32_t dataLinkType, uint32_t snapLen=65535, int32_t tzCorrection=0)
Create and initialize a pcap file.
Definition: trace-helper.cc:49
static void Ipv4L3ProtocolDropSinkWithoutContext(Ptr< OutputStreamWrapper > stream, Ipv4Header const &header, Ptr< const Packet > packet, Ipv4L3Protocol::DropReason reason, Ptr< Ipv4 > ipv4, uint32_t interface)
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:254
std::vector< Ptr< Node > >::const_iterator Iterator
Access to the IPv6 forwarding table, interfaces, and configuration.
Definition: ipv6.h:79
hold variables of type string
Definition: string.h:19
static const uint8_t EXT_NUMBER
Fragmentation extension number.
Hold a value for an Attribute.
Definition: attribute.h:56
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.
void Write(Time t, Ptr< const Packet > p)
Write the next packet to file.
virtual Ipv4RoutingHelper * Copy(void) const =0
virtual constructor
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Definition: callback.h:1463
static InterfaceFileMapIpv4 g_interfaceFileMapIpv4
virtual Ipv6RoutingHelper * Copy(void) const =0
virtual constructor
#define NS_ASSERT(condition)
Definition: assert.h:64
static void DefaultDropSinkWithContext(Ptr< OutputStreamWrapper > file, std::string context, Ptr< const Packet > p)
void SetTypeId(TypeId tid)
aggregate IP/TCP/UDP functionality to existing Nodes.
std::map< InterfacePairIpv6, Ptr< PcapFileWrapper > > InterfaceFileMapIpv6
static void Ipv4L3ProtocolRxSinkWithoutContext(Ptr< OutputStreamWrapper > stream, Ptr< const Packet > packet, Ptr< Ipv4 > ipv4, uint32_t interface)
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container.
#define NS_LOG_INFO(msg)
Definition: log.h:264
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)
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. ...
std::map< InterfacePairIpv6, Ptr< OutputStreamWrapper > > InterfaceStreamMapIpv6
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:728
static InterfaceStreamMapIpv4 g_interfaceStreamMapIpv4
std::map< InterfacePairIpv4, Ptr< OutputStreamWrapper > > InterfaceStreamMapIpv4
static void Ipv4L3ProtocolTxSinkWithoutContext(Ptr< OutputStreamWrapper > stream, Ptr< const Packet > packet, Ptr< Ipv4 > ipv4, uint32_t interface)
#define NS_FATAL_ERROR(msg)
fatal error handling
Definition: fatal-error.h:72
InternetStackHelper & operator=(const InternetStackHelper &o)
static void CreateAndAggregateObjectFromTypeId(Ptr< Node > node, const std::string typeId)
DropReason
Reason why a packet has been dropped.
Packet header for IPv4.
Definition: ipv4-header.h:31
double GetSeconds(void) const
Definition: nstime.h:266
static void Ipv4L3ProtocolTxSinkWithContext(Ptr< OutputStreamWrapper > stream, std::string context, Ptr< const Packet > packet, Ptr< Ipv4 > ipv4, uint32_t interface)
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)
Definition: packet.cc:552
Ptr< Object > Create(void) const
void SetIpv4StackInstall(bool enable)
Enable/disable IPv4 stack install.
static InterfaceFileMapIpv6 g_interfaceFileMapIpv6
std::pair< Ptr< Ipv6 >, uint32_t > InterfacePairIpv6
A factory to create ns3::Ipv6RoutingProtocol objects.
An implementation of the ICMPv6 protocol.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:1238
bool PcapHooked(Ptr< Ipv4 > ipv4)
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...
void AggregateObject(Ptr< Object > other)
Definition: object.cc:242
bool m_ipv6Enabled
IPv6 install state (enabled/disabled) ?
a factory to create ns3::Ipv4RoutingProtocol objects
static void Ipv6L3ProtocolTxSinkWithoutContext(Ptr< OutputStreamWrapper > stream, Ptr< const Packet > packet, Ptr< Ipv6 > ipv6, uint32_t interface)
static void Ipv6L3ProtocolTxSinkWithContext(Ptr< OutputStreamWrapper > stream, std::string context, Ptr< const Packet > packet, Ptr< Ipv6 > ipv6, uint32_t interface)
Access to the Ipv4 forwarding table, interfaces, and configuration.
Definition: ipv4.h:75
Ptr< Packet > Copy(void) const
Definition: packet.cc:122
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)
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Definition: object-base.cc:268
Implement the Ipv4 layer.
keep track of a set of node pointers.
Helper class that adds ns3::Ipv6StaticRouting objects.
Iterator Begin(void) const
Get an iterator which refers to the first Node in the container.
NS_LOG_COMPONENT_DEFINE("InternetStackHelper")
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)
void Install(std::string nodeName) const
void Set(std::string name, const AttributeValue &value)
static Time Now(void)
Definition: simulator.cc:180
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)
An interface aggregated to a node to provide global routing info.
#define NS_ASSERT_MSG(condition, message)
Definition: assert.h:86
static NodeContainer GetGlobal(void)
Create a NodeContainer that contains a list of all nodes created through NodeContainer::Create() and ...
void Add(const Ipv6RoutingHelper &routing, int16_t priority)
std::pair< Ptr< Ipv4 >, uint32_t > InterfacePairIpv4
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)
instantiate subclasses of ns3::Object.
const Ipv6RoutingHelper * m_routingv6
IPv6 routing helper.
int64_t AssignStreams(NodeContainer c, int64_t stream)
uint32_t GetId(void) const
Definition: node.cc:103
static void Ipv4L3ProtocolRxSinkWithContext(Ptr< OutputStreamWrapper > stream, std::string context, Ptr< const Packet > packet, Ptr< Ipv4 > ipv4, uint32_t interface)
Helper class that adds ns3::Ipv4StaticRouting objects.
A network Node.
Definition: node.h:55
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::Ipv6ListRouting objects.
Helper class that adds ns3::Ipv4ListRouting objects.
bool AsciiHooked(Ptr< Ipv4 > ipv4)
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.
a base class which provides memory management and object aggregation
Definition: object.h:63
std::map< InterfacePairIpv4, Ptr< PcapFileWrapper > > InterfaceFileMapIpv4
const Ipv4RoutingHelper * m_routing
Ptr< T > GetObject(void) const
Definition: object.h:360
void SetIpv6NsRsJitter(bool enable)
Enable/disable IPv6 NS and RS Jitter.
static InterfaceStreamMapIpv6 g_interfaceStreamMapIpv6
void SetRoutingHelper(const Ipv4RoutingHelper &routing)
std::ostream * GetStream(void)
void AddHeader(const Header &header)
Definition: packet.cc:253
bool m_ipv4Enabled
IPv4 install state (enabled/disabled) ?
static void Ipv6L3ProtocolRxTxSink(Ptr< const Packet > p, Ptr< Ipv6 > ipv6, uint32_t interface)
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)