我在配置如下的基础结构拓扑中使用了NS3(v3.13)Wi-Fi模型(附加了仿真文件):


单AP(BSS)
多个STA(站)
申请时间= 10秒
从AP到所有STA的饱和下行链路流量(OnTime = 2s,OffTime = 0的OnOffApplication)
Phy:802.11a
默认的YansWifiChannelHelper和YansWifiPhyHelper
速率控制:ConstantRateWifiManager
移动性:ConstantPositionMobilityModel(STA位于AP周围2米半径的圆上)


尽管一切顺利,但是对于高比特率(饱和流量),当每个BSS的STA数量大量增加时,某些STA将不会收到任何BYTE!

实验:


OnOffApplication DataRate = 60Mb / s,Phy DataMode = OfdmRate54Mbps和30个STA,一个STA接收比特率为7.2Mb / s的数据包,另一个STA接收15.3Mb / s的比特率(其他28个STA不接收任何BYTE)
OnOffApplication DataRate = 60Mb / s,DataMode = OfdmRate6Mbps和30个STA,一个STA接收的比特率为1.95Mb / s,另一个为4.3Mb / s(其他28个STA均未接收到BYTE)


我认为问题出在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();
}

最佳答案

我认为媒体太忙了。

您需要调低onoff数据速率,例如1 mbps。实际上,全缓冲720p视频只需要不超过1mbps

您也可以使用pcap,ascii或netanim检查跟踪,也可以查看数据包丢失,数据包永不发送或代码中的错误

10-08 20:16