The ECN implement in ns-3-dce

52 views
Skip to first unread message

GANLIN TANG

unread,
Apr 8, 2025, 7:40:35 AM4/8/25
to ns-3-users
Hello everyone:
I'm running the ns-3-dce and test some setting in the code, I has set the ECN option in the code but after running the code there is not ecn in pcap except the SYN and SYN|ACK, so it's meaning ECN has open but not using.

The code is in the below document: dce-tcp-ns3-nsc-comparison.cc.

I will very appreciate it if anyone could reply me.

Thanks!!!
dce-tcp-comparison-3-0.pcap
dce-tcp-ns3-nsc-comparison.cc

GANLIN TANG

unread,
Apr 8, 2025, 7:41:53 AM4/8/25
to ns-3-users
dce-tcp-comparison-0-0.pcap
dce-tcp-comparison-1-1.pcap
dce-tcp-comparison-1-0.pcap

GANLIN TANG

unread,
Apr 8, 2025, 7:43:27 AM4/8/25
to ns-3-users
The length has limited so I send the .pcap document separately.

在2025年4月8日星期二 UTC+9 20:41:53<GANLIN TANG> 写道:
dce-tcp-comparison-2-1.pcap
dce-tcp-comparison-2-0.pcap

GANLIN TANG

unread,
Apr 9, 2025, 1:04:40 AM4/9/25
to ns-3-users
Is any have some idea, I have not searched any relevant information in the document of DCE.

GANLIN TANG

unread,
Apr 10, 2025, 3:52:02 AM4/10/25
to ns-3-users
Hello eveyrone:
I found a way to allow the ecn translate in the simulation.
The question is even open the ecn option, the queuedisc still not install in the router, so the packet will not be marked by ecn.

And the linuxstack will not allow install queue like red in the sim0 like:
process_router.ParseArguments ("qdisc add dev eth0 root handle 1: red limit 3000 min 1200 avpkt 1024 burst 2 bandwidth 10mbit probability 0.4 ecn");

So the point is set ns3 stack in the routers!

There is a code which will help to produce the ecn option, which inspired by the example of dce-tcp-ns3-nsc-comparison.cc 103-111 in ns3-dec example.

#include "ns3/log.h"
#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/dce-module.h"
#include "ns3/flow-monitor-module.h"
#include "ns3/traffic-control-module.h"
using namespace ns3;
NS_LOG_COMPONENT_DEFINE ("ECN-TEST");
std::string m_stack = "dce";
std::string sock_factory = "ns3::LinuxTcpSocketFactory";
int m_seed = 1;
double startTime = 4.0;
double stopTime = 20.0;
int m_nNodes = 1;
bool enablePcap = true;
std::string m_pktSize = "1024";
bool m_frag = false;
bool m_bulk = false;
static void RunIp (Ptr<Node> node, Time at, std::string str)
{
DceApplicationHelper process;
ApplicationContainer apps;
process.SetBinary ("ip");
process.SetStackSize (1 << 16);
process.ResetArguments ();
process.ParseArguments (str.c_str ());
apps = process.Install (node);
apps.Start (at);
}

int
main (int argc, char *argv[])
{
// LogComponentEnable ("OnOffApplication", LOG_LEVEL_INFO);
// LogComponentEnable ("PacketSink", LOG_LEVEL_INFO);
/*CommandLine cmd;
cmd.AddValue ("stack", "choose network stack", m_stack);
cmd.AddValue ("seed", "randomize seed", m_seed);
cmd.AddValue ("nNodes", "the number of nodes in left side", m_nNodes);
cmd.AddValue ("stopTime", "duration", stopTime);
cmd.AddValue ("enablePcap", "pcap", enablePcap);
cmd.AddValue ("pktSize", "packet size", m_pktSize);
cmd.AddValue ("frag", "fragment", m_frag);
cmd.AddValue ("bulk", "use BulkSendApp instead of OnOffApp", m_bulk);
cmd.Parse (argc, argv);*/

SeedManager::SetSeed (m_seed);

NodeContainer lefts, routers, rights, nodes;
lefts.Create (m_nNodes);
routers.Create (1);
rights.Create (m_nNodes);
nodes = NodeContainer (lefts, routers, rights);

DceManagerHelper dceManager;
LinuxStackHelper stack;
InternetStackHelper stack_net;
GlobalValue::Bind ("ChecksumEnabled", BooleanValue (true));

// internetStack.Install (routers);
sock_factory = "ns3::LinuxTcpSocketFactory";
//sock_factory = "ns3::TcpSocketFactory";

dceManager.SetNetworkStack ("ns3::LinuxSocketFdFactory",
"Library", StringValue ("liblinux.so"));
stack_net.Install (routers);
stack.Install (lefts);
stack.Install (rights);


PointToPointHelper pointToPoint;
pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
pointToPoint.SetChannelAttribute ("Delay", StringValue ("1ns"));

Config::SetDefault ("ns3::RedQueueDisc::UseEcn", BooleanValue (true));
TrafficControlHelper tchBottleneck;
QueueDiscContainer queueDiscs;
tchBottleneck.SetRootQueueDisc ("ns3::RedQueueDisc");

Ipv4AddressHelper address;
Ipv4InterfaceContainer interfaces;
NetDeviceContainer dev0, dev1, dev2;
for (uint32_t i = 0; i < m_nNodes; i++)
{
std::ostringstream oss;
oss << "10.0." << i << ".0";
address.SetBase (oss.str ().c_str (), "255.255.255.0");
dev0 = pointToPoint.Install (NodeContainer (lefts.Get (i), routers.Get (0)));

queueDiscs = tchBottleneck.Install (dev0.Get (1));

address.Assign (dev0);
}
// bottle neck link
/*pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("2Mbps"));
pointToPoint.SetChannelAttribute ("Delay", StringValue ("100ms"));
dev1 = pointToPoint.Install (NodeContainer (routers.Get (0), routers.Get (1)));
if (m_frag)
{
dev1.Get (0)->SetMtu (1000);
dev1.Get (1)->SetMtu (1000);
}*/
// bottle neck link
/*Ptr<RateErrorModel> em1 =
CreateObjectWithAttributes<RateErrorModel> ("RanVar", StringValue ("ns3::UniformRandomVariable[Min=0.0|Max=1.0]"),
"ErrorRate", DoubleValue (0.5),
"ErrorUnit", EnumValue (RateErrorModel::ERROR_UNIT_PACKET)
);
dev0.Get (1)->SetAttribute ("ReceiveErrorModel", PointerValue (em1));*/
/*address.SetBase ("10.1.0.0", "255.255.255.0");
address.Assign (dev1);*/
pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("1Mbps"));
pointToPoint.SetChannelAttribute ("Delay", StringValue ("10ns"));

