Netzwerksimulator-Tutorial ns-3. Kapitel 6


Kapitel 1.2
Kapitel 3
Kapitel 4
Kapitel 5


Kapitel 6 Erstellen von Topologien
6.1 Erstellen einer Busnetzwerktopologie
6.2 Modelle, Attribute und Realität
6.3 Erstellen einer drahtlosen Netzwerktopologie
6.4 Warteschlangen in ns-3
6.4.1 In ns-3 verfĂĽgbare Warteschlangenmodelle
6.4.2 Ă„ndern der Standardeinstellungen


Kapitel 6



6.1


ns‑3, . Ns‑3 , CSMA ( ).


CSMA ns‑3 Ethernet. Ethernet CSMA/CD ( ) . CSMA ns‑3 .


, -, CSMA. .


examples/tutorial . first.cc CSMA -, . examples/tutorial/second.cc . ns‑3, , , .


first.cc ( ns‑3), emacs GPL .


, first.cc.


#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/csma-module.h"
#include "ns3/internet-module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/applications-module.h"
#include "ns3/ipv4-global-routing-helper.h"

, , ASCII , , . «» .


, ( n0 n1 ), . , , , . nCsma , ( CSMA) — «» . «» , :


// Default Network Topology
//
//       10.1.1.0
// n0 -------------- n1   n2   n3   n4
//    point-to-point  |    |    |    |
//                    ================
//                      LAN 10.1.2.0

ns‑3 . , first.cc, .


using namespace ns3;
NS_LOG_COMPONENT_DEFINE ("SecondScriptExample");

-. verbose , UdpEchoClientApplication UdpEchoServerApplication. true ( ), .


, CSMA . 5.2.2, . , «» .
API, .


bool verbose = true;
uint32_t nCsma = 3;
CommandLine cmd;
cmd.AddValue ("nCsma", "Number of \"extra\" CSMA nodes/devices", nCsma);
cmd.AddValue ("verbose", "Tell echo applications to log if true", verbose);
cmd.Parse (argc, argv);
if (verbose)
{
LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_INFO);
LogComponentEnable("UdpEchoServerApplication", LOG_LEVEL_INFO);
}
nCsma = nCsma == 0 ? 1 : nCsma;

, -. NodeContainer , first.cc.


NodeContainer p2pNodes;
p2pNodes.Create (2);

NodeContainer , (CSMA). -.


NodeContainer csmaNodes;
csmaNodes.Add (p2pNodes.Get (1));
csmaNodes.Create (nCsma);

(, ) , CSMA . - CSMA . «» , CSMA . CSMA — , - CSMA , «» CSMA .


. PointToPointHelper , , .


PointToPointHelper pointToPoint;
pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));
NetDeviceContainer p2pDevices;
p2pDevices = pointToPoint.Install (p2pNodes);

NetDeviceContainer «-» -.


, CSMA . CsmaHelper , PointToPointHelper, CSMA . , CSMA — , channelAttribute deviceAttribute. , CSMA , 10Base-T 100Base-T . 100 , 6560 ( 1 , 100 ). , , .


CsmaHelper csma;
csma.SetChannelAttribute ("DataRate", StringValue ("100Mbps"));
csma.SetChannelAttribute ("Delay", TimeValue (NanoSeconds (6560)));
NetDeviceContainer csmaDevices;
csmaDevices = csma.Install (csmaNodes);

, NetDeviceContainer , PointToPointHelper, NetDeviceContainer , CsmaHelper. Install CsmaHelper csmaNodes NodeContainer.


, , . first.cc , InternetStackHelper .


InternetStackHelper stack;
stack.Install (p2pNodes.Get (0));
stack.Install (csmaNodes);

, p2pNodes csmaNodes. , p2pNodes csmaNodes. first.cc, IP- Ipv4AddressHelper. 10.1.1.0 , -.


Ipv4AddressHelper address;
address.SetBase ("10.1.1.0", "255.255.255.0");
Ipv4InterfaceContainer p2pInterfaces;
p2pInterfaces = address.Assign (p2pDevices);

, , . IP- CSMA . , -, , CSMA — , CSMA . CSMA IP- 10.1.2.0, .


address.SetBase ("10.1.2.0", "255.255.255.0");
Ipv4InterfaceContainer csmaInterfaces;
csmaInterfaces = address.Assign (csmaDevices);

, . first.cc, CSMA , . -. UdpEchoServerHelper , . , , , , SetAttribute, .


UdpEchoServerHelper echoServer (9);
ApplicationContainer serverApps = echoServer.Install (csmaNodes.Get (nCsma));
serverApps.Start (Seconds (1.0));
serverApps.Stop (Seconds (10.0));

, csmaNodes , , nCsma «» . , «» . csmaNodes -. , , «» CSMA , csmaNodes 1. , , nCsma «» , nCsma. Get.


, first.cc. , UdpEchoClientHelper ( ). , «» CSMA . , .


UdpEchoClientHelper echoClient (csmaInterfaces.GetAddress (nCsma), 9);
echoClient.SetAttribute ("MaxPackets", UintegerValue (1));
echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.0)));
echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
ApplicationContainer clientApps = echoClient.Install (p2pNodes.Get (0));
clientApps.Start (Seconds (2.0));
clientApps.Stop (Seconds (10.0));

, . Ns‑3, , , . , , — . , , OSPF1, . , . :


Ipv4GlobalRoutingHelper::PopulateRoutingTables ();

pcap. pcap . pcap CSMA, , .


pointToPoint.EnablePcapAll ("second");
csma.EnablePcap ("second", csmaDevices.Get (1), true);

CSMA . , ( ). . . — , . — . (Promiscuous mode). «» pcap . , , tcpdump. CSMA .


CSMA , , tcpdump. Linux, - tcpdump -i eth0. csmaDevices.Get(1), . true . , first.cc.


Simulator::Run ();
Simulator::Destroy ();
return 0;
}

, - second.cc waf , first.cc. , ,


$ cp examples/tutorial/second.cc scratch/mysecond.cc
$ ./waf

: second.cc , . .. second . , second.cc mysecond.cc.


( ), NS_LOG, , .


$ export NS_LOG=
$ ./waf --run scratch/mysecond

UDP - , first.cc, , .


Waf: Entering directory `/home/craigdo/repos/ns-3-allinone/ns-3-dev/build'
Waf: Leaving directory `/home/craigdo/repos/ns-3-allinone/ns-3-dev/build'
'build' finished successfully (0.415s)
Sent 1024 bytes to 10.1.2.4
Received 1024 bytes from 10.1.1.1
Received 1024 bytes from 10.1.2.4
,    «
Sent 1024 bytes to 10.1.2.4

» UDP -, . (10.1.2.0). «Received 1024 bytes from 10.1.1.1
» UDP -, -. «Received 1024 bytes from 10.1.2.4» -, , .


, :


second-0-0.pcap second-1-0.pcap second-2-0.pcap

. ,<> - <> - <> .pcap. , — second-0-0.pcap pcap 0, 0. . second-1-0.pcap — pcap , -; second-2-0.pcap — pcap . , , -, 1 — , -, CSMA . , 2 «» CSMA , 0 .


- . tcpdump - — 0.


$ tcpdump -nn -tt -r second-0-0.pcap

pcap:


reading from file second-0-0.pcap, link-type PPP (PPP)
2.000000 IP 10.1.1.1.49153 > 10.1.2.4.9: UDP, length 1024
2.017607 IP 10.1.2.4.9 > 10.1.1.1.49153: UDP, length 1024

, — PPP (-)3. -, 0 , IP-
10.1.1.1, IP- 10.1.2.4 ( CSMA ). «-» «-» . :
$ tcpdump -nn -tt -r second-1-0.pcap
pcap :


reading from file second-1-0.pcap, link-type PPP (PPP)
2.003686 IP 10.1.1.1.49153 > 10.1.2.4.9: UDP, length 1024
2.013921 IP 10.1.2.4.9 > 10.1.1.1.49153: UDP, length 1024

, PPP, . IP- 10.1.1.1 ( 2.000000 ) IP- 10.1.2.4 . CSMA, , , .


, 2 CSMA , second-2-0.pcap .


$ tcpdump -nn -tt -r second-2-0.pcap

0 2:


reading from file second-2-0.pcap, link-type EN10MB (Ethernet)
2.007698 ARP, Request who-has 10.1.2.4 (ff:ff:ff:ff:ff:ff) tell 10.1.2.1, length 50
2.007710 ARP, Reply 10.1.2.4 is-at 00:00:00:00:00:06, length 50
2.007803 IP 10.1.1.1.49153 > 10.1.2.4.9: UDP, length 1024
2.013815 ARP, Request who-has 10.1.2.1 (ff:ff:ff:ff:ff:ff) tell 10.1.2.4, length 50
2.013828 ARP, Reply 10.1.2.1 is-at 00:00:00:00:00:03, length 50
2.013921 IP 10.1.2.4.9 > 10.1.1.1.49153: UDP, length 1024

, «Ethernet». - . ARP, . , IP- 10.1.2.4, MAC- . CSMA (ff: ff: ff: ff: ff: ff), IP- 10.1.2.4. , MAC- 00: 00: 00: 00: 00: 06. , , . ,


2.007698 ARP, Request who-has 10.1.2.4 (ff:ff:ff:ff:ff:ff) tell 10.1.2.1, length 50
2.007710 ARP, Reply 10.1.2.4 is-at 00:00:00:00:00:06, length 50

, 1 1 - UDP - IP- 10.1.2.4.


2.007803 IP 10.1.1.1.49153 > 10.1.2.4.9: UDP, length 1024

- , . , , IP- 10.1.2.1. , , . - MAC- CSMA , ARP , CSMA .


2.013815 ARP, Request who-has 10.1.2.1 (ff:ff:ff:ff:ff:ff) tell 10.1.2.4, length 50
2.013828 ARP, Reply 10.1.2.1 is-at 00:00:00:00:00:03, length 50

- .


2.013921 IP 10.1.2.4.9 > 10.1.1.1.49153: UDP, length 1024

, ,


$ tcpdump -nn -tt -r second-1-0.pcap

, .


reading from file second-1-0.pcap, link-type PPP (PPP)
2.003686 IP 10.1.1.1.49153 > 10.1.2.4.9: UDP, length 1024
2.013921 IP 10.1.2.4.9 > 10.1.1.1.49153: UDP, length 1024

, ,


$ tcpdump -nn -tt -r second-0-0.pcap

, 2,017607 ,


reading from file second-0-0.pcap, link-type PPP (PPP)
2.000000 IP 10.1.1.1.49153 > 10.1.2.4.9: UDP, length 1024
2.017607 IP 10.1.2.4.9 > 10.1.1.1.49153: UDP, length 1024

, CSMA . , first.cc. :


$ ./waf --run "scratch/mysecond --nCsma=4"

,


Waf: Entering directory `/home/craigdo/repos/ns-3-allinone/ns-3-dev/build'
Waf: Leaving directory `/home/craigdo/repos/ns-3-allinone/ns-3-dev/build'
'build' finished successfully (0.405s)
At time 2s client sent 1024 bytes to 10.1.2.5 port 9
At time 2.0118s server received 1024 bytes from 10.1.1.1 port 49153
At time 2.0118s server sent 1024 bytes to 10.1.1.1 port 49153
At time 2.02461s client received 1024 bytes from 10.1.2.5 port 9

, - CSMA , 10.1.2.5 , 10.1.2.4.


, , CSMA. , . .
, scratch/mysecond.cc . ns‑3 , . EnablePcap .


pointToPoint.EnablePcap ("second", p2pNodes.Get (0)->GetId (), 0);
csma.EnablePcap ("second", csmaNodes.Get (nCsma)->GetId (), 0, false);
csma.EnablePcap ("second", csmaNodes.Get (nCsma-1)->GetId (), 0, false);

, pcap «second», , 0, .


, : , , . — «», , . , , , CSMA
nCsma + 1. .


, , , Node ns‑3, NodeContainer. Node GetId, , , . Doxygen Node , ns‑3 , . .


Doxygen (, - ). Node, «» « », ns3::Node. ns3::Node, Node. GetId , . GetId .


, , ,


$ rm *.pcap
$ rm *.tr


nCsma=100,


$ ./waf --run "scratch/mysecond --nCsma=100"

:


Waf: Entering directory `/home/craigdo/repos/ns-3-allinone/ns-3-dev/build'
Waf: Leaving directory `/home/craigdo/repos/ns-3-allinone/ns-3-dev/build'
'build' finished successfully (0.407s)
At time 2s client sent 1024 bytes to 10.1.2.101 port 9
At time 2.0068s server received 1024 bytes from 10.1.1.1 port 49153
At time 2.0068s server sent 1024 bytes to 10.1.1.1 port 49153
At time 2.01761s client received 1024 bytes from 10.1.2.101 port 9

, - 10.1.2.101
, 100 «» CSMA - . pcap , ,


second-0-0.pcap second-100-0.pcap second-101-0.pcap

second-0-0.pcap « » , -. second-101-0.pcap CSMA, -. , , pcap - false. , , , .


, . tcpdump second-100-0.pcap.


$ tcpdump -nn -tt -r second-100-0.pcap

, 100 -. , , ARP-, CSMA .


