TapBridge: issues with Access Point wifi network

254 views
Skip to first unread message

Mauro Sardara

unread,
Aug 14, 2015, 12:24:11 AM8/14/15
to ns-3-users
Hi there,

I'm meeting some problems with the TapBridge Device. I'm trying to build a very simple netwotk:

- 2 Linux container
- 1 Access Point
- 2 Simulated Hosts

Here is the code:

 std::string mode = "UseLocal";
  std
::string tapName = "tap-left";


  
CommandLine cmd;
  cmd
.AddValue ("mode", "Mode setting of TapBridge", mode);
  cmd
.AddValue ("tapName", "Name of the OS tap device", tapName);
  cmd
.Parse (argc, argv);


  
GlobalValue::Bind ("SimulatorImplementationType", StringValue ("ns3::RealtimeSimulatorImpl"));
  
GlobalValue::Bind ("ChecksumEnabled", BooleanValue (true));


  
//
  
// The topology has a Wifi network of four nodes on the left side.  We'll make
  
// node zero the AP and have the other three will be the STAs.
  
//
  
NodeContainer nodesLeft;
  nodesLeft
.Create (4);


  
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
  
YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
  wifiPhy
.SetChannel (wifiChannel.Create ());


  
Ssid ssid = Ssid ("left");
  
WifiHelper wifi = WifiHelper::Default ();
  
NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
  wifi
.SetRemoteStationManager ("ns3::ArfWifiManager");


  wifiMac
.SetType ("ns3::ApWifiMac",
                   
"Ssid", SsidValue (ssid));
  
NetDeviceContainer devicesLeft = wifi.Install (wifiPhy, wifiMac, nodesLeft.Get (0));




  wifiMac
.SetType ("ns3::StaWifiMac",
                   
"Ssid", SsidValue (ssid),
                   
"ActiveProbing", BooleanValue (false));
  devicesLeft
.Add (wifi.Install (wifiPhy, wifiMac, NodeContainer (nodesLeft.Get (1), nodesLeft.Get (2), nodesLeft.Get (3))));


  
MobilityHelper mobility;
  mobility
.Install (nodesLeft);


  
InternetStackHelper internetLeft;
  internetLeft
.Install (nodesLeft);


  
Ipv4AddressHelper ipv4Left;
  ipv4Left
.SetBase ("10.0.0.0", "255.255.255.0");
  
Ipv4InterfaceContainer interfacesLeft = ipv4Left.Assign (devicesLeft);


  
TapBridgeHelper tapBridge;
  tapBridge
.SetAttribute ("Mode", StringValue (mode));
  tapBridge
.SetAttribute ("DeviceName", StringValue (tapName));
  tapBridge
.Install (nodesLeft.Get (0), devicesLeft.Get (0));

  tapBridge
.SetAttribute ("DeviceName", StringValue ("tap-right"));
  tapBridge
.Install (nodesLeft.Get (1), devicesLeft.Get (1));
  
//
  
// Run the simulation for ten minutes to give the user time to play around
  
//
  
Simulator::Stop (Seconds (600.));
  
Simulator::Run ();
  
Simulator::Destroy ();


I took this code from a your example.
Here is the list of things I tried:

- When I connect with one container to the AP node, I'm able to ping all the virtual nodes
- If I connect the linux container on a virtual node (so a Ghost node), I'm not able to ping the other virtual nodes
- If I connect with a Lxc to the AP, I'm able to ping the other virtual hosts but not another virtual container connected to a ghost

With the ad hoc topology everything is working well, I do not understand why with an access point the interaction does not work.

I wait for your help as soon as possible.

Thank you in advance,
Mauro.

Mauro Sardara

