From 7eab0b51c9d48395d45d3230ddd0b44b94aefa97 Mon Sep 17 00:00:00 2001 From: Tom Henderson Date: Sat, 3 Jun 2017 08:10:44 -0700 Subject: [PATCH] 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 is instead passed to the channel object, and channel object is responsible for copy. --- src/point-to-point/model/point-to-point-channel.cc | 4 ++-- src/point-to-point/model/point-to-point-channel.h | 2 +- src/point-to-point/model/point-to-point-remote-channel.cc | 4 ++-- src/point-to-point/model/point-to-point-remote-channel.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/point-to-point/model/point-to-point-channel.cc b/src/point-to-point/model/point-to-point-channel.cc index d59cbd17b..77dd626d5 100644 --- a/src/point-to-point/model/point-to-point-channel.cc +++ b/src/point-to-point/model/point-to-point-channel.cc @@ -85,7 +85,7 @@ PointToPointChannel::Attach (Ptr device) bool PointToPointChannel::TransmitStart ( - Ptr p, + Ptr p, Ptr 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); diff --git a/src/point-to-point/model/point-to-point-channel.h b/src/point-to-point/model/point-to-point-channel.h index e53bfe141..732bfca94 100644 --- a/src/point-to-point/model/point-to-point-channel.h +++ b/src/point-to-point/model/point-to-point-channel.h @@ -78,7 +78,7 @@ public: * \param txTime Transmit time to apply * \returns true if successful (currently always true) */ - virtual bool TransmitStart (Ptr p, Ptr src, Time txTime); + virtual bool TransmitStart (Ptr p, Ptr src, Time txTime); /** * \brief Get number of devices on this channel diff --git a/src/point-to-point/model/point-to-point-remote-channel.cc b/src/point-to-point/model/point-to-point-remote-channel.cc index 40f98cecb..46fe81be3 100644 --- a/src/point-to-point/model/point-to-point-remote-channel.cc +++ b/src/point-to-point/model/point-to-point-remote-channel.cc @@ -55,7 +55,7 @@ PointToPointRemoteChannel::~PointToPointRemoteChannel () bool PointToPointRemoteChannel::TransmitStart ( - Ptr p, + Ptr p, Ptr 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 diff --git a/src/point-to-point/model/point-to-point-remote-channel.h b/src/point-to-point/model/point-to-point-remote-channel.h index fd1a9a8a5..f10b2df91 100644 --- a/src/point-to-point/model/point-to-point-remote-channel.h +++ b/src/point-to-point/model/point-to-point-remote-channel.h @@ -66,7 +66,7 @@ public: * \param txTime Transmit time to apply * \returns true if successful (currently always true) */ - virtual bool TransmitStart (Ptr p, Ptr src, + virtual bool TransmitStart (Ptr p, Ptr src, Time txTime); };