mirror of
https://gitlab.ibr.cs.tu-bs.de/tschuber/ns-3-leo.git
synced 2025-06-08 18:13:57 +02:00
fixup: multiple devices per channel
This commit is contained in:
parent
13e4bf1aa7
commit
07cff2c920
6 changed files with 29 additions and 38 deletions
|
@ -21,11 +21,10 @@ main (int argc, char *argv[])
|
||||||
Time::SetResolution (Time::NS);
|
Time::SetResolution (Time::NS);
|
||||||
LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO);
|
LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO);
|
||||||
LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO);
|
LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO);
|
||||||
LogComponentEnable ("UdpClient", LOG_LEVEL_DEBUG);
|
LogComponentEnable ("UdpClient", LOG_LEVEL_INFO);
|
||||||
LogComponentEnable ("IslChannel", LOG_LEVEL_LOGIC);
|
|
||||||
|
|
||||||
NodeContainer nodes;
|
NodeContainer nodes;
|
||||||
nodes.Create (2);
|
nodes.Create (300);
|
||||||
|
|
||||||
IslHelper isl;
|
IslHelper isl;
|
||||||
isl.SetDeviceAttribute ("DataRate", StringValue ("5Gbps"));
|
isl.SetDeviceAttribute ("DataRate", StringValue ("5Gbps"));
|
||||||
|
@ -45,11 +44,13 @@ main (int argc, char *argv[])
|
||||||
|
|
||||||
UdpEchoServerHelper echoServer (9);
|
UdpEchoServerHelper echoServer (9);
|
||||||
|
|
||||||
ApplicationContainer serverApps = echoServer.Install (nodes.Get (1));
|
for (uint32_t i = 1; i < nodes.GetN (); i++)
|
||||||
|
{
|
||||||
|
ApplicationContainer serverApps = echoServer.Install (nodes.Get (i));
|
||||||
serverApps.Start (Seconds (1.0));
|
serverApps.Start (Seconds (1.0));
|
||||||
serverApps.Stop (Seconds (10.0));
|
serverApps.Stop (Seconds (10.0));
|
||||||
|
|
||||||
Address destAddress = interfaces.GetAddress (1, 0);
|
Address destAddress = interfaces.GetAddress (i, 0);
|
||||||
UdpEchoClientHelper echoClient (destAddress, 9);
|
UdpEchoClientHelper echoClient (destAddress, 9);
|
||||||
echoClient.SetAttribute ("MaxPackets", UintegerValue (10));
|
echoClient.SetAttribute ("MaxPackets", UintegerValue (10));
|
||||||
echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.0)));
|
echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.0)));
|
||||||
|
@ -58,6 +59,7 @@ main (int argc, char *argv[])
|
||||||
ApplicationContainer clientApps = echoClient.Install (nodes.Get (0));
|
ApplicationContainer clientApps = echoClient.Install (nodes.Get (0));
|
||||||
clientApps.Start (Seconds (2.0));
|
clientApps.Start (Seconds (2.0));
|
||||||
clientApps.Stop (Seconds (10.0));
|
clientApps.Stop (Seconds (10.0));
|
||||||
|
}
|
||||||
|
|
||||||
Simulator::Run ();
|
Simulator::Run ();
|
||||||
Simulator::Destroy ();
|
Simulator::Destroy ();
|
||||||
|
|
|
@ -8,4 +8,3 @@ namespace ns3 {
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,4 +11,3 @@ namespace ns3 {
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* LEO_HELPER_H */
|
#endif /* LEO_HELPER_H */
|
||||||
|
|
||||||
|
|
|
@ -127,7 +127,8 @@ bool IslChannel::Deliver (
|
||||||
delay,
|
delay,
|
||||||
&IslNetDevice::Receive,
|
&IslNetDevice::Receive,
|
||||||
dst,
|
dst,
|
||||||
p->Copy ());
|
p->Copy (),
|
||||||
|
src);
|
||||||
|
|
||||||
// Call the tx anim callback on the net device
|
// Call the tx anim callback on the net device
|
||||||
m_txrxIsl (p, src, dst, txTime, delay);
|
m_txrxIsl (p, src, dst, txTime, delay);
|
||||||
|
|
|
@ -368,7 +368,7 @@ IslNetDevice::SetReceiveErrorModel (Ptr<ErrorModel> em)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
IslNetDevice::Receive (Ptr<Packet> packet)
|
IslNetDevice::Receive (Ptr<Packet> packet, Ptr<IslNetDevice> senderDevice)
|
||||||
{
|
{
|
||||||
NS_LOG_FUNCTION (this << packet);
|
NS_LOG_FUNCTION (this << packet);
|
||||||
uint16_t protocol = 0;
|
uint16_t protocol = 0;
|
||||||
|
@ -406,14 +406,15 @@ IslNetDevice::Receive (Ptr<Packet> packet)
|
||||||
//
|
//
|
||||||
ProcessHeader (packet, protocol);
|
ProcessHeader (packet, protocol);
|
||||||
|
|
||||||
|
Address remote = GetRemote (senderDevice);
|
||||||
if (!m_promiscCallback.IsNull ())
|
if (!m_promiscCallback.IsNull ())
|
||||||
{
|
{
|
||||||
m_macPromiscRxTrace (originalPacket);
|
m_macPromiscRxTrace (originalPacket);
|
||||||
m_promiscCallback (this, packet, protocol, GetRemote (), GetAddress (), NetDevice::PACKET_HOST);
|
m_promiscCallback (this, packet, protocol, remote, GetAddress (), NetDevice::PACKET_HOST);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_macRxTrace (originalPacket);
|
m_macRxTrace (originalPacket);
|
||||||
m_rxCallback (this, packet, protocol, GetRemote ());
|
m_rxCallback (this, packet, protocol, remote);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -653,28 +654,17 @@ IslNetDevice::SupportsSendFrom (void) const
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
IslNetDevice::DoMpiReceive (Ptr<Packet> p)
|
IslNetDevice::DoMpiReceive (Ptr<Packet> p, Ptr<IslNetDevice> senderDevice)
|
||||||
{
|
{
|
||||||
NS_LOG_FUNCTION (this << p);
|
NS_LOG_FUNCTION (this << p);
|
||||||
Receive (p);
|
Receive (p, senderDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
Address
|
Address
|
||||||
IslNetDevice::GetRemote (void) const
|
IslNetDevice::GetRemote (Ptr<IslNetDevice> senderDevice) const
|
||||||
{
|
{
|
||||||
NS_LOG_FUNCTION (this);
|
NS_LOG_FUNCTION (this);
|
||||||
NS_ASSERT (m_channel->GetNDevices () == 2);
|
return senderDevice->GetAddress ();
|
||||||
for (std::size_t i = 0; i < m_channel->GetNDevices (); ++i)
|
|
||||||
{
|
|
||||||
Ptr<NetDevice> tmp = m_channel->GetDevice (i);
|
|
||||||
if (tmp != this)
|
|
||||||
{
|
|
||||||
return tmp->GetAddress ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
NS_ASSERT (false);
|
|
||||||
// quiet compiler.
|
|
||||||
return Address ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
|
@ -150,7 +150,7 @@ public:
|
||||||
*
|
*
|
||||||
* \param p Ptr to the received packet.
|
* \param p Ptr to the received packet.
|
||||||
*/
|
*/
|
||||||
void Receive (Ptr<Packet> p);
|
void Receive (Ptr<Packet> p, Ptr<IslNetDevice> senderDevice);
|
||||||
|
|
||||||
// The remaining methods are documented in ns3::NetDevice*
|
// The remaining methods are documented in ns3::NetDevice*
|
||||||
|
|
||||||
|
@ -205,7 +205,7 @@ protected:
|
||||||
*
|
*
|
||||||
* \param p Packet received
|
* \param p Packet received
|
||||||
*/
|
*/
|
||||||
void DoMpiReceive (Ptr<Packet> p);
|
void DoMpiReceive (Ptr<Packet> p, Ptr<IslNetDevice> sender);
|
||||||
|
|
||||||
virtual void DoInitialize (void);
|
virtual void DoInitialize (void);
|
||||||
virtual void NotifyNewAggregate (void);
|
virtual void NotifyNewAggregate (void);
|
||||||
|
@ -242,7 +242,7 @@ private:
|
||||||
* \returns the address of the remote device connected to this device
|
* \returns the address of the remote device connected to this device
|
||||||
* through the point to point channel.
|
* through the point to point channel.
|
||||||
*/
|
*/
|
||||||
Address GetRemote (void) const;
|
Address GetRemote (Ptr<IslNetDevice> senderDevice) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the necessary headers and trailers to a packet of data in order to
|
* Adds the necessary headers and trailers to a packet of data in order to
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue