Commit 0a21a380 authored by Tom Henderson's avatar Tom Henderson
Browse files

Update coding style

parent bbc1b0c7
No related merge requests found
Showing with 192 additions and 192 deletions
+192 -192
......@@ -108,184 +108,184 @@
using namespace ns3;
NS_LOG_COMPONENT_DEFINE("EmuFdNetDeviceSaturationExample");
NS_LOG_COMPONENT_DEFINE ("EmuFdNetDeviceSaturationExample");
int main(int argc, char *argv[])
int main (int argc, char *argv[])
{
uint16_t sinkPort = 8000;
uint32_t packetSize = 190; // bytes
std::string dataRate("950Mb/s");
bool serverMode = false;
std::string deviceName("eno1");
std::string client("10.0.1.11");
std::string server("10.0.1.22");
std::string netmask("255.255.255.0");
std::string macClient("00:00:00:00:00:01");
std::string macServer("00:00:00:00:00:02");
std::string transportProt = "Udp";
std::string socketType;
bool dpdkMode = true;
bool ping = false;
int dpdkTimeout = 2000;
double samplingPeriod = 0.5; // s
CommandLine cmd;
cmd.AddValue("deviceName", "Device name", deviceName);
cmd.AddValue("client", "Local IP address (dotted decimal only please)", client);
cmd.AddValue("server", "Remote IP address (dotted decimal only please)", server);
cmd.AddValue("localmask", "Local mask address (dotted decimal only please)", netmask);
cmd.AddValue("serverMode", "1:true, 0:false, default client", serverMode);
cmd.AddValue("macClient", "Mac Address for Client. Default : 00:00:00:00:00:01", macClient);
cmd.AddValue("macServer", "Mac Address for Server. Default : 00:00:00:00:00:02", macServer);
cmd.AddValue("dataRate", "Data rate defaults to 1000Mb/s", dataRate);
cmd.AddValue("transportPort", "Transport protocol to use: Tcp, Udp", transportProt);
cmd.AddValue("dpdkMode", "Enable the netmap emulation mode", dpdkMode);
cmd.AddValue("dpdkTimeout", "Tx Timeout to use in dpdkMode. (in microseconds)", dpdkTimeout);
cmd.AddValue("ping", "Enable server ping client side", ping);
cmd.AddValue("packetSize", "Size of the packet (without header) in bytes.", packetSize);
cmd.Parse(argc, argv);
Ipv4Address remoteIp;
Ipv4Address localIp;
Mac48AddressValue localMac;
if (serverMode)
uint16_t sinkPort = 8000;
uint32_t packetSize = 190; // bytes
std::string dataRate ("950Mb/s");
bool serverMode = false;
std::string deviceName ("eno1");
std::string client ("10.0.1.11");
std::string server ("10.0.1.22");
std::string netmask ("255.255.255.0");
std::string macClient ("00:00:00:00:00:01");
std::string macServer ("00:00:00:00:00:02");
std::string transportProt = "Udp";
std::string socketType;
bool dpdkMode = true;
bool ping = false;
int dpdkTimeout = 2000;
double samplingPeriod = 0.5; // s
CommandLine cmd;
cmd.AddValue ("deviceName", "Device name", deviceName);
cmd.AddValue ("client", "Local IP address (dotted decimal only please)", client);
cmd.AddValue ("server", "Remote IP address (dotted decimal only please)", server);
cmd.AddValue ("localmask", "Local mask address (dotted decimal only please)", netmask);
cmd.AddValue ("serverMode", "1:true, 0:false, default client", serverMode);
cmd.AddValue ("macClient", "Mac Address for Client. Default : 00:00:00:00:00:01", macClient);
cmd.AddValue ("macServer", "Mac Address for Server. Default : 00:00:00:00:00:02", macServer);
cmd.AddValue ("dataRate", "Data rate defaults to 1000Mb/s", dataRate);
cmd.AddValue ("transportPort", "Transport protocol to use: Tcp, Udp", transportProt);
cmd.AddValue ("dpdkMode", "Enable the netmap emulation mode", dpdkMode);
cmd.AddValue ("dpdkTimeout", "Tx Timeout to use in dpdkMode. (in microseconds)", dpdkTimeout);
cmd.AddValue ("ping", "Enable server ping client side", ping);
cmd.AddValue ("packetSize", "Size of the packet (without header) in bytes.", packetSize);
cmd.Parse (argc, argv);
Ipv4Address remoteIp;
Ipv4Address localIp;
Mac48AddressValue localMac;
if (serverMode)
{
remoteIp = Ipv4Address(client.c_str());
localIp = Ipv4Address(server.c_str());
localMac = Mac48AddressValue(macServer.c_str());
remoteIp = Ipv4Address (client.c_str ());
localIp = Ipv4Address (server.c_str ());
localMac = Mac48AddressValue (macServer.c_str ());
}
else
else
{
remoteIp = Ipv4Address(server.c_str());
localIp = Ipv4Address(client.c_str());
localMac = Mac48AddressValue(macClient.c_str());
remoteIp = Ipv4Address (server.c_str ());
localIp = Ipv4Address (client.c_str ());
localMac = Mac48AddressValue (macClient.c_str ());
}
if (transportProt.compare("Tcp") == 0)
if (transportProt.compare ("Tcp") == 0)
{
socketType = "ns3::TcpSocketFactory";
socketType = "ns3::TcpSocketFactory";
}
else
else
{
socketType = "ns3::UdpSocketFactory";
socketType = "ns3::UdpSocketFactory";
}
Ipv4Mask localMask(netmask.c_str());
Ipv4Mask localMask (netmask.c_str ());
GlobalValue::Bind("SimulatorImplementationType", StringValue("ns3::RealtimeSimulatorImpl"));
GlobalValue::Bind ("SimulatorImplementationType", StringValue ("ns3::RealtimeSimulatorImpl"));
GlobalValue::Bind("ChecksumEnabled", BooleanValue(true));
GlobalValue::Bind ("ChecksumEnabled", BooleanValue (true));
Config::SetDefault("ns3::TcpSocketBase::Sack", BooleanValue(true));
Config::SetDefault ("ns3::TcpSocketBase::Sack", BooleanValue (true));
NS_LOG_INFO("Create Node");
Ptr<Node> node = CreateObject<Node>();
NS_LOG_INFO ("Create Node");
Ptr<Node> node = CreateObject<Node> ();
NS_LOG_INFO("Create Device");
EmuFdNetDeviceHelper emu;
NS_LOG_INFO ("Create Device");
EmuFdNetDeviceHelper emu;
// set the dpdk emulation mode
if (dpdkMode)
// set the dpdk emulation mode
if (dpdkMode)
{
// set the dpdk emulation mode
char **ealArgv = new char*[20];
// arg[0] is program name (optional)
ealArgv[0] = new char[20];
strcpy (ealArgv[0], "");
// logical core usage
ealArgv[1] = new char[20];
strcpy (ealArgv[1], "-l");
// Use core 0 and 1
ealArgv[2] = new char[20];
strcpy (ealArgv[2], "0,1");
// Load library
ealArgv[3] = new char[20];
strcpy (ealArgv[3], "-d");
// Use e1000 driver library
ealArgv[4] = new char[20];
strcpy (ealArgv[4], "librte_pmd_e1000.so");
// Load library
ealArgv[5] = new char[20];
strcpy (ealArgv[5], "-d");
// Use mempool ring library
ealArgv[6] = new char[50];
strcpy (ealArgv[6], "librte_mempool_ring.so");
emu.SetDpdkMode(7, ealArgv);
// set the dpdk emulation mode
char **ealArgv = new char*[20];
// arg[0] is program name (optional)
ealArgv[0] = new char[20];
strcpy (ealArgv[0], "");
// logical core usage
ealArgv[1] = new char[20];
strcpy (ealArgv[1], "-l");
// Use core 0 and 1
ealArgv[2] = new char[20];
strcpy (ealArgv[2], "0,1");
// Load library
ealArgv[3] = new char[20];
strcpy (ealArgv[3], "-d");
// Use e1000 driver library
ealArgv[4] = new char[20];
strcpy (ealArgv[4], "librte_pmd_e1000.so");
// Load library
ealArgv[5] = new char[20];
strcpy (ealArgv[5], "-d");
// Use mempool ring library
ealArgv[6] = new char[50];
strcpy (ealArgv[6], "librte_mempool_ring.so");
emu.SetDpdkMode (7, ealArgv);
}
emu.SetDeviceName(deviceName);
NetDeviceContainer devices = emu.Install(node);
Ptr<NetDevice> device = devices.Get(0);
device->SetAttribute("Address", localMac);
if (dpdkMode)
{
device->SetAttribute("TxTimeout", UintegerValue (dpdkTimeout) );
}
NS_LOG_INFO("Add Internet Stack");
InternetStackHelper internetStackHelper;
internetStackHelper.SetIpv4StackInstall(true);
internetStackHelper.Install(node);
NS_LOG_INFO("Create IPv4 Interface");
Ptr<Ipv4> ipv4 = node->GetObject<Ipv4>();
uint32_t interface = ipv4->AddInterface(device);
Ipv4InterfaceAddress address = Ipv4InterfaceAddress(localIp, localMask);
ipv4->AddAddress(interface, address);
ipv4->SetMetric(interface, 1);
ipv4->SetUp(interface);
Config::SetDefault("ns3::TcpSocket::SegmentSize", UintegerValue(packetSize));
if (serverMode)
emu.SetDeviceName (deviceName);
NetDeviceContainer devices = emu.Install (node);
Ptr<NetDevice> device = devices.Get (0);
device->SetAttribute ("Address", localMac);
if (dpdkMode)
{
Address sinkLocalAddress(InetSocketAddress(localIp, sinkPort));
PacketSinkHelper sinkHelper(socketType, sinkLocalAddress);
ApplicationContainer sinkApp = sinkHelper.Install(node);
sinkApp.Start(Seconds(1));
sinkApp.Stop(Seconds(30.0));
device->SetAttribute ("TxTimeout", UintegerValue (dpdkTimeout) );
}
NS_LOG_INFO ("Add Internet Stack");
InternetStackHelper internetStackHelper;
internetStackHelper.SetIpv4StackInstall (true);
internetStackHelper.Install (node);
NS_LOG_INFO ("Create IPv4 Interface");
Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> ();
uint32_t interface = ipv4->AddInterface (device);
Ipv4InterfaceAddress address = Ipv4InterfaceAddress (localIp, localMask);
ipv4->AddAddress (interface, address);
ipv4->SetMetric (interface, 1);
ipv4->SetUp (interface);
Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (packetSize));
if (serverMode)
{
Address sinkLocalAddress (InetSocketAddress (localIp, sinkPort));
PacketSinkHelper sinkHelper (socketType, sinkLocalAddress);
ApplicationContainer sinkApp = sinkHelper.Install (node);
sinkApp.Start (Seconds (1));
sinkApp.Stop (Seconds (30.0));
emu.EnablePcap("fd-server", device);
emu.EnablePcap ("fd-server", device);
}
else
else
{
// add traffic generator
AddressValue remoteAddress(InetSocketAddress(remoteIp, sinkPort));
OnOffHelper onoff(socketType, Address());
onoff.SetAttribute("Remote", remoteAddress);
onoff.SetAttribute("OnTime", StringValue("ns3::ConstantRandomVariable[Constant=1]"));
onoff.SetAttribute("OffTime", StringValue("ns3::ConstantRandomVariable[Constant=0]"));
onoff.SetAttribute("DataRate", DataRateValue(dataRate));
onoff.SetAttribute("PacketSize", UintegerValue(packetSize));
ApplicationContainer clientApps = onoff.Install(node);
clientApps.Start(Seconds(6.0));
clientApps.Stop(Seconds(106.0));
if (ping)
// add traffic generator
AddressValue remoteAddress (InetSocketAddress (remoteIp, sinkPort));
OnOffHelper onoff (socketType, Address ());
onoff.SetAttribute ("Remote", remoteAddress);
onoff.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
onoff.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
onoff.SetAttribute ("DataRate", DataRateValue (dataRate));
onoff.SetAttribute ("PacketSize", UintegerValue (packetSize));
ApplicationContainer clientApps = onoff.Install (node);
clientApps.Start (Seconds (6.0));
clientApps.Stop (Seconds (106.0));
if (ping)
{
printf("Adding ping app\n");
// add ping application
Ptr<V4Ping> app = CreateObject<V4Ping>();
app->SetAttribute("Remote", Ipv4AddressValue(remoteIp));
app->SetAttribute("Verbose", BooleanValue(true));
app->SetAttribute("Interval", TimeValue(Seconds(samplingPeriod)));
node->AddApplication(app);
app->SetStartTime(Seconds(6.0));
app->SetStopTime(Seconds(106.0));
printf ("Adding ping app\n");
// add ping application
Ptr<V4Ping> app = CreateObject<V4Ping> ();
app->SetAttribute ("Remote", Ipv4AddressValue (remoteIp));
app->SetAttribute ("Verbose", BooleanValue (true));
app->SetAttribute ("Interval", TimeValue (Seconds (samplingPeriod)));
node->AddApplication (app);
app->SetStartTime (Seconds (6.0));
app->SetStopTime (Seconds (106.0));
}
emu.EnablePcap("fd-client", device);
emu.EnablePcap ("fd-client", device);
}
Simulator::Stop(Seconds(120));
Simulator::Run();
Simulator::Destroy();
Simulator::Stop (Seconds (120));
Simulator::Run ();
Simulator::Destroy ();
return 0;
return 0;
}
......@@ -93,7 +93,7 @@ main (int argc, char *argv[])
NS_LOG_INFO ("Dpdk Emulation Ping Example");
std::string deviceName ("0000:00:1f.6");
std::string macClient("78:0c:b8:d8:e1:95");
std::string macClient ("78:0c:b8:d8:e1:95");
// ping a real host connected back-to-back through the ethernet interfaces
std::string remote ("192.168.43.2");
......
......@@ -43,7 +43,7 @@
//
// This example is aimed at measuring the throughput of the FdNetDevice
// when using the EmuFdNetDeviceHelper. This is achieved by saturating
// the channel with TCP traffic. Then the throughput can be obtained from
// the channel with TCP traffic. Then the throughput can be obtained from
// the generated .pcap files.
//
// To run this example you will need two hosts (client & server).
......@@ -71,7 +71,7 @@
// server host: $ ./waf --run="fd-emu-onoff --serverMode=1"
//
// 6 - Run the client side:
//
//
// client host: $ ./waf --run="fd-emu-onoff"
//
......@@ -91,12 +91,12 @@ using namespace ns3;
NS_LOG_COMPONENT_DEFINE ("EmuFdNetDeviceSaturationExample");
int
int
main (int argc, char *argv[])
{
uint16_t sinkPort = 8000;
uint32_t packetSize = 10000; // bytes
std::string dataRate("1000Mb/s");
std::string dataRate ("1000Mb/s");
bool serverMode = false;
std::string deviceName ("eth0");
......@@ -120,22 +120,22 @@ main (int argc, char *argv[])
Ipv4Address remoteIp;
Ipv4Address localIp;
Mac48AddressValue localMac;
if (serverMode)
{
remoteIp = Ipv4Address (client.c_str ());
localIp = Ipv4Address (server.c_str ());
localMac = Mac48AddressValue (macServer.c_str ());
}
{
remoteIp = Ipv4Address (client.c_str ());
localIp = Ipv4Address (server.c_str ());
localMac = Mac48AddressValue (macServer.c_str ());
}
else
{
remoteIp = Ipv4Address (server.c_str ());
localIp = Ipv4Address (client.c_str ());
localMac = Mac48AddressValue (macClient.c_str ());
}
{
remoteIp = Ipv4Address (server.c_str ());
localIp = Ipv4Address (client.c_str ());
localMac = Mac48AddressValue (macClient.c_str ());
}
Ipv4Mask localMask (netmask.c_str ());
GlobalValue::Bind ("SimulatorImplementationType", StringValue ("ns3::RealtimeSimulatorImpl"));
GlobalValue::Bind ("ChecksumEnabled", BooleanValue (true));
......@@ -152,7 +152,7 @@ main (int argc, char *argv[])
NS_LOG_INFO ("Add Internet Stack");
InternetStackHelper internetStackHelper;
internetStackHelper.SetIpv4StackInstall(true);
internetStackHelper.SetIpv4StackInstall (true);
internetStackHelper.Install (node);
NS_LOG_INFO ("Create IPv4 Interface");
......@@ -163,32 +163,32 @@ main (int argc, char *argv[])
ipv4->SetMetric (interface, 1);
ipv4->SetUp (interface);
if(serverMode)
{
Address sinkLocalAddress (InetSocketAddress (localIp, sinkPort));
PacketSinkHelper sinkHelper ("ns3::TcpSocketFactory", sinkLocalAddress);
ApplicationContainer sinkApp = sinkHelper.Install (node);
sinkApp.Start (Seconds (1.0));
sinkApp.Stop (Seconds (60.0));
emu.EnablePcap ("fd-server", device);
}
if (serverMode)
{
Address sinkLocalAddress (InetSocketAddress (localIp, sinkPort));
PacketSinkHelper sinkHelper ("ns3::TcpSocketFactory", sinkLocalAddress);
ApplicationContainer sinkApp = sinkHelper.Install (node);
sinkApp.Start (Seconds (1.0));
sinkApp.Stop (Seconds (60.0));
emu.EnablePcap ("fd-server", device);
}
else
{
AddressValue remoteAddress (InetSocketAddress (remoteIp, sinkPort));
OnOffHelper onoff ("ns3::TcpSocketFactory", Address ());
onoff.SetAttribute ("Remote", remoteAddress);
onoff.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
onoff.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
onoff.SetAttribute ("DataRate", DataRateValue (dataRate));
onoff.SetAttribute ("PacketSize", UintegerValue (packetSize));
ApplicationContainer clientApps = onoff.Install (node);
clientApps.Start (Seconds (4.0));
clientApps.Stop (Seconds (58.0));
emu.EnablePcap ("fd-client", device);
}
{
AddressValue remoteAddress (InetSocketAddress (remoteIp, sinkPort));
OnOffHelper onoff ("ns3::TcpSocketFactory", Address ());
onoff.SetAttribute ("Remote", remoteAddress);
onoff.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
onoff.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
onoff.SetAttribute ("DataRate", DataRateValue (dataRate));
onoff.SetAttribute ("PacketSize", UintegerValue (packetSize));
ApplicationContainer clientApps = onoff.Install (node);
clientApps.Start (Seconds (4.0));
clientApps.Stop (Seconds (58.0));
emu.EnablePcap ("fd-client", device);
}
Simulator::Stop (Seconds (61.0));
Simulator::Run ();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment