2013-03-28 50 views
3

我使用NS3(v3.13)的Wi-Fi模式接收的吞吐量問題,配置如下(附模擬文件):在基礎設施拓撲飽和交通

  • 單AP(BSS)
  • 多個STA (站)
  • 應用持續時間= 10秒
  • 飽和的下行鏈路業務(OnOffApplication與ONTIME = 2S和OFFTIME = 0)從AP到所有STA
  • 物理層:802 .11a
  • 默認YansWifiChannelHelper和YansWifiPhyHelper
  • 速率控制:ConstantRateWifiManager
  • 移動性:ConstantPositionMobilityModel(STA被定位在2個百米方圓周圍的AP圓)

雖然一切都進展順利,爲高比特率(飽和流量),當每個BSS的STA數量增加很多時,一些STA不會收到任何BYTE!

實驗:

  • OnOffApplication DATARATE = 60MB/s的,物理層器件DataMode = OfdmRate Mbps和30個STA時,一個STA接收具有7.2MB/s的比特率和另一個與15.3MB包/ s的(所有其它的STA 28沒有收到任何BYTE)
  • OnOffApplication DATARATE = 60MB/s的,DataMode = OfdmRate Mbps和30個STA時,一個STA接收具有的1.95MB /秒的比特率的數據包和另一個是4.3Mb/s(所有其他2 8 STA沒有收到任何字節)

我認爲問題來自OnOff應用程序配置;我應該如何配置它來模擬完整的緩衝區下行流量?

在此先感謝您的任何建議。

#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" 
#include "ns3/flow-monitor-helper.h" 
#include "ns3/flow-monitor-module.h" 
#include "ns3/applications-module.h" 
#include "ns3/internet-module.h" 
#include "ns3/gnuplot.h" 
#include "ns3/constant-velocity-helper.h" 
#include "ns3/integer.h" 
#include "ns3/mpi-interface.h" 
#include "math.h" 
#include <iostream> 

/** 
* PARAMETERS 
*/ 
#define StaNb  30 
#define Distance 2 
#define Duration 10 
#define DataRate 90000000 
#define PacketSize 1500 

#define couleur(param) printf("\033[%sm",param) 

using namespace ns3; 

class Experiment { 
public: 
    Experiment(); 
    void CreateArchi(void); 
    void CreateApplis(); 

private: 

    Ptr<ListPositionAllocator> positionAllocAp; 
    Ptr<ListPositionAllocator> positionAllocSta; 
    Ptr<GridPositionAllocator> positionAllocStaCouloir; 
    Ptr<RandomDiscPositionAllocator> positionAllocStaAmphi; 

    std::vector<Ptr<ConstantPositionMobilityModel> > constant; 

    NodeContainer m_wifiAP, m_wifiQSta; 

    NetDeviceContainer m_APDevice; 

    NetDeviceContainer m_QStaDevice; 

    YansWifiChannelHelper m_channel; 
    Ptr<YansWifiChannel> channel; 

    YansWifiPhyHelper m_phyLayer_Sta, m_phyLayer_AP; 
    WifiHelper m_wifi; 

    QosWifiMacHelper m_macSta, m_macAP; 

    InternetStackHelper m_stack; 
    Ipv4InterfaceContainer m_StaInterface; 
    Ipv4InterfaceContainer m_ApInterface; 

    Ssid m_ssid; 
}; 

Experiment::Experiment() { 

    positionAllocStaCouloir = CreateObject<GridPositionAllocator>(); 
    positionAllocAp = CreateObject<ListPositionAllocator>(); 
    positionAllocSta = CreateObject<ListPositionAllocator>(); 
    positionAllocStaAmphi = CreateObject<RandomDiscPositionAllocator>(); 

    m_wifi = WifiHelper::Default(); 

    constant.resize(StaNb + 1); 
    for (int i = 0; i < StaNb + 1; i++) { 
     constant[i] = CreateObject<ConstantPositionMobilityModel>(); 
    } 
} 

