2014-03-24 18 views
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(); 
} 

回答

1

CSMA桥的实施是半双工的,这就是为什么性能是可怕的。

+1

在ns3中是否有任何CSMA的全双工替代品? – JC1

+0

两年前我正在与它合作。有一件P2P事情。 – zehelvion

相关问题