質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
コンパイル

コンパイルとは、プログラミング言語のテキストソース(ソースコード)をコンピュータ上で実行可能な形式(オブジェクトコード)に変換することをいいます

コンパイルエラー

コンパイルのフェーズで生成されるエラーです。よく無効なシンタックスやタイプが含まれているとき発生します。

C++

C++はC言語をもとにしてつくられた最もよく使われるマルチパラダイムプログラミング言語の1つです。オブジェクト指向、ジェネリック、命令型など広く対応しており、多目的に使用されています。

ネットワーク

ネットワークとは、複数のコンピューター間を接続する技術です。インターネットが最も主流なネットワークの形態で、TCP/IP・HTTP・DNSなどの様々なプロトコルや、ルータやサーバーなどの様々な機器の上に成り立っています。

Network Simulator

The Network Simulator

Q&A

解決済

1回答

2119閲覧

ns3で1つのWi-Fi (AP)に複数の端末 (station) を接続してスループットを測定したい

zlatan

総合スコア12

コンパイル

コンパイルとは、プログラミング言語のテキストソース(ソースコード)をコンピュータ上で実行可能な形式(オブジェクトコード)に変換することをいいます

コンパイルエラー

コンパイルのフェーズで生成されるエラーです。よく無効なシンタックスやタイプが含まれているとき発生します。

C++

C++はC言語をもとにしてつくられた最もよく使われるマルチパラダイムプログラミング言語の1つです。オブジェクト指向、ジェネリック、命令型など広く対応しており、多目的に使用されています。

ネットワーク

ネットワークとは、複数のコンピューター間を接続する技術です。インターネットが最も主流なネットワークの形態で、TCP/IP・HTTP・DNSなどの様々なプロトコルや、ルータやサーバーなどの様々な機器の上に成り立っています。

Network Simulator

The Network Simulator

0グッド

0クリップ

投稿2020/06/28 04:16

編集2020/06/29 09:29

概要

 ns3を用いて、Wi-Fiのスループットを測定したいのですがコンパイルをするとエラーが起きてしまいます。どのように修正すればいいのかを教えていただきたいです。 __UdpClientHelper__のところでエラーが起きてるのかなというのは予想しているのですが、なぜエラー原因と解決策がわからないです。

## エラー文

<nr>hogehoge:ns-3-dev$ ./waf --run 'scratch/teratail' Waf: Entering directory `/Users/hogehoge/Desktop/ns-allinone-3.30.1/ns-3-dev/build' [2800/2849] Compiling scratch/teratail.cc [2809/2849] Linking build/scratch/teratail Waf: Leaving directory `/Users/hogehoge/Desktop/ns-allinone-3.30.1/ns-3-dev/build' Build commands will be stored in build/compile_commands.json 'build' finished successfully (3.256s) assert failed. cond="duration.IsPositive ()", msg="Please provide test case to maintainers if this assert is hit.", file=../src/wifi/model/mac-low.cc, line=2146 libc++abi.dylib: terminating Command ['/Users/hogehoge/Desktop/ns-allinone-3.30.1/ns-3-dev/build/scratch/teratail'] terminated with signal SIGIOT. Run it under a debugger to get more information (./waf --run <program> --command-template="gdb --args %s <args>").

## ネットワークトポロジー図
イメージ説明

プログラム説明

 50m×50mのエリアに10個の端末をランダムで配置し、中央にAPを設置する。APはRemoteHostと接続されており、端末はRemoteHostと通信を行う。その際のスループットを表示する。

プログラムコード

C++

