nyuwireless-unipd / ns3-mmwave

ns-3 module for simulating mmWave-based cellular systems. See https://ieeexplore.ieee.org/document/8344116/ (open access) as a reference.
GNU General Public License v2.0
292 stars 190 forks source link

mmwave can not work in linux-dce environment #241

Closed jackmygreat closed 2 years ago

jackmygreat commented 2 years ago

Hello, I run mmwave module in linux-dce-1.11 environment. Data packets can be transmitted from the UE to the Server, but not from the Server to the UE. I found that the uplink path from UE to PGW works, but the downlink path from PGW to UE does not work in DCE environment. The topo is UE-----enb----pgw-----server. And I test LTE module with same topo, but LTE module can work. The mmwave code show as below.

// -------------------- topo -----------------------> // UE---pp-enb----pgw-------remotehost // <-------------------- ----------------------->

include "ns3/network-module.h"

include "ns3/core-module.h"

include "ns3/internet-module.h"

include "ns3/dce-module.h"

include "ns3/point-to-point-module.h"

include "ns3/wifi-module.h"

include "ns3/lte-module.h"

include "ns3/mobility-module.h"

include "ns3/applications-module.h"

include "ns3/netanim-module.h"

include "ns3/constant-position-mobility-model.h"

include "ns3/config-store-module.h"

include "ns3/mmwave-module.h"

using namespace ns3; using namespace mmwave;

NS_LOG_COMPONENT_DEFINE ("DceMMwaveSimple");

void setPos(Ptr n, int x, int y, int z) { Ptr loc = CreateObject(); n->AggregateObject(loc); Vector locVec2(x, y, z); loc->SetPosition(locVec2); }

void PrintTcpFlags(std::string key, std::string value) { NS_LOG_INFO (key << "=" << value); }

