add example fd2fd-onoff.cc from the fd-net-device module to unit tests using UDP as default mode
This commit is contained in:
@@ -38,6 +38,7 @@
|
||||
// Steps to run the experiment:
|
||||
//
|
||||
// $ ./waf --run="fd2fd-onoff"
|
||||
// $ ./waf --run="fd2fd-onoff --tcpMode=1"
|
||||
//
|
||||
|
||||
#include <sys/socket.h>
|
||||
@@ -56,6 +57,24 @@ NS_LOG_COMPONENT_DEFINE ("FdNetDeviceSaturationExample");
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
|
||||
// Command-line arguments
|
||||
//
|
||||
bool tcpMode = false;
|
||||
CommandLine cmd;
|
||||
cmd.AddValue ("tcpMode", "1:true, 0:false, default mode UDP",tcpMode);
|
||||
cmd.Parse (argc, argv);
|
||||
|
||||
std::string factory;
|
||||
if (tcpMode==1)
|
||||
{
|
||||
factory = "ns3::TcpSocketFactory";
|
||||
}
|
||||
else
|
||||
{
|
||||
factory = "ns3::UdpSocketFactory";
|
||||
}
|
||||
|
||||
GlobalValue::Bind ("ChecksumEnabled", BooleanValue (true));
|
||||
|
||||
uint16_t sinkPort = 8000;
|
||||
@@ -100,7 +119,8 @@ main (int argc, char *argv[])
|
||||
|
||||
// server
|
||||
Address sinkLocalAddress (InetSocketAddress (serverIp, sinkPort));
|
||||
PacketSinkHelper sinkHelper ("ns3::TcpSocketFactory", sinkLocalAddress);
|
||||
|
||||
PacketSinkHelper sinkHelper (factory, sinkLocalAddress);
|
||||
ApplicationContainer sinkApp = sinkHelper.Install (serverNode);
|
||||
sinkApp.Start (Seconds (0.0));
|
||||
sinkApp.Stop (Seconds (30.0));
|
||||
@@ -108,7 +128,7 @@ main (int argc, char *argv[])
|
||||
|
||||
// client
|
||||
AddressValue serverAddress (InetSocketAddress (serverIp, sinkPort));
|
||||
OnOffHelper onoff ("ns3::TcpSocketFactory", Address ());
|
||||
OnOffHelper onoff (factory, Address ());
|
||||
onoff.SetAttribute ("Remote", serverAddress);
|
||||
onoff.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
|
||||
onoff.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
|
||||
|
||||
@@ -13,7 +13,7 @@ cpp_examples = [
|
||||
("fd-emu-onoff", "False", "True"),
|
||||
("fd-emu-udp-echo", "False", "True"),
|
||||
("realtime-dummy-network", "False", "True"),
|
||||
("fd2fd-onoff", "False", "True"),
|
||||
("fd2fd-onoff", "True", "True"),
|
||||
("fd-tap-ping", "False", "True"),
|
||||
("realtime-fd2fd-onoff", "False", "True"),
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user