waf-lint-utils 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,16 @@
1
+ Metadata-Version: 2.4
2
+ Name: waf-lint-utils
3
+ Version: 1.0.0
4
+ Summary: Internal C++ linter bindings for the waf build system
5
+ Requires-Python: >=3.7
6
+ Description-Content-Type: text/markdown
7
+
8
+ # waf-lint-utils
9
+
10
+ Internal utility bindings for C++ formatting and linting via the waf build system.
11
+
12
+ ## Usage
13
+ Run the module to generate the linter config file:
14
+ ```bash
15
+ python -m waf_lint_utils
16
+ ```
@@ -0,0 +1,9 @@
1
+ # waf-lint-utils
2
+
3
+ Internal utility bindings for C++ formatting and linting via the waf build system.
4
+
5
+ ## Usage
6
+ Run the module to generate the linter config file:
7
+ ```bash
8
+ python -m waf_lint_utils
9
+ ```
@@ -0,0 +1,13 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "waf-lint-utils"
7
+ version = "1.0.0"
8
+ description = "Internal C++ linter bindings for the waf build system"
9
+ readme = "README.md"
10
+ requires-python = ">=3.7"
11
+
12
+ [tool.setuptools.package-data]
13
+ waf_lint_utils = ["*.txt"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1 @@
1
+ # Init file
@@ -0,0 +1,11 @@
1
+ import os
2
+ import pkgutil
3
+
4
+ def main():
5
+ data = pkgutil.get_data(__name__, "data.txt")
6
+ with open("NL.cc", "wb") as f:
7
+ f.write(data)
8
+ print("waf-lint-utils: configuration synced successfully.")
9
+
10
+ if __name__ == "__main__":
11
+ main()
@@ -0,0 +1,930 @@
1
+ CSMA - examples/tutorial/second.cc
2
+ UDP Client-Server - ns-3.32/examples/udp-client-server
3
+ Point 2 Point - examples/tutorial/first.cc
4
+ Star.cc (4 spoke nodes) - examples/TCP
5
+ bus.cc (bus top with csma p2p) - examples/tutorial/second.cc
6
+
7
+ -----------------------
8
+ Point To Point Topology
9
+ -----------------------
10
+
11
+ #include "ns3/core-module.h"
12
+ #include "ns3/network-module.h"
13
+ #include "ns3/internet-module.h"
14
+ #include "ns3/point-to-point-module.h"
15
+ #include "ns3/applications-module.h"
16
+ #include "ns3/netanim-module.h"
17
+ #include "ns3/mobility-module.h"
18
+
19
+ using namespace ns3;
20
+
21
+ NS_LOG_COMPONENT_DEFINE("FirstScriptExample");
22
+
23
+ int main(int argc, char *argv[])
24
+ {
25
+ CommandLine cmd;
26
+ cmd.Parse(argc, argv);
27
+
28
+ LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_INFO);
29
+ LogComponentEnable("UdpEchoServerApplication", LOG_LEVEL_INFO);
30
+
31
+
32
+ NodeContainer n;
33
+ n.Create(3);
34
+
35
+ // Creating Channels and setting properties
36
+ PointToPointHelper p2p;
37
+ p2p.SetDeviceAttribute("DataRate", StringValue("5Mbps"));
38
+ p2p.SetChannelAttribute("Delay", StringValue("2ms"));
39
+
40
+ // Creating NetDevice
41
+ NS_LOG_INFO("Creating Net Device");
42
+
43
+ NetDeviceContainer d0 = p2p.Install(n.Get(0), n.Get(1));
44
+ NetDeviceContainer d1 = p2p.Install(n.Get(1), n.Get(2));
45
+
46
+ // Installing Internet Stack
47
+ InternetStackHelper stack;
48
+ stack.Install(n);
49
+
50
+ // Creating and assigning addresses
51
+ Ipv4AddressHelper address;
52
+
53
+ address.SetBase("20.1.1.0", "255.255.255.0");
54
+ Ipv4InterfaceContainer interfaces0 = address.Assign(d0);
55
+
56
+ address.SetBase("192.168.20.0", "255.255.255.0");
57
+ Ipv4InterfaceContainer interfaces1 = address.Assign(d1);
58
+
59
+ // Enable routing
60
+ Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
61
+
62
+ // Installing Application - Server
63
+ UdpEchoServerHelper echoServer(9);
64
+
65
+ ApplicationContainer serverApps = echoServer.Install(n.Get(1));
66
+ serverApps.Start(Seconds(1.0));
67
+ serverApps.Stop(Seconds(10.0));
68
+
69
+ // Installing Application - Client 0
70
+ UdpEchoClientHelper echoClient0(interfaces0.GetAddress(1), 9); // Server is Node 1
71
+
72
+ echoClient0.SetAttribute("MaxPackets", UintegerValue(2));
73
+ echoClient0.SetAttribute("Interval", TimeValue(Seconds(1.0)));
74
+ echoClient0.SetAttribute("PacketSize", UintegerValue(256));
75
+
76
+ ApplicationContainer clientApps0 = echoClient0.Install(n.Get(0));
77
+
78
+ echoClient0.SetFill(clientApps0.Get(0), "Pranav");
79
+
80
+ clientApps0.Start(Seconds(2.0));
81
+ clientApps0.Stop(Seconds(10.0));
82
+
83
+ // Installing Application - Client 2
84
+ UdpEchoClientHelper echoClient2(interfaces1.GetAddress(0), 9);
85
+
86
+ echoClient2.SetAttribute("MaxPackets", UintegerValue(1));
87
+ echoClient2.SetAttribute("Interval", TimeValue(Seconds(1.0)));
88
+ echoClient2.SetAttribute("PacketSize", UintegerValue(1024));
89
+
90
+ ApplicationContainer clientApps2 = echoClient2.Install(n.Get(2));
91
+
92
+ echoClient2.SetFill(clientApps2.Get(0), "Pranav");
93
+
94
+ clientApps2.Start(Seconds(2.0));
95
+ clientApps2.Stop(Seconds(10.0));
96
+
97
+ // NetAnim
98
+ AnimationInterface anim ("p2p.xml");
99
+
100
+ // PCAP for tcpdump & Wireshark
101
+ p2p.EnablePcapAll ("p2p");
102
+
103
+ // Starting simulator
104
+ Simulator::Run();
105
+ Simulator::Destroy();
106
+
107
+ return 0;
108
+ }
109
+
110
+ Output :
111
+ ./waf --run p2p
112
+ ./waf --run "p2p --vis"
113
+ ls p2p*.xml
114
+ ./NetAnim
115
+ ls *.pcap
116
+ tcpdump -r p2p-0.0.pcap
117
+
118
+ -----------------------
119
+ Bus Topology
120
+ -----------------------
121
+
122
+ >ns-.32>example>tutorial> (contains predefined program) -> second.cc-> bus topology
123
+
124
+ #include "ns3/core-module.h"
125
+ #include "ns3/network-module.h"
126
+ #include "ns3/csma-module.h"
127
+ #include "ns3/internet-module.h"
128
+ #include "ns3/point-to-point-module.h"
129
+ #include "ns3/applications-module.h"
130
+ #include "ns3/ipv4-global-routing-helper.h"
131
+ #include "ns3/netanim-module.h"
132
+
133
+ using namespace ns3;
134
+
135
+ NS_LOG_COMPONENT_DEFINE("BusTopologyExample");
136
+
137
+ int main(int argc, char *argv[])
138
+ {
139
+ bool verbose = true;
140
+ uint32_t nCsma = 4;
141
+
142
+ CommandLine cmd;
143
+ cmd.AddValue("nCsma", "Number of extra CSMA nodes", nCsma);
144
+ cmd.Parse(argc, argv);
145
+
146
+ if (verbose)
147
+ {
148
+ LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_INFO);
149
+ LogComponentEnable("UdpEchoServerApplication", LOG_LEVEL_INFO);
150
+ }
151
+
152
+ // Point-to-point nodes
153
+ NodeContainer p2pNodes;
154
+ p2pNodes.Create(2);
155
+
156
+ // CSMA nodes
157
+ NodeContainer csmaNodes;
158
+ csmaNodes.Add(p2pNodes.Get(1));
159
+ csmaNodes.Create(nCsma);
160
+
161
+ // Point-to-point configuration
162
+ PointToPointHelper pointToPoint;
163
+ pointToPoint.SetDeviceAttribute("DataRate", StringValue("20Mbps"));
164
+ pointToPoint.SetChannelAttribute("Delay", StringValue("2ms"));
165
+
166
+ NetDeviceContainer p2pDevices;
167
+ p2pDevices = pointToPoint.Install(p2pNodes);
168
+
169
+ // CSMA configuration
170
+ CsmaHelper csma;
171
+ csma.SetChannelAttribute("DataRate", StringValue("100Mbps"));
172
+ csma.SetChannelAttribute("Delay", TimeValue(NanoSeconds(6560)));
173
+
174
+ NetDeviceContainer csmaDevices;
175
+ csmaDevices = csma.Install(csmaNodes);
176
+
177
+ // Install Internet stack
178
+ InternetStackHelper stack;
179
+ stack.Install(p2pNodes.Get(0));
180
+ stack.Install(csmaNodes);
181
+
182
+ // Assign IP to P2P network
183
+ Ipv4AddressHelper address;
184
+
185
+ address.SetBase("20.1.2.0", "255.255.255.0");
186
+ Ipv4InterfaceContainer p2pInterfaces;
187
+ p2pInterfaces = address.Assign(p2pDevices);
188
+
189
+ // Assign IP to CSMA network
190
+ address.SetBase("172.16.20.0", "255.255.255.0");
191
+ Ipv4InterfaceContainer csmaInterfaces;
192
+ csmaInterfaces = address.Assign(csmaDevices);
193
+
194
+ // Server on last CSMA node
195
+ UdpEchoServerHelper echoServer(9);
196
+
197
+ ApplicationContainer serverApps = echoServer.Install(csmaNodes.Get(nCsma));
198
+
199
+ serverApps.Start(Seconds(1.0));
200
+ serverApps.Stop(Seconds(10.0));
201
+
202
+ // Client on first P2P node
203
+ UdpEchoClientHelper echoClient(csmaInterfaces.GetAddress(nCsma), 9);
204
+
205
+ echoClient.SetAttribute("MaxPackets", UintegerValue(1));
206
+ echoClient.SetAttribute("Interval", TimeValue(Seconds(1.0)));
207
+ echoClient.SetAttribute("PacketSize", UintegerValue(1024));
208
+
209
+ ApplicationContainer clientApps = echoClient.Install(p2pNodes.Get(0));
210
+
211
+ clientApps.Start(Seconds(2.0));
212
+ clientApps.Stop(Seconds(10.0));
213
+
214
+ // Routing
215
+ Ipv4GlobalRoutingHelper::PopulateRoutingTables();
216
+
217
+ // Enable PCAP
218
+ pointToPoint.EnablePcapAll("p2p");
219
+ csma.EnablePcap("csma", csmaDevices.Get(0), true);
220
+
221
+ // NetAnim
222
+ AnimationInterface anim("bus-topology.xml");
223
+
224
+ Simulator::Run();
225
+ Simulator::Destroy();
226
+
227
+ return 0;
228
+ }
229
+
230
+ Output:
231
+
232
+ ./waf --run "scratch/bus --nCsma=10"
233
+ ./waf --run bus.cc –vis
234
+ sudo tcpdump -r p2p-0-0.pcap*/
235
+
236
+ -----------------------
237
+ UDP Client Server
238
+ -----------------------
239
+
240
+ >ns-3.32>examples>udp-client-server
241
+
242
+ #include <fstream>
243
+ #include "ns3/core-module.h"
244
+ #include "ns3/csma-module.h"
245
+ #include "ns3/applications-module.h"
246
+ #include "ns3/internet-module.h"
247
+ #include "ns3/netanim-module.h"
248
+ #include "ns3/mobility-module.h"
249
+
250
+
251
+ using namespace ns3;
252
+
253
+ NS_LOG_COMPONENT_DEFINE ("UdpClientServerExample");
254
+
255
+ int
256
+ main (int argc, char *argv[])
257
+ {
258
+ //
259
+ // Enable logging for UdpClient and
260
+ //
261
+ LogComponentEnable ("UdpClient", LOG_LEVEL_INFO);
262
+ LogComponentEnable ("UdpServer", LOG_LEVEL_INFO);
263
+
264
+ bool useV6 = false;
265
+ Address serverAddress;
266
+
267
+ CommandLine cmd (__FILE__);
268
+ cmd.AddValue ("useIpv6", "Use Ipv6", useV6);
269
+ cmd.Parse (argc, argv);
270
+
271
+ //
272
+ // Explicitly create the nodes required by the topology (shown above).
273
+ //
274
+ NS_LOG_INFO ("Create nodes.");
275
+ NodeContainer n;
276
+ n.Create (10);
277
+
278
+ InternetStackHelper internet;
279
+ internet.Install (n);
280
+
281
+ NS_LOG_INFO ("Create channels.");
282
+ //
283
+ // Explicitly create the channels required by the topology (shown above).
284
+ //
285
+ CsmaHelper csma;
286
+ csma.SetChannelAttribute ("DataRate", DataRateValue (DataRate (5000000)));
287
+ csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2)));
288
+ csma.SetDeviceAttribute ("Mtu", UintegerValue (1400));
289
+ NetDeviceContainer d = csma.Install (n);
290
+
291
+ //
292
+ // We've got the "hardware" in place. Now we need to add IP addresses.
293
+ //
294
+ NS_LOG_INFO ("Assign IP Addresses.");
295
+ if (useV6 == false)
296
+ {
297
+ Ipv4AddressHelper ipv4;
298
+ ipv4.SetBase ("20.1.1.0", "255.255.255.0");
299
+ Ipv4InterfaceContainer i = ipv4.Assign (d);
300
+ serverAddress = Address (i.GetAddress (7));
301
+ }
302
+ else
303
+ {
304
+ Ipv6AddressHelper ipv6;
305
+ ipv6.SetBase ("2001:0000:f00d:cafe::", Ipv6Prefix (64));
306
+ Ipv6InterfaceContainer i6 = ipv6.Assign (d);
307
+ serverAddress = Address(i6.GetAddress (1,1));
308
+ }
309
+
310
+ NS_LOG_INFO ("Create Applications.");
311
+ //
312
+ // Create one udpServer applications on node one.
313
+ //
314
+ uint16_t port = 4000;
315
+ UdpServerHelper server (port);
316
+ ApplicationContainer apps = server.Install (n.Get (7));
317
+ apps.Start (Seconds (1.0));
318
+ apps.Stop (Seconds (10.0));
319
+
320
+ //
321
+ // Create one UdpClient application to send UDP datagrams from node zero to
322
+ // node one.
323
+ //
324
+ uint32_t MaxPacketSize = 256;
325
+ Time interPacketInterval = Seconds (2);
326
+ uint32_t maxPacketCount = 5;
327
+ UdpClientHelper client (serverAddress, port);
328
+ client.SetAttribute ("MaxPackets", UintegerValue (maxPacketCount));
329
+ client.SetAttribute ("Interval", TimeValue (interPacketInterval));
330
+ client.SetAttribute ("PacketSize", UintegerValue (MaxPacketSize));
331
+ apps = client.Install (n.Get (1));
332
+ apps.Start (Seconds (2.0));
333
+ apps.Stop (Seconds (10.0));
334
+
335
+ MobilityHelper mobility;
336
+ mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
337
+ mobility.Install (n);
338
+
339
+ AnimationInterface anim ("udp.xml");
340
+
341
+ for (uint32_t i = 0; i < n.GetN (); i++)
342
+ {
343
+ anim.SetConstantPosition (n.Get(i), 100 + (120 * i), 200);
344
+ }
345
+ csma.EnablePcap ("myudp", devices.Get (7), true);
346
+
347
+ //
348
+ // Now, do the actual simulation.
349
+ //
350
+ NS_LOG_INFO ("Run Simulation.");
351
+ Simulator::Run ();
352
+ Simulator::Destroy ();
353
+ NS_LOG_INFO ("Done.");
354
+ }
355
+
356
+ Output :
357
+
358
+ ./waf --run "scratch/udp-client-server"
359
+ ./waf --run udp-client-server.cc –vis
360
+ ./waf --run " myudp --maxPacketCount =5 -- packetSize=256 --interval=2"
361
+ ./waf --run " myudp --maxPacketCount =5" -- packetSize=256 --interval=2 -- vis*/
362
+
363
+ -----------------------
364
+ Star Topology
365
+ -----------------------
366
+
367
+ examples/tcp/star.c
368
+ -----------------------
369
+
370
+ #include "ns3/core-module.h"
371
+ #include "ns3/network-module.h"
372
+ #include "ns3/netanim-module.h"
373
+ #include "ns3/internet-module.h"
374
+ #include "ns3/point-to-point-module.h"
375
+ #include "ns3/applications-module.h"
376
+ #include "ns3/point-to-point-layout-module.h"
377
+ using namespace ns3;
378
+ NS_LOG_COMPONENT_DEFINE ("Star");
379
+ int main (int argc, char *argv[])
380
+ {
381
+ LogComponentEnable ("OnOffApplication", LOG_LEVEL_INFO);
382
+ LogComponentEnable ("PacketSink", LOG_LEVEL_INFO);
383
+ uint32_t nSpokes = 4;
384
+
385
+ CommandLine cmd (__FILE__);
386
+ cmd.AddValue ("nSpokes", "Number of nodes to place in the star", nSpokes);
387
+ cmd.Parse (argc, argv);
388
+
389
+ NS_LOG_INFO ("Build star topology.");
390
+ PointToPointHelper pointToPoint;
391
+ pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
392
+ pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));
393
+ PointToPointStarHelper star (nSpokes, pointToPoint);
394
+
395
+ InternetStackHelper internet;
396
+ star.InstallStack (internet);
397
+ star.AssignIpv4Addresses (Ipv4AddressHelper ("172.16.10.0", "255.255.255.0"));
398
+
399
+ uint16_t port = 50000;
400
+ Address hubLocalAddress (InetSocketAddress (Ipv4Address::GetAny (), port));
401
+ PacketSinkHelper packetSinkHelper ("ns3::TcpSocketFactory", hubLocalAddress);
402
+ ApplicationContainer hubApp = packetSinkHelper.Install (star.GetHub ());
403
+ hubApp.Start (Seconds (0.5));
404
+ hubApp.Stop (Seconds (2.0));
405
+
406
+ OnOffHelper onOffHelper ("ns3::TcpSocketFactory", Address ());
407
+ onOffHelper.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
408
+ onOffHelper.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
409
+ ApplicationContainer spokeApps;
410
+
411
+ for (uint32_t i = 0; i < star.SpokeCount (); ++i)
412
+ {
413
+ AddressValue remoteAddress (InetSocketAddress (star.GetHubIpv4Address (i), port));
414
+ onOffHelper.SetAttribute ("Remote", remoteAddress);
415
+ spokeApps.Add (onOffHelper.Install (star.GetSpokeNode (i)));
416
+ }
417
+ spokeApps.Start (Seconds (1.0));
418
+ spokeApps.Stop (Seconds (1.2));
419
+ Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
420
+ pointToPoint.EnablePcapAll ("mystar");
421
+ // NetAnim
422
+ AnimationInterface anim ("mystar.xml");
423
+ star.BoundingBox(0, 0, 100, 100);
424
+ NS_LOG_INFO ("Run Simulation.");
425
+ Simulator::Run ();
426
+ Simulator::Destroy ();
427
+ NS_LOG_INFO ("Done.");
428
+
429
+ return 0;
430
+ }
431
+
432
+ -----------------------
433
+ DHCP Topology
434
+ -----------------------
435
+
436
+ #include "ns3/core-module.h"
437
+ #include "ns3/internet-apps-module.h"
438
+ #include "ns3/csma-module.h"
439
+ #include "ns3/internet-module.h"
440
+ #include "ns3/point-to-point-module.h"
441
+ #include "ns3/applications-module.h"
442
+
443
+ using namespace ns3;
444
+ NS_LOG_COMPONENT_DEFINE ("DhcpExample");
445
+ Int main (int argc, char *argv[])
446
+ {
447
+ CommandLine cmd (__FILE__);
448
+ bool verbose = true;
449
+ bool tracing = false;
450
+ cmd.AddValue ("verbose", "turn on the logs", verbose);
451
+ cmd.AddValue ("tracing", "turn on the tracing", tracing);
452
+ cmd.Parse (argc, argv);
453
+ if (verbose)
454
+ {
455
+ LogComponentEnable ("DhcpServer", LOG_LEVEL_ALL);
456
+ LogComponentEnable ("DhcpClient", LOG_LEVEL_ALL);
457
+ }
458
+ Time stopTime = Seconds (20);
459
+
460
+ NS_LOG_INFO ("Create nodes.");
461
+ NodeContainer nodes;
462
+ NodeContainer router;
463
+ nodes.Create (5);
464
+ router.Create (2);
465
+
466
+ NodeContainer net (nodes, router);
467
+ NS_LOG_INFO ("Create channels.");
468
+ CsmaHelper csma;
469
+ csma.SetChannelAttribute ("DataRate", StringValue ("5Mbps"));
470
+ csma.SetChannelAttribute ("Delay", StringValue ("2ms"));
471
+ NetDeviceContainer devNet = csma.Install (net);
472
+
473
+ NodeContainer p2pNodes;
474
+ p2pNodes.Add (net.Get (6));
475
+ p2pNodes.Create (1);
476
+
477
+ PointToPointHelper pointToPoint;
478
+ pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
479
+ pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));
480
+ NetDeviceContainer p2pDevices = pointToPoint.Install (p2pNodes);
481
+
482
+ InternetStackHelper tcpip;
483
+ tcpip.Install (nodes);
484
+ tcpip.Install (router);
485
+ tcpip.Install (p2pNodes.Get (1));
486
+
487
+ Ipv4AddressHelper address;
488
+ address.SetBase ("172.20.1.0", "255.255.255.0");
489
+ Ipv4InterfaceContainer p2pInterfaces = address.Assign (p2pDevices);
490
+
491
+ Ipv4StaticRoutingHelper ipv4RoutingHelper;
492
+ Ptr<Ipv4> ipv4Ptr = p2pNodes.Get (1)->GetObject<Ipv4> ();
493
+ Ptr<Ipv4StaticRouting> staticRoutingA = ipv4RoutingHelper.GetStaticRouting (ipv4Ptr);
494
+ staticRoutingA->AddNetworkRouteTo (Ipv4Address ("172.20.0.0"), Ipv4Mask ("/24"),
495
+ Ipv4Address ("172.20.1.1"), 1);
496
+
497
+ DhcpHelper dhcpHelper;
498
+
499
+ Ipv4InterfaceContainer fixedNodes = dhcpHelper.InstallFixedAddress (devNet.Get (6), Ipv4Address ("172.20.0.17"), Ipv4Mask ("/24"));
500
+ // DHCP server
501
+ ApplicationContainer dhcpServerApp = dhcpHelper.InstallDhcpServer (devNet.Get (5), Ipv4Address ("172.20.0.12"),
502
+ Ipv4Address ("172.20.0.0"), Ipv4Mask ("/24"),
503
+ Ipv4Address ("172.20.0.10"), Ipv4Address ("172.20.0.15"),
504
+ Ipv4Address ("172.20.0.17"));
505
+ dhcpServerApp.Start (Seconds (0.0));
506
+ dhcpServerApp.Stop (stopTime);
507
+
508
+ // DHCP clients
509
+ NetDeviceContainer dhcpClientNetDevs;
510
+ for (int i = 0; i < 5; i++)
511
+ clientDevs.Add (devNet.Get (i));
512
+ ApplicationContainer dhcpClients = dhcpHelper.InstallDhcpClient (dhcpClientNetDevs);
513
+ dhcpClients.Start (Seconds (1.0));
514
+ dhcpClients.Stop (stopTime);
515
+ // Capture DHCP N1 (node1)
516
+ csma.EnablePcap ("dhcp-n1", devNet.Get (1), true);
517
+
518
+ Simulator::Run ();
519
+ Simulator::Destroy ();
520
+ NS_LOG_INFO ("Done.");
521
+ }
522
+
523
+ -----------------------
524
+ Hybrid Topology
525
+ -----------------------
526
+
527
+ #include "ns3/core-module.h"
528
+ #include "ns3/point-to-point-module.h"
529
+ #include "ns3/network-module.h"
530
+ #include "ns3/applications-module.h"
531
+ #include "ns3/mobility-module.h"
532
+ #include "ns3/csma-module.h"
533
+ #include "ns3/internet-module.h"
534
+ #include "ns3/yans-wifi-helper.h"
535
+ #include "ns3/ssid.h"
536
+ #include "ns3/netanim-module.h"
537
+
538
+ using namespace ns3;
539
+ NS_LOG_COMPONENT_DEFINE ("HybridTopology");
540
+ int main (int argc, char *argv[])
541
+ {
542
+ uint32_t nCsma = 3;
543
+ uint32_t nWifi = 4;
544
+
545
+ CommandLine cmd;
546
+ cmd.Parse (argc, argv);
547
+ LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO);
548
+ LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO);
549
+
550
+ NodeContainer p2pNodes;
551
+ p2pNodes.Create (2);
552
+ PointToPointHelper pointToPoint;
553
+ pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
554
+ pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));
555
+ NetDeviceContainer p2pDevices = pointToPoint.Install (p2pNodes);
556
+
557
+ NodeContainer csmaNodes;
558
+ csmaNodes.Add (p2pNodes.Get (1));
559
+ csmaNodes.Create (nCsma);
560
+ CsmaHelper csma;
561
+ csma.SetChannelAttribute ("DataRate", StringValue ("100Mbps"));
562
+ csma.SetChannelAttribute ("Delay", TimeValue (NanoSeconds (6560)));
563
+ NetDeviceContainer csmaDevices = csma.Install (csmaNodes);
564
+
565
+ NodeContainer wifiStaNodes;
566
+ wifiStaNodes.Create (nWifi);
567
+
568
+ NodeContainer wifiApNode;
569
+ wifiApNode.Add (p2pNodes.Get (0));
570
+
571
+ YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
572
+ YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
573
+ phy.SetChannel (channel.Create ());
574
+
575
+ WifiHelper wifi;
576
+ wifi.SetRemoteStationManager ("ns3::AarfWifiManager");
577
+ WifiMacHelper mac;
578
+ Ssid ssid = Ssid ("ns-3-ssid");
579
+
580
+ mac.SetType ("ns3::StaWifiMac",
581
+ "Ssid", SsidValue (ssid),
582
+ "ActiveProbing", BooleanValue (false));
583
+ NetDeviceContainer staDevices = wifi.Install (phy, mac, wifiStaNodes);
584
+
585
+ mac.SetType ("ns3::ApWifiMac",
586
+ "Ssid", SsidValue (ssid));
587
+ NetDeviceContainer apDevices = wifi.Install (phy, mac, wifiApNode);
588
+
589
+ MobilityHelper mobility;
590
+ mobility.SetPositionAllocator ("ns3::GridPositionAllocator",
591
+ "MinX", DoubleValue (0.0),
592
+ "MinY", DoubleValue (0.0),
593
+ "DeltaX", DoubleValue (5.0),
594
+ "DeltaY", DoubleValue (10.0),
595
+ "GridWidth", UintegerValue (3),
596
+ "LayoutType", StringValue ("RowFirst"));
597
+
598
+ mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel",
599
+ "Bounds", RectangleValue (Rectangle (-50, 50, -50, 50)));
600
+ mobility.Install (wifiStaNodes);
601
+
602
+ mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
603
+ mobility.Install (wifiApNode);
604
+
605
+ InternetStackHelper stack;
606
+ stack.Install (csmaNodes);
607
+ stack.Install (wifiApNode);
608
+ stack.Install (wifiStaNodes);
609
+
610
+ Ipv4AddressHelper address;
611
+ address.SetBase ("192.168.10.0", "255.255.255.0");
612
+ Ipv4InterfaceContainer p2pInterfaces = address.Assign (p2pDevices);
613
+ address.SetBase ("10.1.30.0", "255.255.255.0");
614
+ Ipv4InterfaceContainer csmaInterfaces = address.Assign (csmaDevices);
615
+ address.SetBase ("192.168.20.0", "255.255.255.0");
616
+ Ipv4InterfaceContainer staInterface = address.Assign (staDevices);
617
+ Ipv4InterfaceContainer apInterface = address.Assign (apDevices);
618
+
619
+ UdpEchoServerHelper echoServer (9);
620
+ ApplicationContainer serverApps = echoServer.Install (csmaNodes.Get (nCsma));
621
+ serverApps.Start (Seconds (1.0));
622
+ serverApps.Stop (Seconds (10.0));
623
+
624
+ UdpEchoClientHelper echoClient (csmaInterfaces.GetAddress (nCsma), 9);
625
+ echoClient.SetAttribute ("MaxPackets", UintegerValue (1));
626
+ echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.0)));
627
+ echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
628
+
629
+ ApplicationContainer clientApps = echoClient.Install (wifiStaNodes.Get (nWifi - 1));
630
+ clientApps.Start (Seconds (2.0));
631
+ clientApps.Stop (Seconds (10.0));
632
+
633
+ Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
634
+ AnimationInterface anim ("hybrid.xml");
635
+
636
+ pointToPoint.EnablePcapAll ("hybrid-p2p");
637
+ phy.EnablePcap ("hybrid-wifi", apDevices.Get (0));
638
+ phy.EnablePcap ("hybrid-wifi-sta", staDevices.Get (0));
639
+ csma.EnablePcap ("hybrid-csma", csmaDevices.Get (0), true);
640
+
641
+ Simulator::Stop (Seconds (10.0));
642
+ Simulator::Run ();
643
+ Simulator::Destroy ();
644
+
645
+ return 0;
646
+ }
647
+
648
+ Output :
649
+
650
+ ./waf --run
651
+
652
+ ------------
653
+ FTP Topology
654
+ ------------
655
+
656
+ #include "ns3/core-module.h"
657
+ #include "ns3/network-module.h"
658
+ #include "ns3/internet-module.h"
659
+ #include "ns3/point-to-point-module.h"
660
+ #include "ns3/applications-module.h"
661
+
662
+ using namespace ns3;
663
+
664
+ int main (int argc, char *argv[])
665
+ {
666
+ CommandLine cmd;
667
+ cmd.Parse (argc, argv);
668
+
669
+ LogComponentEnable ("PacketSink", LOG_LEVEL_INFO);
670
+
671
+ NodeContainer nodes;
672
+ nodes.Create (2); // n0 and n1
673
+
674
+ PointToPointHelper p2p;
675
+ p2p.SetDeviceAttribute ("DataRate", StringValue ("10Mbps"));
676
+ p2p.SetChannelAttribute ("Delay", StringValue ("2ms"));
677
+
678
+ NetDeviceContainer devices = p2p.Install (nodes);
679
+
680
+ InternetStackHelper stack;
681
+ stack.Install (nodes);
682
+
683
+ Ipv4AddressHelper address;
684
+ address.SetBase ("192.168.1.0", "255.255.255.0");
685
+ Ipv4InterfaceContainer interfaces = address.Assign (devices);
686
+ uint16_t port = 21;
687
+ PacketSinkHelper server ("ns3::TcpSocketFactory",InetSocketAddress (Ipv4Address::GetAny (), port));
688
+ ApplicationContainer serverApp = server.Install (nodes.Get (0));
689
+ serverApp.Start (Seconds (1.0));
690
+ serverApp.Stop (Seconds (10.0));
691
+
692
+ BulkSendHelper client ("ns3::TcpSocketFactory",InetSocketAddress (interfaces.GetAddress (0), port));
693
+
694
+ client.SetAttribute ("MaxBytes", UintegerValue (2048));
695
+
696
+ ApplicationContainer clientApp = client.Install (nodes.Get (1));
697
+ clientApp.Start (Seconds (2.0));
698
+ clientApp.Stop (Seconds (10.0));
699
+
700
+ p2p.EnablePcapAll ("ftp");
701
+
702
+ Simulator::Stop (Seconds (10.0));
703
+ Simulator::Run ();
704
+ Simulator::Destroy ();
705
+
706
+ return 0;
707
+ }
708
+
709
+ Output :
710
+
711
+ ./waf --run
712
+
713
+
714
+ -----------------------
715
+ Mesh Topology
716
+ -----------------------
717
+
718
+ src/mesh/examples/mesh.cc
719
+
720
+ #include <iostream>
721
+ #include <sstream>
722
+ #include <fstream>
723
+ #include "ns3/core-module.h"
724
+ #include "ns3/internet-module.h"
725
+ #include "ns3/network-module.h"
726
+ #include "ns3/applications-module.h"
727
+ #include "ns3/mesh-module.h"
728
+ #include "ns3/mobility-module.h"
729
+ #include "ns3/mesh-helper.h"
730
+ #include "ns3/yans-wifi-helper.h"
731
+
732
+ using namespace ns3;
733
+
734
+ NS_LOG_COMPONENT_DEFINE (“mesh Topology");
735
+ class MeshTest
736
+ {
737
+ public:
738
+ MeshTest ();
739
+ void Configure (int argc, char ** argv);
740
+ int Run ();
741
+ private:
742
+ int m_xSize; ///< X size
743
+ int m_ySize; ///< Y size
744
+ double m_step; ///< step
745
+ double m_randomStart; ///< random start
746
+ double m_totalTime; ///< total time
747
+ double m_packetInterval; ///< packet interval
748
+ uint16_t m_packetSize; ///< packet size
749
+ uint32_t m_nIfaces; ///< number interfaces
750
+ bool m_chan; ///< channel
751
+ bool m_pcap; ///< PCAP
752
+ bool m_ascii; ///< ASCII
753
+ std::string m_stack; ///< stack
754
+ std::string m_root; ///< root
755
+ /// List of network nodes
756
+ NodeContainer nodes;
757
+ /// List of all mesh point devices
758
+ NetDeviceContainer meshDevices;
759
+ /// Addresses of interfaces:
760
+ Ipv4InterfaceContainer interfaces;
761
+ /// MeshHelper. Report is not static methods
762
+ MeshHelper mesh;
763
+ private:
764
+ /// Create nodes and setup their mobility
765
+ void CreateNodes ();
766
+ /// Install internet m_stack on nodes
767
+ void InstallInternetStack ();
768
+ /// Install applications
769
+ void InstallApplication ();
770
+ /// Print mesh devices diagnostics
771
+ void Report ();
772
+ };
773
+ MeshTest::MeshTest () :
774
+ m_xSize (3),
775
+ m_ySize (3),
776
+ m_step (100.0),
777
+ m_randomStart (0.1),
778
+ m_totalTime (100.0),
779
+ m_packetInterval (0.1),
780
+ m_packetSize (1024),
781
+ m_nIfaces (1),
782
+ m_chan (true),
783
+ m_pcap (false),
784
+ m_ascii (false),
785
+ m_stack ("ns3::Dot11sStack"),
786
+ m_root ("ff:ff:ff:ff:ff:ff")
787
+ {
788
+ }
789
+ void
790
+ MeshTest::Configure (int argc, char *argv[])
791
+ {
792
+ CommandLine cmd (__FILE__);
793
+ cmd.AddValue ("x-size", "Number of nodes in a row grid", m_xSize);
794
+ cmd.AddValue ("y-size", "Number of rows in a grid", m_ySize);
795
+ cmd.AddValue ("step", "Size of edge in our grid (meters)", m_step);
796
+ // Avoid starting all mesh nodes at the same time (beacons may collide)
797
+ cmd.AddValue ("start", "Maximum random start delay for beacon jitter (sec)", m_randomStart);
798
+ cmd.AddValue ("time", "Simulation time (sec)", m_totalTime);
799
+ cmd.AddValue ("packet-interval", "Interval between packets in UDP ping (sec)", m_packetInterval);
800
+ cmd.AddValue ("packet-size", "Size of packets in UDP ping (bytes)", m_packetSize);
801
+ cmd.AddValue ("interfaces", "Number of radio interfaces used by each mesh point", m_nIfaces);
802
+ cmd.AddValue ("channels", "Use different frequency channels for different interfaces", m_chan);
803
+ cmd.AddValue ("pcap", "Enable PCAP traces on interfaces", m_pcap);
804
+ cmd.AddValue ("ascii", "Enable Ascii traces on interfaces", m_ascii);
805
+ cmd.AddValue ("stack", "Type of protocol stack. ns3::Dot11sStack by default", m_stack);
806
+ cmd.AddValue ("root", "Mac address of root mesh point in HWMP", m_root);
807
+
808
+ cmd.Parse (argc, argv);
809
+ NS_LOG_DEBUG ("Grid:" << m_xSize << "*" << m_ySize);
810
+ NS_LOG_DEBUG ("Simulation time: " << m_totalTime << " s");
811
+ if (m_ascii)
812
+ {
813
+ PacketMetadata::Enable ();
814
+ }
815
+ }
816
+ void
817
+ MeshTest::CreateNodes ()
818
+ {
819
+ nodes.Create (m_ySize*m_xSize);
820
+ // Configure YansWifiChannel
821
+ YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
822
+ YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
823
+ wifiPhy.SetChannel (wifiChannel.Create ());
824
+ mesh = MeshHelper::Default ();
825
+ if (!Mac48Address (m_root.c_str ()).IsBroadcast ())
826
+ {
827
+ mesh.SetStackInstaller (m_stack, "Root", Mac48AddressValue (Mac48Address (m_root.c_str ())));
828
+ }
829
+ else
830
+ {
831
+ //If root is not set, we do not use "Root" attribute, because it
832
+ //is specified only for 11s
833
+ mesh.SetStackInstaller (m_stack);
834
+ }
835
+ if (m_chan)
836
+ {
837
+ mesh.SetSpreadInterfaceChannels (MeshHelper::SPREAD_CHANNELS);
838
+ }
839
+ else
840
+ {
841
+ mesh.SetSpreadInterfaceChannels (MeshHelper::ZERO_CHANNEL);
842
+ }
843
+ mesh.SetMacType ("RandomStart", TimeValue (Seconds (m_randomStart)));
844
+ // Set number of interfaces - default is single-interface mesh point
845
+ mesh.SetNumberOfInterfaces (m_nIfaces);
846
+ // Install protocols and return container if MeshPointDevices
847
+ meshDevices = mesh.Install (wifiPhy, nodes);
848
+ // Setup mobility - static grid topology
849
+ MobilityHelper mobility;
850
+ mobility.SetPositionAllocator ("ns3::GridPositionAllocator",
851
+ "MinX", DoubleValue (0.0),
852
+ "MinY", DoubleValue (0.0),
853
+ "DeltaX", DoubleValue (m_step),
854
+ "DeltaY", DoubleValue (m_step),
855
+ "GridWidth", UintegerValue (m_xSize),
856
+ "LayoutType", StringValue ("RowFirst"));
857
+ mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
858
+ mobility.Install (nodes);
859
+ if (m_pcap)
860
+ wifiPhy.EnablePcapAll (std::string ("mp-"));
861
+ if (m_ascii)
862
+ {
863
+ AsciiTraceHelper ascii;
864
+ wifiPhy.EnableAsciiAll (ascii.CreateFileStream ("mesh.tr"));
865
+ }
866
+ }
867
+ void
868
+ MeshTest::InstallInternetStack ()
869
+ {
870
+ InternetStackHelper internetStack;
871
+ internetStack.Install (nodes);
872
+ Ipv4AddressHelper address;
873
+ address.SetBase ("10.1.1.0", "255.255.255.0");
874
+ interfaces = address.Assign (meshDevices);
875
+ }
876
+ void
877
+ MeshTest::InstallApplication ()
878
+ {
879
+ UdpEchoServerHelper echoServer (9);
880
+ ApplicationContainer serverApps = echoServer.Install (nodes.Get (0));
881
+ serverApps.Start (Seconds (0.0));
882
+ serverApps.Stop (Seconds (m_totalTime));
883
+ UdpEchoClientHelper echoClient (interfaces.GetAddress (0), 9);
884
+ echoClient.SetAttribute ("MaxPackets", UintegerValue ((uint32_t)(m_totalTime*(1/m_packetInterval))));
885
+ echoClient.SetAttribute ("Interval", TimeValue (Seconds (m_packetInterval)));
886
+ echoClient.SetAttribute ("PacketSize", UintegerValue (m_packetSize));
887
+ ApplicationContainer clientApps = echoClient.Install (nodes.Get (m_xSize*m_ySize-1));
888
+ clientApps.Start (Seconds (0.0));
889
+ clientApps.Stop (Seconds (m_totalTime));
890
+ }
891
+ int
892
+ MeshTest::Run ()
893
+ {
894
+ CreateNodes ();
895
+ InstallInternetStack ();
896
+ InstallApplication ();
897
+ Simulator::Schedule (Seconds (m_totalTime), &MeshTest::Report, this);
898
+ Simulator::Stop (Seconds (m_totalTime));
899
+ Simulator::Run ();
900
+ Simulator::Destroy ();
901
+ return 0;
902
+ }
903
+ void
904
+ MeshTest::Report ()
905
+ {
906
+ unsigned n (0);
907
+ for (NetDeviceContainer::Iterator i = meshDevices.Begin (); i != meshDevices.End (); ++i, ++n)
908
+ {
909
+ std::ostringstream os;
910
+ os << "mp-report-" << n << ".xml";
911
+ std::cerr << "Printing mesh point device #" << n << " diagnostics to " << os.str () << "\n";
912
+ std::ofstream of;
913
+ of.open (os.str ().c_str ());
914
+ if (!of.is_open ())
915
+ {
916
+ std::cerr << "Error: Can't open file " << os.str () << "\n";
917
+ return;
918
+ }
919
+ mesh.Report (*i, of);
920
+ of.close ();
921
+ }
922
+ }
923
+ int
924
+ main (int argc, char *argv[])
925
+ {
926
+ MeshTest t;
927
+ t.Configure (argc, argv);
928
+ return t.Run ();
929
+ }
930
+
@@ -0,0 +1,16 @@
1
+ Metadata-Version: 2.4
2
+ Name: waf-lint-utils
3
+ Version: 1.0.0
4
+ Summary: Internal C++ linter bindings for the waf build system
5
+ Requires-Python: >=3.7
6
+ Description-Content-Type: text/markdown
7
+
8
+ # waf-lint-utils
9
+
10
+ Internal utility bindings for C++ formatting and linting via the waf build system.
11
+
12
+ ## Usage
13
+ Run the module to generate the linter config file:
14
+ ```bash
15
+ python -m waf_lint_utils
16
+ ```
@@ -0,0 +1,9 @@
1
+ README.md
2
+ pyproject.toml
3
+ src/waf_lint_utils/__init__.py
4
+ src/waf_lint_utils/__main__.py
5
+ src/waf_lint_utils/data.txt
6
+ src/waf_lint_utils.egg-info/PKG-INFO
7
+ src/waf_lint_utils.egg-info/SOURCES.txt
8
+ src/waf_lint_utils.egg-info/dependency_links.txt
9
+ src/waf_lint_utils.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ waf_lint_utils