Accessing UDP client attributes (remote port and address)

81 views
Skip to first unread message

anas

unread,
Aug 5, 2019, 10:48:58 AM8/5/19
to ns-3-users
Hello all,

I am having problem with reading values of UDP client attributes. I have a UdpClientHelper acting as source and a UdpServerHelper as sink. Source sends packets to server when simulation start. After some time i need to change the destination address.
I am using SetAttribute() function to set new destination address and port but i cant seem to somehow read the current destination address and port values in source application. There are no GetAttiribute() function in UdpClientHelper or in UdpClient. Part of my code is like this

uint16_t originalPort = xyz;
uint16_t dPort = xxxx;
UdpClientHelper srcApp (ueIpIface.GetAddress(0), originalPort);   //create source application

//After specific simulation time, a function is called which have following code
Ptr<Ipv4> ipv4 = destNode -> GetObject<Ipv4>();      // get ipv4 module of new destination node
Ipv4Address ip = ipv4->GetAddress(1,0).GetLocal();   // get ip address of new destination node

srcApp.SetAttributes("RemotePort", UintegerValue(dport));    // set new ip address in source app
srcApp.SetAttributes("RemoteAddress", AddressValue(ip));   // set new port number in source app

Here, I want to read the new destination port and address values to ensure that they are correct but i cannot find any function in UdpClientHelper or in UdpClient to do that. In Configuration and Attributes section, GetAttribute() function is mentioned in an example of Queue class. But said function do not exists for UdpClientHelper or Udp Client.

So Is there any method to read these destination values from UDP Client?

** Simulation file is attached if it helps. Function is defined on line # 57 and is called on line # 298. **

Thanks and regards,
Anas

lte+wifi.cc
Reply all
Reply to author
Forward
0 new messages