reading from file second-100-0.pcap, link-type EN10MB (Ethernet)
2.006698 ARP, Request who-has 10.1.2.101 (ff:ff:ff:ff:ff:ff) tell 10.1.2.1, length 50
2.013815 ARP, Request who-has 10.1.2.1 (ff:ff:ff:ff:ff:ff) tell 10.1.2.101, length 50

tcpdump second-101-0.pcap.


$ tcpdump -nn -tt -r second-101-0.pcap

, 101 -.


reading from file second-101-0.pcap, link-type EN10MB (Ethernet)
2.006698 ARP, Request who-has 10.1.2.101 (ff:ff:ff:ff:ff:ff) tell 10.1.2.1, length 50
2.006698 ARP, Reply 10.1.2.101 is-at 00:00:00:00:00:67, length 50
2.006803 IP 10.1.1.1.49153 > 10.1.2.101.9: UDP, length 1024
2.013803 ARP, Request who-has 10.1.2.1 (ff:ff:ff:ff:ff:ff) tell 10.1.2.101, length 50
2.013828 ARP, Reply 10.1.2.1 is-at 00:00:00:00:00:03, length 50
2.013828 IP 10.1.2.101.9 > 10.1.1.1.49153: UDP, length 1024

6.2 ,


, . . , , - , , , . , CSMA, , Ethernet ; , , Ethernet. .


, , . « » « » .


, , Csma, , . (csma.h) , CSMA , , .


, , . , .


, ns‑3 , . CsmaNetDevice: Mtu EncapsulationMode. Mtu (Maximum Transmission Unit). ( PDU), .


CsmaNetDevice MTU 1500 . , RFC 894, « IP- Ethernet». 10Base5 ( Ethernet) — 1518 . Ethernet DIX4 (18 ), (MTU) 1500 . , MTU IEEE 802.3 1492 . , LLC/SNAP . 1518 , .


, CsmaNetDevice , EncapsulationMode, Dix Llc. Ethernet LLC/SNAP .


Mtu 1500 Llc, , 1500- PDU LLC/SNAP, 1526 . , 1518 . , .


, , jumbo () (1500 < MTU ≤ 9000 ) super-jumbo (-) (MTU > 9000) ) , IEEE, () . Dix Mtu CsmaNetDevice 64000 — , CsmaChannel DataRate 10 . , Ethernet 10Base5 « » 1980- , - . , , , - , - , «» .


, 100 Csma. 500 . 10Base5 , Ethernet- 500 , — 2,5 . , 200 . , . , , .


ns‑3 . , , , , .
Ns‑3 , , - . , ns‑3 . , , .


6.3


, ns‑3, . Ns‑3 802.11, MAC 802.11 « » PHY- 802.11a.


Wi-Fi , - CSMA. .


examples/tutorial. second.cc Wi-Fi. , examples/tutorial/third.cc . ns‑3, , , , .


second.cc ( ns‑3), emacs GPL.


ASCII ( ), , . , , . , , , . second.cc, nCsma, «» CSMA . nWifi, STA (). AP ( ). «» CSMA STA .
, second.cc. , Wi-Fi , .


#include "ns3/core-module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/network-module.h"
#include "ns3/applications-module.h"
#include "ns3/wifi-module.h"
#include "ns3/mobility-module.h"
#include "ns3/csma-module.h"
#include "ns3/internet-module.h"

:


// Default Network Topology
//
// Wifi 10.1.3.0
//                 AP
//  *    *    *    *
//  |    |    |    |     10.1.1.0
// n5   n6   n7   n0 -------------- n1   n2   n3   n4
//                   point-to-point  |    |    |    |
//                                   ================
//                                     LAN 10.1.2.0

, , . STA
10.1.3.0, . ns‑3 . .


using namespace ns3;
NS_LOG_COMPONENT_DEFINE ("ThirdScriptExample");

, second.cc, .


bool verbose = true;
uint32_t nCsma = 3;
uint32_t nWifi = 3;
CommandLine cmd;
cmd.AddValue ("nCsma", "Number of \"extra\" CSMA nodes/devices", nCsma);
cmd.AddValue ("nWifi", "Number of wifi STA devices", nWifi);
cmd.AddValue ("verbose", "Tell echo applications to log if true", verbose);
cmd.Parse (argc,argv);
if (verbose)
{
LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_INFO);
LogComponentEnable("UdpEchoServerApplication", LOG_LEVEL_INFO);
}

, , -.


NodeContainer p2pNodes;
p2pNodes.Create (2);

. PointToPointHelper , , . .


PointToPointHelper pointToPoint;
pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));
NetDeviceContainer p2pDevices;
p2pDevices = pointToPoint.Install (p2pNodes);

