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"
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
53namespace ns3 {
54
55NS_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// The use of global maps allows this to continue to work properly even if
86// the helper is destroyed before the simulation completes. If the maps
87// are populated, the reference counting smart pointers to
88// OutputStreamWrapper and PcapFileWrapper will cause those objects to be
89// destroyed at static object destruction time; i.e., the simulator does
90// not explicitly clear these maps before the program ends.
91//
92typedef std::pair<uint32_t, uint32_t> InterfacePairIpv4;
93typedef std::map<InterfacePairIpv4, Ptr<PcapFileWrapper> > InterfaceFileMapIpv4;
94typedef std::map<InterfacePairIpv4, Ptr<OutputStreamWrapper> > InterfaceStreamMapIpv4;
99typedef std::pair<uint32_t, uint32_t> InterfacePairIpv6;
100typedef std::map<InterfacePairIpv6, Ptr<PcapFileWrapper> > InterfaceFileMapIpv6;
101typedef std::map<InterfacePairIpv6, Ptr<OutputStreamWrapper> > InterfaceStreamMapIpv6;
107 : m_routing (0),
108 m_routingv6 (0),
109 m_ipv4Enabled (true),
110 m_ipv6Enabled (true),
111 m_ipv4ArpJitterEnabled (true),
112 m_ipv6NsRsJitterEnabled (true)
113
114{
115 Initialize ();
116}
117
118// private method called by both constructor and Reset ()
119void
121{
122 SetTcp ("ns3::TcpL4Protocol");
123 Ipv4StaticRoutingHelper staticRouting;
124 Ipv4GlobalRoutingHelper globalRouting;
125 Ipv4ListRoutingHelper listRouting;
126 Ipv6StaticRoutingHelper staticRoutingv6;
127 listRouting.Add (staticRouting, 0);
128 listRouting.Add (globalRouting, -10);
129 SetRoutingHelper (listRouting);
130 SetRoutingHelper (staticRoutingv6);
131}
132
134{
135 delete m_routing;
136 delete m_routingv6;
137}
138
140{
141 m_routing = o.m_routing->Copy ();
148}
149
152{
153 if (this == &o)
154 {
155 return *this;
156 }
157 m_routing = o.m_routing->Copy ();
159 return *this;
160}
161
162void
164{
165 delete m_routing;
166 m_routing = 0;
167 delete m_routingv6;
168 m_routingv6 = 0;
169 m_ipv4Enabled = true;
170 m_ipv6Enabled = true;
173 Initialize ();
174}
175
176void
178{
179 delete m_routing;
180 m_routing = routing.Copy ();
181}
182
183void
185{
186 delete m_routingv6;
187 m_routingv6 = routing.Copy ();
188}
189
190void
192{
193 m_ipv4Enabled = enable;
194}
195
197{
198 m_ipv6Enabled = enable;
199}
200
202{
203 m_ipv4ArpJitterEnabled = enable;
204}
205
207{
209}
210
211int64_t
213{
214 int64_t currentStream = stream;
215 for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
216 {
217 Ptr<Node> node = *i;
218 Ptr<GlobalRouter> router = node->GetObject<GlobalRouter> ();
219 if (router)
220 {
221 Ptr<Ipv4GlobalRouting> gr = router->GetRoutingProtocol ();
222 if (gr)
223 {
224 currentStream += gr->AssignStreams (currentStream);
225 }
226 }
228 if (demux)
229 {
230 Ptr<Ipv6Extension> fe = demux->GetExtension (Ipv6ExtensionFragment::EXT_NUMBER);
231 NS_ASSERT (fe); // should always exist in the demux
232 currentStream += fe->AssignStreams (currentStream);
233 }
234 Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> ();
235 if (ipv4)
236 {
237 Ptr<ArpL3Protocol> arpL3Protocol = ipv4->GetObject<ArpL3Protocol> ();
238 if (arpL3Protocol)
239 {
240 currentStream += arpL3Protocol->AssignStreams (currentStream);
241 }
242 }
243 Ptr<Ipv6> ipv6 = node->GetObject<Ipv6> ();
244 if (ipv6)
245 {
246 Ptr<Icmpv6L4Protocol> icmpv6L4Protocol = ipv6->GetObject<Icmpv6L4Protocol> ();
247 if (icmpv6L4Protocol)
248 {
249 currentStream += icmpv6L4Protocol->AssignStreams (currentStream);
250 }
251 }
252 }
253 return (currentStream - stream);
254}
255
256void
257InternetStackHelper::SetTcp (const std::string tid)
258{
260}
261
262void
264{
265 for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
266 {
267 Install (*i);
268 }
269}
270
271void
273{
275}
276
277void
279{
280 ObjectFactory factory;
281 factory.SetTypeId (typeId);
282 Ptr<Object> protocol = factory.Create <Object> ();
283 node->AggregateObject (protocol);
284}
285
286void
288{
289 if (m_ipv4Enabled)
290 {
291 if (node->GetObject<Ipv4> ())
292 {
293 NS_FATAL_ERROR ("InternetStackHelper::Install (): Aggregating "
294 "an InternetStack to a node with an existing Ipv4 object");
295 return;
296 }
297
298 CreateAndAggregateObjectFromTypeId (node, "ns3::ArpL3Protocol");
299 CreateAndAggregateObjectFromTypeId (node, "ns3::Ipv4L3Protocol");
300 CreateAndAggregateObjectFromTypeId (node, "ns3::Icmpv4L4Protocol");
301 if (m_ipv4ArpJitterEnabled == false)
302 {
304 NS_ASSERT (arp);
305 arp->SetAttribute ("RequestJitter", StringValue ("ns3::ConstantRandomVariable[Constant=0.0]"));
306 }
307 // Set routing
308 Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> ();
309 Ptr<Ipv4RoutingProtocol> ipv4Routing = m_routing->Create (node);
310 ipv4->SetRoutingProtocol (ipv4Routing);
311 }
312
313 if (m_ipv6Enabled)
314 {
315 /* IPv6 stack */
316 if (node->GetObject<Ipv6> ())
317 {
318 NS_FATAL_ERROR ("InternetStackHelper::Install (): Aggregating "
319 "an InternetStack to a node with an existing Ipv6 object");
320 return;
321 }
322
323 CreateAndAggregateObjectFromTypeId (node, "ns3::Ipv6L3Protocol");
324 CreateAndAggregateObjectFromTypeId (node, "ns3::Icmpv6L4Protocol");
325 if (m_ipv6NsRsJitterEnabled == false)
326 {
328 NS_ASSERT (icmpv6l4);
329 icmpv6l4->SetAttribute ("SolicitationJitter", StringValue ("ns3::ConstantRandomVariable[Constant=0.0]"));
330 }
331 // Set routing
332 Ptr<Ipv6> ipv6 = node->GetObject<Ipv6> ();
333 Ptr<Ipv6RoutingProtocol> ipv6Routing = m_routingv6->Create (node);
334 ipv6->SetRoutingProtocol (ipv6Routing);
335
336 /* register IPv6 extensions and options */
337 ipv6->RegisterExtensions ();
338 ipv6->RegisterOptions ();
339 }
340
342 {
343 CreateAndAggregateObjectFromTypeId (node, "ns3::TrafficControlLayer");
344 CreateAndAggregateObjectFromTypeId (node, "ns3::UdpL4Protocol");
346 Ptr<PacketSocketFactory> factory = CreateObject<PacketSocketFactory> ();
347 node->AggregateObject (factory);
348 }
349
350 if (m_ipv4Enabled)
351 {
354 NS_ASSERT (arp);
355 NS_ASSERT (tc);
356 arp->SetTrafficControl (tc);
357 }
358}
359
360void
361InternetStackHelper::Install (std::string nodeName) const
362{
363 Ptr<Node> node = Names::Find<Node> (nodeName);
364 Install (node);
365}
366
373static void
375{
376 NS_LOG_FUNCTION (p << ipv4 << interface);
377
378 //
379 // Since trace sources are independent of interface, if we hook a source
380 // on a particular protocol we will get traces for all of its interfaces.
381 // We need to filter this to only report interfaces for which the user
382 // has expressed interest.
383 //
384 InterfacePairIpv4 pair = std::make_pair (ipv4->GetObject<Node> ()->GetId (), interface);
385 if (g_interfaceFileMapIpv4.find (pair) == g_interfaceFileMapIpv4.end ())
386 {
387 NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
388 return;
389 }
390
392 file->Write (Simulator::Now (), p);
393}
394
395bool
397{
398 for ( InterfaceFileMapIpv4::const_iterator i = g_interfaceFileMapIpv4.begin ();
399 i != g_interfaceFileMapIpv4.end ();
400 ++i)
401 {
402 if ((*i).first.first == ipv4->GetObject<Node> ()->GetId ())
403 {
404 return true;
405 }
406 }
407 return false;
408}
409
410void
411InternetStackHelper::EnablePcapIpv4Internal (std::string prefix, Ptr<Ipv4> ipv4, uint32_t interface, bool explicitFilename)
412{
413 NS_LOG_FUNCTION (prefix << ipv4 << interface);
414
415 if (!m_ipv4Enabled)
416 {
417 NS_LOG_INFO ("Call to enable Ipv4 pcap tracing but Ipv4 not enabled");
418 return;
419 }
420
421 //
422 // We have to create a file and a mapping from protocol/interface to file
423 // irrespective of how many times we want to trace a particular protocol.
424 //
425 PcapHelper pcapHelper;
426
427 std::string filename;
428 if (explicitFilename)
429 {
430 filename = prefix;
431 }
432 else
433 {
434 filename = pcapHelper.GetFilenameFromInterfacePair (prefix, ipv4, interface);
435 }
436
437 Ptr<PcapFileWrapper> file = pcapHelper.CreateFile (filename, std::ios::out, PcapHelper::DLT_RAW);
438
439 //
440 // However, we only hook the trace source once to avoid multiple trace sink
441 // calls per event (connect is independent of interface).
442 //
443 if (!PcapHooked (ipv4))
444 {
445 //
446 // Ptr<Ipv4> is aggregated to node and Ipv4L3Protocol is aggregated to
447 // node so we can get to Ipv4L3Protocol through Ipv4.
448 //
449 Ptr<Ipv4L3Protocol> ipv4L3Protocol = ipv4->GetObject<Ipv4L3Protocol> ();
450 NS_ASSERT_MSG (ipv4L3Protocol, "InternetStackHelper::EnablePcapIpv4Internal(): "
451 "m_ipv4Enabled and ipv4L3Protocol inconsistent");
452
453 bool result = ipv4L3Protocol->TraceConnectWithoutContext ("Tx", MakeCallback (&Ipv4L3ProtocolRxTxSink));
454 NS_ASSERT_MSG (result == true, "InternetStackHelper::EnablePcapIpv4Internal(): "
455 "Unable to connect ipv4L3Protocol \"Tx\"");
456
457 result = ipv4L3Protocol->TraceConnectWithoutContext ("Rx", MakeCallback (&Ipv4L3ProtocolRxTxSink));
458 NS_ASSERT_MSG (result == true, "InternetStackHelper::EnablePcapIpv4Internal(): "
459 "Unable to connect ipv4L3Protocol \"Rx\"");
460 }
461
462 g_interfaceFileMapIpv4[std::make_pair (ipv4->GetObject<Node> ()->GetId (), interface)] = file;
463}
464
471static void
473{
474 NS_LOG_FUNCTION (p << ipv6 << interface);
475
476 //
477 // Since trace sources are independent of interface, if we hook a source
478 // on a particular protocol we will get traces for all of its interfaces.
479 // We need to filter this to only report interfaces for which the user
480 // has expressed interest.
481 //
482 InterfacePairIpv6 pair = std::make_pair (ipv6->GetObject<Node> ()->GetId (), interface);
483 if (g_interfaceFileMapIpv6.find (pair) == g_interfaceFileMapIpv6.end ())
484 {
485 NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
486 return;
487 }
488
490 file->Write (Simulator::Now (), p);
491}
492
493bool
495{
496 for ( InterfaceFileMapIpv6::const_iterator i = g_interfaceFileMapIpv6.begin ();
497 i != g_interfaceFileMapIpv6.end ();
498 ++i)
499 {
500 if ((*i).first.first == ipv6->GetObject<Node> ()->GetId ())
501 {
502 return true;
503 }
504 }
505 return false;
506}
507
508void
509InternetStackHelper::EnablePcapIpv6Internal (std::string prefix, Ptr<Ipv6> ipv6, uint32_t interface, bool explicitFilename)
510{
511 NS_LOG_FUNCTION (prefix << ipv6 << interface);
512
513 if (!m_ipv6Enabled)
514 {
515 NS_LOG_INFO ("Call to enable Ipv6 pcap tracing but Ipv6 not enabled");
516 return;
517 }
518
519 //
520 // We have to create a file and a mapping from protocol/interface to file
521 // irrespective of how many times we want to trace a particular protocol.
522 //
523 PcapHelper pcapHelper;
524
525 std::string filename;
526 if (explicitFilename)
527 {
528 filename = prefix;
529 }
530 else
531 {
532 filename = pcapHelper.GetFilenameFromInterfacePair (prefix, ipv6, interface);
533 }
534
535 Ptr<PcapFileWrapper> file = pcapHelper.CreateFile (filename, std::ios::out, PcapHelper::DLT_RAW);
536
537 //
538 // However, we only hook the trace source once to avoid multiple trace sink
539 // calls per event (connect is independent of interface).
540 //
541 if (!PcapHooked (ipv6))
542 {
543 //
544 // Ptr<Ipv6> is aggregated to node and Ipv6L3Protocol is aggregated to
545 // node so we can get to Ipv6L3Protocol through Ipv6.
546 //
547 Ptr<Ipv6L3Protocol> ipv6L3Protocol = ipv6->GetObject<Ipv6L3Protocol> ();
548 NS_ASSERT_MSG (ipv6L3Protocol, "InternetStackHelper::EnablePcapIpv6Internal(): "
549 "m_ipv6Enabled and ipv6L3Protocol inconsistent");
550
551 bool result = ipv6L3Protocol->TraceConnectWithoutContext ("Tx", MakeCallback (&Ipv6L3ProtocolRxTxSink));
552 NS_ASSERT_MSG (result == true, "InternetStackHelper::EnablePcapIpv6Internal(): "
553 "Unable to connect ipv6L3Protocol \"Tx\"");
554
555 result = ipv6L3Protocol->TraceConnectWithoutContext ("Rx", MakeCallback (&Ipv6L3ProtocolRxTxSink));
556 NS_ASSERT_MSG (result == true, "InternetStackHelper::EnablePcapIpv6Internal(): "
557 "Unable to connect ipv6L3Protocol \"Rx\"");
558 }
559
560 g_interfaceFileMapIpv6[std::make_pair (ipv6->GetObject<Node> ()->GetId (), interface)] = file;
561}
562
572static void
575 Ipv4Header const &header,
576 Ptr<const Packet> packet,
578 Ptr<Ipv4> ipv4,
579 uint32_t interface)
580{
581 //
582 // Since trace sources are independent of interface, if we hook a source
583 // on a particular protocol we will get traces for all of its interfaces.
584 // We need to filter this to only report interfaces for which the user
585 // has expressed interest.
586 //
587 InterfacePairIpv4 pair = std::make_pair (ipv4->GetObject<Node> ()->GetId (), interface);
588 if (g_interfaceStreamMapIpv4.find (pair) == g_interfaceStreamMapIpv4.end ())
589 {
590 NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
591 return;
592 }
593
594 Ptr<Packet> p = packet->Copy ();
595 p->AddHeader (header);
596 *stream->GetStream () << "d " << Simulator::Now ().GetSeconds () << " " << *p << std::endl;
597}
598
606static void
609 Ptr<const Packet> packet,
610 Ptr<Ipv4> ipv4,
611 uint32_t interface)
612{
613 InterfacePairIpv4 pair = std::make_pair (ipv4->GetObject<Node> ()->GetId (), interface);
614
615 if (g_interfaceStreamMapIpv4.find (pair) == g_interfaceStreamMapIpv4.end ())
616 {
617 NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
618 return;
619 }
620 *stream->GetStream () << "t " << Simulator::Now ().GetSeconds () << " " << *packet << std::endl;
621}
622
630static void
633 Ptr<const Packet> packet,
634 Ptr<Ipv4> ipv4,
635 uint32_t interface)
636{
637 InterfacePairIpv4 pair = std::make_pair (ipv4->GetObject<Node> ()->GetId (), interface);
638 if (g_interfaceStreamMapIpv4.find (pair) == g_interfaceStreamMapIpv4.end ())
639 {
640 NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
641 return;
642 }
643
644 *stream->GetStream () << "r " << Simulator::Now ().GetSeconds () << " " << *packet << std::endl;
645}
646
657static void
660 std::string context,
661 Ipv4Header const &header,
662 Ptr<const Packet> packet,
664 Ptr<Ipv4> ipv4,
665 uint32_t interface)
666{
667 //
668 // Since trace sources are independent of interface, if we hook a source
669 // on a particular protocol we will get traces for all of its interfaces.
670 // We need to filter this to only report interfaces for which the user
671 // has expressed interest.
672 //
673 InterfacePairIpv4 pair = std::make_pair (ipv4->GetObject<Node> ()->GetId (), interface);
674 if (g_interfaceStreamMapIpv4.find (pair) == g_interfaceStreamMapIpv4.end ())
675 {
676 NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
677 return;
678 }
679
680 Ptr<Packet> p = packet->Copy ();
681 p->AddHeader (header);
682#ifdef INTERFACE_CONTEXT
683 *stream->GetStream () << "d " << Simulator::Now ().GetSeconds () << " " << context << "(" << interface << ") "
684 << *p << std::endl;
685#else
686 *stream->GetStream () << "d " << Simulator::Now ().GetSeconds () << " " << context << " " << *p << std::endl;
687#endif
688}
689
698static void
701 std::string context,
702 Ptr<const Packet> packet,
703 Ptr<Ipv4> ipv4,
704 uint32_t interface)
705{
706 InterfacePairIpv4 pair = std::make_pair (ipv4->GetObject<Node> ()->GetId (), interface);
707 if (g_interfaceStreamMapIpv4.find (pair) == g_interfaceStreamMapIpv4.end ())
708 {
709 NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
710 return;
711 }
712
713#ifdef INTERFACE_CONTEXT
714 *stream->GetStream () << "t " << Simulator::Now ().GetSeconds () << " " << context << "(" << interface << ") "
715 << *packet << std::endl;
716#else
717 *stream->GetStream () << "t " << Simulator::Now ().GetSeconds () << " " << context << " " << *packet << std::endl;
718#endif
719}
720
729static void
732 std::string context,
733 Ptr<const Packet> packet,
734 Ptr<Ipv4> ipv4,
735 uint32_t interface)
736{
737 InterfacePairIpv4 pair = std::make_pair (ipv4->GetObject<Node> ()->GetId (), interface);
738 if (g_interfaceStreamMapIpv4.find (pair) == g_interfaceStreamMapIpv4.end ())
739 {
740 NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
741 return;
742 }
743
744#ifdef INTERFACE_CONTEXT
745 *stream->GetStream () << "r " << Simulator::Now ().GetSeconds () << " " << context << "(" << interface << ") "
746 << *packet << std::endl;
747#else
748 *stream->GetStream () << "r " << Simulator::Now ().GetSeconds () << " " << context << " " << *packet << std::endl;
749#endif
750}
751
752bool
754{
755 for ( InterfaceStreamMapIpv4::const_iterator i = g_interfaceStreamMapIpv4.begin ();
756 i != g_interfaceStreamMapIpv4.end ();
757 ++i)
758 {
759 if ((*i).first.first == ipv4->GetObject<Node> ()->GetId ())
760 {
761 return true;
762 }
763 }
764 return false;
765}
766
767void
770 std::string prefix,
771 Ptr<Ipv4> ipv4,
772 uint32_t interface,
773 bool explicitFilename)
774{
775 if (!m_ipv4Enabled)
776 {
777 NS_LOG_INFO ("Call to enable Ipv4 ascii tracing but Ipv4 not enabled");
778 return;
779 }
780
781 //
782 // Our trace sinks are going to use packet printing, so we have to
783 // make sure that is turned on.
784 //
786
787 //
788 // If we are not provided an OutputStreamWrapper, we are expected to create
789 // one using the usual trace filename conventions and hook WithoutContext
790 // since there will be one file per context and therefore the context would
791 // be redundant.
792 //
793 if (!stream)
794 {
795 //
796 // Set up an output stream object to deal with private ofstream copy
797 // constructor and lifetime issues. Let the helper decide the actual
798 // name of the file given the prefix.
799 //
800 // We have to create a stream and a mapping from protocol/interface to
801 // stream irrespective of how many times we want to trace a particular
802 // protocol.
803 //
804 AsciiTraceHelper asciiTraceHelper;
805
806 std::string filename;
807 if (explicitFilename)
808 {
809 filename = prefix;
810 }
811 else
812 {
813 filename = asciiTraceHelper.GetFilenameFromInterfacePair (prefix, ipv4, interface);
814 }
815
816 Ptr<OutputStreamWrapper> theStream = asciiTraceHelper.CreateFileStream (filename);
817
818 //
819 // However, we only hook the trace sources once to avoid multiple trace sink
820 // calls per event (connect is independent of interface).
821 //
822 if (!AsciiHooked (ipv4))
823 {
824 //
825 // We can use the default drop sink for the ArpL3Protocol since it has
826 // the usual signature. We can get to the Ptr<ArpL3Protocol> through
827 // our Ptr<Ipv4> since they must both be aggregated to the same node.
828 //
829 Ptr<ArpL3Protocol> arpL3Protocol = ipv4->GetObject<ArpL3Protocol> ();
830 asciiTraceHelper.HookDefaultDropSinkWithoutContext<ArpL3Protocol> (arpL3Protocol, "Drop", theStream);
831
832 //
833 // The drop sink for the Ipv4L3Protocol uses a different signature than
834 // the default sink, so we have to cook one up for ourselves. We can get
835 // to the Ptr<Ipv4L3Protocol> through our Ptr<Ipv4> since they must both
836 // be aggregated to the same node.
837 //
838 Ptr<Ipv4L3Protocol> ipv4L3Protocol = ipv4->GetObject<Ipv4L3Protocol> ();
839 bool result = ipv4L3Protocol->TraceConnectWithoutContext ("Drop",
841 NS_ASSERT_MSG (result == true, "InternetStackHelper::EnableAsciiIpv4Internal(): "
842 "Unable to connect ipv4L3Protocol \"Drop\"");
843 result = ipv4L3Protocol->TraceConnectWithoutContext ("Tx",
845 NS_ASSERT_MSG (result == true, "InternetStackHelper::EnableAsciiIpv4Internal(): "
846 "Unable to connect ipv4L3Protocol \"Tx\"");
847 result = ipv4L3Protocol->TraceConnectWithoutContext ("Rx",
849 NS_ASSERT_MSG (result == true, "InternetStackHelper::EnableAsciiIpv4Internal(): "
850 "Unable to connect ipv4L3Protocol \"Rx\"");
851 }
852
853 g_interfaceStreamMapIpv4[std::make_pair (ipv4->GetObject<Node> ()->GetId (), interface)] = theStream;
854 return;
855 }
856
857 //
858 // If we are provided an OutputStreamWrapper, we are expected to use it, and
859 // to provide a context. We are free to come up with our own context if we
860 // want, and use the AsciiTraceHelper Hook*WithContext functions, but for
861 // compatibility and simplicity, we just use Config::Connect and let it deal
862 // with the context.
863 //
864 // We need to associate the ipv4/interface with a stream to express interest
865 // in tracing events on that pair, however, we only hook the trace sources
866 // once to avoid multiple trace sink calls per event (connect is independent
867 // of interface).
868 //
869 if (!AsciiHooked (ipv4))
870 {
871 Ptr<Node> node = ipv4->GetObject<Node> ();
872 std::ostringstream oss;
873
874 //
875 // For the ARP Drop, we are going to use the default trace sink provided by
876 // the ascii trace helper. There is actually no AsciiTraceHelper in sight
877 // here, but the default trace sinks are actually publicly available static
878 // functions that are always there waiting for just such a case.
879 //
880 oss << "/NodeList/" << node->GetId () << "/$ns3::ArpL3Protocol/Drop";
882
883 //
884 // This has all kinds of parameters coming with, so we have to cook up our
885 // own sink.
886 //
887 oss.str ("");
888 oss << "/NodeList/" << node->GetId () << "/$ns3::Ipv4L3Protocol/Drop";
890 oss.str ("");
891 oss << "/NodeList/" << node->GetId () << "/$ns3::Ipv4L3Protocol/Tx";
893 oss.str ("");
894 oss << "/NodeList/" << node->GetId () << "/$ns3::Ipv4L3Protocol/Rx";
896 }
897
898 g_interfaceStreamMapIpv4[std::make_pair (ipv4->GetObject<Node> ()->GetId (), interface)] = stream;
899}
900
910static void
913 Ipv6Header const &header,
914 Ptr<const Packet> packet,
916 Ptr<Ipv6> ipv6,
917 uint32_t interface)
918{
919 //
920 // Since trace sources are independent of interface, if we hook a source
921 // on a particular protocol we will get traces for all of its interfaces.
922 // We need to filter this to only report interfaces for which the user
923 // has expressed interest.
924 //
925 InterfacePairIpv6 pair = std::make_pair (ipv6->GetObject<Node> ()->GetId (), interface);
926 if (g_interfaceStreamMapIpv6.find (pair) == g_interfaceStreamMapIpv6.end ())
927 {
928 NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
929 return;
930 }
931
932 Ptr<Packet> p = packet->Copy ();
933 p->AddHeader (header);
934 *stream->GetStream () << "d " << Simulator::Now ().GetSeconds () << " " << *p << std::endl;
935}
936
944static void
947 Ptr<const Packet> packet,
948 Ptr<Ipv6> ipv6,
949 uint32_t interface)
950{
951 InterfacePairIpv6 pair = std::make_pair (ipv6->GetObject<Node> ()->GetId (), interface);
952 if (g_interfaceStreamMapIpv6.find (pair) == g_interfaceStreamMapIpv6.end ())
953 {
954 NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
955 return;
956 }
957
958 *stream->GetStream () << "t " << Simulator::Now ().GetSeconds () << " " << *packet << std::endl;
959}
960
968static void
971 Ptr<const Packet> packet,
972 Ptr<Ipv6> ipv6,
973 uint32_t interface)
974{
975 InterfacePairIpv6 pair = std::make_pair (ipv6->GetObject<Node> ()->GetId (), interface);
976 if (g_interfaceStreamMapIpv6.find (pair) == g_interfaceStreamMapIpv6.end ())
977 {
978 NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
979 return;
980 }
981
982 *stream->GetStream () << "r " << Simulator::Now ().GetSeconds () << " " << *packet << std::endl;
983}
984
995static void
998 std::string context,
999 Ipv6Header const &header,
1000 Ptr<const Packet> packet,
1002 Ptr<Ipv6> ipv6,
1003 uint32_t interface)
1004{
1005 //
1006 // Since trace sources are independent of interface, if we hook a source
1007 // on a particular protocol we will get traces for all of its interfaces.
1008 // We need to filter this to only report interfaces for which the user
1009 // has expressed interest.
1010 //
1011 InterfacePairIpv6 pair = std::make_pair (ipv6->GetObject<Node> ()->GetId (), interface);
1012 if (g_interfaceStreamMapIpv6.find (pair) == g_interfaceStreamMapIpv6.end ())
1013 {
1014 NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
1015 return;
1016 }
1017
1018 Ptr<Packet> p = packet->Copy ();
1019 p->AddHeader (header);
1020#ifdef INTERFACE_CONTEXT
1021 *stream->GetStream () << "d " << Simulator::Now ().GetSeconds () << " " << context << "(" << interface << ") "
1022 << *p << std::endl;
1023#else
1024 *stream->GetStream () << "d " << Simulator::Now ().GetSeconds () << " " << context << " " << *p << std::endl;
1025#endif
1026}
1027
1036static void
1039 std::string context,
1040 Ptr<const Packet> packet,
1041 Ptr<Ipv6> ipv6,
1042 uint32_t interface)
1043{
1044 InterfacePairIpv6 pair = std::make_pair (ipv6->GetObject<Node> ()->GetId (), interface);
1045 if (g_interfaceStreamMapIpv6.find (pair) == g_interfaceStreamMapIpv6.end ())
1046 {
1047 NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
1048 return;
1049 }
1050
1051#ifdef INTERFACE_CONTEXT
1052 *stream->GetStream () << "t " << Simulator::Now ().GetSeconds () << " " << context << "(" << interface << ") "
1053 << *packet << std::endl;
1054#else
1055 *stream->GetStream () << "t " << Simulator::Now ().GetSeconds () << " " << context << " " << *packet << std::endl;
1056#endif
1057}
1058
1067static void
1070 std::string context,
1071 Ptr<const Packet> packet,
1072 Ptr<Ipv6> ipv6,
1073 uint32_t interface)
1074{
1075 InterfacePairIpv6 pair = std::make_pair (ipv6->GetObject<Node> ()->GetId (), interface);
1076 if (g_interfaceStreamMapIpv6.find (pair) == g_interfaceStreamMapIpv6.end ())
1077 {
1078 NS_LOG_INFO ("Ignoring packet to/from interface " << interface);
1079 return;
1080 }
1081
1082#ifdef INTERFACE_CONTEXT
1083 *stream->GetStream () << "r " << Simulator::Now ().GetSeconds () << " " << context << "(" << interface << ") "
1084 << *packet << std::endl;
1085#else
1086 *stream->GetStream () << "r " << Simulator::Now ().GetSeconds () << " " << context << " " << *packet << std::endl;
1087#endif
1088}
1089
1090bool
1092{
1093 for ( InterfaceStreamMapIpv6::const_iterator i = g_interfaceStreamMapIpv6.begin ();
1094 i != g_interfaceStreamMapIpv6.end ();
1095 ++i)
1096 {
1097 if ((*i).first.first == ipv6->GetObject<Node> ()->GetId ())
1098 {
1099 return true;
1100 }
1101 }
1102 return false;
1103}
1104
1105void
1108 std::string prefix,
1109 Ptr<Ipv6> ipv6,
1110 uint32_t interface,
1111 bool explicitFilename)
1112{
1113 if (!m_ipv6Enabled)
1114 {
1115 NS_LOG_INFO ("Call to enable Ipv6 ascii tracing but Ipv6 not enabled");
1116 return;
1117 }
1118
1119 //
1120 // Our trace sinks are going to use packet printing, so we have to
1121 // make sure that is turned on.
1122 //
1124
1125 //
1126 // If we are not provided an OutputStreamWrapper, we are expected to create
1127 // one using the usual trace filename conventions and do a hook WithoutContext
1128 // since there will be one file per context and therefore the context would
1129 // be redundant.
1130 //
1131 if (!stream)
1132 {
1133 //
1134 // Set up an output stream object to deal with private ofstream copy
1135 // constructor and lifetime issues. Let the helper decide the actual
1136 // name of the file given the prefix.
1137 //
1138 // We have to create a stream and a mapping from protocol/interface to
1139 // stream irrespective of how many times we want to trace a particular
1140 // protocol.
1141 //
1142 AsciiTraceHelper asciiTraceHelper;
1143
1144 std::string filename;
1145 if (explicitFilename)
1146 {
1147 filename = prefix;
1148 }
1149 else
1150 {
1151 filename = asciiTraceHelper.GetFilenameFromInterfacePair (prefix, ipv6, interface);
1152 }
1153
1154 Ptr<OutputStreamWrapper> theStream = asciiTraceHelper.CreateFileStream (filename);
1155
1156 //
1157 // However, we only hook the trace sources once to avoid multiple trace sink
1158 // calls per event (connect is independent of interface).
1159 //
1160 if (!AsciiHooked (ipv6))
1161 {
1162 //
1163 // The drop sink for the Ipv6L3Protocol uses a different signature than
1164 // the default sink, so we have to cook one up for ourselves. We can get
1165 // to the Ptr<Ipv6L3Protocol> through our Ptr<Ipv6> since they must both
1166 // be aggregated to the same node.
1167 //
1168 Ptr<Ipv6L3Protocol> ipv6L3Protocol = ipv6->GetObject<Ipv6L3Protocol> ();
1169 bool result = ipv6L3Protocol->TraceConnectWithoutContext ("Drop",
1171 NS_ASSERT_MSG (result == true, "InternetStackHelper::EnableAsciiIpv6Internal(): "
1172 "Unable to connect ipv6L3Protocol \"Drop\"");
1173 result = ipv6L3Protocol->TraceConnectWithoutContext ("Tx",
1175 NS_ASSERT_MSG (result == true, "InternetStackHelper::EnableAsciiIpv6Internal(): "
1176 "Unable to connect ipv6L3Protocol \"Tx\"");
1177 result = ipv6L3Protocol->TraceConnectWithoutContext ("Rx",
1179 NS_ASSERT_MSG (result == true, "InternetStackHelper::EnableAsciiIpv6Internal(): "
1180 "Unable to connect ipv6L3Protocol \"Rx\"");
1181 }
1182
1183 g_interfaceStreamMapIpv6[std::make_pair (ipv6->GetObject<Node> ()->GetId (), interface)] = theStream;
1184 return;
1185 }
1186
1187 //
1188 // If we are provided an OutputStreamWrapper, we are expected to use it, and
1189 // to provide a context. We are free to come up with our own context if we
1190 // want, and use the AsciiTraceHelper Hook*WithContext functions, but for
1191 // compatibility and simplicity, we just use Config::Connect and let it deal
1192 // with the context.
1193 //
1194 // We need to associate the ipv4/interface with a stream to express interest
1195 // in tracing events on that pair, however, we only hook the trace sources
1196 // once to avoid multiple trace sink calls per event (connect is independent
1197 // of interface).
1198 //
1199 if (!AsciiHooked (ipv6))
1200 {
1201 Ptr<Node> node = ipv6->GetObject<Node> ();
1202 std::ostringstream oss;
1203
1204 oss.str ("");
1205 oss << "/NodeList/" << node->GetId () << "/$ns3::Ipv6L3Protocol/Drop";
1207 oss.str ("");
1208 oss << "/NodeList/" << node->GetId () << "/$ns3::Ipv6L3Protocol/Tx";
1210 oss.str ("");
1211 oss << "/NodeList/" << node->GetId () << "/$ns3::Ipv6L3Protocol/Rx";
1213 }
1214
1215 g_interfaceStreamMapIpv6[std::make_pair (ipv6->GetObject<Node> ()->GetId (), interface)] = stream;
1216}
1217
1218} // 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 Ipv4RoutingHelper * Copy(void) const =0
virtual constructor
virtual Ptr< Ipv4RoutingProtocol > Create(Ptr< Node > node) const =0
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.
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
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()
Create a NodeContainer that contains a list of all nodes created through NodeContainer::Create() and ...
A network Node.
Definition: node.h:57
uint32_t GetId(void) const
Definition: node.cc:109
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
Definition: object-base.cc:364
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:380
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:206
#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:282
auto MakeBoundCallback(R(*fnPtr)(Args...), BArgs... bargs)
Make Callbacks with varying number of bound arguments.
Definition: callback.h:714
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition: callback.h:661
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< uint32_t, uint32_t > InterfacePairIpv6
Ipv6/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.
std::pair< uint32_t, uint32_t > InterfacePairIpv4
Ipv4/interface pair.
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.
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.