Network programming 饱和流量下的接收吞吐量问题
我在基础设施拓扑中使用NS3(v3.13)Wi-Fi模型,配置如下(随附模拟文件):Network programming 饱和流量下的接收吞吐量问题,network-programming,ns-3,Network Programming,Ns 3,我在基础设施拓扑中使用NS3(v3.13)Wi-Fi模型,配置如下(随附模拟文件): 单一AP(BSS) 多个STA(站) 应用持续时间=10秒 从AP到所有STA的饱和下行链路流量(OnOffApplication,OnTime=2s,OffTime=0) 物理层:802.11a 默认YanSwificChannelHelper和YansWifiPhyHelper 费率控制:ConstantRateWifiManager 机动性:ConstantPositionMobilityModel(S
- 单一AP(BSS)
- 多个STA(站)
- 应用持续时间=10秒
- 从AP到所有STA的饱和下行链路流量(OnOffApplication,OnTime=2s,OffTime=0)
- 物理层:802.11a
- 默认YanSwificChannelHelper和YansWifiPhyHelper
- 费率控制:ConstantRateWifiManager
- 机动性:ConstantPositionMobilityModel(STA位于AP周围半径为2米的圆圈上)
- OnOffApplication DataRate=60Mb/s,Phy DataMode=OfdmRate54Mbps和30个STA,一个STA接收比特率为7.2Mb/s的数据包,另一个STA接收比特率为15.3Mb/s的数据包(所有其他28个STA不接收任何字节)
- OnOffApplication DataRate=60Mb/s,DataMode=OfdmRate6Mbps和30个STA,一个STA接收比特率为1.95Mb/s的数据包,另一个STA接收比特率为4.3Mb/s的数据包(所有其他28个STA不接收任何字节)
#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();
}
#包括“ns3/core module.h”
#包括“ns3/点对点模块.h”
#包括“ns3/网络模块.h”
#包括“ns3/applications module.h”
#包括“ns3/wifi模块.h”
#包括“ns3/mobility module.h”
#包括“ns3/csma模块.h”
#包括“ns3/internet模块.h”
#包括“ns3/flow monitor helper.h”
#包括“ns3/flow monitor module.h”
#包括“ns3/applications module.h”
#包括“ns3/internet模块.h”
#包括“ns3/gnuplot.h”
#包括“ns3/constant velocity helper.h”
#包括“ns3/integer.h”
#包括“ns3/mpi接口.h”
#包括“math.h”
#包括
/**
*参数
*/
#定义StaNb 30
#定义距离2
#定义持续时间10
#定义数据速率90000000
#定义PacketSize 1500
#定义couleur(param)printf(“\033[%sm”,param)
使用名称空间ns3;
课堂实验{
公众:
实验();
void CreateArchi(void);
void CreateApplis();
私人:
Ptr定位图;
Ptr-locsta;
Ptr位置控制器;
葡萄球菌;
std::向量常数;
NodeContainer m_wifiAP,m_wifiQSta;
NetDeviceContainer MAPU设备;
NetDeviceContainer m_QStaDevice;
Yanswific水道和Mu水道;
Ptr通道;
Yanswifiphylayer m_phyLayer_Sta,m_phyLayer_AP;
wifimu wifi;
QosWifiMacHelper m_macSta,m_macAP;
InternetStackHelper m_stack;
IPV4接口容器MU接口;
IPV4接口容器Mu接口;
Ssid m_Ssid;
};
实验::实验(){
PositionLocStaculoir=CreateObject();
positionAllocAp=CreateObject();
positionalocsta=CreateObject();
positionalLocalStatamphi=CreateObject();
m_wifi=WifiHelper::Default();
常量。调整大小(StaNb+1);
对于(int i=0;i添加(矢量3D(0.0,0.0,0.0));
流动性帮助流动性;
mobilityAp.SetPositionLocator(位置定位器);
mobilityAp.SetMobilityModel(“ns3::ConstantPositionMobilityModel”);
mobilityAp.Install(m_wifiAP.Get(0));
常数[0]->设置位置(矢量3D(0.0,0.0,0.0));
浮动三角洲角=2*M_PI/StaNb;
浮动角度=0.0;
双x=0.0;
双y=0.0;
对于(int i=0;i添加(矢量3D(x,y,0.0));
移动帮助移动系统;
移动系统设置位置定位器(位置定位器);
MobilitySystem.SetMobilityModel(“ns3::ConstantPositionMobilityModel”);
mobilitySta.Install(m_wifiQSta.Get(i));
常数[i]->设定位置(向量3D(x,y,0.0));
角度+=三角洲角度;
}
m_macSta=QosWifiMacHelper::Default();
m_macSta.SetType(“ns3::Statwifimac”、“ActiveProbling”、布尔值(true),
“Ssid”,Ssid值(m_Ssid));
m_macAP=QosWifiMacHelper::Default();
m_macAP.SetType(“ns3::ApWifiMac”、“Ssid”、SsidValue(m_Ssid),
“信标区间”,时间值(时间(标准:字符串(“100ms”));
m_-APDevice.Add(m_-wifi.Install(m_-phyLayer_-AP、m_-macAP、m_-wifiAP));
对于(int i=0;i