unread,
Aug 17, 2015, 10:25:48 AM8/17/15
to ns-3-users
So, nobody in the community could help me? :(

Tommaso Pecorella

unread,
Aug 17, 2015, 11:15:48 AM8/17/15
to ns-3-users
Hi,

sadly my current setup doesn't allow me to run this code. I need the work computers and... well, it's holidays.
Moreover, mind to attach the full script and tell us exactly the commands you used (and are either working or not working) ?

Thanks,

T.

Mauro Sardara

unread,
Aug 25, 2015, 4:21:35 AM8/25/15
to ns-3-users
Hi Tommaso!

I'm following this tutorial:


Rapidly, you have to do the following operations:

#Create bridge and tap net devices

sudo brctl addbr br
-left
sudo brctl addbr br-right

sudo tunctl -t tap-left
sudo tunctl -t tap-right

sudo ifconfig tap-left 0.0.0.0 promisc up
sudo ifconfig tap-right 0.0.0.0 promisc up

sudo brctl addif br-left tap-left
sudo ifconfig br-left up
sudo brctl addif br-right tap-right
sudo ifconfig br-right up

cd /proc/sys/net/bridge
sudo -s
for f in bridge-nf-*; do echo 0 > $f; done
exit
cd -

# Create linux containers with conf file in ns3-allinone/src/tap-bridge/examples

sudo lxc-create -n left -f lxc-left.conf
sudo lxc-create -n right -f lxc-right.conf

sudo lxc-start -n left /bin/bash
sudo lxc-start -n right /bin/bash

After this, you have 2 linux containers connected to a tap interface through a linux bridge.
Now, you can try the example script ns3-allinone/src/tap-bridge/examples/tap-wifi-virtual-machine.cc

This script, connects the 2 linux container with an emulated AD-HOC wifi network. And with this network, all works well, I can create an arbitrary number of linux container, they are always able to talk together through the wifi.

The problem happens when I try to connect the containers through an emulated Wi-Fi network with an access point.

The linux containers are not able to communicate, and I can only ping emulated hosts.

You can try the following script:

/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation;
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

//
// This is an illustration of how one could use virtualization techniques to
// allow running applications on virtual machines talking over simulated
// networks.
//
// The actual steps required to configure the virtual machines can be rather
// involved, so we don't go into that here.  Please have a look at one of
// our HOWTOs on the nsnam wiki for more details about how to get the 
// system confgured.  For an example, have a look at "HOWTO Use Linux 
// Containers to set up virtual networks" which uses this code as an 
// example.
//
// The configuration you are after is explained in great detail in the 
// HOWTO, but looks like the following:
//
//  +----------+                           +----------+
//  | virtual  |                           | virtual  |
//  |  Linux   |                           |  Linux   |
//  |   Host   |                           |   Host   |
//  |          |                           |          |
//  |   eth0   |                           |   eth0   |
//  +----------+                           +----------+
//       |                                      |
//  +----------+                           +----------+
//  |  Linux   |                           |  Linux   |
//  |  Bridge  |                           |  Bridge  |
//  +----------+                           +----------+
//       |                                      |
//  +------------+                       +-------------+
//  | "tap-" |                       | "tap-right" |
//  +------------+                       +-------------+
//       |           n0            n1           |
//       |       +--------+    +--------+       |
//       +-------|  tap   |    |  tap   |-------+
//               | bridge |    | bridge |
//               +--------+    +--------+
//               |  wifi  |    |  wifi  |
//               +--------+    +--------+
//                   |             |
//                 ((*))         ((*))
//
//                       Wifi LAN
//
//                        ((*))
//                          |
//                     +--------+
//                     |  wifi  |
//                     +--------+
//                     | access |
//                     |  point |
//                     +--------+
//

#include <iostream>
#include <fstream>

#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/mobility-module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/wifi-module.h"
#include "ns3/internet-module.h"
#include "ns3/csma-module.h"
#include "ns3/applications-module.h"
#include "ns3/ipv4-global-routing-helper.h"
#include "ns3/tap-bridge-module.h"
using namespace ns3;

NS_LOG_COMPONENT_DEFINE ("TapWifiVirtualMachineExample");

int 
main (int argc, char *argv[])
{

  //
  // We are interacting with the outside, real, world.  This means we have to 
  // interact in real-time and therefore means we have to use the real-time
  // simulator and take the time to calculate checksums.
  //
  GlobalValue::Bind ("SimulatorImplementationType", StringValue ("ns3::RealtimeSimulatorImpl"));
  GlobalValue::Bind ("ChecksumEnabled", BooleanValue (true));

  std::string mode = "UseLocal";
  std::string tapName = "tap-left";

  CommandLine cmd;
  cmd.AddValue ("mode", "Mode setting of TapBridge", mode);
  cmd.AddValue ("tapName", "Name of the OS tap device", tapName);
  cmd.Parse (argc, argv);

  //
  // The topology has a Wifi network of four nodes on the  side.  We'll make
  // node zero the AP and have the other three will be the STAs.
  //
  NodeContainer nodes;
  nodes.Create (4);

  YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
  YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
  wifiPhy.SetChannel (wifiChannel.Create ());

  Ssid ssid = Ssid ("WiFi");
  WifiHelper wifi = WifiHelper::Default ();
  NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
  wifi.SetRemoteStationManager ("ns3::ArfWifiManager");

  wifiMac.SetType ("ns3::ApWifiMac",
                   "Ssid", SsidValue (ssid));
  NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, nodes.Get (0));


  wifiMac.SetType ("ns3::StaWifiMac",
                   "Ssid", SsidValue (ssid),
                   "ActiveProbing", BooleanValue (false));
  devices.Add (wifi.Install (wifiPhy, wifiMac, NodeContainer (nodes.Get (1), nodes.Get (2), nodes.Get (3))));

  MobilityHelper mobility;
  mobility.Install (nodes);

  InternetStackHelper internet;
  internet.Install (nodes);

  Ipv4AddressHelper ipv4;
  ipv4.SetBase ("10.0.0.0", "255.255.255.0");
  Ipv4InterfaceContainer interfaces = ipv4.Assign (devices);

  TapBridgeHelper tapBridge;
  tapBridge.SetAttribute ("Mode", StringValue (mode));
  tapBridge.SetAttribute ("DeviceName", StringValue (tapName));
  tapBridge.Install (nodes.Get (1), devices.Get (1));

  tapBridge.SetAttribute ("DeviceName", StringValue ("tap-right"));
  tapBridge.Install (nodes.Get (2), devices.Get (2));


  //
  // Run the simulation for ten minutes to give the user time to play around
  //
  Simulator::Stop (Seconds (600.));
  Simulator::Run ();
  Simulator::Destroy ();
}

Is there an error in this script? Maybe I'm missing some things, I don't know.

Thank you in advance for the response.

Kind Regards,
Mauro Sardara.

Mauro Sardara

unread,
Aug 25, 2015, 8:00:18 AM8/25/15
to ns-3-users
Any suggestion?
...
Reply all
Reply to author
Forward
Message has been deleted
0 new messages