workaround for impossible multiple udp client on same node

This commit is contained in:
Tim Schubert 2020-06-21 18:40:31 +02:00
parent d898890fa6
commit 76c314130e
3 changed files with 22 additions and 14 deletions

View file

@ -24,7 +24,7 @@ main (int argc, char *argv[])
LogComponentEnable ("UdpClient", LOG_LEVEL_INFO); LogComponentEnable ("UdpClient", LOG_LEVEL_INFO);
NodeContainer nodes; NodeContainer nodes;
nodes.Create (300); nodes.Create (3);
IslHelper isl; IslHelper isl;
isl.SetDeviceAttribute ("DataRate", StringValue ("5Gbps")); isl.SetDeviceAttribute ("DataRate", StringValue ("5Gbps"));
@ -43,24 +43,28 @@ main (int argc, char *argv[])
Ipv6InterfaceContainer interfaces = address.Assign (devices); Ipv6InterfaceContainer interfaces = address.Assign (devices);
UdpEchoServerHelper echoServer (9); UdpEchoServerHelper echoServer (9);
ApplicationContainer serverApps = echoServer.Install (nodes);
ApplicationContainer clientApps;
UdpEchoClientHelper echoClient (devices.Get (0)->GetAddress (), 9);
echoClient.SetAttribute ("MaxPackets", UintegerValue (10));
echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.0)));
echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
for (uint32_t i = 1; i < nodes.GetN (); i++) for (uint32_t i = 1; i < nodes.GetN (); i++)
{ {
ApplicationContainer serverApps = echoServer.Install (nodes.Get (i));
serverApps.Start (Seconds (1.0));
serverApps.Stop (Seconds (10.0));
Address destAddress = interfaces.GetAddress (i, 0); Address destAddress = interfaces.GetAddress (i, 0);
UdpEchoClientHelper echoClient (destAddress, 9); echoClient.SetAttribute ("RemoteAddress", AddressValue (destAddress));
echoClient.SetAttribute ("MaxPackets", UintegerValue (10));
echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.0)));
echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
ApplicationContainer clientApps = echoClient.Install (nodes.Get (0)); clientApps.Add (echoClient.Install (nodes.Get (i-1)));
clientApps.Start (Seconds (2.0));
clientApps.Stop (Seconds (10.0));
} }
clientApps.Start (Seconds (2.0));
clientApps.Stop (Seconds (10.0));
serverApps.Start (Seconds (1.0));
serverApps.Stop (Seconds (10.0));
Simulator::Run (); Simulator::Run ();
Simulator::Destroy (); Simulator::Destroy ();

View file

@ -118,6 +118,7 @@ bool MockChannel::Deliver (
Ptr<MockNetDevice> dst, Ptr<MockNetDevice> dst,
Time txTime) Time txTime)
{ {
NS_LOG_FUNCTION (this << p << src->GetAddress () << dst->GetAddress () << txTime);
Time delay = GetDelay (src, dst, txTime); Time delay = GetDelay (src, dst, txTime);
/* Check if there is LOS between the source and destination */ /* Check if there is LOS between the source and destination */
@ -149,7 +150,7 @@ MockChannel::TransmitStart (
Address destAddr, Address destAddr,
Time txTime) Time txTime)
{ {
NS_LOG_FUNCTION (destAddr << this << p << srcId); NS_LOG_FUNCTION (this << p << srcId << destAddr << txTime);
NS_LOG_LOGIC ("UID is " << p->GetUid () << ")"); NS_LOG_LOGIC ("UID is " << p->GetUid () << ")");
Ptr<MockNetDevice> src = m_link[srcId]; Ptr<MockNetDevice> src = m_link[srcId];

View file

@ -370,7 +370,10 @@ MockNetDevice::SetReceiveErrorModel (Ptr<ErrorModel> em)
void void
MockNetDevice::Receive (Ptr<Packet> packet, Ptr<MockNetDevice> senderDevice) MockNetDevice::Receive (Ptr<Packet> packet, Ptr<MockNetDevice> senderDevice)
{ {
NS_LOG_FUNCTION (this << packet); NS_LOG_FUNCTION (this << packet << senderDevice);
NS_LOG_DEBUG (GetAddress () << " receiving packet from " << senderDevice->GetAddress ());
uint16_t protocol = 0; uint16_t protocol = 0;
if (m_receiveErrorModel && m_receiveErrorModel->IsCorrupt (packet) ) if (m_receiveErrorModel && m_receiveErrorModel->IsCorrupt (packet) )