如何查找可以为SetAttribute()函数设置的属性名称集合

问题描述 投票:0回答:1

我想知道

ns3::UdpEchoClientHelper::SetAttribute()
的哪些属性可以设置。 以下是函数定义和参数含义:

void ns3::UdpEchoClientHelper::SetAttribute (std::string name,const AttributeValue & value )
Parameters
    name    the name of the attribute to set
    value   the value of the attribute to set 

在ns-3的官方文档上找不到我想要的答案

ns-3
1个回答
0
投票

此调用可用于设置任何对象属性。由于您正在谈论 UdpEchoClient 帮助程序,因此它设置了 UdpEchoClient 的属性,您可以在 .cc 源代码中看到这些属性:

        TypeId("ns3::UdpEchoClient")
            .SetParent<Application>()
            .SetGroupName("Applications")
            .AddConstructor<UdpEchoClient>()
            .AddAttribute(
                "MaxPackets",
                "The maximum number of packets the application will send (zero means infinite)",
                UintegerValue(100),
                MakeUintegerAccessor(&UdpEchoClient::m_count),
                MakeUintegerChecker<uint32_t>())
            .AddAttribute("Interval",
                          "The time to wait between packets",
                          TimeValue(Seconds(1.0)),
                          MakeTimeAccessor(&UdpEchoClient::m_interval),
                          MakeTimeChecker())
            .AddAttribute("RemoteAddress",
                          "The destination Address of the outbound packets",
                          AddressValue(),
                          MakeAddressAccessor(&UdpEchoClient::m_peerAddress),
                          MakeAddressChecker())
            .AddAttribute("RemotePort",
                          "The destination port of the outbound packets",
                          UintegerValue(0),
                          MakeUintegerAccessor(&UdpEchoClient::m_peerPort),
                          MakeUintegerChecker<uint16_t>())
            .AddAttribute("Tos",
                          "The Type of Service used to send IPv4 packets. "
                          "All 8 bits of the TOS byte are set (including ECN bits).",
                          UintegerValue(0),
                          MakeUintegerAccessor(&UdpEchoClient::m_tos),
                          MakeUintegerChecker<uint8_t>())
            .AddAttribute(
                "PacketSize",
                "Size of echo data in outbound packets",
                UintegerValue(100),
                MakeUintegerAccessor(&UdpEchoClient::SetDataSize, &UdpEchoClient::GetDataSize),
                MakeUintegerChecker<uint32_t>())

文件链接:https://gitlab.com/nsnam/ns-3-dev/-/blob/master/src/applications/model/udp-echo-client.cc?ref_type=heads#L47-L79

如您所见,

.AddAttribute
调用定义了可以设置的可能属性,在本例中为:
Interval
RemoteAddress
RemotePort
ToS
PacketSize

您还可以查看它们的值类型(UintegerValue、TimeValue、AddressValue)。

所以你可以打电话

ns3::UdpEchoClientHelper::SetAttribute("MaxPackets", UintegerValue(1234));

这将配置由此帮助程序创建的 UdpEchoClient 应用程序,以在达到 1234 阈值后发送停止发送数据包。

© www.soinside.com 2019 - 2024. All rights reserved.