point-to-point: (fixes #2556) Avoid modification of transmitted packets
Packets sent to channel may later be modified by calling device. Possible solutions are to copy before or after sending the packet to the channel. Adopted solution similar to YansWifiChannel; a Ptr<const Packet> is instead passed to the channel object, and channel object is responsible for copy.
This commit is contained in:
@@ -85,7 +85,7 @@ PointToPointChannel::Attach (Ptr<PointToPointNetDevice> device)
|
||||
|
||||
bool
|
||||
PointToPointChannel::TransmitStart (
|
||||
Ptr<Packet> p,
|
||||
Ptr<const Packet> p,
|
||||
Ptr<PointToPointNetDevice> src,
|
||||
Time txTime)
|
||||
{
|
||||
@@ -99,7 +99,7 @@ PointToPointChannel::TransmitStart (
|
||||
|
||||
Simulator::ScheduleWithContext (m_link[wire].m_dst->GetNode ()->GetId (),
|
||||
txTime + m_delay, &PointToPointNetDevice::Receive,
|
||||
m_link[wire].m_dst, p);
|
||||
m_link[wire].m_dst, p->Copy ());
|
||||
|
||||
// Call the tx anim callback on the net device
|
||||
m_txrxPointToPoint (p, src, m_link[wire].m_dst, txTime, txTime + m_delay);
|
||||
|
||||
@@ -78,7 +78,7 @@ public:
|
||||
* \param txTime Transmit time to apply
|
||||
* \returns true if successful (currently always true)
|
||||
*/
|
||||
virtual bool TransmitStart (Ptr<Packet> p, Ptr<PointToPointNetDevice> src, Time txTime);
|
||||
virtual bool TransmitStart (Ptr<const Packet> p, Ptr<PointToPointNetDevice> src, Time txTime);
|
||||
|
||||
/**
|
||||
* \brief Get number of devices on this channel
|
||||
|
||||
@@ -55,7 +55,7 @@ PointToPointRemoteChannel::~PointToPointRemoteChannel ()
|
||||
|
||||
bool
|
||||
PointToPointRemoteChannel::TransmitStart (
|
||||
Ptr<Packet> p,
|
||||
Ptr<const Packet> p,
|
||||
Ptr<PointToPointNetDevice> src,
|
||||
Time txTime)
|
||||
{
|
||||
@@ -70,7 +70,7 @@ PointToPointRemoteChannel::TransmitStart (
|
||||
#ifdef NS3_MPI
|
||||
// Calculate the rxTime (absolute)
|
||||
Time rxTime = Simulator::Now () + txTime + GetDelay ();
|
||||
MpiInterface::SendPacket (p, rxTime, dst->GetNode ()->GetId (), dst->GetIfIndex ());
|
||||
MpiInterface::SendPacket (p->Copy (), rxTime, dst->GetNode ()->GetId (), dst->GetIfIndex ());
|
||||
#else
|
||||
NS_FATAL_ERROR ("Can't use distributed simulator without MPI compiled in");
|
||||
#endif
|
||||
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
* \param txTime Transmit time to apply
|
||||
* \returns true if successful (currently always true)
|
||||
*/
|
||||
virtual bool TransmitStart (Ptr<Packet> p, Ptr<PointToPointNetDevice> src,
|
||||
virtual bool TransmitStart (Ptr<const Packet> p, Ptr<PointToPointNetDevice> src,
|
||||
Time txTime);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user