NodeContainer , (CSMA).


NodeContainer csmaNodes;
csmaNodes.Add (p2pNodes.Get (1));
csmaNodes.Create (nCsma);

(, ) , CSMA. - CSMA . «» , CSMA .


, CsmaHelper , . NetDeviceContainer CSMA , CSMA .


CsmaHelper csma;
csma.SetChannelAttribute ("DataRate", StringValue ("100Mbps"));
csma.SetChannelAttribute ("Delay", TimeValue (NanoSeconds (6560)));
NetDeviceContainer csmaDevices;
csmaDevices = csma.Install (csmaNodes);

, Wi-Fi. «», , « » .


NodeContainer wifiStaNodes;
wifiStaNodes.Create (nWifi);
NodeContainer wifiApNode = p2pNodes.Get (0);

Wi-Fi Wi-Fi . PHY :


YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();

, PHY- ,
YansWifiChannelHelper::Default YansWifiPhyHelper::Default, Doxygen API. , PHY , , PHY , YansWifiPhyHelper , , :


phy.SetChannel (channel.Create ());

PHY , MAC . non-Qos MAC. MAC WifiMacHelper.


WifiHelper wifi;
wifi.SetRemoteStationManager ("ns3::AarfWifiManager");
WifiMacHelper mac;

SetRemoteStationManager . AARF (Adaptive AutoRate Fallback) — , , Doxygen.


MAC, SSID (Service Set Identification), , :


Ssid ssid = Ssid ("ns-3-ssid");
mac.SetType ("ns3::StaWifiMac",
  "Ssid", SsidValue (ssid),
  "ActiveProbing", BooleanValue (false));

(SSID) 802.11, «Ssid», MAC . «ns3::StaWifiMac» MAC , . «QosSupported» WifiMacHelper false. , MAC (STA) QoS AP BSS ( BSS AP). , «ActiveProbing» false. , MAC, . , , MAC , PHY , Wi-Fi :


NetDeviceContainer staDevices;
staDevices = wifi.Install (phy, mac, wifiStaNodes);

Wi-Fi STA , AP ( ). AP, , WifiMacHelper.


mac.SetType ("ns3::ApWifiMac",
"Ssid", SsidValue (ssid));

WifiMacHelper MAC
«ns3::ApWifiMac», , MAC, AP. «QosSupported», false — QoS 802.11e/WMM. , PHY ( ), :


NetDeviceContainer apDevices;
apDevices = wifi.Install (phy, mac, wifiApNode);

. , STA , AP . , MobilityHelper. MobilityHelper , « ».


MobilityHelper mobility;
mobility.SetPositionAllocator ("ns3::GridPositionAllocator",
"MinX", DoubleValue (0.0),
"MinY", DoubleValue (0.0),
"DeltaX", DoubleValue (5.0),
"DeltaY", DoubleValue (10.0),
"GridWidth", UintegerValue (3),
"LayoutType", StringValue ("RowFirst"));

STA . Doxygen ns3::GridPositionAllocator, , . , , . RandomWalk2dMobilityModel, .


mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel",
"Bounds", RectangleValue (Rectangle (-50, 50, -50, 50)));

MobilityHelper STA .


mobility.Install (wifiStaNodes);

, . ,


ns3::ConstantPositionMobilityModel:
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
mobility.Install (wifiApNode);

, , , Wi-Fi. . , InternetStackHelper.


InternetStackHelper stack;
stack.Install (csmaNodes);
stack.Install (wifiApNode);
stack.Install (wifiStaNodes);

second.cc, Ipv4AddressHelper IP- .
10.1.1.0 , -. 10.1.2.0 CSMA , 10.1.3.0 STA .


Ipv4AddressHelper address;
address.SetBase ("10.1.1.0", "255.255.255.0");
Ipv4InterfaceContainer p2pInterfaces;
p2pInterfaces = address.Assign (p2pDevices);
address.SetBase ("10.1.2.0", "255.255.255.0");
Ipv4InterfaceContainer csmaInterfaces;
csmaInterfaces = address.Assign (csmaDevices);
address.SetBase ("10.1.3.0", "255.255.255.0");
address.Assign (staDevices);
address.Assign (apDevices);

- « » . .


UdpEchoServerHelper echoServer (9);
ApplicationContainer serverApps = echoServer.Install (csmaNodes.Get (nCsma));
serverApps.Start (Seconds (1.0));
serverApps.Stop (Seconds (10.0));

- STA , CSMA . .


