From dd2d0858d18c0853ccae2085eeca147135db5153 Mon Sep 17 00:00:00 2001 From: Tommaso Pecorella Date: Thu, 18 Feb 2016 20:50:59 +0100 Subject: [PATCH] sixlowpan: use standard internet helpers --- .../bindings/modulegen__gcc_ILP32.py | 12 ++++- src/sixlowpan/bindings/modulegen__gcc_LP64.py | 12 ++++- .../test/sixlowpan-fragmentation-test.cc | 48 ++++--------------- src/sixlowpan/test/sixlowpan-hc1-test.cc | 36 ++------------ src/sixlowpan/test/sixlowpan-iphc-test.cc | 36 ++------------ 5 files changed, 40 insertions(+), 104 deletions(-) diff --git a/src/sixlowpan/bindings/modulegen__gcc_ILP32.py b/src/sixlowpan/bindings/modulegen__gcc_ILP32.py index 563490907..320c753d3 100644 --- a/src/sixlowpan/bindings/modulegen__gcc_ILP32.py +++ b/src/sixlowpan/bindings/modulegen__gcc_ILP32.py @@ -1061,6 +1061,11 @@ def register_Ns3Ipv4Address_methods(root_module, cls): 'ns3::Ipv4Address', [], is_static=True) + ## ipv4-address.h (module 'network'): bool ns3::Ipv4Address::IsAny() const [member function] + cls.add_method('IsAny', + 'bool', + [], + is_const=True) ## ipv4-address.h (module 'network'): bool ns3::Ipv4Address::IsBroadcast() const [member function] cls.add_method('IsBroadcast', 'bool', @@ -1076,6 +1081,11 @@ def register_Ns3Ipv4Address_methods(root_module, cls): 'bool', [], is_const=True) + ## ipv4-address.h (module 'network'): bool ns3::Ipv4Address::IsLocalhost() const [member function] + cls.add_method('IsLocalhost', + 'bool', + [], + is_const=True) ## ipv4-address.h (module 'network'): static bool ns3::Ipv4Address::IsMatchingType(ns3::Address const & address) [member function] cls.add_method('IsMatchingType', 'bool', @@ -1252,7 +1262,7 @@ def register_Ns3Ipv6Address_methods(root_module, cls): cls.add_method('IsAllHostsMulticast', 'bool', [], - is_const=True) + deprecated=True, is_const=True) ## ipv6-address.h (module 'network'): bool ns3::Ipv6Address::IsAllNodesMulticast() const [member function] cls.add_method('IsAllNodesMulticast', 'bool', diff --git a/src/sixlowpan/bindings/modulegen__gcc_LP64.py b/src/sixlowpan/bindings/modulegen__gcc_LP64.py index 563490907..320c753d3 100644 --- a/src/sixlowpan/bindings/modulegen__gcc_LP64.py +++ b/src/sixlowpan/bindings/modulegen__gcc_LP64.py @@ -1061,6 +1061,11 @@ def register_Ns3Ipv4Address_methods(root_module, cls): 'ns3::Ipv4Address', [], is_static=True) + ## ipv4-address.h (module 'network'): bool ns3::Ipv4Address::IsAny() const [member function] + cls.add_method('IsAny', + 'bool', + [], + is_const=True) ## ipv4-address.h (module 'network'): bool ns3::Ipv4Address::IsBroadcast() const [member function] cls.add_method('IsBroadcast', 'bool', @@ -1076,6 +1081,11 @@ def register_Ns3Ipv4Address_methods(root_module, cls): 'bool', [], is_const=True) + ## ipv4-address.h (module 'network'): bool ns3::Ipv4Address::IsLocalhost() const [member function] + cls.add_method('IsLocalhost', + 'bool', + [], + is_const=True) ## ipv4-address.h (module 'network'): static bool ns3::Ipv4Address::IsMatchingType(ns3::Address const & address) [member function] cls.add_method('IsMatchingType', 'bool', @@ -1252,7 +1262,7 @@ def register_Ns3Ipv6Address_methods(root_module, cls): cls.add_method('IsAllHostsMulticast', 'bool', [], - is_const=True) + deprecated=True, is_const=True) ## ipv6-address.h (module 'network'): bool ns3::Ipv6Address::IsAllNodesMulticast() const [member function] cls.add_method('IsAllNodesMulticast', 'bool', diff --git a/src/sixlowpan/test/sixlowpan-fragmentation-test.cc b/src/sixlowpan/test/sixlowpan-fragmentation-test.cc index c2d7a4f0c..6a576eddd 100644 --- a/src/sixlowpan/test/sixlowpan-fragmentation-test.cc +++ b/src/sixlowpan/test/sixlowpan-fragmentation-test.cc @@ -35,14 +35,8 @@ #include "ns3/inet-socket-address.h" #include "ns3/boolean.h" -#include "ns3/ipv6-static-routing.h" -#include "ns3/ipv6-list-routing.h" -#include "ns3/inet6-socket-address.h" #include "ns3/sixlowpan-net-device.h" - -#include "ns3/udp-l4-protocol.h" - -#include "ns3/ipv6-l3-protocol.h" +#include "ns3/internet-stack-helper.h" #include "ns3/icmpv6-l4-protocol.h" #include @@ -51,42 +45,12 @@ using namespace ns3; -class UdpSocketImpl; - -static void -AddInternetStack (Ptr node) -{ - //IPV6 - Ptr ipv6 = CreateObject (); - - //Routing for Ipv6 - Ptr ipv6Routing = CreateObject (); - ipv6->SetRoutingProtocol (ipv6Routing); - Ptr ipv6staticRouting = CreateObject (); - ipv6Routing->AddRoutingProtocol (ipv6staticRouting, 0); - node->AggregateObject (ipv6); - - //ICMPv6 - Ptr icmp6 = CreateObject (); - node->AggregateObject (icmp6); - - //Ipv6 Extensions - ipv6->RegisterExtensions (); - ipv6->RegisterOptions (); - - //UDP - Ptr udp = CreateObject (); - node->AggregateObject (udp); -} - - class SixlowpanFragmentationTest : public TestCase { Ptr m_sentPacketClient; Ptr m_receivedPacketClient; Ptr m_receivedPacketServer; - Ptr m_socketServer; Ptr m_socketClient; uint32_t m_dataSize; @@ -122,6 +86,9 @@ SixlowpanFragmentationTest::SixlowpanFragmentationTest () m_socketServer = 0; m_data = 0; m_dataSize = 0; + m_size = 0; + m_icmpType = 0; + m_icmpCode = 0; } SixlowpanFragmentationTest::~SixlowpanFragmentationTest () @@ -256,12 +223,13 @@ void SixlowpanFragmentationTest::DoRun (void) { // Create topology - + InternetStackHelper internet; + internet.SetIpv4StackInstall (false); Packet::EnablePrinting (); // Receiver Node Ptr serverNode = CreateObject (); - AddInternetStack (serverNode); + internet.Install (serverNode); Ptr serverDev; Ptr serverDevErrorModel = CreateObject (); { @@ -292,7 +260,7 @@ SixlowpanFragmentationTest::DoRun (void) // Sender Node Ptr clientNode = CreateObject (); - AddInternetStack (clientNode); + internet.Install (clientNode); Ptr clientDev; Ptr clientDevErrorModel = CreateObject (); { diff --git a/src/sixlowpan/test/sixlowpan-hc1-test.cc b/src/sixlowpan/test/sixlowpan-hc1-test.cc index 9cff7ba2b..0517c592b 100644 --- a/src/sixlowpan/test/sixlowpan-hc1-test.cc +++ b/src/sixlowpan/test/sixlowpan-hc1-test.cc @@ -31,12 +31,7 @@ #include "ns3/log.h" #include "ns3/node.h" #include "ns3/inet6-socket-address.h" - -#include "ns3/ipv6-l3-protocol.h" -#include "ns3/icmpv6-l4-protocol.h" -#include "ns3/udp-l4-protocol.h" -#include "ns3/ipv6-list-routing.h" -#include "ns3/ipv6-static-routing.h" +#include "ns3/internet-stack-helper.h" #include "ns3/sixlowpan-net-device.h" @@ -45,29 +40,6 @@ using namespace ns3; -static void -AddInternetStack6 (Ptr node) -{ - //IPV6 - Ptr ipv6 = CreateObject (); - //Routing for Ipv6 - Ptr ipv6Routing = CreateObject (); - ipv6->SetRoutingProtocol (ipv6Routing); - Ptr ipv6staticRouting = CreateObject (); - ipv6Routing->AddRoutingProtocol (ipv6staticRouting, 0); - node->AggregateObject (ipv6); - //ICMP - Ptr icmp = CreateObject (); - node->AggregateObject (icmp); - //Ipv6 Extensions - ipv6->RegisterExtensions (); - ipv6->RegisterOptions (); - //UDP - Ptr udp = CreateObject (); - node->AggregateObject (udp); -} - - class SixlowpanHc1ImplTest : public TestCase { Ptr m_receivedPacket; @@ -127,10 +99,12 @@ void SixlowpanHc1ImplTest::DoRun (void) { // Create topology + InternetStackHelper internet; + internet.SetIpv4StackInstall (false); // Receiver Node Ptr rxNode = CreateObject (); - AddInternetStack6 (rxNode); + internet.Install (rxNode); Ptr rxDev; { // first interface rxDev = CreateObject (); @@ -153,7 +127,7 @@ SixlowpanHc1ImplTest::DoRun (void) // Sender Node Ptr txNode = CreateObject (); - AddInternetStack6 (txNode); + internet.Install (txNode); Ptr txDev; { txDev = CreateObject (); diff --git a/src/sixlowpan/test/sixlowpan-iphc-test.cc b/src/sixlowpan/test/sixlowpan-iphc-test.cc index 40e975b25..043e81e2c 100644 --- a/src/sixlowpan/test/sixlowpan-iphc-test.cc +++ b/src/sixlowpan/test/sixlowpan-iphc-test.cc @@ -31,12 +31,7 @@ #include "ns3/log.h" #include "ns3/node.h" #include "ns3/inet6-socket-address.h" - -#include "ns3/ipv6-l3-protocol.h" -#include "ns3/icmpv6-l4-protocol.h" -#include "ns3/udp-l4-protocol.h" -#include "ns3/ipv6-list-routing.h" -#include "ns3/ipv6-static-routing.h" +#include "ns3/internet-stack-helper.h" #include "ns3/sixlowpan-net-device.h" @@ -45,29 +40,6 @@ using namespace ns3; -static void -AddInternetStack6 (Ptr node) -{ - //IPV6 - Ptr ipv6 = CreateObject (); - //Routing for Ipv6 - Ptr ipv6Routing = CreateObject (); - ipv6->SetRoutingProtocol (ipv6Routing); - Ptr ipv6staticRouting = CreateObject (); - ipv6Routing->AddRoutingProtocol (ipv6staticRouting, 0); - node->AggregateObject (ipv6); - //ICMP - Ptr icmp = CreateObject (); - node->AggregateObject (icmp); - //Ipv6 Extensions - ipv6->RegisterExtensions (); - ipv6->RegisterOptions (); - //UDP - Ptr udp = CreateObject (); - node->AggregateObject (udp); -} - - class SixlowpanIphcImplTest : public TestCase { Ptr m_receivedPacket; @@ -127,10 +99,12 @@ void SixlowpanIphcImplTest::DoRun (void) { // Create topology + InternetStackHelper internet; + internet.SetIpv4StackInstall (false); // Receiver Node Ptr rxNode = CreateObject (); - AddInternetStack6 (rxNode); + internet.Install (rxNode); Ptr rxDev; { // first interface rxDev = CreateObject (); @@ -152,7 +126,7 @@ SixlowpanIphcImplTest::DoRun (void) // Sender Node Ptr txNode = CreateObject (); - AddInternetStack6 (txNode); + internet.Install (txNode); Ptr txDev; { txDev = CreateObject ();