void Experiment::CreateArchi(void) { 

    m_wifiQSta.Create(StaNb); 

    m_wifiAP.Create(1); 

    m_ssid = Ssid("BSS_circle"); 

    m_channel = YansWifiChannelHelper::Default(); 

    channel = m_channel.Create(); 

    m_wifi.SetStandard(WIFI_PHY_STANDARD_80211a); 
    m_wifi.SetRemoteStationManager("ns3::ConstantRateWifiManager", "DataMode", 
      StringValue("OfdmRate6Mbps")); 

    m_phyLayer_Sta = YansWifiPhyHelper::Default(); 
    m_phyLayer_AP = YansWifiPhyHelper::Default(); 

    m_phyLayer_Sta.SetChannel(channel); 
    m_phyLayer_AP.SetChannel(channel); 

    positionAllocAp->Add(Vector3D(0.0, 0.0, 0.0)); 

    MobilityHelper mobilityAp; 
    mobilityAp.SetPositionAllocator(positionAllocAp); 
    mobilityAp.SetMobilityModel("ns3::ConstantPositionMobilityModel"); 
    mobilityAp.Install(m_wifiAP.Get(0)); 

    constant[0]->SetPosition(Vector3D(0.0, 0.0, 0.0)); 

    float deltaAngle = 2 * M_PI/StaNb; 
    float angle = 0.0; 
    double x = 0.0; 
    double y = 0.0; 

    for (int i = 0; i < StaNb; i++) { 
     x = cos(angle) * Distance; 
     y = sin(angle) * Distance; 

     positionAllocSta->Add(Vector3D(x, y, 0.0)); 

     MobilityHelper mobilitySta; 
     mobilitySta.SetPositionAllocator(positionAllocSta); 
     mobilitySta.SetMobilityModel("ns3::ConstantPositionMobilityModel"); 
     mobilitySta.Install(m_wifiQSta.Get(i)); 

     constant[i]->SetPosition(Vector3D(x, y, 0.0)); 

     angle += deltaAngle; 
    } 

    m_macSta = QosWifiMacHelper::Default(); 

    m_macSta.SetType("ns3::StaWifiMac", "ActiveProbing", BooleanValue(true), 
      "Ssid", SsidValue(m_ssid)); 

    m_macAP = QosWifiMacHelper::Default(); 

    m_macAP.SetType("ns3::ApWifiMac", "Ssid", SsidValue(m_ssid), 
      "BeaconInterval", TimeValue(Time(std::string("100ms")))); 

    m_APDevice.Add(m_wifi.Install(m_phyLayer_AP, m_macAP, m_wifiAP)); 

    for (int i = 0; i < StaNb; i++) { 
     m_QStaDevice.Add(
       m_wifi.Install(m_phyLayer_Sta, m_macSta, m_wifiQSta.Get(i))); 
    } 

    m_stack.Install(m_wifiAP); 
    m_stack.Install(m_wifiQSta); 

    Ipv4AddressHelper address; 
    address.SetBase("192.168.1.0", "255.255.255.0"); 

    m_ApInterface.Add(address.Assign(m_APDevice.Get(0))); 

    for (int i = 0; i < StaNb; i++) { 
     m_StaInterface.Add(address.Assign(m_QStaDevice.Get(i))); 
    } 

    Ipv4GlobalRoutingHelper::PopulateRoutingTables(); 
} 

void Experiment::CreateApplis() { 

    ApplicationContainer source; 

    OnOffHelper onoff("ns3::UdpSocketFactory", Address()); 
    onoff.SetAttribute("OnTime", RandomVariableValue(ConstantVariable(2))); 
    onoff.SetAttribute("OffTime", RandomVariableValue(ConstantVariable(0))); 
    onoff.SetAttribute("DataRate", StringValue("500kb/s")); 

    for (int i = 0; i < StaNb; i++) { 
     AddressValue remoteAddress(
       InetSocketAddress(m_StaInterface.GetAddress(i), 5010)); 
     onoff.SetAttribute("Remote", remoteAddress); 
     source.Add(onoff.Install(m_wifiAP.Get(0))); 
     source.Start(Seconds(3.0)); 
     source.Stop(Seconds(Duration)); 
    } 

    ApplicationContainer sinks; 
    PacketSinkHelper packetSinkHelper("ns3::UdpSocketFactory", 
      Address(InetSocketAddress(Ipv4Address::GetAny(), 5010))); 

    for (int i = 0; i < StaNb; i++) { 

     sinks.Add(packetSinkHelper.Install(m_wifiQSta.Get(i))); 
     sinks.Start(Seconds(3.0)); 
     sinks.Stop(Seconds(Duration)); 
    } 

} 

int main(int argc, char *argv[]) { 

    Experiment exp = Experiment(); 

    Config::SetDefault("ns3::WifiRemoteStationManager::RtsCtsThreshold", 
      StringValue("2346")); 

    exp.CreateArchi(); 

    exp.CreateApplis(); 

    FlowMonitorHelper flowmon; 
    Ptr<FlowMonitor> monitor = flowmon.InstallAll(); 

    Simulator::Stop(Seconds(Duration)); 

    Simulator::Run(); 

    monitor->CheckForLostPackets(); 
    Ptr<Ipv4FlowClassifier> classifier = DynamicCast<Ipv4FlowClassifier>(
      flowmon.GetClassifier()); 
    std::map<FlowId, FlowMonitor::FlowStats> stats = monitor->GetFlowStats(); 
    int c = 0; 
    for (std::map<FlowId, FlowMonitor::FlowStats>::const_iterator i = 
      stats.begin(); i != stats.end(); ++i) { 
     Ipv4FlowClassifier::FiveTuple t = classifier->FindFlow(i->first); 
     std::cout << "Flux " << i->first << " (" << t.sourceAddress << " -> " 
       << t.destinationAddress << ")\n"; 
     std::cout << " Tx Bytes : " << i->second.txBytes << "\n"; 
     std::cout << " Rx Bytes : " << i->second.rxBytes << "\n"; 

     couleur("33"); 
     std::cout << " Bitrate : " 
       << i->second.rxBytes * 8.0 
         /(i->second.timeLastRxPacket.GetSeconds() 
           - i->second.timeFirstRxPacket.GetSeconds()) 
         /1000000 << " Mbps\n\n"; 
     couleur("0"); 

     if (i->second.rxBytes > 0) 
      c++; 
    } 

    std::cout << " Number of receiving nodes : " << c << "\n"; 

    Simulator::Destroy(); 
} 

回答

1

我覺得媒體太忙了。

您需要調整開啓數據速率,例如1 mbps。實際上,全緩衝720p視頻只需要沒有達到1Mbps以上

您也可以勾選使用PCAP,ASCII或netanim跟蹤太看到的要麼是丟包,包永不在你的代碼發送或錯誤