UdpEchoClientHelper echoClient (csmaInterfaces.GetAddress (nCsma), 9);
echoClient.SetAttribute ("MaxPackets", UintegerValue (1));
echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.0)));
echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
ApplicationContainer clientApps =
echoClient.Install (wifiStaNodes.Get (nWifi - 1));
clientApps.Start (Seconds (2.0));
clientApps.Stop (Seconds (10.0));

, , second.cc.


Ipv4GlobalRoutingHelper::PopulateRoutingTables ();

, « ». , ( beacon ). , , . , . , .


Simulator::Stop (Seconds (10.0));

, :


pointToPoint.EnablePcapAll ("third");
phy.EnablePcap ("third", apDevices.Get (0));
csma.EnablePcap ("third", csmaDevices.Get (0), true);

pcap , , () Wi-Fi CSMA . .
, , .


Simulator::Run ();
Simulator::Destroy ();
return 0;
}

third.cc Waf, second.cc. , ,


$ cp examples/tutorial/third.cc scratch/mythird.cc
$ ./waf
$ ./waf --run scratch/mythird

, UDP - , second.cc, .


Waf: Entering directory `/home/craigdo/repos/ns-3-allinone/ns-3-dev/build'
Waf: Leaving directory `/home/craigdo/repos/ns-3-allinone/ns-3-dev/build'
'build' finished successfully (0.407s)
At time 2s client sent 1024 bytes to 10.1.2.4 port 9
At time 2.01796s server received 1024 bytes from 10.1.3.3 port 49153
At time 2.01796s server sent 1024 bytes to 10.1.3.3 port 49153
At time 2.03364s client received 1024 bytes from 10.1.2.4 port 9

, «sent 1024 bytes to 10.1.2.4» — UDP -, . (10.1.3.0). «received 1024 bytes from 10.1.3.3» UDP -, -. «received 1024 bytes from 10.1.2.4» -, , . , , 0 1:


third-0-0.pcap third-0-1.pcap third-1-0.pcap third-1-1.pcap

«third-0-0.pcap» «-» — («backborn»). «third-1-0.pcap» - — . «Third-0-1.pcap» — ( ) Wi-Fi «third-1-1.pcap» CSMA . , ?
- Wi-Fi, . ( ), .


$ tcpdump -nn -tt -r third-0-1.pcap

wifi- , :


reading from file third-0-1.pcap, link-type IEEE802_11 (802.11)
0.000025 Beacon (ns-3-ssid) [6.0* 9.0 12.0 18.0 24.0 36.0 48.0 54.0 Mbit] IBSS
0.000308 Assoc Request (ns-3-ssid) [6.0 9.0 12.0 18.0 24.0 36.0 48.0 54.0 Mbit]
0.000324 Acknowledgment RA:00:00:00:00:00:08
0.000402 Assoc Response AID(0) :: Successful
0.000546 Acknowledgment RA:00:00:00:00:00:0a
0.000721 Assoc Request (ns-3-ssid) [6.0 9.0 12.0 18.0 24.0 36.0 48.0 54.0 Mbit]
0.000737 Acknowledgment RA:00:00:00:00:00:07
0.000824 Assoc Response AID(0) :: Successful
0.000968 Acknowledgment RA:00:00:00:00:00:0a
0.001134 Assoc Request (ns-3-ssid) [6.0 9.0 12.0 18.0 24.0 36.0 48.0 54.0 Mbit]
0.001150 Acknowledgment RA:00:00:00:00:00:09
0.001273 Assoc Response AID(0) :: Successful
0.001417 Acknowledgment RA:00:00:00:00:00:0a
0.102400 Beacon (ns-3-ssid) [6.0* 9.0 12.0 18.0 24.0 36.0 48.0 54.0 Mbit] IBSS
0.204800 Beacon (ns-3-ssid) [6.0* 9.0 12.0 18.0 24.0 36.0 48.0 54.0 Mbit] IBSS
0.307200 Beacon (ns-3-ssid) [6.0* 9.0 12.0 18.0 24.0 36.0 48.0 54.0 Mbit] IBSS

, 802.11, . , , IP- - . . pcap «-»,


$ tcpdump -nn -tt -r third-0-0.pcap

, :


reading from file third-0-0.pcap, link-type PPP (PPP)
2.008151 IP 10.1.3.3.49153 > 10.1.2.4.9: UDP, length 1024
2.026758 IP 10.1.2.4.9 > 10.1.3.3.49153: UDP, length 1024

-, ( Wi-Fi CSMA) «-». pcap «-»,


