ns-3中UDP饱和流发包时间间隔设置最合理值

发布于:2025-04-16 ⋅ 阅读:(14) ⋅ 点赞:(0)

  ns3的官方手册很全,相关书籍也是有的,官网先贴在这里:

ns-3 | a discrete-event network simulator for internet systemsa discrete-event network simulator for internet systemshttps://www.nsnam.org/相关的脚本介绍也都有一些:

ns-3.35_wifi-he-network.cc_ns-3网络仿真工具wifi脚本解析_wifi脚本网络拓扑_ns-3wifi6吞吐脚本关键注释_吞吐部分_基础ns-3_ns3.35-CSDN博客

ns-3-model-library wifi 浅析_ns-3wifi部分解析_ns-3网络模拟器wifi部分文档分析_Part1_ns3 wifiphy物理层冲突-CSDN博客

ns-3-model-library wifi 浅析_ns-3wifi部分解析_ns-3网络模拟器wifi部分文档分析_Part2_yansphy-CSDN博客

在进行wifi饱和流测试的时候我们需要指定UDP 包间隔,如下interval 

        const auto maxLoad = nLinks *
                                     EhtPhy::GetDataRate(mcs,
                                                         MHz_u{static_cast<double>(width)},
                                                         NanoSeconds(gi),
                                                         1) /
                                     nStations;

                std::cout << " nLinks= " << nLinks << " nStations=" << nStations << " maxLoad=" << maxLoad << " bps" <<std::endl;
                if (udp)
                {
                    // UDP flow
                    uint16_t port = 9;
                    UdpServerHelper server(port);
                    serverApp = server.Install(serverNodes.get());
                    streamNumber += server.AssignStreams(serverNodes.get(), streamNumber);

                    serverApp.Start(Seconds(0));
                    serverApp.Stop(simulationTime + Seconds(1));
                    const auto packetInterval = payloadSize * 8.0 / maxLoad;

                    for (std::size_t i = 0; i < nStations; i++)
                    {
                        UdpClientHelper client(serverInterfaces.GetAddress(i), port);
                        client.SetAttribute("MaxPackets", UintegerValue(4294967295U));
                        client.SetAttribute("Interval", TimeValue(Seconds(packetInterval)));
                        client.SetAttribute("PacketSize", UintegerValue(payloadSize));
                        ApplicationContainer clientApp = client.Install(clientNodes.Get(i));
                        streamNumber += client.AssignStreams(clientNodes.Get(i), streamNumber);

                        clientApp.Start(Seconds(1));
                        clientApp.Stop(simulationTime + Seconds(1));
                    }
                }

那么最合理的包间隔就是刚好满足上限,这样仿真更快还保证饱和,上面代码就是很好的例子,运行打印如下:

nLinks= 1 nStations=1 maxLoad=8602942 bps

根据mcs0 单流 gi 800ns,20M 带宽,我们可以作如下计算:

理论协商最大速率 = (1 * 1/2 * 1 * 234)/ (12.8 + 0.8) = 8.60294117

BPSK 1符号1bit

码率1/2

单流

子载波234个

数据时间12.8us

guard interval 0.8us

计算与函数输出一致

包长乘8就是就是一包bit数,除以最大速率就是一包用多少秒,也就是interval。


网站公告

今日签到

点亮在社区的每一天
去签到