int main(int argc, char *argv[]) { LogComponentEnable("DceMMwaveSimple", LOG_LEVEL_ALL); std::string bufSize = ""; bool disWifi = false; bool disLte = false; double stopTime = 45.0; std::string p2pdelay = "10ms";

GlobalValue::Bind("ChecksumEnabled", BooleanValue(true));
NodeContainer ueNodes;
NodeContainer enbNodes;
NodeContainer remotehostNode;

ueNodes.Create(1);
enbNodes.Create(1);
remotehostNode.Create(1);

DceManagerHelper dceManager;
dceManager.SetNetworkStack("ns3::LinuxSocketFdFactory",
                           "Library", StringValue("liblinux.so"));
dceManager.Install(ueNodes);
dceManager.Install(remotehostNode);

LinuxStackHelper stack;
stack.Install(ueNodes);
stack.Install(remotehostNode);

PointToPointHelper pointToPoint;
NetDeviceContainer devices1, devices2;

Ptr<MmWaveHelper> mmwaveHelper = CreateObject<MmWaveHelper>();
mmwaveHelper->SetSchedulerType("ns3::MmWaveFlexTtiMacScheduler");
mmwaveHelper->SetChannelConditionModelType("ns3::AlwaysLosChannelConditionModel");
Ptr<MmWavePointToPointEpcHelper> epcHelper = CreateObject<MmWavePointToPointEpcHelper>();
mmwaveHelper->SetEpcHelper(epcHelper);
Ptr<Node> pgw = epcHelper->GetPgwNode();

MobilityHelper enbmobility;
Ptr<ListPositionAllocator> enbPositionAlloc = CreateObject<ListPositionAllocator>();
enbPositionAlloc->Add(Vector(0.0, 0.0, 25.0));
enbmobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
enbmobility.SetPositionAllocator(enbPositionAlloc);
enbmobility.Install(enbNodes);

MobilityHelper uemobility;
Ptr<ListPositionAllocator> uePositionAlloc = CreateObject<ListPositionAllocator>();
uePositionAlloc->Add(Vector(30.0, 0.0, 1.8));
uemobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
uemobility.SetPositionAllocator(uePositionAlloc);
uemobility.Install(ueNodes);

NS_LOG_INFO ("ue "<< ueNodes.Get(0)->GetId());
NS_LOG_INFO ("server "<< remotehostNode.Get(0)->GetId());
NS_LOG_INFO ("end  "<< enbNodes.Get(0)->GetId());
NS_LOG_INFO ("pgw  "<< pgw->GetId());

Ipv4AddressHelper address2;
std::ostringstream cmd_oss;
address2.SetBase("10.2.0.0", "255.255.255.0");
Ipv4InterfaceContainer if1, if2;
pointToPoint.SetDeviceAttribute("DataRate", StringValue("2Mbps"));
pointToPoint.SetChannelAttribute("Delay", StringValue(p2pdelay));
Ptr<RateErrorModel> em1 =
        CreateObjectWithAttributes<RateErrorModel>("RanVar",
                                                   StringValue("ns3::UniformRandomVariable[Min=0.0|Max=1.0]"),
                                                   "ErrorRate", DoubleValue(0.01),
                                                   "ErrorUnit", EnumValue(RateErrorModel::ERROR_UNIT_PACKET)
                                                   );

// Left link: H1 <-> LTE-R
NetDeviceContainer enbDevs = mmwaveHelper->InstallEnbDevice(enbNodes);
NetDeviceContainer ueDevs = mmwaveHelper->InstallUeDevice(ueNodes);

// Assign ip addresses

if1 = epcHelper->AssignUeIpv4Address(NetDeviceContainer(ueDevs));
mmwaveHelper->AttachToClosestEnb (ueDevs, enbDevs);
mmwaveHelper->EnableTraces ();

NS_LOG_INFO ("ue ip "<< if1.GetAddress(0, 0));

// setup ip routes
cmd_oss.str("");
cmd_oss << "rule add from " << if1.GetAddress(0, 0) << " table " << 1;
LinuxStackHelper::RunIp(ueNodes.Get(0), Seconds(0.1), cmd_oss.str().c_str());
cmd_oss.str("");
cmd_oss << "route add default via " << "7.0.0.1 " << " dev sim" << 0 << " table " << 1;
LinuxStackHelper::RunIp(ueNodes.Get(0), Seconds(0.1), cmd_oss.str().c_str());

// LTE-R <-> H2
// Right link
devices2 = pointToPoint.Install(remotehostNode.Get(0), pgw);
devices2.Get(0)->SetAttribute("ReceiveErrorModel", PointerValue(em1));
// Assign ip addresses
if2 = address2.Assign(devices2);
address2.NewNetwork();
// setup ip routes
cmd_oss.str("");
cmd_oss << "rule add from " << if2.GetAddress(0, 0) << " table " << (1);
LinuxStackHelper::RunIp(remotehostNode.Get(0), Seconds(0.1), cmd_oss.str().c_str());
cmd_oss.str("");
cmd_oss << "route add 10.2." << 0 << ".0/24 dev sim" << 0 << " scope link table " << (1);
LinuxStackHelper::RunIp(remotehostNode.Get(0), Seconds(0.1), cmd_oss.str().c_str());
setPos(pgw, 70, 0, 0);

// default route
LinuxStackHelper::RunIp(ueNodes.Get(0), Seconds(0.1), "route add default via 7.0.0.1 dev sim0");
LinuxStackHelper::RunIp(remotehostNode.Get(0), Seconds(0.1), "route add default via 10.2.0.2 dev sim0");
LinuxStackHelper::RunIp(ueNodes.Get(0), Seconds(0.1), "rule show");
LinuxStackHelper::RunIp(ueNodes.Get(0), Seconds(5.1), "route show table all");
LinuxStackHelper::RunIp(remotehostNode.Get(0), Seconds(0.1), "rule show");
LinuxStackHelper::RunIp(remotehostNode.Get(0), Seconds(5.1), "route show table all");

// debug
//  stack.SysctlSet(nodes, ".net.mptcp.mptcp_debug", "1");

DceApplicationHelper dce;
ApplicationContainer apps;

dce.SetStackSize(1 << 20);

// Launch iperf client on node 0
dce.SetBinary("iperf");
dce.ResetArguments();
dce.ResetEnvironment();
dce.AddArgument("-c");

// Extract server IP address
dce.AddArgument("10.2.0.1");
dce.AddArgument("-i");
dce.AddArgument("1");
dce.AddArgument("--time");
dce.AddArgument("10");

apps = dce.Install(ueNodes.Get(0));
apps.Start(Seconds(0.7));
apps.Stop(Seconds(20));

// Launch iperf server on node 1
dce.SetBinary("iperf");
dce.ResetArguments();
dce.ResetEnvironment();
dce.AddArgument("-s");
dce.AddArgument("-P");
dce.AddArgument("1");

apps = dce.Install(remotehostNode.Get(0));

pointToPoint.EnablePcapAll("mmwave-iperf-", false);

apps.Start(Seconds(4));

Simulator::Stop(Seconds(stopTime));
Simulator::Run();
Simulator::Destroy();

return 0;

}

jackmygreat commented 2 years ago

// This is my LTE code in DCE environment

// -------------------- topo -----------------------> // UE---pp-enb----pgw-------remotehost // <-------------------- ----------------------->

include "ns3/network-module.h"

include "ns3/core-module.h"

include "ns3/internet-module.h"

include "ns3/dce-module.h"

include "ns3/point-to-point-module.h"

include "ns3/wifi-module.h"

include "ns3/lte-module.h"

include "ns3/mobility-module.h"

include "ns3/applications-module.h"