$ tcpdump -nn -tt -r third-1-0.pcap

, :


reading from file third-1-0.pcap, link-type PPP (PPP)
2.011837 IP 10.1.3.3.49153 > 10.1.2.4.9: UDP, length 1024
2.023072 IP 10.1.2.4.9 > 10.1.3.3.49153: UDP, length 1024

-, ( Wi-Fi CSMA) - , .
- CSMA , :


$ tcpdump -nn -tt -r third-1-1.pcap

:


reading from file third-1-1.pcap, link-type EN10MB (Ethernet)
2.017837 ARP, Request who-has 10.1.2.4 (ff:ff:ff:ff:ff:ff) tell 10.1.2.1, length 50
2.017861 ARP, Reply 10.1.2.4 is-at 00:00:00:00:00:06, length 50
2.017861 IP 10.1.3.3.49153 > 10.1.2.4.9: UDP, length 1024
2.022966 ARP, Request who-has 10.1.2.1 (ff:ff:ff:ff:ff:ff) tell 10.1.2.4, length 50
2.022966 ARP, Reply 10.1.2.1 is-at 00:00:00:00:00:03, length 50
2.023072 IP 10.1.2.4.9 > 10.1.3.3.49153: UDP, length 1024

. , second.cc. .


, , STA . , MobilityModel. 7, , .


5, ns‑3 , . . , . , . scratch/mythird.cc (..
NS_LOG_COMPONENT_DEFINE), :


void
CourseChange (std::string context, Ptr<const MobilityModel> model)
{
Vector position = model->GetPosition ();
NS_LOG_UNCOND (context <<
" x = " << position.x << ", y = " << position.y);
}

x y . , , - . Config::Connect. Simulator::Run.


std::ostringstream oss;
oss <<
"/NodeList/" << wifiStaNodes.Get (nWifi - 1)->GetId () <<
"/$ns3::MobilityModel/CourseChange";
Config::Connect (oss.str (), MakeCallback (&CourseChange));

, , . -, GetId, , . CSMA , ,
/NodeList/7/$ns3::MobilityModel/CourseChange.


, , NodeList. , ns3::MobilityModel. , MobilityModel . , «CourseChange» .


7 , Config::Connect . , , .


, , .


'build' finished successfully (5.989s)
/NodeList/7/$ns3::MobilityModel/CourseChange x = 10, y = 0
/NodeList/7/$ns3::MobilityModel/CourseChange x = 10.3841, y = 0.923277
/NodeList/7/$ns3::MobilityModel/CourseChange x = 10.2049, y = 1.90708
/NodeList/7/$ns3::MobilityModel/CourseChange x = 10.8136, y = 1.11368
/NodeList/7/$ns3::MobilityModel/CourseChange x = 10.8452, y = 2.11318
/NodeList/7/$ns3::MobilityModel/CourseChange x = 10.9797, y = 3.10409
At time 2s client sent 1024 bytes to 10.1.2.4 port 9
At time 2.01796s server received 1024 bytes from 10.1.3.3 port 49153
At time 2.01796s server sent 1024 bytes to 10.1.3.3 port 49153
At time 2.03364s client received 1024 bytes from 10.1.2.4 port 9
/NodeList/7/$ns3::MobilityModel/CourseChange x = 11.3273, y = 4.04175
/NodeList/7/$ns3::MobilityModel/CourseChange x = 12.013, y = 4.76955
/NodeList/7/$ns3::MobilityModel/CourseChange x = 12.4317, y = 5.67771
/NodeList/7/$ns3::MobilityModel/CourseChange x = 11.4607, y = 5.91681
/NodeList/7/$ns3::MobilityModel/CourseChange x = 12.0155, y = 6.74878
/NodeList/7/$ns3::MobilityModel/CourseChange x = 13.0076, y = 6.62336
/NodeList/7/$ns3::MobilityModel/CourseChange x = 12.6285, y = 5.698
/NodeList/7/$ns3::MobilityModel/CourseChange x = 13.32, y = 4.97559
/NodeList/7/$ns3::MobilityModel/CourseChange x = 13.1134, y = 3.99715
/NodeList/7/$ns3::MobilityModel/CourseChange x = 13.8359, y = 4.68851
/NodeList/7/$ns3::MobilityModel/CourseChange x = 13.5953, y = 3.71789
/NodeList/7/$ns3::MobilityModel/CourseChange x = 12.7595, y = 4.26688
/NodeList/7/$ns3::MobilityModel/CourseChange x = 11.7629, y = 4.34913
/NodeList/7/$ns3::MobilityModel/CourseChange x = 11.2292, y = 5.19485
/NodeList/7/$ns3::MobilityModel/CourseChange x = 10.2344, y = 5.09394
/NodeList/7/$ns3::MobilityModel/CourseChange x = 9.3601, y = 4.60846
/NodeList/7/$ns3::MobilityModel/CourseChange x = 8.40025, y = 4.32795
/NodeList/7/$ns3::MobilityModel/CourseChange x = 9.14292, y = 4.99761
/NodeList/7/$ns3::MobilityModel/CourseChange x = 9.08299, y = 5.99581
/NodeList/7/$ns3::MobilityModel/CourseChange x = 8.26068, y = 5.42677
/NodeList/7/$ns3::MobilityModel/CourseChange x = 8.35917, y = 6.42191
/NodeList/7/$ns3::MobilityModel/CourseChange x = 7.66805, y = 7.14466
/NodeList/7/$ns3::MobilityModel/CourseChange x = 6.71414, y = 6.84456
/NodeList/7/$ns3::MobilityModel/CourseChange x = 6.42489, y = 7.80181