1#include "ns3/core-module.h" 2#include "ns3/point-to-point-module.h" 3#include "ns3/command-line.h" 4#include "ns3/config.h" 5#include "ns3/uinteger.h" 6#include "ns3/boolean.h" 7#include "ns3/double.h" 8#include "ns3/string.h" 9#include "ns3/yans-wifi-helper.h" 10#include "ns3/ssid.h" 11#include "ns3/mobility-helper.h" 12#include "ns3/mobility-module.h" 13#include "ns3/internet-stack-helper.h" 14#include "ns3/ipv4-address-helper.h" 15#include "ns3/udp-client-server-helper.h" 16#include "ns3/packet-sink-helper.h" 17#include "ns3/on-off-helper.h" 18#include "ns3/ipv4-global-routing-helper.h" 19#include "ns3/packet-sink.h" 20#include "ns3/yans-wifi-channel.h" 21#include <array> 22 23using namespace ns3; 24 25int main (int argc, char *argv[]) 26{ 27 uint32_t nStaNodes = 10; 28 double simulationTime = 5; 29 30 CommandLine cmd; 31 cmd.AddValue ("nStaNodes", "Number of \"extra\" Station nodes/devices", nStaNodes); 32 cmd.AddValue ("simulationTime", "Simulation time per step (in seconds)", simulationTime); 33 34 cmd.Parse (argc,argv); 35 36 std::string phyRate = "HtMcs15"; /* Physical layer bitrate. */ 37 38 uint32_t payloadSize = 1472; //bytes 39 40 NodeContainer p2pNodes; 41 p2pNodes.Create (2); 42 43 NodeContainer remoteNode; 44 remoteNode.Add (p2pNodes.Get (1)); 45 46 PointToPointHelper pointToPoint; 47 pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("130Mbps")); 48 pointToPoint.SetChannelAttribute ("Delay", StringValue ("1ms")); 49 50 NetDeviceContainer p2pDevices; 51 p2pDevices = pointToPoint.Install (p2pNodes); 52 53 NodeContainer wifiStaNodes; 54 wifiStaNodes.Create (nStaNodes); 55 NodeContainer wifiApNode = p2pNodes.Get (0); 56 57 YansWifiChannelHelper channel = YansWifiChannelHelper::Default (); 58 YansWifiPhyHelper phy = YansWifiPhyHelper::Default (); 59 phy.SetChannel (channel.Create ()); 60 61 WifiHelper wifi; 62 wifi.SetStandard (WIFI_PHY_STANDARD_80211n_2_4GHZ); 63 Config::SetDefault ("ns3::LogDistancePropagationLossModel::ReferenceLoss", DoubleValue (40.046)); 64 65 StringValue ctrlRate; 66 ctrlRate = StringValue ("ErpOfdmRate24Mbps"); 67 68 wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", 69 "DataMode", StringValue (phyRate), 70 "ControlMode", ctrlRate); 71 72 WifiMacHelper mac; 73 Ssid ssid = Ssid ("ns3-80211n"); 74 mac.SetType ("ns3::StaWifiMac", 75 "Ssid", SsidValue (ssid)); 76 NetDeviceContainer staDevices; 77 staDevices = wifi.Install (phy, mac, wifiStaNodes); 78 mac.SetType ("ns3::ApWifiMac", 79 "Ssid", SsidValue (ssid)); 80 NetDeviceContainer apDevice; 81 apDevice = wifi.Install (phy, mac, wifiApNode); 82 83 // mobility. 84 MobilityHelper mobility; 85 Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> (); 86 positionAlloc->Add (Vector (25.0, 25.0, 0.0)); 87 double xPositionArray[nStaNodes]; 88 double yPositionArray[nStaNodes]; 89 for (uint32_t nodeCount = 0; nodeCount < nStaNodes; nodeCount++) //distance 90 { 91 xPositionArray[nodeCount] = rand() % 50; 92 yPositionArray[nodeCount] = rand() % 50; 93 positionAlloc->Add (Vector (xPositionArray[nodeCount], yPositionArray[nodeCount], 0.0)); 94 } 95 96 mobility.SetPositionAllocator (positionAlloc); 97 mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); 98 mobility.Install (wifiApNode); 99 mobility.Install (wifiStaNodes); 100 101 /* Internet stack*/ 102 InternetStackHelper stack; 103 stack.Install (remoteNode); 104 stack.Install (wifiApNode); 105 stack.Install (wifiStaNodes); 106 107 Ipv4AddressHelper address; 108 109 address.SetBase ("10.1.1.0", "255.255.255.0"); 110 Ipv4InterfaceContainer p2pInterfaces; 111 p2pInterfaces = address.Assign (p2pDevices); 112 113 address.SetBase ("10.1.2.0", "255.255.255.0"); 114 Ipv4InterfaceContainer staNodesInterface; 115 Ipv4InterfaceContainer apNodeInterface; 116 staNodesInterface = address.Assign (staDevices); 117 apNodeInterface = address.Assign (apDevice); 118 119 ApplicationContainer serverApp; 120 //UDP flow 121 uint16_t port = 9; 122 UdpServerHelper server (port); 123 serverApp = server.Install (wifiStaNodes); 124 serverApp.Start (Seconds (0.0)); 125 serverApp.Stop (Seconds (simulationTime + 1)); 126 127 ApplicationContainer clientApp; 128 129 for (int i = 0; i < nStaNodes; i++) { 130 UdpClientHelper client (staNodesInterface.GetAddress (i), port); 131 client.SetAttribute ("MaxPackets", UintegerValue (4294967295u)); 132 client.SetAttribute ("Interval", TimeValue (Time ("0.00001"))); //packets/s 133 client.SetAttribute ("PacketSize", UintegerValue (payloadSize)); 134 135 if (i == 0) { 136 clientApp = client.Install (wifiApNode.Get (0)); 137 } 138 else { 139 clientApp.Add(client.Install (wifiApNode.Get (0))); 140 } 141 } 142 143 clientApp.Start (Seconds (1.0)); 144 clientApp.Stop (Seconds (simulationTime + 1)); 145 146 Ipv4GlobalRoutingHelper::PopulateRoutingTables (); 147 Simulator::Stop (Seconds (simulationTime + 1)); 148 149 Simulator::Run (); 150 double throughput = 0; 151 //UDP 152 uint64_t totalPacketsThrough = DynamicCast<UdpServer> (serverApp.Get (0))->GetReceived (); 153 throughput = totalPacketsThrough * payloadSize * 8 / (simulationTime * 1000000.0); //Mbit/s 154 std::cout << throughput << " Mbit/s" << std::endl; 155 Simulator::Destroy (); 156 157 return 0; 158}

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

自己解決

根本的な解決ではないのですが、11nのビットレートなどを定義するMCSの部分でHtMcs15を指定していたのですが、それが原因でした。
NS3の内部的なエラーでHtMcs815では上記のエラーが出ているようです。HtMcs07の間では正常に動くことができました。

投稿2020/07/07 06:06

zlatan

総合スコア12

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問