TrafficControlHelper tchBottleneck2;
QueueDiscContainer queueDiscs2;
tchBottleneck2.SetRootQueueDisc ("ns3::RedQueueDisc");

// for right links
for (uint32_t i = 0; i < m_nNodes; i++)
{
std::ostringstream oss;
oss << "10.2." << i << ".0";
address.SetBase (oss.str ().c_str (), "255.255.255.0");
dev2 = pointToPoint.Install (NodeContainer (routers.Get (0), rights.Get (i)));

queueDiscs = tchBottleneck2.Install (dev2.Get (0));
address.Assign (dev2);
}
Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
LinuxStackHelper::PopulateRoutingTables ();
dceManager.Install (nodes);
//stack.SysctlSet (nodes, ".net.ipv4.conf.default.forwarding", "1");


//------------------------------------------------------------------------------------------
//stack.SysctlSet (nodes, ".net.ipv4.tcp_ecn", "1");
//stack.SysctlSet (routers, ".net.core.default_qdisc", "sch_red");
//------------------------------------------
//router setting
/*DceApplicationHelper process_router;
ApplicationContainer router_app;
process_router.SetBinary ("tc");
process_router.SetStackSize (1 << 16);
process_router.ResetArguments ();

RunIp (routers.Get (0), Seconds (0.2), "link show");
process_router.ParseArguments ("qdisc add dev eth0 root handle 1: red limit 3000 min 1200 avpkt 1024 burst 2 bandwidth 10mbit probability 0.4 ecn");
router_app = process_router.Install (routers);
router_app.Start (Seconds (1.0));*/

//RunIp (routers.Get(0), Seconds (1), "link show");

/*DceApplicationHelper process;
process.SetBinary ("echo");
process.AddArgument ("hello-dce");
process.SetStackSize (1 << 16);
ApplicationContainer apps1 = process.Install (routers);
apps1.Start (Seconds (1.0));*/

//-------------------------------------------



ApplicationContainer apps;
DceApplicationHelper process;
BulkSendHelper bulk = BulkSendHelper (sock_factory,
InetSocketAddress ("10.2.0.2", 2000));
// Set the amount of data to send in bytes. Zero is unlimited.
bulk.SetAttribute ("MaxBytes", UintegerValue (0));
bulk.SetAttribute ("SendSize", UintegerValue (atoi (m_pktSize.c_str ())));
// Flow 1 - n
for (uint32_t i = 0; i < m_nNodes; i++)
{
std::ostringstream oss;
oss << "10.2." << i << ".2";
bulk.SetAttribute ("Remote", AddressValue (InetSocketAddress (Ipv4Address (oss.str ().c_str ()), 2000)));
apps = bulk.Install (lefts.Get (i));
apps.Start (Seconds (startTime));
}
PacketSinkHelper sink = PacketSinkHelper (sock_factory,
InetSocketAddress (Ipv4Address::GetAny (), 2000));
apps = sink.Install (rights);
apps.Start (Seconds (2));
if (enablePcap)
{
pointToPoint.EnablePcapAll ("ecn-test");
}
//stack.SysctlSet (routers, ".net.ipv4.ip_forward", "1812");
//stack.SysctlSet (routers, ".net.core.default_qdisc", "sch_red");


stack.SysctlSet (nodes, ".net.mptcp.mptcp_enabled", "0");
stack.SysctlSet (nodes, ".net.ipv4.tcp_congestion_control", "dctcp");
Simulator::Stop (Seconds (stopTime));
Simulator::Run ();
Ptr<PacketSink> pktsink;
uint64_t total = 0;
std::cout << "Total ";
for (uint32_t i = 0; i < m_nNodes; i++)
{
pktsink = apps.Get (i)->GetObject<PacketSink> ();
std::cout << "Rx(" << i << ") = " << pktsink->GetTotalRx ()
<< " bytes ("
<< pktsink->GetTotalRx () * 8 / (stopTime - startTime)
<< " bps), ";
total += pktsink->GetTotalRx () ;
}
std::cout << " total = " << total * 8 / (stopTime - startTime) << " bps";
std::cout << std::endl;
Simulator::Destroy ();
return 0;
}

Thanks!!
在2025年4月8日星期二 UTC+9 20:43:27<GANLIN TANG> 写道:
ecn-test.cc
Reply all
Reply to author
Forward
0 new messages