1.1 --- a/src/helper/internet-stack-helper.cc Wed May 07 14:40:03 2008 -0700
1.2 +++ b/src/helper/internet-stack-helper.cc Thu May 08 11:16:12 2008 -0700
1.3 @@ -25,12 +25,28 @@
1.4 #include "ns3/internet-stack.h"
1.5 #include "ns3/packet-socket-factory.h"
1.6 #include "ns3/config.h"
1.7 +#include "ns3/simulator.h"
1.8
1.9 namespace ns3 {
1.10
1.11 std::vector<InternetStackHelper::Trace> InternetStackHelper::m_traces;
1.12 std::string InternetStackHelper::m_pcapBaseFilename;
1.13
1.14 +void
1.15 +InternetStackHelper::Cleanup (void)
1.16 +{
1.17 + uint32_t illegal = std::numeric_limits<uint32_t>::max();
1.18 +
1.19 + for (std::vector<Trace>::iterator i = m_traces.begin ();
1.20 + i != m_traces.end (); i++)
1.21 + {
1.22 + i->nodeId = illegal;
1.23 + i->interfaceId = illegal;
1.24 + i->writer = 0;
1.25 + }
1.26 + m_traces.clear ();
1.27 +}
1.28 +
1.29 void
1.30 InternetStackHelper::Install (NodeContainer c)
1.31 {
1.32 @@ -52,6 +68,8 @@
1.33 void
1.34 InternetStackHelper::EnablePcapAll (std::string filename)
1.35 {
1.36 + Simulator::ScheduleDestroy (&InternetStackHelper::Cleanup);
1.37 +
1.38 InternetStackHelper::m_pcapBaseFilename = filename;
1.39 Config::Connect ("/NodeList/*/$ns3::Ipv4L3Protocol/Tx",
1.40 MakeCallback (&InternetStackHelper::LogTxIp));
2.1 --- a/src/helper/internet-stack-helper.h Wed May 07 14:40:03 2008 -0700
2.2 +++ b/src/helper/internet-stack-helper.h Thu May 08 11:16:12 2008 -0700
2.3 @@ -49,10 +49,18 @@
2.4 *
2.5 * Enable pcap output on each protocol instance which is of the
2.6 * ns3::Ipv4L3Protocol type. Both Tx and Rx events will be logged.
2.7 + *
2.8 + * \warning If you perform multiple simulations in a single script,
2.9 + * each iteration of the simulation will result in the trace files
2.10 + * being overwritten. We don't attempt to anticipate what a user
2.11 + * might actually want to do, so we leave it up to them. If you want
2.12 + * to save any particular data, do so manually at inter-simulation
2.13 + * time.
2.14 */
2.15 static void EnablePcapAll (std::string filename);
2.16
2.17 private:
2.18 + static void Cleanup (void);
2.19 static void LogRxIp (std::string context, Ptr<const Packet> packet, uint32_t deviceId);
2.20 static void LogTxIp (std::string context, Ptr<const Packet> packet, uint32_t deviceId);
2.21 static Ptr<PcapWriter> GetStream (uint32_t nodeId, uint32_t interfaceId);