Skip to content

Commit

Permalink
Update MilliCar to ns-3.36.1 and ns3-mmwave latest updates (#174)
Browse files Browse the repository at this point in the history
* Delete classes that have been integrated in ns-3 main repo

* Update method name and delete comments

* Make beamforming model configurable by the user

* Init new channel model config

* Add method to create spectrum channel

* Add CMakeLists.txt

* Add CMakeLists for examples

* Fix file for CI configuration

* Fix examples

* Fix warnings on pointers

* Change code to support changes of spectrum channel model

* Delete wscript

* Remove mmwave-vehicular-link-adaptation-example

Co-authored-by: tommasozugno <tommasozugno@gmail.com>
  • Loading branch information
MatteoDrago and tommasozugno authored Sep 26, 2022
1 parent 51f2cdd commit b81a765
Show file tree
Hide file tree
Showing 26 changed files with 383 additions and 3,920 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ jobs:

- name: check that millicar is correctly installed
run: ls src/ | grep millicar

- name: enable only millicar
run: printf "#! /usr/bin/env python \n modules_enabled = ['millicar']" > .ns3rc

- name: build and run the tests
run: ./waf configure --enable-examples --enable-tests && ./waf build && ./test.py
run: ./ns3 configure --enable-examples --enable-tests --enable-modules=millicar && ./ns3 build && ./test.py
42 changes: 42 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
set(source_files
model/mmwave-vehicular.cc
model/mmwave-sidelink-spectrum-phy.cc
model/mmwave-sidelink-spectrum-signal-parameters.cc
model/mmwave-sidelink-phy.cc
model/mmwave-sidelink-mac.cc
model/mmwave-vehicular-net-device.cc
model/mmwave-vehicular-antenna-array-model.cc
helper/mmwave-vehicular-helper.cc
helper/mmwave-vehicular-traces-helper.cc
)

set(test_sources
test/mmwave-vehicular-spectrum-phy-test.cc
test/mmwave-vehicular-rate-test.cc
test/mmwave-vehicular-interference-test.cc
)

set(header_files
model/mmwave-vehicular.h
model/mmwave-sidelink-spectrum-phy.h
model/mmwave-sidelink-spectrum-signal-parameters.h
model/mmwave-sidelink-phy.h
model/mmwave-sidelink-mac.h
model/mmwave-sidelink-sap.h
model/mmwave-vehicular-net-device.h
model/mmwave-vehicular-antenna-array-model.h
helper/mmwave-vehicular-helper.h
helper/mmwave-vehicular-traces-helper.h
)

build_lib(
LIBNAME millicar
SOURCE_FILES ${source_files}
HEADER_FILES ${header_files}
LIBRARIES_TO_LINK
${libcore}
${libpropagation}
${libspectrum}
${libmmwave}
TEST_SOURCES ${test_sources}
)
23 changes: 23 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
set(base_examples
vehicular-simple-one
vehicular-simple-two
vehicular-simple-three
vehicular-simple-four
mmwave-vehicular-link-adaptation-example
)

foreach(
example
${base_examples}
)
build_lib_example(
NAME ${example}
SOURCE_FILES ${example}.cc
LIBRARIES_TO_LINK
${libmillicar}
${libcore}
${libpropagation}
${libspectrum}
${libmmwave}
)
endforeach()
105 changes: 0 additions & 105 deletions examples/mmwave-vehicular-link-adaptation-example.cc

This file was deleted.

21 changes: 15 additions & 6 deletions examples/vehicular-simple-four.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@
#include "ns3/spectrum-helper.h"
#include "ns3/mmwave-spectrum-value-helper.h"
#include "ns3/applications-module.h"
#include "ns3/buildings-module.h"
#include "ns3/internet-module.h"
#include "ns3/core-module.h"
#include "ns3/config.h"
#include "ns3/command-line.h"

NS_LOG_COMPONENT_DEFINE ("VehicularSimpleFour");

Expand Down Expand Up @@ -56,21 +58,25 @@ int main (int argc, char *argv[])

Time endTime = Seconds (10.0);
double bandwidth = 1e8;
std::string scenario = "V2V-Urban";

double speed = 20; // m/s
CommandLine cmd;
cmd.AddValue ("vehicleSpeed", "The speed of the vehicle", speed);
cmd.AddValue ("scenario", "set the vehicular scenario", scenario);
cmd.Parse (argc, argv);

Config::SetDefault ("ns3::MmWaveSidelinkMac::UseAmc", BooleanValue (true));
//Config::SetDefault ("ns3::MmWaveSidelinkMac::Mcs", UintegerValue (28));
Config::SetDefault ("ns3::MmWaveSidelinkMac::Mcs", UintegerValue (28));
Config::SetDefault ("ns3::MmWavePhyMacCommon::CenterFreq", DoubleValue (60.0e9));
Config::SetDefault ("ns3::MmWaveVehicularNetDevice::RlcType", StringValue("LteRlcUm"));
Config::SetDefault ("ns3::LteRlcUm::MaxTxBufferSize", UintegerValue (50*1024));
Config::SetDefault ("ns3::MmWaveVehicularPropagationLossModel::ChannelCondition", StringValue ("l"));
Config::SetDefault ("ns3::MmWaveVehicularHelper::Bandwidth", DoubleValue (bandwidth));

Config::SetDefault ("ns3::MmWaveVehicularHelper::SchedulingPatternOption", EnumValue(2)); // use 2 for SchedulingPatternOption=OPTIMIZED, 1 or SchedulingPatternOption=DEFAULT
Config::SetDefault ("ns3::MmWaveVehicularHelper::Bandwidth", DoubleValue (bandwidth));

Config::SetDefault ("ns3::ThreeGppChannelModel::UpdatePeriod", TimeValue (MilliSeconds (10)));

// create the nodes
NodeContainer group;
group.Create (3);
Expand All @@ -91,10 +97,13 @@ int main (int argc, char *argv[])

// create and configure the helper
Ptr<MmWaveVehicularHelper> helper = CreateObject<MmWaveVehicularHelper> ();
helper->SetPropagationLossModelType ("ns3::MmWaveVehicularPropagationLossModel");
helper->SetSpectrumPropagationLossModelType ("ns3::MmWaveVehicularSpectrumPropagationLossModel");
helper->SetNumerology (3);
helper->SetChannelModelType (scenario);
NetDeviceContainer devs = helper->InstallMmWaveVehicularNetDevices (group);

// Mandatory to install buildings helper even if there are no buildings,
// otherwise V2V-Urban scenario does not work
BuildingsHelper::Install (group);

InternetStackHelper internet;
internet.Install (group);
Expand Down
76 changes: 63 additions & 13 deletions examples/vehicular-simple-one.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,17 @@
#include "ns3/mmwave-spectrum-value-helper.h"
#include "ns3/applications-module.h"
#include "ns3/internet-module.h"
#include "ns3/core-module.h"
#include "ns3/buildings-module.h"
#include "ns3/command-line.h"
#include "ns3/node-list.h"

NS_LOG_COMPONENT_DEFINE ("VehicularSimpleOne");

using namespace ns3;
using namespace millicar;

void PrintGnuplottableNodeListToFile (std::string filename);

uint32_t g_rxPackets; // total number of received packets
uint32_t g_txPackets; // total number of transmitted packets

Expand Down Expand Up @@ -81,27 +85,28 @@ int main (int argc, char *argv[])
// mobility
double speed = 20; // speed of the vehicles m/s
double intraGroupDistance = 10; // distance between two vehicles belonging to the same group

std::string scenario = "V2V-Urban";

CommandLine cmd;
//
cmd.AddValue ("bandwidth", "used bandwidth", bandwidth);
cmd.AddValue ("iip", "inter packet interval, in microseconds", interPacketInterval);
cmd.AddValue ("intraGroupDistance", "distance between two vehicles belonging to the same group, y-coord", intraGroupDistance);
cmd.AddValue ("numerology", "set the numerology to use at the physical layer", numerology);
cmd.AddValue ("frequency", "set the carrier frequency", frequency);
cmd.AddValue ("scenario", "set the vehicular scenario", scenario);
cmd.Parse (argc, argv);

Config::SetDefault ("ns3::MmWaveSidelinkMac::UseAmc", BooleanValue (true));
Config::SetDefault ("ns3::MmWaveSidelinkMac::Mcs", UintegerValue (28));
Config::SetDefault ("ns3::MmWavePhyMacCommon::CenterFreq", DoubleValue (frequency));

Config::SetDefault ("ns3::MmWaveVehicularHelper::Bandwidth", DoubleValue (bandwidth));
Config::SetDefault ("ns3::MmWaveVehicularHelper::Numerology", UintegerValue (numerology));
Config::SetDefault ("ns3::MmWaveVehicularPropagationLossModel::ChannelCondition", StringValue ("a"));
Config::SetDefault ("ns3::MmWaveVehicularPropagationLossModel::Shadowing", BooleanValue (true));
Config::SetDefault ("ns3::MmWaveVehicularSpectrumPropagationLossModel::UpdatePeriod", TimeValue (MilliSeconds (1)));
Config::SetDefault ("ns3::MmWaveVehicularAntennaArrayModel::AntennaElements", UintegerValue (16));
Config::SetDefault ("ns3::MmWaveVehicularAntennaArrayModel::AntennaElementPattern", StringValue ("3GPP-V2V"));
Config::SetDefault ("ns3::MmWaveVehicularAntennaArrayModel::IsotropicAntennaElements", BooleanValue (true));
Config::SetDefault ("ns3::MmWaveVehicularAntennaArrayModel::NumSectors", UintegerValue (2));
Config::SetDefault ("ns3::MmWaveVehicularHelper::ChannelModelType", StringValue (scenario));

Config::SetDefault ("ns3::ThreeGppChannelModel::UpdatePeriod", TimeValue (MilliSeconds (10)));
Config::SetDefault ("ns3::ThreeGppChannelConditionModel::UpdatePeriod", TimeValue (MilliSeconds (10)));

Config::SetDefault ("ns3::MmWaveVehicularNetDevice::RlcType", StringValue("LteRlcUm"));
Config::SetDefault ("ns3::MmWaveVehicularHelper::SchedulingPatternOption", EnumValue(2)); // use 2 for SchedulingPatternOption=OPTIMIZED, 1 or SchedulingPatternOption=DEFAULT
Expand All @@ -124,19 +129,20 @@ int main (int argc, char *argv[])
// create and configure the helper
Ptr<MmWaveVehicularHelper> helper = CreateObject<MmWaveVehicularHelper> ();
helper->SetNumerology (3);
helper->SetPropagationLossModelType ("ns3::MmWaveVehicularPropagationLossModel");
helper->SetSpectrumPropagationLossModelType ("ns3::MmWaveVehicularSpectrumPropagationLossModel");
NetDeviceContainer devs = helper->InstallMmWaveVehicularNetDevices (n);

// Install the TCP/IP stack in the two nodes

InternetStackHelper internet;
internet.Install (n);

Ipv4AddressHelper ipv4;
NS_LOG_INFO ("Assign IP Addresses.");
ipv4.SetBase ("10.1.1.0", "255.255.255.0");
Ipv4InterfaceContainer i = ipv4.Assign (devs);

// Mandatory to install buildings helper even if there are no buildings,
// otherwise V2V-Urban scenario does not work
BuildingsHelper::Install (n);

// Need to pair the devices in order to create a correspondence between transmitter and receiver
// and to populate the < IP addr, RNTI > map.
Expand Down Expand Up @@ -174,7 +180,9 @@ int main (int argc, char *argv[])
// set the application start/end time
apps.Start (MilliSeconds (startTime));
apps.Stop (MilliSeconds (endTime));


PrintGnuplottableNodeListToFile ("scenario.txt");

Simulator::Stop (MilliSeconds (endTime + 1000));
Simulator::Run ();
Simulator::Destroy ();
Expand All @@ -186,3 +194,45 @@ int main (int argc, char *argv[])

return 0;
}

