|
|
| 26 |
#include "ns3/config.h" |
26 |
#include "ns3/config.h" |
| 27 |
#include "ns3/packet.h" |
27 |
#include "ns3/packet.h" |
| 28 |
|
28 |
|
| 29 |
|
|
|
| 30 |
namespace ns3 { |
29 |
namespace ns3 { |
| 31 |
|
30 |
|
|
|
31 |
std::vector<PointToPointHelper::Trace> PointToPointHelper::m_traces; |
| 32 |
|
32 |
|
| 33 |
PointToPointHelper::PointToPointHelper () |
33 |
PointToPointHelper::PointToPointHelper () |
| 34 |
{ |
34 |
{ |
| 35 |
m_queueFactory.SetTypeId ("ns3::DropTailQueue"); |
35 |
m_queueFactory.SetTypeId ("ns3::DropTailQueue"); |
| 36 |
m_deviceFactory.SetTypeId ("ns3::PointToPointNetDevice"); |
36 |
m_deviceFactory.SetTypeId ("ns3::PointToPointNetDevice"); |
| 37 |
m_channelFactory.SetTypeId ("ns3::PointToPointChannel"); |
37 |
m_channelFactory.SetTypeId ("ns3::PointToPointChannel"); |
|
|
38 |
} |
| 39 |
|
| 40 |
void |
| 41 |
PointToPointHelper::Cleanup (void) |
| 42 |
{ |
| 43 |
uint32_t illegal = std::numeric_limits<uint32_t>::max(); |
| 44 |
|
| 45 |
for (std::vector<Trace>::iterator i = m_traces.begin (); |
| 46 |
i != m_traces.end (); i++) |
| 47 |
{ |
| 48 |
i->nodeId = illegal; |
| 49 |
i->deviceId = illegal; |
| 50 |
i->writer->Close(); |
| 51 |
i->writer = 0; |
| 52 |
} |
| 53 |
m_traces.clear (); |
| 38 |
} |
54 |
} |
| 39 |
|
55 |
|
| 40 |
void |
56 |
void |
|
Lines 95-100
PointToPointHelper::EnablePcap (std::str
|
Link Here
|
|---|
|
| 95 |
oss.str (""); |
111 |
oss.str (""); |
| 96 |
oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::PointToPointNetDevice/TxQueue/Enqueue"; |
112 |
oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::PointToPointNetDevice/TxQueue/Enqueue"; |
| 97 |
Config::ConnectWithoutContext (oss.str (), MakeBoundCallback (&PointToPointHelper::EnqueueEvent, pcap)); |
113 |
Config::ConnectWithoutContext (oss.str (), MakeBoundCallback (&PointToPointHelper::EnqueueEvent, pcap)); |
|
|
114 |
// Store pcap pointer for later destruction |
| 115 |
PointToPointHelper::Trace trace; |
| 116 |
trace.nodeId = nodeid; |
| 117 |
trace.deviceId = deviceid; |
| 118 |
trace.writer = pcap; |
| 119 |
m_traces.push_back (trace); |
| 98 |
} |
120 |
} |
| 99 |
void |
121 |
void |
| 100 |
PointToPointHelper::EnablePcap (std::string filename, NetDeviceContainer d) |
122 |
PointToPointHelper::EnablePcap (std::string filename, NetDeviceContainer d) |
|
|
| 123 |
void |
145 |
void |
| 124 |
PointToPointHelper::EnablePcapAll (std::string filename) |
146 |
PointToPointHelper::EnablePcapAll (std::string filename) |
| 125 |
{ |
147 |
{ |
|
|
148 |
Simulator::ScheduleDestroy (&PointToPointHelper::Cleanup); |
| 149 |
|
| 126 |
EnablePcap (filename, NodeContainer::GetGlobal ()); |
150 |
EnablePcap (filename, NodeContainer::GetGlobal ()); |
| 127 |
} |
151 |
} |
| 128 |
|
152 |
|
|
Lines 251-255
PointToPointHelper::AsciiRxEvent (std::o
|
Link Here
|
|---|
|
| 251 |
*os << path << " " << *packet << std::endl; |
275 |
*os << path << " " << *packet << std::endl; |
| 252 |
} |
276 |
} |
| 253 |
|
277 |
|
|
|
278 |
Ptr<PcapWriter> |
| 279 |
PointToPointHelper::GetStream (uint32_t nodeId, uint32_t deviceId) |
| 280 |
{ |
| 281 |
for (std::vector<Trace>::iterator i = m_traces.begin (); |
| 282 |
i != m_traces.end (); i++) |
| 283 |
{ |
| 284 |
if (i->nodeId == nodeId && |
| 285 |
i->deviceId == deviceId) |
| 286 |
{ |
| 287 |
return i->writer; |
| 288 |
} |
| 289 |
} |
| 290 |
return 0; |
| 291 |
} |
| 254 |
|
292 |
|
| 255 |
} // namespace ns3 |
293 |
} // namespace ns3 |