1
我正在努力獲得ns3的掛起並進行完整性檢查,但事實證明是錯誤的。以17.x秒的速度通過一個10MB/s的鏈路通過一個交換機在ns3上發送10MB
我想通過交換機以10MB/s的速率在TCP上發送10MB的數據,我預計它會花費1.x秒,但由於某些明顯的錯誤操作,它需要高達17.x秒。 我似乎無法找出谷歌搜索和檢查用戶ns-3組後發生了什麼問題。 如果有人能指出我如何有效地調試這個正確的方向,我會把它作爲一個答案。順便說一句,如果我設置延遲爲零,它的工作速度快了十倍,我無法理解,只需要1.7x秒。
這裏是足夠的代碼來重現問題:
#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();
}
在ns3中是否有任何CSMA的全雙工替代品? – JC1
兩年前我正在與它合作。有一件P2P事情。 – zehelvion