151 #include "ns3/assert.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"
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"
194 #define INTERFACE_CONTEXT
236 m_ipv4Enabled (true),
237 m_ipv6Enabled (true),
238 m_ipv4ArpJitterEnabled (true),
239 m_ipv6NsRsJitterEnabled (true)
249 SetTcp (
"ns3::TcpL4Protocol");
255 listRouting.
Add (staticRouting, 0);
256 listRouting.
Add (globalRouting, -10);
257 listRoutingv6.
Add (staticRoutingv6, 0);
343 int64_t currentStream = stream;
367 if (arpL3Protocol != 0)
369 currentStream += arpL3Protocol->AssignStreams (currentStream);
376 if (icmpv6L4Protocol != 0)
378 currentStream += icmpv6L4Protocol->AssignStreams (currentStream);
382 return (currentStream - stream);
430 "an InternetStack to a node with an existing Ipv4 object");
441 arp->SetAttribute (
"RequestJitter",
StringValue (
"ns3::ConstantRandomVariable[Constant=0.0]"));
455 "an InternetStack to a node with an existing Ipv6 object");
465 icmpv6l4->SetAttribute (
"SolicitationJitter",
StringValue (
"ns3::ConstantRandomVariable[Constant=0.0]"));
489 Ptr<Node> node = Names::Find<Node> (nodeName);
507 NS_LOG_INFO (
"Ignoring packet to/from interface " << interface);
522 if ((*i).first.first == ipv4)
537 NS_LOG_INFO (
"Call to enable Ipv4 pcap tracing but Ipv4 not enabled");
547 std::string filename;
548 if (explicitFilename)
570 NS_ASSERT_MSG (ipv4L3Protocol,
"InternetStackHelper::EnablePcapIpv4Internal(): "
571 "m_ipv4Enabled and ipv4L3Protocol inconsistent");
574 NS_ASSERT_MSG (result ==
true,
"InternetStackHelper::EnablePcapIpv4Internal(): "
575 "Unable to connect ipv4L3Protocol \"Tx\"");
578 NS_ASSERT_MSG (result ==
true,
"InternetStackHelper::EnablePcapIpv4Internal(): "
579 "Unable to connect ipv4L3Protocol \"Rx\"");
599 NS_LOG_INFO (
"Ignoring packet to/from interface " << interface);
614 if ((*i).first.first == ipv6)
629 NS_LOG_INFO (
"Call to enable Ipv6 pcap tracing but Ipv6 not enabled");
639 std::string filename;
640 if (explicitFilename)
662 NS_ASSERT_MSG (ipv6L3Protocol,
"InternetStackHelper::EnablePcapIpv6Internal(): "
663 "m_ipv6Enabled and ipv6L3Protocol inconsistent");
666 NS_ASSERT_MSG (result ==
true,
"InternetStackHelper::EnablePcapIpv6Internal(): "
667 "Unable to connect ipv6L3Protocol \"Tx\"");
670 NS_ASSERT_MSG (result ==
true,
"InternetStackHelper::EnablePcapIpv6Internal(): "
671 "Unable to connect ipv6L3Protocol \"Rx\"");
695 NS_LOG_INFO (
"Ignoring packet to/from interface " << interface);
714 NS_LOG_INFO (
"Ignoring packet to/from interface " << interface);
731 NS_LOG_INFO (
"Ignoring packet to/from interface " << interface);
757 NS_LOG_INFO (
"Ignoring packet to/from interface " << interface);
763 #ifdef INTERFACE_CONTEXT
782 NS_LOG_INFO (
"Ignoring packet to/from interface " << interface);
786 #ifdef INTERFACE_CONTEXT
788 << *packet << std::endl;
805 NS_LOG_INFO (
"Ignoring packet to/from interface " << interface);
809 #ifdef INTERFACE_CONTEXT
811 << *packet << std::endl;
824 if ((*i).first.first == ipv4)
838 bool explicitFilename)
842 NS_LOG_INFO (
"Call to enable Ipv4 ascii tracing but Ipv4 not enabled");
871 std::string filename;
872 if (explicitFilename)
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\"");
937 std::ostringstream oss;
945 oss <<
"/NodeList/" << node->
GetId () <<
"/$ns3::ArpL3Protocol/Drop";
953 oss <<
"/NodeList/" << node->
GetId () <<
"/$ns3::Ipv4L3Protocol/Drop";
956 oss <<
"/NodeList/" << node->
GetId () <<
"/$ns3::Ipv4L3Protocol/Tx";
959 oss <<
"/NodeList/" << node->
GetId () <<
"/$ns3::Ipv4L3Protocol/Rx";
984 NS_LOG_INFO (
"Ignoring packet to/from interface " << interface);
1003 NS_LOG_INFO (
"Ignoring packet to/from interface " << interface);
1020 NS_LOG_INFO (
"Ignoring packet to/from interface " << interface);
1030 std::string context,
1046 NS_LOG_INFO (
"Ignoring packet to/from interface " << interface);
1052 #ifdef INTERFACE_CONTEXT
1063 std::string context,
1071 NS_LOG_INFO (
"Ignoring packet to/from interface " << interface);
1075 #ifdef INTERFACE_CONTEXT
1077 << *packet << std::endl;
1086 std::string context,
1094 NS_LOG_INFO (
"Ignoring packet to/from interface " << interface);
1098 #ifdef INTERFACE_CONTEXT
1100 << *packet << std::endl;
1113 if ((*i).first.first == ipv6)
1127 bool explicitFilename)
1131 NS_LOG_INFO (
"Call to enable Ipv6 ascii tracing but Ipv6 not enabled");
1160 std::string filename;
1161 if (explicitFilename)
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\"");
1218 std::ostringstream oss;
1221 oss <<
"/NodeList/" << node->
GetId () <<
"/$ns3::Ipv6L3Protocol/Drop";
1224 oss <<
"/NodeList/" << node->
GetId () <<
"/$ns3::Ipv6L3Protocol/Tx";
1227 oss <<
"/NodeList/" << node->
GetId () <<
"/$ns3::Ipv6L3Protocol/Rx";