bug 170
This commit is contained in:
@@ -25,12 +25,28 @@
|
||||
#include "ns3/internet-stack.h"
|
||||
#include "ns3/packet-socket-factory.h"
|
||||
#include "ns3/config.h"
|
||||
#include "ns3/simulator.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
std::vector<InternetStackHelper::Trace> InternetStackHelper::m_traces;
|
||||
std::string InternetStackHelper::m_pcapBaseFilename;
|
||||
|
||||
void
|
||||
InternetStackHelper::Cleanup (void)
|
||||
{
|
||||
uint32_t illegal = std::numeric_limits<uint32_t>::max();
|
||||
|
||||
for (std::vector<Trace>::iterator i = m_traces.begin ();
|
||||
i != m_traces.end (); i++)
|
||||
{
|
||||
i->nodeId = illegal;
|
||||
i->interfaceId = illegal;
|
||||
i->writer = 0;
|
||||
}
|
||||
m_traces.clear ();
|
||||
}
|
||||
|
||||
void
|
||||
InternetStackHelper::Install (NodeContainer c)
|
||||
{
|
||||
@@ -52,6 +68,8 @@ InternetStackHelper::Install (NodeContainer c)
|
||||
void
|
||||
InternetStackHelper::EnablePcapAll (std::string filename)
|
||||
{
|
||||
Simulator::ScheduleDestroy (&InternetStackHelper::Cleanup);
|
||||
|
||||
InternetStackHelper::m_pcapBaseFilename = filename;
|
||||
Config::Connect ("/NodeList/*/$ns3::Ipv4L3Protocol/Tx",
|
||||
MakeCallback (&InternetStackHelper::LogTxIp));
|
||||
|
||||
@@ -49,10 +49,18 @@ public:
|
||||
*
|
||||
* Enable pcap output on each protocol instance which is of the
|
||||
* ns3::Ipv4L3Protocol type. Both Tx and Rx events will be logged.
|
||||
*
|
||||
* \warning If you perform multiple simulations in a single script,
|
||||
* each iteration of the simulation will result in the trace files
|
||||
* being overwritten. We don't attempt to anticipate what a user
|
||||
* might actually want to do, so we leave it up to them. If you want
|
||||
* to save any particular data, do so manually at inter-simulation
|
||||
* time.
|
||||
*/
|
||||
static void EnablePcapAll (std::string filename);
|
||||
|
||||
private:
|
||||
static void Cleanup (void);
|
||||
static void LogRxIp (std::string context, Ptr<const Packet> packet, uint32_t deviceId);
|
||||
static void LogTxIp (std::string context, Ptr<const Packet> packet, uint32_t deviceId);
|
||||
static Ptr<PcapWriter> GetStream (uint32_t nodeId, uint32_t interfaceId);
|
||||
|
||||
Reference in New Issue
Block a user