Skip to content

Commit 1d3cc04

Browse files
committed
enable tracing in V1modle
1 parent 1aff19d commit 1d3cc04

13 files changed

Lines changed: 3432 additions & 40 deletions

examples/CMakeLists.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,4 +144,27 @@ build_lib_example(
144144
${libapplications}
145145
${libnetwork}
146146
${libcsma}
147+
)
148+
149+
# network test
150+
build_lib_example(
151+
NAME p4-traffic-gene
152+
SOURCE_FILES p4-traffic-gene.cc
153+
LIBRARIES_TO_LINK
154+
${libp4sim}
155+
${libinternet}
156+
${libapplications}
157+
${libnetwork}
158+
${libpoint-to-point}
159+
)
160+
161+
# network test
162+
build_lib_example(
163+
NAME p4-queue-test
164+
SOURCE_FILES p4-queue-test.cc
165+
LIBRARIES_TO_LINK
166+
${libp4sim}
167+
${libinternet}
168+
${libapplications}
169+
${libnetwork}
147170
)

examples/p4-basic-tunnel.cc

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ unsigned long start = getTickCount();
4040
double global_start_time = 1.0;
4141
double sink_start_time = global_start_time + 1.0;
4242
double client_start_time = sink_start_time + 1.0;
43-
double client_stop_time = client_start_time + 5; // sending time
43+
double client_stop_time = client_start_time + 30; // sending time
4444
double sink_stop_time = client_stop_time + 5;
4545
double global_stop_time = sink_stop_time + 5;
4646

@@ -185,8 +185,8 @@ main(int argc, char* argv[])
185185

186186
int running_number = 0;
187187
uint16_t pktSize = 1000; // in Bytes. 1458 to prevent fragments, default 512
188-
std::string appDataRate[] = {"1Mbps", "3Mbps"}; // Default application data rate
189-
std::string ns3_link_rate = "1000Mbps";
188+
std::string appDataRate[] = {"10Mbps", "40Mbps"}; // Default application data rate
189+
std::string ns3_link_rate = "100Mbps";
190190
bool enableTracePcap = true;
191191

192192
std::string p4JsonPath =
@@ -230,8 +230,8 @@ main(int argc, char* argv[])
230230

231231
// set default network link parameter
232232
P4PointToPointHelper p4p2phelper;
233-
p4p2phelper.SetDeviceAttribute("DataRate", DataRateValue(DataRate("10Mbps")));
234-
p4p2phelper.SetChannelAttribute("Delay", TimeValue(MilliSeconds(0.01)));
233+
p4p2phelper.SetDeviceAttribute("DataRate", DataRateValue(DataRate(ns3_link_rate)));
234+
p4p2phelper.SetChannelAttribute("Delay", TimeValue(MilliSeconds(1)));
235235

236236
P4TopologyReader::ConstLinksIterator_t iter;
237237
SwitchNodeC_t switchNodes[switchNum];
@@ -350,6 +350,7 @@ main(int argc, char* argv[])
350350
// p4SwitchHelper.SetDeviceAttribute("ChannelType", UintegerValue(0));
351351
p4SwitchHelper.SetDeviceAttribute("P4SwitchArch", UintegerValue(0));
352352
p4SwitchHelper.SetDeviceAttribute("ChannelType", UintegerValue(1));
353+
p4SwitchHelper.SetDeviceAttribute("SwitchRate", UintegerValue(10000));
353354

354355
for (unsigned int i = 0; i < switchNum; i++)
355356
{
@@ -410,18 +411,12 @@ main(int argc, char* argv[])
410411
onOff1.SetAttribute("DataRate", StringValue(appDataRate[0]));
411412
onOff1.SetAttribute("OnTime", StringValue("ns3::ConstantRandomVariable[Constant=1]"));
412413
onOff1.SetAttribute("OffTime", StringValue("ns3::ConstantRandomVariable[Constant=0]"));
413-
onOff1.SetAttribute("MaxBytes", UintegerValue(5000));
414+
// onOff1.SetAttribute("MaxBytes", UintegerValue(5000));
414415

415416
ApplicationContainer app1 = onOff1.Install(terminals.Get(clientI));
416417
app1.Start(Seconds(client_start_time));
417418
app1.Stop(Seconds(client_stop_time));
418419

419-
// === Setup Tracing ===
420-
Ptr<OnOffApplication> ptr_app1 =
421-
DynamicCast<OnOffApplication>(terminals.Get(clientI)->GetApplication(0));
422-
ptr_app1->TraceConnectWithoutContext("Tx", MakeCallback(&TxCallback));
423-
sinkApp1.Get(0)->TraceConnectWithoutContext("Rx", MakeCallback(&RxCallback));
424-
425420
// Normal Stream == Second == send link h0 -----> h1
426421
servPort = 1301; // change the application port
427422

@@ -441,18 +436,12 @@ main(int argc, char* argv[])
441436
onOff2.SetAttribute("DataRate", StringValue(appDataRate[1]));
442437
onOff2.SetAttribute("OnTime", StringValue("ns3::ConstantRandomVariable[Constant=1]"));
443438
onOff2.SetAttribute("OffTime", StringValue("ns3::ConstantRandomVariable[Constant=0]"));
444-
onOff2.SetAttribute("MaxBytes", UintegerValue(10000));
439+
// onOff2.SetAttribute("MaxBytes", UintegerValue(10000));
445440

446441
ApplicationContainer app2 = onOff2.Install(terminals.Get(clientI));
447442
app2.Start(Seconds(client_start_time));
448443
app2.Stop(Seconds(client_stop_time));
449444

450-
// === Setup Tracing ===
451-
Ptr<OnOffApplication> ptr_app2 =
452-
DynamicCast<OnOffApplication>(terminals.Get(clientI)->GetApplication(1));
453-
ptr_app2->TraceConnectWithoutContext("Tx", MakeCallback(&TxCallback_2));
454-
sinkApp2.Get(0)->TraceConnectWithoutContext("Rx", MakeCallback(&RxCallback_2));
455-
456445
// Enable pcap tracing
457446
p4p2phelper.EnablePcapAll("p4-basic-tunnel");
458447

0 commit comments

Comments
 (0)