include "ns3/netanim-module.h"

include "ns3/constant-position-mobility-model.h"

include "ns3/config-store-module.h"

include "ns3/mmwave-module.h"

using namespace ns3; using namespace mmwave;

NS_LOG_COMPONENT_DEFINE ("DceMMwaveSimple");

void setPos(Ptr n, int x, int y, int z) { Ptr loc = CreateObject(); n->AggregateObject(loc); Vector locVec2(x, y, z); loc->SetPosition(locVec2); }

void PrintTcpFlags(std::string key, std::string value) { NS_LOG_INFO (key << "=" << value); }

int main(int argc, char *argv[]) { LogComponentEnable("DceMMwaveSimple", LOG_LEVEL_ALL); std::string bufSize = ""; bool disWifi = false; bool disLte = false; double stopTime = 45.0; std::string p2pdelay = "10ms";

GlobalValue::Bind("ChecksumEnabled", BooleanValue(true));
NodeContainer ueNodes;
NodeContainer enbNodes;
NodeContainer remotehostNode;

ueNodes.Create(1);
enbNodes.Create(1);
remotehostNode.Create(1);

DceManagerHelper dceManager;
dceManager.SetNetworkStack("ns3::LinuxSocketFdFactory",
                           "Library", StringValue("liblinux.so"));
dceManager.Install(ueNodes);
dceManager.Install(remotehostNode);

LinuxStackHelper stack;
stack.Install(ueNodes);
stack.Install(remotehostNode);

PointToPointHelper pointToPoint;
NetDeviceContainer devices1, devices2;

Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
Ptr<PointToPointEpcHelper> epcHelper = CreateObject<PointToPointEpcHelper> ();
lteHelper->SetEpcHelper(epcHelper);
Ptr<Node> pgw = epcHelper->GetPgwNode();

MobilityHelper enbmobility;
Ptr<ListPositionAllocator> enbPositionAlloc = CreateObject<ListPositionAllocator>();
enbPositionAlloc->Add(Vector(0.0, 0.0, 25.0));
enbmobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
enbmobility.SetPositionAllocator(enbPositionAlloc);
enbmobility.Install(enbNodes);

MobilityHelper uemobility;
Ptr<ListPositionAllocator> uePositionAlloc = CreateObject<ListPositionAllocator>();
uePositionAlloc->Add(Vector(30.0, 0.0, 1.8));
uemobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
uemobility.SetPositionAllocator(uePositionAlloc);
uemobility.Install(ueNodes);

NS_LOG_INFO ("ue "<< ueNodes.Get(0)->GetId());
NS_LOG_INFO ("server "<< remotehostNode.Get(0)->GetId());
NS_LOG_INFO ("end  "<< enbNodes.Get(0)->GetId());
NS_LOG_INFO ("pgw  "<< pgw->GetId());

Ipv4AddressHelper address2;
std::ostringstream cmd_oss;
address2.SetBase("1.0.0.0", "255.0.0.0");
Ipv4InterfaceContainer if1, if2;
pointToPoint.SetDeviceAttribute("DataRate", StringValue("2Mbps"));
pointToPoint.SetChannelAttribute("Delay", StringValue(p2pdelay));
Ptr<RateErrorModel> em1 =
        CreateObjectWithAttributes<RateErrorModel>("RanVar",
                                                   StringValue("ns3::UniformRandomVariable[Min=0.0|Max=1.0]"),
                                                   "ErrorRate", DoubleValue(0.01),
                                                   "ErrorUnit", EnumValue(RateErrorModel::ERROR_UNIT_PACKET)
                                                   );

// Left link: H1 <-> LTE-R
NetDeviceContainer enbDevs = lteHelper->InstallEnbDevice(enbNodes);
NetDeviceContainer ueDevs = lteHelper->InstallUeDevice(ueNodes);

// Assign ip addresses

if1 = epcHelper->AssignUeIpv4Address(NetDeviceContainer(ueDevs));
lteHelper->AttachToClosestEnb(ueDevs, enbDevs);
lteHelper->EnableTraces();

NS_LOG_INFO ("ue ip "<< if1.GetAddress(0, 0));

// setup ip routes
// cmd_oss.str("");
// cmd_oss << "rule add from " << if1.GetAddress(0, 0) << " table " << 1;
// LinuxStackHelper::RunIp(ueNodes.Get(0), Seconds(0.1), cmd_oss.str().c_str());
// cmd_oss.str("");
// cmd_oss << "route add default via " << "7.0.0.1 " << " dev sim" << 0 << " table " << 1;
// LinuxStackHelper::RunIp(ueNodes.Get(0), Seconds(0.1), cmd_oss.str().c_str());

// LTE-R <-> H2
// Right link
devices2 = pointToPoint.Install(remotehostNode.Get(0), pgw);
//devices2.Get(0)->SetAttribute("ReceiveErrorModel", PointerValue(em1));
// Assign ip addresses
if2 = address2.Assign(devices2);
address2.NewNetwork();
// setup ip routes
// cmd_oss.str("");
// cmd_oss << "rule add from " << if2.GetAddress(0, 0) << " table " << (1);
// LinuxStackHelper::RunIp(remotehostNode.Get(0), Seconds(0.1), cmd_oss.str().c_str());
// cmd_oss.str("");
// cmd_oss << "route add 10.2." << 0 << ".0/24 dev sim" << 0 << " scope link table " << (1);
// LinuxStackHelper::RunIp(remotehostNode.Get(0), Seconds(0.1), cmd_oss.str().c_str());
// setPos(pgw, 70, 0, 0);

Ptr<Ipv4L3Protocol> ipv4l3 = pgw->GetObject<Ipv4L3Protocol>();
for (unsigned int i = 0; i < ipv4l3->GetNInterfaces(); i++) {
    Ptr<Ipv4Interface> interface = ipv4l3->GetInterface(i);
    Ipv4InterfaceAddress interfaceAddr = interface->GetAddress(0);
    Ipv4Address ipv4Addr = interfaceAddr.GetLocal();
    NS_LOG_INFO ("pgw address " << ipv4Addr);

}

Ptr<Ipv4L3Protocol> enbip = enbNodes.Get(0)->GetObject<Ipv4L3Protocol>();
for (unsigned int i = 0; i < enbip->GetNInterfaces(); i++) {
    Ptr<Ipv4Interface> interface = enbip->GetInterface(i);
    Ipv4InterfaceAddress interfaceAddr = interface->GetAddress(0);
    Ipv4Address ipv4Addr = interfaceAddr.GetLocal();
    NS_LOG_INFO ("enb address " << ipv4Addr);

}

// default route
LinuxStackHelper::RunIp(ueNodes.Get(0), Seconds(0.1), "route add default via 7.0.0.1 dev sim0");
LinuxStackHelper::RunIp(ueNodes.Get(0), Seconds(0.1), "rule show");
LinuxStackHelper::RunIp(ueNodes.Get(0), Seconds(5.1), "route show table all");
LinuxStackHelper::RunIp(remotehostNode.Get(0), Seconds(0.1), "route add default via 1.0.0.2 dev sim0");
LinuxStackHelper::RunIp(remotehostNode.Get(0), Seconds(0.1), "rule show");
LinuxStackHelper::RunIp(remotehostNode.Get(0), Seconds(5.1), "route show table all");

// debug
//  stack.SysctlSet(nodes, ".net.mptcp.mptcp_debug", "1");

DceApplicationHelper dce;
ApplicationContainer apps;

dce.SetStackSize(1 << 20);

// Launch iperf client on node 0
dce.SetBinary("iperf");
dce.ResetArguments();
dce.ResetEnvironment();
dce.AddArgument("-c");

// Extract server IP address
dce.AddArgument("1.0.0.1");
dce.AddArgument("-i");
dce.AddArgument("1");
dce.AddArgument("--time");
dce.AddArgument("10");

apps = dce.Install(ueNodes.Get(0));
apps.Start(Seconds(2));
apps.Stop(Seconds(20));

// Launch iperf server on node 1
dce.SetBinary("iperf");
dce.ResetArguments();
dce.ResetEnvironment();
dce.AddArgument("-s");
dce.AddArgument("-P");
dce.AddArgument("1");

apps = dce.Install(remotehostNode.Get(0));

pointToPoint.EnablePcapAll("lte-iperf-", false);

apps.Start(Seconds(1));

Simulator::Stop(Seconds(stopTime));
Simulator::Run();
Simulator::Destroy();

return 0;

}

jackmygreat commented 2 years ago

If more detailed information is required, I can provide the PCAP file.

jackmygreat commented 2 years ago

I close this issue. The paper "End-to-End Simulation of 5G mmWave Networks" has mentioned, that it is necessary to patch the KernelFdSocketFactory class. Everyone who wants to run mmwave module in DCE environment should read this paper.

soapopera12 commented 1 year ago

Hi I am trying to run the dce-example-mptcp-mmwave.cc in ubuntu 20.04 however the integration always fails whenever i try to integrate the ns-3.35 folder with any version of ns3-mmwave folder. I also found the patch and applied them however it did not work Further after going through the issues i found your repository mptcp-experiment This one worked completely in ubuntu 16.04 however in the end the execution of programs fails with SIGABRT error. and the pcap files generated won't open. My aim is to run and replicate the performance in the paper "End-to-End Simulation of 5G mmWave Networks" for mptcp in lte and mmwave links for my Mtech thesis. If you can help or guide me please do reply. Thanks in advance.