A Discrete-Event Network Simulator
API
internet-stack-helper.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008 INRIA
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18 * Author: Faker Moatamri <faker.moatamri@sophia.inria.fr>
19 */
20
22
23#include "ns3/arp-l3-protocol.h"
24#include "ns3/assert.h"
25#include "ns3/callback.h"
26#include "ns3/config.h"
27#include "ns3/core-config.h"
28#include "ns3/global-router-interface.h"
29#include "ns3/icmpv6-l4-protocol.h"
30#include "ns3/ipv4-global-routing-helper.h"
31#include "ns3/ipv4-global-routing.h"
32#include "ns3/ipv4-list-routing-helper.h"
33#include "ns3/ipv4-static-routing-helper.h"
34#include "ns3/ipv4.h"
35#include "ns3/ipv6-extension-demux.h"
36#include "ns3/ipv6-extension-header.h"
37#include "ns3/ipv6-extension.h"
38#include "ns3/ipv6-static-routing-helper.h"
39#include "ns3/ipv6.h"
40#include "ns3/log.h"
41#include "ns3/names.h"
42#include "ns3/net-device.h"
43#include "ns3/node-list.h"
44#include "ns3/node.h"
45#include "ns3/object.h"
46#include "ns3/packet-socket-factory.h"
47#include "ns3/simulator.h"
48#include "ns3/string.h"
49#include "ns3/traffic-control-layer.h"
50
51#include <limits>
52#include <map>
53
54namespace ns3
55{
56
57NS_LOG_COMPONENT_DEFINE("InternetStackHelper");
58
59//
60// Historically, the only context written to ascii traces was the protocol.
61// Traces from the protocols include the interface, though. It is not
62// possible to really determine where an event originated without including
63// this. If you want the additional context information, define
64// INTERFACE_CONTEXT. If you want compatibility with the old-style traces
65// comment it out.
66//
67#define INTERFACE_CONTEXT
68
69//
70// Things are going to work differently here with respect to trace file handling
71// than in most places because the Tx and Rx trace sources we are interested in
72// are going to multiplex receive and transmit callbacks for all Ipv4 and
73// interface pairs through one callback. We want packets to or from each
74// distinct pair to go to an individual file, so we have got to demultiplex the
75// Ipv4 and interface pair into a corresponding Ptr<PcapFileWrapper> at the
76// callback.
77//
78// A complication in this situation is that the trace sources are hooked on
79// a protocol basis. There is no trace source hooked by an Ipv4 and interface
80// pair. This means that if we naively proceed to hook, say, a drop trace
81// for a given Ipv4 with interface 0, and then hook for Ipv4 with interface 1
82// we will hook the drop trace twice and get two callbacks per event. What
83// we need to do is to hook the event once, and that will result in a single
84// callback per drop event, and the trace source will provide the interface
85// which we filter on in the trace sink.
86//
87// The use of global maps allows this to continue to work properly even if
88// the helper is destroyed before the simulation completes. If the maps
89// are populated, the reference counting smart pointers to
90// OutputStreamWrapper and PcapFileWrapper will cause those objects to be
91// destroyed at static object destruction time; i.e., the simulator does
92// not explicitly clear these maps before the program ends.
93//
94typedef std::pair<uint32_t, uint32_t> InterfacePairIpv4;
95typedef std::map<InterfacePairIpv4, Ptr<PcapFileWrapper>>
97typedef std::map<InterfacePairIpv4, Ptr<OutputStreamWrapper>>
99
104
105typedef std::pair<uint32_t, uint32_t> InterfacePairIpv6;
106typedef std::map<InterfacePairIpv6, Ptr<PcapFileWrapper>>
108typedef std::map<InterfacePairIpv6, Ptr<OutputStreamWrapper>>
110
115
117 : m_routing(nullptr),
118 m_routingv6(nullptr),
119 m_ipv4Enabled(true),
120 m_ipv6Enabled(true),
121 m_ipv4ArpJitterEnabled(true),
122 m_ipv6NsRsJitterEnabled(true)
123
124{
125 Initialize();
126}
127
128// private method called by both constructor and Reset ()
129void
131{
132 SetTcp("ns3::TcpL4Protocol");
133 Ipv4StaticRoutingHelper staticRouting;
134 Ipv4GlobalRoutingHelper globalRouting;
135 Ipv4ListRoutingHelper listRouting;
136 Ipv6StaticRoutingHelper staticRoutingv6;
137 listRouting.Add(staticRouting, 0);
138 listRouting.Add(globalRouting, -10);
139 SetRoutingHelper(listRouting);
140 SetRoutingHelper(staticRoutingv6);
141}
142
144{
145 delete m_routing;
146 delete m_routingv6;
147}
148
150{
151 m_routing = o.m_routing->Copy();
158}
159
162{
163 if (this == &o)
164 {
165 return *this;
166 }
167 m_routing = o.m_routing->Copy();
169 return *this;
170}
171
172void
174{
175 delete m_routing;
176 m_routing = nullptr;
177 delete m_routingv6;
178 m_routingv6 = nullptr;
179 m_ipv4Enabled = true;
180 m_ipv6Enabled = true;
183 Initialize();
184}
185
186void
188{
189 delete m_routing;
190 m_routing = routing.Copy();
191}
192
193void
195{
196 delete m_routingv6;
197 m_routingv6 = routing.Copy();
198}
199
200void
202{
203 m_ipv4Enabled = enable;
204}
205
206void
208{
209 m_ipv6Enabled = enable;
210}
211
212void
214{
215 m_ipv4ArpJitterEnabled = enable;
216}
217
218void
220{
222}
223
224int64_t
226{
227 int64_t currentStream = stream;
228 for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i)
229 {
230 Ptr<Node> node = *i;
231 Ptr<GlobalRouter> router = node->GetObject<GlobalRouter>();
232 if (router)
233 {
234 Ptr<Ipv4GlobalRouting> gr = router->GetRoutingProtocol();
235 if (gr)
236 {
237 currentStream += gr->AssignStreams(currentStream);
238 }
239 }
241 if (demux)
242 {
244 NS_ASSERT(fe); // should always exist in the demux
245 currentStream += fe->AssignStreams(currentStream);
246 }
247 Ptr<Ipv4> ipv4 = node->GetObject<Ipv4>();
248 if (ipv4)
249 {
250 Ptr<ArpL3Protocol> arpL3Protocol = ipv4->GetObject<ArpL3Protocol>();
251 if (arpL3Protocol)
252 {
253 currentStream += arpL3Protocol->AssignStreams(currentStream);
254 }
255 }
256 Ptr<Ipv6> ipv6 = node->GetObject<Ipv6>();
257 if (ipv6)
258 {
259 Ptr<Icmpv6L4Protocol> icmpv6L4Protocol = ipv6->GetObject<Icmpv6L4Protocol>();
260 if (icmpv6L4Protocol)
261 {
262 currentStream += icmpv6L4Protocol->AssignStreams(currentStream);
263 }
264 }
265 }
266 return (currentStream - stream);
267}
268
269void
270InternetStackHelper::SetTcp(const std::string tid)
271{
273}
274
275void
277{
278 for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i)
279 {
280 Install(*i);
281 }
282}
283
284void
286{
288}
289
290void
292{
293 ObjectFactory factory;
294 factory.SetTypeId(typeId);
295 Ptr<Object> protocol = factory.Create<Object>();
296 node->AggregateObject(protocol);
297}
298
299void
301{
302 if (m_ipv4Enabled)
303 {
304 if (node->GetObject<Ipv4>())
305 {
306 NS_FATAL_ERROR("InternetStackHelper::Install (): Aggregating "
307 "an InternetStack to a node with an existing Ipv4 object");
308 return;
309 }
310
311 CreateAndAggregateObjectFromTypeId(node, "ns3::ArpL3Protocol");
312 CreateAndAggregateObjectFromTypeId(node, "ns3::Ipv4L3Protocol");
313 CreateAndAggregateObjectFromTypeId(node, "ns3::Icmpv4L4Protocol");
314 if (m_ipv4ArpJitterEnabled == false)
315 {
317 NS_ASSERT(arp);
318 arp->SetAttribute("RequestJitter",
319 StringValue("ns3::ConstantRandomVariable[Constant=0.0]"));
320 }
321 // Set routing
322 Ptr<Ipv4> ipv4 = node->GetObject<Ipv4>();
323 Ptr<Ipv4RoutingProtocol> ipv4Routing = m_routing->Create(node);
324 ipv4->SetRoutingProtocol(ipv4Routing);
325 }
326
327 if (m_ipv6Enabled)
328 {
329 /* IPv6 stack */
330 if (node->GetObject<Ipv6>())
331 {
332 NS_FATAL_ERROR("InternetStackHelper::Install (): Aggregating "
333 "an InternetStack to a node with an existing Ipv6 object");
334 return;
335 }
336
337 CreateAndAggregateObjectFromTypeId(node, "ns3::Ipv6L3Protocol");
338 CreateAndAggregateObjectFromTypeId(node, "ns3::Icmpv6L4Protocol");
339 if (m_ipv6NsRsJitterEnabled == false)
340 {
342 NS_ASSERT(icmpv6l4);
343 icmpv6l4->SetAttribute("SolicitationJitter",
344 StringValue("ns3::ConstantRandomVariable[Constant=0.0]"));
345 }
346 // Set routing
347 Ptr<Ipv6> ipv6 = node->GetObject<Ipv6>();
348 Ptr<Ipv6RoutingProtocol> ipv6Routing = m_routingv6->Create(node);
349 ipv6->SetRoutingProtocol(ipv6Routing);
350
351 /* register IPv6 extensions and options */
352 ipv6->RegisterExtensions();
353 ipv6->RegisterOptions();
354 }
355
357 {
358 CreateAndAggregateObjectFromTypeId(node, "ns3::TrafficControlLayer");
359 CreateAndAggregateObjectFromTypeId(node, "ns3::UdpL4Protocol");
361 Ptr<PacketSocketFactory> factory = CreateObject<PacketSocketFactory>();
362 node->AggregateObject(factory);
363 }
364
365 if (m_ipv4Enabled)
366 {
369 NS_ASSERT(arp);
370 NS_ASSERT(tc);
371 arp->SetTrafficControl(tc);
372 }
373}
374
375void
376InternetStackHelper::Install(std::string nodeName) const
377{
378 Ptr<Node> node = Names::Find<Node>(nodeName);
379 Install(node);
380}
381
388static void
390{
391 NS_LOG_FUNCTION(p << ipv4 << interface);
392
393 //
394 // Since trace sources are independent of interface, if we hook a source
395 // on a particular protocol we will get traces for all of its interfaces.
396 // We need to filter this to only report interfaces for which the user
397 // has expressed interest.
398 //
399 InterfacePairIpv4 pair = std::make_pair(ipv4->GetObject<Node>()->GetId(), interface);
400 if (g_interfaceFileMapIpv4.find(pair) == g_interfaceFileMapIpv4.end())
401 {
402 NS_LOG_INFO("Ignoring packet to/from interface " << interface);
403 return;
404 }
405
407 file->Write(Simulator::Now(), p);
408}
409
410bool
412{
413 for (InterfaceFileMapIpv4::const_iterator i = g_interfaceFileMapIpv4.begin();
414 i != g_interfaceFileMapIpv4.end();
415 ++i)
416 {
417 if ((*i).first.first == ipv4->GetObject<Node>()->GetId())
418 {
419 return true;
420 }
421 }
422 return false;
423}
424
425void
427 Ptr<Ipv4> ipv4,
428 uint32_t interface,
429 bool explicitFilename)
430{
431 NS_LOG_FUNCTION(prefix << ipv4 << interface);
432
433 if (!m_ipv4Enabled)
434 {
435 NS_LOG_INFO("Call to enable Ipv4 pcap tracing but Ipv4 not enabled");
436 return;
437 }
438
439 //
440 // We have to create a file and a mapping from protocol/interface to file
441 // irrespective of how many times we want to trace a particular protocol.
442 //
443 PcapHelper pcapHelper;
444
445 std::string filename;
446 if (explicitFilename)
447 {
448 filename = prefix;
449 }
450 else
451 {
452 filename = pcapHelper.GetFilenameFromInterfacePair(prefix, ipv4, interface);
453 }
454
455 Ptr<PcapFileWrapper> file = pcapHelper.CreateFile(filename, std::ios::out, PcapHelper::DLT_RAW);
456
457 //
458 // However, we only hook the trace source once to avoid multiple trace sink
459 // calls per event (connect is independent of interface).
460 //
461 if (!PcapHooked(ipv4))
462 {
463 //
464 // Ptr<Ipv4> is aggregated to node and Ipv4L3Protocol is aggregated to
465 // node so we can get to Ipv4L3Protocol through Ipv4.
466 //
467 Ptr<Ipv4L3Protocol> ipv4L3Protocol = ipv4->GetObject<Ipv4L3Protocol>();
468 NS_ASSERT_MSG(ipv4L3Protocol,
469 "InternetStackHelper::EnablePcapIpv4Internal(): "
470 "m_ipv4Enabled and ipv4L3Protocol inconsistent");
471
472 bool result =
473 ipv4L3Protocol->TraceConnectWithoutContext("Tx", MakeCallback(&Ipv4L3ProtocolRxTxSink));
474 NS_ASSERT_MSG(result == true,
475 "InternetStackHelper::EnablePcapIpv4Internal(): "
476 "Unable to connect ipv4L3Protocol \"Tx\"");
477
478 result =
479 ipv4L3Protocol->TraceConnectWithoutContext("Rx", MakeCallback(&Ipv4L3ProtocolRxTxSink));
480 NS_ASSERT_MSG(result == true,
481 "InternetStackHelper::EnablePcapIpv4Internal(): "
482 "Unable to connect ipv4L3Protocol \"Rx\"");
483 }
484
485 g_interfaceFileMapIpv4[std::make_pair(ipv4->GetObject<Node>()->GetId(), interface)] = file;
486}
487
494static void
496{
497 NS_LOG_FUNCTION(p << ipv6 << interface);
498
499 //
500 // Since trace sources are independent of interface, if we hook a source
501 // on a particular protocol we will get traces for all of its interfaces.
502 // We need to filter this to only report interfaces for which the user
503 // has expressed interest.
504 //
505 InterfacePairIpv6 pair = std::make_pair(ipv6->GetObject<Node>()->GetId(), interface);
506 if (g_interfaceFileMapIpv6.find(pair) == g_interfaceFileMapIpv6.end())
507 {
508 NS_LOG_INFO("Ignoring packet to/from interface " << interface);
509 return;
510 }
511
513 file->Write(Simulator::Now(), p);
514}
515
516bool
518{
519 for (InterfaceFileMapIpv6::const_iterator i = g_interfaceFileMapIpv6.begin();
520 i != g_interfaceFileMapIpv6.end();
521 ++i)
522 {
523 if ((*i).first.first == ipv6->GetObject<Node>()->GetId())
524 {
525 return true;
526 }
527 }
528 return false;
529}
530
531void
533 Ptr<Ipv6> ipv6,
534 uint32_t interface,
535 bool explicitFilename)
536{
537 NS_LOG_FUNCTION(prefix << ipv6 << interface);
538
539 if (!m_ipv6Enabled)
540 {
541 NS_LOG_INFO("Call to enable Ipv6 pcap tracing but Ipv6 not enabled");
542 return;
543 }
544
545 //
546 // We have to create a file and a mapping from protocol/interface to file
547 // irrespective of how many times we want to trace a particular protocol.
548 //
549 PcapHelper pcapHelper;
550
551 std::string filename;
552 if (explicitFilename)
553 {
554 filename = prefix;
555 }
556 else
557 {
558 filename = pcapHelper.GetFilenameFromInterfacePair(prefix, ipv6, interface);
559 }
560
561 Ptr<PcapFileWrapper> file = pcapHelper.CreateFile(filename, std::ios::out, PcapHelper::DLT_RAW);
562
563 //
564 // However, we only hook the trace source once to avoid multiple trace sink
565 // calls per event (connect is independent of interface).
566 //
567 if (!PcapHooked(ipv6))
568 {
569 //
570 // Ptr<Ipv6> is aggregated to node and Ipv6L3Protocol is aggregated to
571 // node so we can get to Ipv6L3Protocol through Ipv6.
572 //
573 Ptr<Ipv6L3Protocol> ipv6L3Protocol = ipv6->GetObject<Ipv6L3Protocol>();
574 NS_ASSERT_MSG(ipv6L3Protocol,
575 "InternetStackHelper::EnablePcapIpv6Internal(): "
576 "m_ipv6Enabled and ipv6L3Protocol inconsistent");
577
578 bool result =
579 ipv6L3Protocol->TraceConnectWithoutContext("Tx", MakeCallback(&Ipv6L3ProtocolRxTxSink));
580 NS_ASSERT_MSG(result == true,
581 "InternetStackHelper::EnablePcapIpv6Internal(): "
582 "Unable to connect ipv6L3Protocol \"Tx\"");
583
584 result =
585 ipv6L3Protocol->TraceConnectWithoutContext("Rx", MakeCallback(&Ipv6L3ProtocolRxTxSink));
586 NS_ASSERT_MSG(result == true,
587 "InternetStackHelper::EnablePcapIpv6Internal(): "
588 "Unable to connect ipv6L3Protocol \"Rx\"");
589 }
590
591 g_interfaceFileMapIpv6[std::make_pair(ipv6->GetObject<Node>()->GetId(), interface)] = file;
592}
593
603static void
605 const Ipv4Header& header,
606 Ptr<const Packet> packet,
608 Ptr<Ipv4> ipv4,
609 uint32_t interface)
610{
611 //
612 // Since trace sources are independent of interface, if we hook a source
613 // on a particular protocol we will get traces for all of its interfaces.
614 // We need to filter this to only report interfaces for which the user
615 // has expressed interest.
616 //
617 InterfacePairIpv4 pair = std::make_pair(ipv4->GetObject<Node>()->GetId(), interface);
619 {
620 NS_LOG_INFO("Ignoring packet to/from interface " << interface);
621 return;
622 }
623
624 Ptr<Packet> p = packet->Copy();
625 p->AddHeader(header);
626 *stream->GetStream() << "d " << Simulator::Now().GetSeconds() << " " << *p << std::endl;
627}
628
636static void
638 Ptr<const Packet> packet,
639 Ptr<Ipv4> ipv4,
640 uint32_t interface)
641{
642 InterfacePairIpv4 pair = std::make_pair(ipv4->GetObject<Node>()->GetId(), interface);
643
645 {
646 NS_LOG_INFO("Ignoring packet to/from interface " << interface);
647 return;
648 }
649 *stream->GetStream() << "t " << Simulator::Now().GetSeconds() << " " << *packet << std::endl;
650}
651
659static void
661 Ptr<const Packet> packet,
662 Ptr<Ipv4> ipv4,
663 uint32_t interface)
664{
665 InterfacePairIpv4 pair = std::make_pair(ipv4->GetObject<Node>()->GetId(), interface);
667 {
668 NS_LOG_INFO("Ignoring packet to/from interface " << interface);
669 return;
670 }
671
672 *stream->GetStream() << "r " << Simulator::Now().GetSeconds() << " " << *packet << std::endl;
673}
674
685static void
687 std::string context,
688 const Ipv4Header& header,
689 Ptr<const Packet> packet,
691 Ptr<Ipv4> ipv4,
692 uint32_t interface)
693{
694 //
695 // Since trace sources are independent of interface, if we hook a source
696 // on a particular protocol we will get traces for all of its interfaces.
697 // We need to filter this to only report interfaces for which the user
698 // has expressed interest.
699 //
700 InterfacePairIpv4 pair = std::make_pair(ipv4->GetObject<Node>()->GetId(), interface);
702 {
703 NS_LOG_INFO("Ignoring packet to/from interface " << interface);
704 return;
705 }
706
707 Ptr<Packet> p = packet->Copy();
708 p->AddHeader(header);
709#ifdef INTERFACE_CONTEXT
710 *stream->GetStream() << "d " << Simulator::Now().GetSeconds() << " " << context << "("
711 << interface << ") " << *p << std::endl;
712#else
713 *stream->GetStream() << "d " << Simulator::Now().GetSeconds() << " " << context << " " << *p
714 << std::endl;
715#endif
716}
717
726static void
728 std::string context,
729 Ptr<const Packet> packet,
730 Ptr<Ipv4> ipv4,
731 uint32_t interface)
732{
733 InterfacePairIpv4 pair = std::make_pair(ipv4->GetObject<Node>()->GetId(), interface);
735 {
736 NS_LOG_INFO("Ignoring packet to/from interface " << interface);
737 return;
738 }
739
740#ifdef INTERFACE_CONTEXT
741 *stream->GetStream() << "t " << Simulator::Now().GetSeconds() << " " << context << "("
742 << interface << ") " << *packet << std::endl;
743#else
744 *stream->GetStream() << "t " << Simulator::Now().GetSeconds() << " " << context << " "
745 << *packet << std::endl;
746#endif
747}
748
757static void
759 std::string context,
760 Ptr<const Packet> packet,
761 Ptr<Ipv4> ipv4,
762 uint32_t interface)
763{
764 InterfacePairIpv4 pair = std::make_pair(ipv4->GetObject<Node>()->GetId(), interface);
766 {
767 NS_LOG_INFO("Ignoring packet to/from interface " << interface);
768 return;
769 }
770
771#ifdef INTERFACE_CONTEXT
772 *stream->GetStream() << "r " << Simulator::Now().GetSeconds() << " " << context << "("
773 << interface << ") " << *packet << std::endl;
774#else
775 *stream->GetStream() << "r " << Simulator::Now().GetSeconds() << " " << context << " "
776 << *packet << std::endl;
777#endif
778}
779
780bool
782{
783 for (InterfaceStreamMapIpv4::const_iterator i = g_interfaceStreamMapIpv4.begin();
784 i != g_interfaceStreamMapIpv4.end();
785 ++i)
786 {
787 if ((*i).first.first == ipv4->GetObject<Node>()->GetId())
788 {
789 return true;
790 }
791 }
792 return false;
793}
794
795void
797 std::string prefix,
798 Ptr<Ipv4> ipv4,
799 uint32_t interface,
800 bool explicitFilename)
801{
802 if (!m_ipv4Enabled)
803 {
804 NS_LOG_INFO("Call to enable Ipv4 ascii tracing but Ipv4 not enabled");
805 return;
806 }
807
808 //
809 // Our trace sinks are going to use packet printing, so we have to
810 // make sure that is turned on.
811 //
813
814 //
815 // If we are not provided an OutputStreamWrapper, we are expected to create
816 // one using the usual trace filename conventions and hook WithoutContext
817 // since there will be one file per context and therefore the context would
818 // be redundant.
819 //
820 if (!stream)
821 {
822 //
823 // Set up an output stream object to deal with private ofstream copy
824 // constructor and lifetime issues. Let the helper decide the actual
825 // name of the file given the prefix.
826 //
827 // We have to create a stream and a mapping from protocol/interface to
828 // stream irrespective of how many times we want to trace a particular
829 // protocol.
830 //
831 AsciiTraceHelper asciiTraceHelper;
832
833 std::string filename;
834 if (explicitFilename)
835 {
836 filename = prefix;
837 }
838 else
839 {
840 filename = asciiTraceHelper.GetFilenameFromInterfacePair(prefix, ipv4, interface);
841 }
842
843 Ptr<OutputStreamWrapper> theStream = asciiTraceHelper.CreateFileStream(filename);
844
845 //
846 // However, we only hook the trace sources once to avoid multiple trace sink
847 // calls per event (connect is independent of interface).
848 //
849 if (!AsciiHooked(ipv4))
850 {
851 //
852 // We can use the default drop sink for the ArpL3Protocol since it has
853 // the usual signature. We can get to the Ptr<ArpL3Protocol> through
854 // our Ptr<Ipv4> since they must both be aggregated to the same node.
855 //
856 Ptr<ArpL3Protocol> arpL3Protocol = ipv4->GetObject<ArpL3Protocol>();
857 asciiTraceHelper.HookDefaultDropSinkWithoutContext<ArpL3Protocol>(arpL3Protocol,
858 "Drop",
859 theStream);
860
861 //
862 // The drop sink for the Ipv4L3Protocol uses a different signature than
863 // the default sink, so we have to cook one up for ourselves. We can get
864 // to the Ptr<Ipv4L3Protocol> through our Ptr<Ipv4> since they must both
865 // be aggregated to the same node.
866 //
867 Ptr<Ipv4L3Protocol> ipv4L3Protocol = ipv4->GetObject<Ipv4L3Protocol>();
868 bool result = ipv4L3Protocol->TraceConnectWithoutContext(
869 "Drop",
871 NS_ASSERT_MSG(result == true,
872 "InternetStackHelper::EnableAsciiIpv4Internal(): "
873 "Unable to connect ipv4L3Protocol \"Drop\"");
874 result = ipv4L3Protocol->TraceConnectWithoutContext(
875 "Tx",
877 NS_ASSERT_MSG(result == true,
878 "InternetStackHelper::EnableAsciiIpv4Internal(): "
879 "Unable to connect ipv4L3Protocol \"Tx\"");
880 result = ipv4L3Protocol->TraceConnectWithoutContext(
881 "Rx",
883 NS_ASSERT_MSG(result == true,
884 "InternetStackHelper::EnableAsciiIpv4Internal(): "
885 "Unable to connect ipv4L3Protocol \"Rx\"");
886 }
887
888 g_interfaceStreamMapIpv4[std::make_pair(ipv4->GetObject<Node>()->GetId(), interface)] =
889 theStream;
890 return;
891 }
892
893 //
894 // If we are provided an OutputStreamWrapper, we are expected to use it, and
895 // to provide a context. We are free to come up with our own context if we
896 // want, and use the AsciiTraceHelper Hook*WithContext functions, but for
897 // compatibility and simplicity, we just use Config::Connect and let it deal
898 // with the context.
899 //
900 // We need to associate the ipv4/interface with a stream to express interest
901 // in tracing events on that pair, however, we only hook the trace sources
902 // once to avoid multiple trace sink calls per event (connect is independent
903 // of interface).
904 //
905 if (!AsciiHooked(ipv4))
906 {
907 Ptr<Node> node = ipv4->GetObject<Node>();
908 std::ostringstream oss;
909
910 //
911 // For the ARP Drop, we are going to use the default trace sink provided by
912 // the ascii trace helper. There is actually no AsciiTraceHelper in sight
913 // here, but the default trace sinks are actually publicly available static
914 // functions that are always there waiting for just such a case.
915 //
916 oss << "/NodeList/" << node->GetId() << "/$ns3::ArpL3Protocol/Drop";
917 Config::Connect(oss.str(),
919
920 //
921 // This has all kinds of parameters coming with, so we have to cook up our
922 // own sink.
923 //
924 oss.str("");
925 oss << "/NodeList/" << node->GetId() << "/$ns3::Ipv4L3Protocol/Drop";
927 oss.str("");
928 oss << "/NodeList/" << node->GetId() << "/$ns3::Ipv4L3Protocol/Tx";
930 oss.str("");
931 oss << "/NodeList/" << node->GetId() << "/$ns3::Ipv4L3Protocol/Rx";
933 }
934
935 g_interfaceStreamMapIpv4[std::make_pair(ipv4->GetObject<Node>()->GetId(), interface)] = stream;
936}
937
947static void
949 const Ipv6Header& header,
950 Ptr<const Packet> packet,
952 Ptr<Ipv6> ipv6,
953 uint32_t interface)
954{
955 //
956 // Since trace sources are independent of interface, if we hook a source
957 // on a particular protocol we will get traces for all of its interfaces.
958 // We need to filter this to only report interfaces for which the user
959 // has expressed interest.
960 //
961 InterfacePairIpv6 pair = std::make_pair(ipv6->GetObject<Node>()->GetId(), interface);
963 {
964 NS_LOG_INFO("Ignoring packet to/from interface " << interface);
965 return;
966 }
967
968 Ptr<Packet> p = packet->Copy();
969 p->AddHeader(header);
970 *stream->GetStream() << "d " << Simulator::Now().GetSeconds() << " " << *p << std::endl;
971}
972
980static void
982 Ptr<const Packet> packet,
983 Ptr<Ipv6> ipv6,
984 uint32_t interface)
985{
986 InterfacePairIpv6 pair = std::make_pair(ipv6->GetObject<Node>()->GetId(), interface);
988 {
989 NS_LOG_INFO("Ignoring packet to/from interface " << interface);
990 return;
991 }
992
993 *stream->GetStream() << "t " << Simulator::Now().GetSeconds() << " " << *packet << std::endl;
994}
995
1003static void
1005 Ptr<const Packet> packet,
1006 Ptr<Ipv6> ipv6,
1007 uint32_t interface)
1008{
1009 InterfacePairIpv6 pair = std::make_pair(ipv6->GetObject<Node>()->GetId(), interface);
1010 if (g_interfaceStreamMapIpv6.find(pair) == g_interfaceStreamMapIpv6.end())
1011 {
1012 NS_LOG_INFO("Ignoring packet to/from interface " << interface);
1013 return;
1014 }
1015
1016 *stream->GetStream() << "r " << Simulator::Now().GetSeconds() << " " << *packet << std::endl;
1017}
1018
1029static void
1031 std::string context,
1032 const Ipv6Header& header,
1033 Ptr<const Packet> packet,
1035 Ptr<Ipv6> ipv6,
1036 uint32_t interface)
1037{
1038 //
1039 // Since trace sources are independent of interface, if we hook a source
1040 // on a particular protocol we will get traces for all of its interfaces.
1041 // We need to filter this to only report interfaces for which the user
1042 // has expressed interest.
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 Ptr<Packet> p = packet->Copy();
1052 p->AddHeader(header);
1053#ifdef INTERFACE_CONTEXT
1054 *stream->GetStream() << "d " << Simulator::Now().GetSeconds() << " " << context << "("
1055 << interface << ") " << *p << std::endl;
1056#else
1057 *stream->GetStream() << "d " << Simulator::Now().GetSeconds() << " " << context << " " << *p
1058 << std::endl;
1059#endif
1060}
1061
1070static void
1072 std::string context,
1073 Ptr<const Packet> packet,
1074 Ptr<Ipv6> ipv6,
1075 uint32_t interface)
1076{
1077 InterfacePairIpv6 pair = std::make_pair(ipv6->GetObject<Node>()->GetId(), interface);
1078 if (g_interfaceStreamMapIpv6.find(pair) == g_interfaceStreamMapIpv6.end())
1079 {
1080 NS_LOG_INFO("Ignoring packet to/from interface " << interface);
1081 return;
1082 }
1083
1084#ifdef INTERFACE_CONTEXT
1085 *stream->GetStream() << "t " << Simulator::Now().GetSeconds() << " " << context << "("
1086 << interface << ") " << *packet << std::endl;
1087#else
1088 *stream->GetStream() << "t " << Simulator::Now().GetSeconds() << " " << context << " "
1089 << *packet << std::endl;
1090#endif
1091}
1092
1101static void
1103 std::string context,
1104 Ptr<const Packet> packet,
1105 Ptr<Ipv6> ipv6,
1106 uint32_t interface)
1107{
1108 InterfacePairIpv6 pair = std::make_pair(ipv6->GetObject<Node>()->GetId(), interface);
1109 if (g_interfaceStreamMapIpv6.find(pair) == g_interfaceStreamMapIpv6.end())
1110 {
1111 NS_LOG_INFO("Ignoring packet to/from interface " << interface);
1112 return;
1113 }
1114
1115#ifdef INTERFACE_CONTEXT
1116 *stream->GetStream() << "r " << Simulator::Now().GetSeconds() << " " << context << "("
1117 << interface << ") " << *packet << std::endl;
1118#else
1119 *stream->GetStream() << "r " << Simulator::Now().GetSeconds() << " " << context << " "
1120 << *packet << std::endl;
1121#endif
1122}
1123
1124bool
1126{
1127 for (InterfaceStreamMapIpv6::const_iterator i = g_interfaceStreamMapIpv6.begin();
1128 i != g_interfaceStreamMapIpv6.end();
1129 ++i)
1130 {
1131 if ((*i).first.first == ipv6->GetObject<Node>()->GetId())
1132 {
1133 return true;
1134 }
1135 }
1136 return false;
1137}
1138
1139void
1141 std::string prefix,
1142 Ptr<Ipv6> ipv6,
1143 uint32_t interface,
1144 bool explicitFilename)
1145{
1146 if (!m_ipv6Enabled)
1147 {
1148 NS_LOG_INFO("Call to enable Ipv6 ascii tracing but Ipv6 not enabled");
1149 return;
1150 }
1151
1152 //
1153 // Our trace sinks are going to use packet printing, so we have to
1154 // make sure that is turned on.
1155 //
1157
1158 //
1159 // If we are not provided an OutputStreamWrapper, we are expected to create
1160 // one using the usual trace filename conventions and do a hook WithoutContext
1161 // since there will be one file per context and therefore the context would
1162 // be redundant.
1163 //
1164 if (!stream)
1165 {
1166 //
1167 // Set up an output stream object to deal with private ofstream copy
1168 // constructor and lifetime issues. Let the helper decide the actual
1169 // name of the file given the prefix.
1170 //
1171 // We have to create a stream and a mapping from protocol/interface to
1172 // stream irrespective of how many times we want to trace a particular
1173 // protocol.
1174 //
1175 AsciiTraceHelper asciiTraceHelper;
1176
1177 std::string filename;
1178 if (explicitFilename)
1179 {
1180 filename = prefix;
1181 }
1182 else
1183 {
1184 filename = asciiTraceHelper.GetFilenameFromInterfacePair(prefix, ipv6, interface);
1185 }
1186
1187 Ptr<OutputStreamWrapper> theStream = asciiTraceHelper.CreateFileStream(filename);
1188
1189 //
1190 // However, we only hook the trace sources once to avoid multiple trace sink
1191 // calls per event (connect is independent of interface).
1192 //
1193 if (!AsciiHooked(ipv6))
1194 {
1195 //
1196 // The drop sink for the Ipv6L3Protocol uses a different signature than
1197 // the default sink, so we have to cook one up for ourselves. We can get
1198 // to the Ptr<Ipv6L3Protocol> through our Ptr<Ipv6> since they must both
1199 // be aggregated to the same node.
1200 //
1201 Ptr<Ipv6L3Protocol> ipv6L3Protocol = ipv6->GetObject<Ipv6L3Protocol>();
1202 bool result = ipv6L3Protocol->TraceConnectWithoutContext(
1203 "Drop",
1205 NS_ASSERT_MSG(result == true,
1206 "InternetStackHelper::EnableAsciiIpv6Internal(): "
1207 "Unable to connect ipv6L3Protocol \"Drop\"");
1208 result = ipv6L3Protocol->TraceConnectWithoutContext(
1209 "Tx",
1211 NS_ASSERT_MSG(result == true,
1212 "InternetStackHelper::EnableAsciiIpv6Internal(): "
1213 "Unable to connect ipv6L3Protocol \"Tx\"");
1214 result = ipv6L3Protocol->TraceConnectWithoutContext(
1215 "Rx",
1217 NS_ASSERT_MSG(result == true,
1218 "InternetStackHelper::EnableAsciiIpv6Internal(): "
1219 "Unable to connect ipv6L3Protocol \"Rx\"");
1220 }
1221
1222 g_interfaceStreamMapIpv6[std::make_pair(ipv6->GetObject<Node>()->GetId(), interface)] =
1223 theStream;
1224 return;
1225 }
1226
1227 //
1228 // If we are provided an OutputStreamWrapper, we are expected to use it, and
1229 // to provide a context. We are free to come up with our own context if we
1230 // want, and use the AsciiTraceHelper Hook*WithContext functions, but for
1231 // compatibility and simplicity, we just use Config::Connect and let it deal
1232 // with the context.
1233 //
1234 // We need to associate the ipv4/interface with a stream to express interest
1235 // in tracing events on that pair, however, we only hook the trace sources
1236 // once to avoid multiple trace sink calls per event (connect is independent
1237 // of interface).
1238 //
1239 if (!AsciiHooked(ipv6))
1240 {
1241 Ptr<Node> node = ipv6->GetObject<Node>();
1242 std::ostringstream oss;
1243
1244 oss.str("");
1245 oss << "/NodeList/" << node->GetId() << "/$ns3::Ipv6L3Protocol/Drop";
1247 oss.str("");
1248 oss << "/NodeList/" << node->GetId() << "/$ns3::Ipv6L3Protocol/Tx";
1250 oss.str("");
1251 oss << "/NodeList/" << node->GetId() << "/$ns3::Ipv6L3Protocol/Rx";
1253 }
1254
1255 g_interfaceStreamMapIpv6[std::make_pair(ipv6->GetObject<Node>()->GetId(), interface)] = stream;
1256}
1257
1258} // namespace ns3
An implementation of the ARP protocol.
Manage ASCII trace files for device models.
Definition: trace-helper.h:173
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:533
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 EnablePcapIpv6Internal(std::string prefix, Ptr< Ipv6 > ipv6, uint32_t interface, bool explicitFilename) override
Enable pcap output the indicated Ipv6 and interface pair.
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 EnableAsciiIpv4Internal(Ptr< OutputStreamWrapper > stream, std::string prefix, Ptr< Ipv4 > ipv4, uint32_t interface, bool explicitFilename) override
Enable ascii trace output on the indicated Ipv4 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
bool m_ipv4Enabled
IPv4 install state (enabled/disabled) ?
const Ipv4RoutingHelper * m_routing
IPv4 routing helper.
void InstallAll() 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
void Initialize()
Initialize the helper to its default values.
ObjectFactory m_tcpFactory
TCP objects factory.
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
void EnablePcapIpv4Internal(std::string prefix, Ptr< Ipv4 > ipv4, uint32_t interface, bool explicitFilename) override
Enable pcap output the indicated Ipv4 and interface pair.
bool m_ipv4ArpJitterEnabled
IPv4 ARP Jitter state (enabled/disabled) ?
const Ipv6RoutingHelper * m_routingv6
IPv6 routing helper.
InternetStackHelper & operator=(const InternetStackHelper &o)
Copy constructor.
InternetStackHelper()
Create a new InternetStackHelper which uses a mix of static routing and global routing by default.
void SetTcp(std::string tid)
set the Tcp stack which will not need any other parameter.
void Reset()
Return helper internal state to that of a newly constructed one.
~InternetStackHelper() override
Destroy the InternetStackHelper.
void EnableAsciiIpv6Internal(Ptr< OutputStreamWrapper > stream, std::string prefix, Ptr< Ipv6 > ipv6, uint32_t interface, bool explicitFilename) override
Enable ascii trace output on the indicated Ipv6 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:79
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() 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 Ptr< Ipv6RoutingProtocol > Create(Ptr< Node > node) const =0
virtual Ipv6RoutingHelper * Copy() const =0
virtual constructor
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 End() 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 ...
Iterator Begin() const
Get an iterator which refers to the first Node in the container.
A network Node.
Definition: node.h:56
uint32_t GetId() const
Definition: node.cc:117
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
Definition: object-base.cc:369
Instantiate subclasses of ns3::Object.
Ptr< Object > Create() 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:89
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Definition: object.h:471
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
Definition: object.cc:259
std::ostream * GetStream()
Return a pointer to an ostream previously set in the wrapper.
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:268
Ptr< Packet > Copy() const
performs a COW copy of the packet.
Definition: packet.cc:131
static void EnablePrinting()
Enable printing packets metadata.
Definition: packet.cc:596
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()
Return the current simulation virtual time.
Definition: simulator.cc:199
Hold variables of type string.
Definition: string.h:42
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:402
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:66
#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:86
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:975
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:160
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#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:275
auto MakeBoundCallback(R(*fnPtr)(Args...), BArgs... bargs)
Make Callbacks with varying number of bound arguments.
Definition: callback.h:752
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static void Ipv6L3ProtocolDropSinkWithContext(Ptr< OutputStreamWrapper > stream, std::string context, const Ipv6Header &header, Ptr< const Packet > packet, Ipv6L3Protocol::DropReason reason, Ptr< Ipv6 > ipv6, uint32_t interface)
Sync function for IPv6 dropped packet - Ascii output.
static void Ipv4L3ProtocolDropSinkWithContext(Ptr< OutputStreamWrapper > stream, std::string context, const Ipv4Header &header, Ptr< const Packet > packet, Ipv4L3Protocol::DropReason reason, Ptr< Ipv4 > ipv4, uint32_t interface)
Sync function for IPv4 dropped packet - Ascii output.
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:691
static void Ipv6L3ProtocolRxTxSink(Ptr< const Packet > p, Ptr< Ipv6 > ipv6, uint32_t interface)
Sync function for IPv6 packet - Pcap 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.
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 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 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 Ipv4L3ProtocolDropSinkWithoutContext(Ptr< OutputStreamWrapper > stream, const Ipv4Header &header, Ptr< const Packet > packet, Ipv4L3Protocol::DropReason reason, Ptr< Ipv4 > ipv4, uint32_t interface)
Sync function for IPv4 dropped packet - Ascii output.
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.
static void Ipv6L3ProtocolDropSinkWithoutContext(Ptr< OutputStreamWrapper > stream, const Ipv6Header &header, Ptr< const Packet > packet, Ipv6L3Protocol::DropReason reason, Ptr< Ipv6 > ipv6, uint32_t interface)
Sync function for IPv6 dropped packet - Ascii output.