Hi,
I have a small and simple simulation where i have multiple nodes connected with wifi and lte at the same time. In simulation node 1 sends data from udp client helper to node 0 udp server via LTE.
Now after half simulation time e.g. 5 seconds, i want to change the destination ip address in udp client app (node1) to wifi ip address of node 0 so that data transfer will occur through wifi.
I am trying to do this with schedule() function and setAttributes() function but new ip address does not takes any effect.With this I have output the current ip address, in udp client
whenever it sends a packet, with cout command. But the destination ip
addres in udp client always remains the same i.e. the one with which it
was configured initially.
Is there any way to modify such variables during runtime?
My basic applications configuration and changing of ip address is like following:
-----------------------------------------------------------------------------------------------------------------------------------
// changing ip address function
void reconfigureUdpClient(UdpClientHelper srcNode, Ptr<Node> dstNode, uint16_t dport)
{
Ptr<Ipv4> ipv4 = dstNode->GetObject<Ipv4>();
Ipv4Address ip = ipv4->GetAddress(1,0).GetLocal();
srcNode.SetAttribute("RemotePort", UintegerValue(dport));
srcNode.SetAttribute("RemoteAddress", AddressValue(ip));
}
// Simulation code
uint16_t dport =5001, dport1 = 6001;
UdpClientHelper dlClient ( ueIpIface.GetAddress(0), dport ); // udp source application
dlClient.SetAttributes ( "Interval", TimeValue( Milliseconds ( interPacketInterval ) ) );
dlClient.SetAttributes ( "MaxPackets", UIntegerValue ( 100000000 ) );
dlClient.SetAttributes ( "PacketSize" , UIntegerValue ( payloadSize ) );
dlClient.SetAttributes ( "StartTime", TimeValue( Milliseconds ( 1000 ) ) );
dlClient.SetAttributes ( "StopTime", TimeValue( Milliseconds ( 10000 ) ) );
clientApps.Add ( dlClient.Install ( ueNode.Get(1) ) );
UdpServerHelper dlPacketSinkHelper (dport);
serverApps.Add ( dlPacketSinkHelper.Install ( ueNode.Get(0) ) );
Simulator::Stop(Seconds(duration + 1));
Simulator::Schedule (Seconds (5), &reconfigureUdpClient, dlClient, ueNode.Get(0), dport1);
Simulator::Run ();
-----------------------------------------------------------------------------------------------------------------------------------
Regards,
Anas