Configuring ns 3 Behavior - nps-ros2/ns3_testbed GitHub Wiki
ns-3 testbed programs exist in the ~/gits/ns3_testbed/ns3_programs
directory. Currently, ns3_mobility
and ns3_csma
are available.
Configuration
ns-3 testbed programs take the following parameters:
- Count: The number of robots to simulate.
- Length: The mobility box edge length, in meters, within which mobility robots will move.
- Setup file: A setup file for describing more configuration parameters. Currently, only
mobility
settings are available.
Here is the provided default ns3_defaults.csv
setup file, which defines positions for five stationary robots:
mobility,,,
Node,X,Y,Walks
R1,0,0,false
R2,1,0,false
R3,0,1,false
R4,-1,0,false
R5,0,-1,false
where:
- Mobility starts the section for defining node mobility.
- Column
Node
identifies the robot node name, starting withR
, and one ofR1
,R2
,R3
, etc. The number ofR*
nodes is set using the count parameter you provide when running setup scripts. Note that you may provide an inclusive range for robots, for exampleR2-R29
for 28 robots fromR2
toR29
. - Columns
X
andY
define robot antenna positions, in meters. - Column
Walks
sets whether the robot is stationary or uses ns-3's random walk mobility model.
ns3_mobility
The ns3_mobility
program models a Wifi ad hoc network: https://www.nsnam.org/docs/models/html/wifi.html. Here is the Wifi section of code in ns3_mobility.cpp
:
// Wifi settings
ns3::WifiHelper wifi;
wifi.SetStandard(ns3::WIFI_PHY_STANDARD_80211a);
wifi.SetRemoteStationManager("ns3::ConstantRateWifiManager",
"DataMode", ns3::StringValue("OfdmRate54Mbps"));
// physical layer
ns3::YansWifiChannelHelper wifiChannel(ns3::YansWifiChannelHelper::Default());
ns3::YansWifiPhyHelper wifiPhy(ns3::YansWifiPhyHelper::Default());
wifiPhy.SetChannel(wifiChannel.Create());
// ad-hoc Wifi network
ns3::WifiMacHelper wifiMac;
wifiMac.SetType("ns3::AdhocWifiMac");
This sets the following:
- 802.11 physical layer model to 802.11a.
- Data mode to
OfdmRate54Mbps
. - Physical layer implementation to
YansWifi
with default power values. - Network mode to
AdhocWifiMac
.
Configuration by Changing Code
Wifi settings may be changed by changing code. For alternate Wifi settings, we recommend that you start withns3_mobility.cpp
, copy it to, for example, ns3_my_wifi.cpp
, change it, set up CMakeLists.txt
to build it, then build it using cmake
amd make
.
ns3_csma
This program uses default CSMA settings for a wired instead of wireless setup:
// install the CSMA devices onto our ns3_nodes
ns3::CsmaHelper csma;
ns3::NetDeviceContainer devices = csma.Install(ns3_nodes);