How to find the set of attribute names that can be set for the SetAttribute() function

19 Views Asked by At

I want to know which attributes of the ns3::UdpEchoClientHelper::SetAttribute()can be set. Here are the function definitions and parameter meanings:

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 

I couldn't find the answer I wanted on the official document of ns-3

1

There are 1 best solutions below

0
Gabriel On

This call can be used to set any of the object attributes. Since you're talking about the UdpEchoClient helper, it sets the attributes of UdpEchoClient, which you can see in the .cc source code:

        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>())

Link for the file: https://gitlab.com/nsnam/ns-3-dev/-/blob/master/src/applications/model/udp-echo-client.cc?ref_type=heads#L47-L79

As you can see, the .AddAttribute calls are defining the possible attributes that can be set, which in this case are: Interval, RemoteAddress, RemotePort, ToS and PacketSize.

You can also see their value types (UintegerValue, TimeValue, AddressValue).

So you can call

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

This will configure UdpEchoClient applications created by this helper to send stop sending packets after the 1234 threshold is reached.