From a826db4fbb5d7a66e00857fb0e69179f09ac2db1 Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Tue, 8 Mar 2016 10:45:49 -0800 Subject: [PATCH] internet: install the default TC configuration (pfifo_fast) on every device by default --- src/internet/helper/ipv4-address-helper.cc | 16 ++++++++++++ src/internet/helper/ipv6-address-helper.cc | 29 ++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/src/internet/helper/ipv4-address-helper.cc b/src/internet/helper/ipv4-address-helper.cc index 314fec127..5f748569b 100644 --- a/src/internet/helper/ipv4-address-helper.cc +++ b/src/internet/helper/ipv4-address-helper.cc @@ -21,9 +21,12 @@ #include "ns3/ptr.h" #include "ns3/node.h" #include "ns3/net-device.h" +#include "ns3/loopback-net-device.h" #include "ns3/ipv4.h" #include "ns3/ipv4-address-generator.h" #include "ns3/simulator.h" +#include "ns3/traffic-control-helper.h" +#include "ns3/traffic-control-layer.h" #include "ipv4-address-helper.h" namespace ns3 { @@ -157,6 +160,19 @@ Ipv4AddressHelper::Assign (const NetDeviceContainer &c) ipv4->SetMetric (interface, 1); ipv4->SetUp (interface); retval.Add (ipv4, interface); + + Ptr tc = node->GetObject (); + + NS_ASSERT_MSG (tc, "Ipv4AddressHelper::Assign(): NetDevice is associated" + "with a node without the Traffic Control layer installed"); + + // Install the default traffic control configuration, if this is not a loopback + // interface and there is no queue disc installed already + if (DynamicCast (device) == 0 && tc->GetRootQueueDiscOnDevice (device) == 0) + { + TrafficControlHelper tcHelper = TrafficControlHelper::Default (); + tcHelper.Install (device); + } } return retval; } diff --git a/src/internet/helper/ipv6-address-helper.cc b/src/internet/helper/ipv6-address-helper.cc index c2aa7793c..ce5386cd8 100644 --- a/src/internet/helper/ipv6-address-helper.cc +++ b/src/internet/helper/ipv6-address-helper.cc @@ -23,11 +23,14 @@ #include "ns3/ptr.h" #include "ns3/node.h" #include "ns3/net-device.h" +#include "ns3/loopback-net-device.h" #include "ns3/mac16-address.h" #include "ns3/mac48-address.h" #include "ns3/mac64-address.h" #include "ns3/ipv6.h" #include "ns3/ipv6-address-generator.h" +#include "ns3/traffic-control-helper.h" +#include "ns3/traffic-control-layer.h" #include "ipv6-address-helper.h" @@ -140,6 +143,19 @@ Ipv6InterfaceContainer Ipv6AddressHelper::Assign (const NetDeviceContainer &c) ipv6->SetUp (ifIndex); retval.Add (ipv6, ifIndex); + + Ptr tc = node->GetObject (); + + NS_ASSERT_MSG (tc, "Ipv6AddressHelper::Assign(): NetDevice is associated" + "with a node without the Traffic Control layer installed"); + + // Install the default traffic control configuration, if this is not a loopback + // interface and there is no queue disc installed already + if (DynamicCast (device) == 0 && tc->GetRootQueueDiscOnDevice (device) == 0) + { + TrafficControlHelper tcHelper = TrafficControlHelper::Default (); + tcHelper.Install (device); + } } return retval; } @@ -176,6 +192,19 @@ Ipv6InterfaceContainer Ipv6AddressHelper::Assign (const NetDeviceContainer &c, s ipv6->SetUp (ifIndex); retval.Add (ipv6, ifIndex); + + Ptr tc = node->GetObject (); + + NS_ASSERT_MSG (tc, "Ipv6AddressHelper::Assign(): NetDevice is associated" + "with a node without the Traffic Control layer installed"); + + // Install the default traffic control configuration, if this is not a loopback + // interface and there is no queue disc installed already + if (DynamicCast (device) == 0 && tc->GetRootQueueDiscOnDevice (device) == 0) + { + TrafficControlHelper tcHelper = TrafficControlHelper::Default (); + tcHelper.Install (device); + } } return retval; }