use the API enabled by alina's latest patch
This commit is contained in:
@@ -271,26 +271,6 @@ EmuNetDevice::StartDevice (void)
|
||||
NS_FATAL_ERROR ("EmuNetDevice::StartDevice(): Device is already started");
|
||||
}
|
||||
|
||||
//
|
||||
// We're going to need a pointer to the realtime simulator implementation.
|
||||
// It's important to remember that access to that implementation may happen
|
||||
// in a completely different thread than the simulator is running in (we're
|
||||
// going to spin up that thread below). We are talking about multiple threads
|
||||
// here, so it is very, very dangerous to do any kind of reference couning on
|
||||
// a shared object that is unaware of what is happening. What we are going to
|
||||
// do to address that is to get a reference to the realtime simulator here
|
||||
// where we are running in the context of a running simulator scheduler --
|
||||
// recall we did a Simulator::Schedule of this method above. We get the
|
||||
// simulator implementation pointer in a single-threaded way and save the
|
||||
// underlying raw pointer for use by the (other) read thread. We must not
|
||||
// free this pointer or we may delete the simulator out from under us an
|
||||
// everyone else. We assume that the simulator implementation cannot be
|
||||
// replaced while the emu device is running and so will remain valid through
|
||||
// the time during which the read thread is running.
|
||||
//
|
||||
Ptr<RealtimeSimulatorImpl> impl = DynamicCast<RealtimeSimulatorImpl> (Simulator::GetImplementation ());
|
||||
m_rtImpl = GetPointer (impl);
|
||||
|
||||
//
|
||||
// A similar story exists for the node ID. We can't just naively do a
|
||||
// GetNode ()->GetId () since GetNode is going to give us a Ptr<Node> which
|
||||
@@ -823,8 +803,8 @@ EmuNetDevice::ReadThread (void)
|
||||
|
||||
NS_LOG_INFO ("EmuNetDevice::EmuNetDevice(): Received packet on node " << m_nodeId);
|
||||
NS_LOG_INFO ("EmuNetDevice::ReadThread(): Scheduling handler");
|
||||
NS_ASSERT_MSG (m_rtImpl, "EmuNetDevice::ReadThread(): Realtime simulator implementation pointer not set");
|
||||
m_rtImpl->ScheduleRealtimeNowWithContext (m_nodeId, MakeEvent (&EmuNetDevice::ForwardUp, this, buf, len));
|
||||
Simulator::ScheduleWithContext (m_nodeId, Seconds (0.0),
|
||||
MakeEvent (&EmuNetDevice::ForwardUp, this, buf, len));
|
||||
buf = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
#include "ns3/mac48-address.h"
|
||||
#include "ns3/system-thread.h"
|
||||
#include "ns3/system-mutex.h"
|
||||
#include "ns3/realtime-simulator-impl.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
@@ -517,12 +516,6 @@ private:
|
||||
*/
|
||||
uint8_t *m_packetBuffer;
|
||||
|
||||
/**
|
||||
* A copy of a raw pointer to the required real-time simulator implementation.
|
||||
* Never free this pointer!
|
||||
*/
|
||||
RealtimeSimulatorImpl *m_rtImpl;
|
||||
|
||||
/*
|
||||
* a copy of the node id so the read thread doesn't have to GetNode() in
|
||||
* in order to find the node ID. Thread unsafe reference counting in
|
||||
|
||||
@@ -214,26 +214,6 @@ TapBridge::StartTapDevice (void)
|
||||
|
||||
NS_ABORT_MSG_IF (m_sock != -1, "TapBridge::StartTapDevice(): Tap is already started");
|
||||
|
||||
//
|
||||
// We're going to need a pointer to the realtime simulator implementation.
|
||||
// It's important to remember that access to that implementation may happen
|
||||
// in a completely different thread than the simulator is running in (we're
|
||||
// going to spin up that thread below). We are talking about multiple threads
|
||||
// here, so it is very, very dangerous to do any kind of reference couning on
|
||||
// a shared object that is unaware of what is happening. What we are going to
|
||||
// do to address that is to get a reference to the realtime simulator here
|
||||
// where we are running in the context of a running simulator scheduler --
|
||||
// recall we did a Simulator::Schedule of this method above. We get the
|
||||
// simulator implementation pointer in a single-threaded way and save the
|
||||
// underlying raw pointer for use by the (other) read thread. We must not
|
||||
// free this pointer or we may delete the simulator out from under us an
|
||||
// everyone else. We assume that the simulator implementation cannot be
|
||||
// replaced while the tap bridge is running and so will remain valid through
|
||||
// the time during which the read thread is running.
|
||||
//
|
||||
Ptr<RealtimeSimulatorImpl> impl = DynamicCast<RealtimeSimulatorImpl> (Simulator::GetImplementation ());
|
||||
m_rtImpl = GetPointer (impl);
|
||||
|
||||
//
|
||||
// A similar story exists for the node ID. We can't just naively do a
|
||||
// GetNode ()->GetId () since GetNode is going to give us a Ptr<Node> which
|
||||
@@ -684,8 +664,7 @@ TapBridge::ReadCallback (uint8_t *buf, ssize_t len)
|
||||
|
||||
NS_LOG_INFO ("TapBridge::ReadCallback(): Received packet on node " << m_nodeId);
|
||||
NS_LOG_INFO ("TapBridge::ReadCallback(): Scheduling handler");
|
||||
NS_ASSERT_MSG (m_rtImpl, "TapBridge::ReadCallback(): Realtime simulator implementation pointer not set");
|
||||
m_rtImpl->ScheduleRealtimeNowWithContext (m_nodeId, MakeEvent (&TapBridge::ForwardToBridgedDevice, this, buf, len));
|
||||
Simulator::ScheduleWithContext (m_nodeId, Seconds (0.0), MakeEvent (&TapBridge::ForwardToBridgedDevice, this, buf, len));
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
#include "ns3/ptr.h"
|
||||
#include "ns3/mac48-address.h"
|
||||
#include "ns3/unix-fd-reader.h"
|
||||
#include "ns3/realtime-simulator-impl.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
@@ -458,12 +457,6 @@ private:
|
||||
*/
|
||||
uint8_t *m_packetBuffer;
|
||||
|
||||
/**
|
||||
* A copy of a raw pointer to the required real-time simulator implementation.
|
||||
* Never free this pointer!
|
||||
*/
|
||||
RealtimeSimulatorImpl *m_rtImpl;
|
||||
|
||||
/*
|
||||
* a copy of the node id so the read thread doesn't have to GetNode() in
|
||||
* in order to find the node ID. Thread unsafe reference counting in
|
||||
|
||||
Reference in New Issue
Block a user