Unable to simulate site to site VPN scenario using ipv6 tunneling and measure overhead latency

8 views
Skip to first unread message

PRIYANSHU BISHT

unread,
Oct 7, 2025, 8:05:50 AM (17 hours ago) Oct 7
to ns-3-users
  • I am a student trying to complete an experiment for my 'Advanced Computer Networks' lab. I need to simulate an IPv6-in-IPv6 tunnel.

  • i am using ns-3.42 in ubuntu 24.04.3 in my VMware


  • the code i am using is


  • #include "ns3/core-module.h"
    #include "ns3/network-module.h"
    #include "ns3/internet-module.h"
    #include "ns3/point-to-point-module.h"
    #include "ns3/applications-module.h"
    #include "ns3/netanim-module.h"

    // The necessary tunnel device is in the internet-module.h

    using namespace ns3;

    NS_LOG_COMPONENT_DEFINE("Ipv6VpnTunnel_Final");

    int main(int argc, char *argv[])
    {
        LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_INFO);

        // --- Create Nodes ---
        NodeContainer siteA_nodes, siteB_nodes;
        siteA_nodes.Create(2); // hostA is at index 0, routerA is at index 1
        siteB_nodes.Create(2); // routerB is at index 0, hostB is at index 1

        Ptr<Node> hostA = siteA_nodes.Get(0);
        Ptr<Node> routerA = siteA_nodes.Get(1);
        Ptr<Node> routerB = siteB_nodes.Get(0);
        Ptr<Node> hostB = siteB_nodes.Get(1);

        // --- Install IPv6 Stack ---
        InternetStackHelper stack;
        stack.SetIpv4StackInstall(false);
        stack.Install(siteA_nodes);
        stack.Install(siteB_nodes);

        // --- Create Links ---
        PointToPointHelper p2p;
        p2p.SetDeviceAttribute("DataRate", StringValue("10Mbps"));
        p2p.SetChannelAttribute("Delay", StringValue("5ms"));

        NetDeviceContainer private_link_A = p2p.Install(hostA, routerA);
        NetDeviceContainer public_link = p2p.Install(routerA, routerB);
        NetDeviceContainer private_link_B = p2p.Install(routerB, hostB);

        // --- Assign IPv6 Addresses ---
        Ipv6AddressHelper ipv6;
        ipv6.SetBase(Ipv6Address("2001:a::"), Ipv6Prefix(64));
        Ipv6InterfaceContainer private_if_A = ipv6.Assign(private_link_A);

        ipv6.SetBase(Ipv6Address("2001:12::"), Ipv6Prefix(64));
        Ipv6InterfaceContainer public_if = ipv6.Assign(public_link);

        ipv6.SetBase(Ipv6Address("2001:b::"), Ipv6Prefix(64));
        Ipv6InterfaceContainer private_if_B = ipv6.Assign(private_link_B);

        // --- VPN Tunnel Creation (NEW, ROBUST METHOD) ---
        NS_LOG_INFO("Creating IPv6-in-IPv6 Tunnel");
       
        // Create tunnel device for routerA
        Ptr<Ipv6OverIpv6TunnelNetDevice> tunnelA = CreateObject<Ipv6OverIpv6TunnelNetDevice>();
        tunnelA->SetLocalAddress(public_if.GetAddress(0, 0));
        tunnelA->SetRemoteAddress(public_if.GetAddress(1, 0));
        routerA->AddDevice(tunnelA);

        // Create tunnel device for routerB
        Ptr<Ipv6OverIpv6TunnelNetDevice> tunnelB = CreateObject<Ipv6OverIpv6TunnelNetDevice>();
        tunnelB->SetLocalAddress(public_if.GetAddress(1, 0));
        tunnelB->SetRemoteAddress(public_if.GetAddress(0, 0));
        routerB->AddDevice(tunnelB);

        NetDeviceContainer tunnelDevices;
        tunnelDevices.Add(tunnelA);
        tunnelDevices.Add(tunnelB);

        // Assign addresses to the virtual tunnel link
        ipv6.SetBase(Ipv6Address("2001:ab::"), Ipv6Prefix(64));
        ipv6.Assign(tunnelDevices);

        // --- Routing Configuration ---
        Ipv6StaticRoutingHelper routingHelper;
        Ptr<Ipv6StaticRouting> hostA_routing = routingHelper.GetStaticRouting(hostA->GetObject<Ipv6>());
        hostA_routing->SetDefaultRoute(private_if_A.GetAddress(1, 0), 1);
       
        Ptr<Ipv6StaticRouting> routerA_routing = routingHelper.GetStaticRouting(routerA->GetObject<Ipv6>());
        // Interface 3 is the tunnel device
        routerA_routing->AddNetworkRouteTo(Ipv6Address("2001:b::"), Ipv6Prefix(64), Ipv6Address("2001:ab::2"), 3);

        Ptr<Ipv6StaticRouting> routerB_routing = routingHelper.GetStaticRouting(routerB->GetObject<Ipv6>());
        // Interface 3 is the tunnel device
        routerB_routing->AddNetworkRouteTo(Ipv6Address("2001:a::"), Ipv6Prefix(64), Ipv6Address("2001:ab::1"), 3);

        Ptr<Ipv6StaticRouting> hostB_routing = routingHelper.GetStaticRouting(hostB->GetObject<Ipv6>());
        hostB_routing->SetDefaultRoute(private_if_B.GetAddress(0, 0), 1);

        // --- Application Setup ---
        uint16_t port = 9;
        UdpEchoServerHelper echoServer(port);
        ApplicationContainer serverApps = echoServer.Install(hostB);
        serverApps.Start(Seconds(1.0));

        UdpEchoClientHelper echoClient(private_if_B.GetAddress(1, 0), port);
        echoClient.SetAttribute("MaxPackets", UintegerValue(5));
        echoClient.SetAttribute("Interval", TimeValue(Seconds(1.0)));
        echoClient.SetAttribute("PacketSize", UintegerValue(1024));
        ApplicationContainer clientApps = echoClient.Install(hostA);
        clientApps.Start(Seconds(2.0));

        // --- PCAP Tracing ---
        p2p.EnablePcapAll("vpn-tunnel-capture");

        // --- Run Simulation ---
        Simulator::Stop(Seconds(11.0));
        Simulator::Run();
        Simulator::Destroy();

        NS_LOG_INFO("Done.");
        return 0;
    }



  • the Error i am getting is

  • priyanshu@priyanshu:~/ns-allinone-3.42/ns-3.42$ ./ns3 run scratch/test3.cc
    [0/2] Re-checking globbed directories...
    [1/2] Building CXX object scratch/CMakeFiles/scratch_test3.dir/test3.cc.o
    FAILED: scratch/CMakeFiles/scratch_test3.dir/test3.cc.o
    /usr/bin/ccache /usr/bin/c++ -DEIGEN_MPL2_ONLY -DHAVE_BOOST -DHAVE_BOOST_UNITS -DHAVE_EIGEN3 -DHAVE_GSL -DHAVE_LIBXML2 -DHAVE_PACKET_H -DHAVE_SQLITE3 -DNS3_ASSERT_ENABLE -DNS3_BUILD_PROFILE_DEBUG -DNS3_LOG_ENABLE -DPROJECT_SOURCE_PATH=\"/home/priyanshu/ns-allinone-3.42/ns-3.42\" -DRAW_SOCK_CREATOR=\"/home/priyanshu/ns-allinone-3.42/ns-3.42/build/src/fd-net-device/ns3.42-raw-sock-creator-default\" -DTAP_DEV_CREATOR=\"/home/priyanshu/ns-allinone-3.42/ns-3.42/build/src/fd-net-device/ns3.42-tap-device-creator-default\" -D__LINUX__ -I/home/priyanshu/ns-allinone-3.42/ns-3.42/build/include -I/usr -I/usr/include/eigen3 -I/usr/include/freetype2 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/gtk-3.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/atk-1.0 -I/usr/include/libxml2 -Os -g -DNDEBUG -std=c++20 -fPIE   -fno-semantic-interposition -fdiagnostics-color=always -Wall -Wpedantic -MD -MT scratch/CMakeFiles/scratch_test3.dir/test3.cc.o -MF scratch/CMakeFiles/scratch_test3.dir/test3.cc.o.d -o scratch/CMakeFiles/scratch_test3.dir/test3.cc.o -c /home/priyanshu/ns-allinone-3.42/ns-3.42/scratch/test3.cc
    /home/priyanshu/ns-allinone-3.42/ns-3.42/scratch/test3.cc: In function ‘int main(int, char**)’:
    /home/priyanshu/ns-allinone-3.42/ns-3.42/scratch/test3.cc:58:9: error: ‘Ipv6OverIpv6TunnelNetDevice’ was not declared in this scope
       58 |     Ptr<Ipv6OverIpv6TunnelNetDevice> tunnelA = CreateObject<Ipv6OverIpv6TunnelNetDevice>();
          |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
    /home/priyanshu/ns-allinone-3.42/ns-3.42/scratch/test3.cc:58:36: error: template argument 1 is invalid
       58 |     Ptr<Ipv6OverIpv6TunnelNetDevice> tunnelA = CreateObject<Ipv6OverIpv6TunnelNetDevice>();
          |                                    ^
    /home/priyanshu/ns-allinone-3.42/ns-3.42/scratch/test3.cc:58:89: error: no matching function for call to ‘CreateObject<Ipv6OverIpv6TunnelNetDevice>()’
       58 |     Ptr<Ipv6OverIpv6TunnelNetDevice> tunnelA = CreateObject<Ipv6OverIpv6TunnelNetDevice>();
          |                                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
    In file included from /home/priyanshu/ns-allinone-3.42/ns-3.42/src/core/model/object-factory.h:23,
                     from /home/priyanshu/ns-allinone-3.42/ns-3.42/src/core/model/simulator.h:27,
                     from /home/priyanshu/ns-allinone-3.42/ns-3.42/build/include/ns3/simulator.h:1,
                     from /home/priyanshu/ns-allinone-3.42/ns-3.42/src/core/helper/event-garbage-collector.h:23,
                     from /home/priyanshu/ns-allinone-3.42/ns-3.42/build/include/ns3/event-garbage-collector.h:1,
                     from /home/priyanshu/ns-allinone-3.42/ns-3.42/build/include/ns3/core-module.h:9,
                     from /home/priyanshu/ns-allinone-3.42/ns-3.42/scratch/test3.cc:1:
    /home/priyanshu/ns-allinone-3.42/ns-3.42/src/core/model/object.h:630:1: note: candidate: ‘template<class T, class ... Args> ns3::Ptr<T> ns3::CreateObject(Args&& ...)’
      630 | CreateObject(Args&&... args)
          | ^~~~~~~~~~~~
    /home/priyanshu/ns-allinone-3.42/ns-3.42/src/core/model/object.h:630:1: note:   template argument deduction/substitution failed:
    /home/priyanshu/ns-allinone-3.42/ns-3.42/scratch/test3.cc:59:12: error: base operand of ‘->’ is not a pointer
       59 |     tunnelA->SetLocalAddress(public_if.GetAddress(0, 0));
          |            ^~
    /home/priyanshu/ns-allinone-3.42/ns-3.42/scratch/test3.cc:60:12: error: base operand of ‘->’ is not a pointer
       60 |     tunnelA->SetRemoteAddress(public_if.GetAddress(1, 0));
          |            ^~
    /home/priyanshu/ns-allinone-3.42/ns-3.42/scratch/test3.cc:61:24: error: cannot convert ‘int’ to ‘ns3::Ptr<ns3::NetDevice>’
       61 |     routerA->AddDevice(tunnelA);
          |                        ^~~~~~~
          |                        |
          |                        int
    In file included from /home/priyanshu/ns-allinone-3.42/ns-3.42/src/network/model/application.h:23,
                     from /home/priyanshu/ns-allinone-3.42/ns-3.42/build/include/ns3/application.h:1,
                     from /home/priyanshu/ns-allinone-3.42/ns-3.42/src/network/helper/application-container.h:23,
                     from /home/priyanshu/ns-allinone-3.42/ns-3.42/build/include/ns3/application-container.h:1,
                     from /home/priyanshu/ns-allinone-3.42/ns-3.42/build/include/ns3/network-module.h:6,
                     from /home/priyanshu/ns-allinone-3.42/ns-3.42/scratch/test3.cc:2:
    /home/priyanshu/ns-allinone-3.42/ns-3.42/src/network/model/node.h:104:39: note:   initializing argument 1 of ‘uint32_t ns3::Node::AddDevice(ns3::Ptr<ns3::NetDevice>)’
      104 |     uint32_t AddDevice(Ptr<NetDevice> device);
          |                        ~~~~~~~~~~~~~~~^~~~~~
    /home/priyanshu/ns-allinone-3.42/ns-3.42/scratch/test3.cc:64:89: error: no matching function for call to ‘CreateObject<Ipv6OverIpv6TunnelNetDevice>()’
       64 |     Ptr<Ipv6OverIpv6TunnelNetDevice> tunnelB = CreateObject<Ipv6OverIpv6TunnelNetDevice>();
          |                                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
    /home/priyanshu/ns-allinone-3.42/ns-3.42/src/core/model/object.h:630:1: note: candidate: ‘template<class T, class ... Args> ns3::Ptr<T> ns3::CreateObject(Args&& ...)’
      630 | CreateObject(Args&&... args)
          | ^~~~~~~~~~~~
    /home/priyanshu/ns-allinone-3.42/ns-3.42/src/core/model/object.h:630:1: note:   template argument deduction/substitution failed:
    /home/priyanshu/ns-allinone-3.42/ns-3.42/scratch/test3.cc:65:12: error: base operand of ‘->’ is not a pointer
       65 |     tunnelB->SetLocalAddress(public_if.GetAddress(1, 0));
          |            ^~
    /home/priyanshu/ns-allinone-3.42/ns-3.42/scratch/test3.cc:66:12: error: base operand of ‘->’ is not a pointer
       66 |     tunnelB->SetRemoteAddress(public_if.GetAddress(0, 0));
          |            ^~
    /home/priyanshu/ns-allinone-3.42/ns-3.42/scratch/test3.cc:67:24: error: cannot convert ‘int’ to ‘ns3::Ptr<ns3::NetDevice>’
       67 |     routerB->AddDevice(tunnelB);
          |                        ^~~~~~~
          |                        |
          |                        int
    /home/priyanshu/ns-allinone-3.42/ns-3.42/src/network/model/node.h:104:39: note:   initializing argument 1 of ‘uint32_t ns3::Node::AddDevice(ns3::Ptr<ns3::NetDevice>)’
      104 |     uint32_t AddDevice(Ptr<NetDevice> device);
          |                        ~~~~~~~~~~~~~~~^~~~~~
    /home/priyanshu/ns-allinone-3.42/ns-3.42/scratch/test3.cc:70:22: error: no matching function for call to ‘ns3::NetDeviceContainer::Add(int&)’
       70 |     tunnelDevices.Add(tunnelA);
          |     ~~~~~~~~~~~~~~~~~^~~~~~~~~
    In file included from /home/priyanshu/ns-allinone-3.42/ns-3.42/build/include/ns3/net-device-container.h:1,
                     from /home/priyanshu/ns-allinone-3.42/ns-3.42/build/include/ns3/network-module.h:9:
    /home/priyanshu/ns-allinone-3.42/ns-3.42/src/network/helper/net-device-container.h:182:10: note: candidate: ‘void ns3::NetDeviceContainer::Add(ns3::NetDeviceContainer)’
      182 |     void Add(NetDeviceContainer other);
          |          ^~~
    /home/priyanshu/ns-allinone-3.42/ns-3.42/src/network/helper/net-device-container.h:182:33: note:   no known conversion for argument 1 from ‘int’ to ‘ns3::NetDeviceContainer’
      182 |     void Add(NetDeviceContainer other);
          |              ~~~~~~~~~~~~~~~~~~~^~~~~
    /home/priyanshu/ns-allinone-3.42/ns-3.42/src/network/helper/net-device-container.h:189:10: note: candidate: ‘void ns3::NetDeviceContainer::Add(ns3::Ptr<ns3::NetDevice>)’
      189 |     void Add(Ptr<NetDevice> device);
          |          ^~~
    /home/priyanshu/ns-allinone-3.42/ns-3.42/src/network/helper/net-device-container.h:189:29: note:   no known conversion for argument 1 from ‘int’ to ‘ns3::Ptr<ns3::NetDevice>’
      189 |     void Add(Ptr<NetDevice> device);
          |              ~~~~~~~~~~~~~~~^~~~~~
    /home/priyanshu/ns-allinone-3.42/ns-3.42/src/network/helper/net-device-container.h:197:10: note: candidate: ‘void ns3::NetDeviceContainer::Add(std::string)’
      197 |     void Add(std::string deviceName);
          |          ^~~
    /home/priyanshu/ns-allinone-3.42/ns-3.42/src/network/helper/net-device-container.h:197:26: note:   no known conversion for argument 1 from ‘int’ to ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’}
      197 |     void Add(std::string deviceName);
          |              ~~~~~~~~~~~~^~~~~~~~~~
    /home/priyanshu/ns-allinone-3.42/ns-3.42/scratch/test3.cc:71:22: error: no matching function for call to ‘ns3::NetDeviceContainer::Add(int&)’
       71 |     tunnelDevices.Add(tunnelB);
          |     ~~~~~~~~~~~~~~~~~^~~~~~~~~
    /home/priyanshu/ns-allinone-3.42/ns-3.42/src/network/helper/net-device-container.h:182:10: note: candidate: ‘void ns3::NetDeviceContainer::Add(ns3::NetDeviceContainer)’
      182 |     void Add(NetDeviceContainer other);
          |          ^~~
    /home/priyanshu/ns-allinone-3.42/ns-3.42/src/network/helper/net-device-container.h:182:33: note:   no known conversion for argument 1 from ‘int’ to ‘ns3::NetDeviceContainer’
      182 |     void Add(NetDeviceContainer other);
          |              ~~~~~~~~~~~~~~~~~~~^~~~~
    /home/priyanshu/ns-allinone-3.42/ns-3.42/src/network/helper/net-device-container.h:189:10: note: candidate: ‘void ns3::NetDeviceContainer::Add(ns3::Ptr<ns3::NetDevice>)’
      189 |     void Add(Ptr<NetDevice> device);
          |          ^~~
    /home/priyanshu/ns-allinone-3.42/ns-3.42/src/network/helper/net-device-container.h:189:29: note:   no known conversion for argument 1 from ‘int’ to ‘ns3::Ptr<ns3::NetDevice>’
      189 |     void Add(Ptr<NetDevice> device);
          |              ~~~~~~~~~~~~~~~^~~~~~
    /home/priyanshu/ns-allinone-3.42/ns-3.42/src/network/helper/net-device-container.h:197:10: note: candidate: ‘void ns3::NetDeviceContainer::Add(std::string)’
      197 |     void Add(std::string deviceName);
          |          ^~~
    /home/priyanshu/ns-allinone-3.42/ns-3.42/src/network/helper/net-device-container.h:197:26: note:   no known conversion for argument 1 from ‘int’ to ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’}
      197 |     void Add(std::string deviceName);
          |              ~~~~~~~~~~~~^~~~~~~~~~
    ninja: build stopped: subcommand failed.

Tom Henderson

unread,
Oct 7, 2025, 10:42:03 AM (15 hours ago) Oct 7
to ns-3-...@googlegroups.com, PRIYANSHU BISHT

The compilation error suggests to me that perhaps you have not added your new header file (containing the declaration of class Ipv6OverIpv6TunnelNetDevice) to the file src/internet/CMakeLists.txt; can you check that?

- Tom

Reply all
Reply to author
Forward
0 new messages