void
PrintGnuplottableNodeListToFile (std::string filename)
{
std::ofstream outFile;
outFile.open (filename.c_str (), std::ios_base::out | std::ios_base::trunc);
if (!outFile.is_open ())
{
NS_LOG_ERROR ("Can't open file " << filename);
return;
}
outFile << "set xrange [-200:200]; set yrange [-200:200]" << std::endl;
for (NodeList::Iterator it = NodeList::Begin (); it != NodeList::End (); ++it)
{
Ptr<Node> node = *it;
int nDevs = node->GetNDevices ();
for (int j = 0; j < nDevs; j++)
{
Ptr<MmWaveVehicularNetDevice> vdev = node->GetDevice (j)->GetObject <MmWaveVehicularNetDevice> ();
if (vdev)
{
Vector pos = node->GetObject<MobilityModel> ()->GetPosition ();
outFile << "set label \"" << vdev->GetMac ()->GetRnti ()
<< "\" at "<< pos.x << "," << pos.y << " left font \"Helvetica,8\" textcolor rgb \"black\" front point pt 7 ps 0.3 lc rgb \"black\" offset 0,0"
<< std::endl;

// Simulator::Schedule (Seconds (1), &PrintHelper::UpdateGnuplottableNodeListToFile, filename, node);
}
}
}

uint32_t index = 0;
for (BuildingList::Iterator it = BuildingList::Begin (); it != BuildingList::End (); ++it)
{
++index;
Box box = (*it)->GetBoundaries ();
outFile << "set object " << index
<< " rect from " << box.xMin << "," << box.yMin
<< " to " << box.xMax << "," << box.yMax
<< std::endl;
}
}
Loading

0 comments on commit b81a765

Please sign in to comment.