Hi guys,
So I have a PC with two network card installed. Each of them are connected to PC's(cross-over cable). I was told to connect both PC's using a simulated network (NS-3) by using tap-bridge. Diagram below to make it clear:
PC(Server) -------- (PC to run NS-3 Simulation) --------- PC(Client)
I have started playing with tap-bridge UseLocal configuration but I have no success on it. I modified first.cc as my starting point and attached the tap-bridge helper configurations on the nodes.
So I created a tap0 and tap1 from the instructions
https://www.nsnam.org/docs/release/3.9/doxygen/group___tap_bridge_model.html * sudo tunctl -t tap0
* sudo ifconfig tap0 hw ether 00:10:4b:ad:91:b8
* sudo ifconfig tap0 192.168.1.1 netmask 255.255.255.0 up
* sudo tunctl -t tap1
* sudo ifconfig tap1 hw ether 00:50:da:b2:e4:75
* sudo ifconfig tap0 192.168.1.2 netmask 255.255.255.0 up
So now I modified first.cc to:
#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/tap-bridge-module.h"
using namespace ns3;
NS_LOG_COMPONENT_DEFINE ("FirstScriptExample");
int
main (int argc, char *argv[])
{
Time::SetResolution (Time::NS);
LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO);
LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO);
NodeContainer nodes;
nodes.Create (2);
PointToPointHelper pointToPoint;
pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));
NetDeviceContainer devices;
devices = pointToPoint.Install (nodes);
InternetStackHelper stack;
stack.Install (nodes);
Ipv4AddressHelper address;
address.SetBase ("10.1.1.0", "255.255.255.0");
Ipv4InterfaceContainer interfaces = address.Assign (devices);
UdpEchoServerHelper echoServer (9);
ApplicationContainer serverApps = echoServer.Install (nodes.Get (1));
serverApps.Start (Seconds (1.0));
serverApps.Stop (Seconds (10.0));
// Use the TapBridgeHelper to connect to the pre-configured tap devices for
// the left side. We go with "UseBridge" mode since the CSMA devices support
// promiscuous mode and can therefore make it appear that the bridge is
// extended into ns-3. The install method essentially bridges the specified
// tap to the specified CSMA device.
//
TapBridgeHelper tapBridge;
tapBridge.SetAttribute ("Mode", StringValue ("UseLocal"));
tapBridge.SetAttribute ("DeviceName", StringValue ("tap0"));
tapBridge.Install (nodes.Get (1), devices.Get (1)); UdpEchoClientHelper echoClient (interfaces.GetAddress (1), 9);
echoClient.SetAttribute ("MaxPackets", UintegerValue (1));
echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.0)));
echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
ApplicationContainer clientApps = echoClient.Install (nodes.Get (0));
clientApps.Start (Seconds (2.0));
clientApps.Stop (Seconds (10.0));
// Connect the right side tap to the right side CSMA device on the right-side
// ghost node.
//
tapBridge.SetAttribute ("DeviceName", StringValue ("tap1"));
tapBridge.Install (nodes.Get (0), devices.Get (0));
Simulator::Run ();
Simulator::Destroy ();
return 0;
}
Am I going the wrong way here ? I have little knowledge of both NS-3 and Linux so I am a bit confused here. Any help would be appreciated.
I have approached using lxc containers and had no issues except I couldnt install an Apache server on one of the containers.