私は ns3 のこつをつかむために取り組んでおり、健全性チェックを行っていますが、それは間違っていることが判明しました。
スイッチを介して 10MB/s の速度で TCP で 10MB を送信したいのですが、1.x 秒かかると予想していますが、明らかにバグがあるため、なんと 17.x 秒かかっています。ユーザーのns-3グループをグーグルでチェックした後、何が問題なのかわからないようです。誰かがこれを効果的にデバッグする方法の正しい方向に私を向けることができれば、私はそれを答えとします。ところで、遅延をゼロに設定すると、約 10 倍高速に動作しますが、理解できず、1.7 秒しかかかりません。
動作を再現するのに十分なコードは次のとおりです。
#include <iostream>
#include <fstream>
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/applications-module.h"
#include "ns3/bridge-module.h"
#include "ns3/csma-module.h"
#include "ns3/internet-module.h"
using namespace ns3;
int
main (int argc, char *argv[])
{
uint32_t burstSize = 10000000;
uint32_t packetSize = 1000;
Config::SetDefault("ns3::TcpSocket::SegmentSize", UintegerValue (packetSize));
// Create the topology's nodes.
NodeContainer nodes;
nodes.Create (2);
NodeContainer csmaSwitch;
csmaSwitch.Create (1);
NetDeviceContainer nodeDevices;
NetDeviceContainer switchDevices;
// Setting up csma attributes
CsmaHelper csma;
// Setting up node's channels
csma.SetChannelAttribute ("DataRate", DataRateValue (DataRate ("10MB/s")));
csma.SetChannelAttribute ("Delay", StringValue ("10ms"));
for (int i = 0; i < 2; i++)
{
NetDeviceContainer link = csma.Install (NodeContainer (nodes.Get (i), csmaSwitch));
nodeDevices.Add (link.Get (0));
switchDevices.Add (link.Get (1));
}
// Create the bridge netdevice, which will do the packet switching
Ptr<Node> switchNode = csmaSwitch.Get (0);
BridgeHelper bridge;
bridge.Install (switchNode, switchDevices);
// Add internet protocol stack to nodes
Config::SetDefault ("ns3::TcpL4Protocol::SocketType", StringValue ("ns3::TcpReno"));
InternetStackHelper internet;
internet.Install (nodes);
internet.Install (csmaSwitch);
// Add IP addresses
Ipv4AddressHelper ipv4;
ipv4.SetBase ("10.1.1.0", "255.255.255.0");
Ipv4InterfaceContainer nodeInterfaces;
nodeInterfaces = ipv4.Assign (nodeDevices);
uint16_t port = 10100;
BulkSendHelper source ("ns3::TcpSocketFactory",
InetSocketAddress (nodeInterfaces.GetAddress (0), port));
source.SetAttribute ("MaxBytes", UintegerValue (burstSize));
source.SetAttribute ("SendSize", UintegerValue (packetSize));
ApplicationContainer sourceApps = source.Install (nodes.Get (1));
sourceApps.Start (Seconds (0.0));
sourceApps.Stop (Seconds (1000.0));
//
// Create a PacketSinkApplication and install it on node 0
//
PacketSinkHelper sink ("ns3::TcpSocketFactory",
InetSocketAddress (Ipv4Address::GetAny (), port));
ApplicationContainer sinkApps = sink.Install (nodes.Get (0));
sinkApps.Start (Seconds (0.0));
sinkApps.Stop (Seconds (1000.0));
csma.EnablePcapAll ("results/pcap/data", false);
Simulator::Run ();
Simulator::Destroy ();
}