6.4 ns-3


ns‑3 , , , .
, ns‑3 IP . ns‑3, , , . — , ns‑3 « »; (RFC7567) - (QoS) . NetDevice. (, LTE, Wi-Fi) . , , ( , , , ). , . , . Wi-Fi Linux (https://lwn.net/Articles/705884/).


, NetDevice , , NetDevice. , . , , , NetDevices, Queue ( Queue):


  • -
  • Csma
  • Wi-Fi
  • SimpleNetDevice
    , NetDevices, . , ns‑3 ( , ) , (, FIFO (drop tail), ). , BQL (Byte Queue Limits), Linux , «». BQL NetDevices, . , ns‑3 , :
    . . . « ». , 80 ( C): 1–18, 2018 . DOI: 10.1016 / j.simpat.2017.09.008

    P. Imputato and S. Avallone. An analysis of the impact of network device buffers on packet schedulers through experiments and simulations. Simulation Modelling Practice and Theory, 80(Supplement C):1–18, January 2018. DOI: 10.1016/j.simpat.2017.09.008

6.4.1 ns-3


:


  • PFifoFastQueueDisc: — 1000 .
  • FifoQueueDisc: — 1000 .
  • RedQueueDisc: — 25 .
  • CoDelQueueDisc: 1500 .
  • FqCoDelQueueDisc: — 10024 .
  • PieQueueDisc: 25 .
  • MqQueueDisc: .
  • TbfQueueDisc: — 1000 .
    IPv4 IPv6-, NetDevice, , , NetDevice pfifo_fast.

:


  • PointToPointNetDevice. ( ) DropTail . (100 ).
  • CsmaNetDevice. ( ) DropTail (100 ).
  • WiFiNetDevice: — DropTail (100 ) non-QoS DropTail (100 ) QoS.
  • SimpleNetDevice: — DropTail c (100 ).
  • LTENetDevice: RLC ( RLC UM 10 * 1024 , RLC AM ).
  • UanNetDevice : Standardmäßig hat auf MAC-Ebene eine Warteschlange von 10 Paketen.

6.4.2 Ă„ndern der Standardeinstellungen


  • Der von NetDevice verwendete Warteschlangentyp kann normalerweise mit dem Geräteassistenten geändert werden:
    NodeContainer nodes;
    nodes.Create (2);
    PointToPointHelper p2p;
    p2p.SetQueue ("ns3::DropTailQueue", "MaxSize", StringValue ("50p"));
    NetDeviceContainer devices = p2p.Install (nodes);
  • Der Disziplin-Typ der auf NetDevice installierten Warteschlange kann mit dem Verkehrssteuerungsassistenten geändert werden:
    InternetStackHelper stack;
    stack.Install (nodes);
    TrafficControlHelper tch;
    tch.SetRootQueueDisc ("ns3::CoDelQueueDisc", "MaxSize", StringValue ("1000p"));
    tch.Install (devices);
  • Wenn BQL vom Gerät unterstĂĽtzt wird, kann es ĂĽber den Verkehrssteuerungsassistenten aktiviert werden:
    InternetStackHelper stack;
    stack.Install (nodes);
    TrafficControlHelper tch;
    tch.SetRootQueueDisc ("ns3::CoDelQueueDisc", "MaxSize", StringValue ("1000p"));
    tch.SetQueueLimits ("ns3::DynamicQueueLimits", "HoldTime", StringValue ("4ms"));
    tch.Install (devices);

All Articles