View | Details | Raw Unified | Return to bug 280
Collapse All | Expand All

(-)a/src/helper/csma-helper.cc (-18 / +23 lines)
 Lines 79-93    Link Here 
79
{
79
{
80
  std::ostringstream oss;
80
  std::ostringstream oss;
81
  oss << filename << "-" << nodeid << "-" << deviceid << ".pcap";
81
  oss << filename << "-" << nodeid << "-" << deviceid << ".pcap";
82
  std::string fullFilename = oss.str ();
83
  oss.str ("");
84
  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::CsmaNetDevice/";
85
  Config::MatchContainer matches;
86
  matches = Config::LookupMatches (oss.str ());
87
  if (matches.GetN () == 0)
88
    {
89
      return;
90
    }
82
  Ptr<PcapWriter> pcap = Create<PcapWriter> ();
91
  Ptr<PcapWriter> pcap = Create<PcapWriter> ();
83
  pcap->Open (oss.str ());
92
  pcap->Open (fullFilename);
84
  pcap->WriteEthernetHeader ();
93
  pcap->WriteEthernetHeader ();
85
  oss.str ("");
94
  matches.ConnectWithoutContext ("Rx", MakeBoundCallback (&CsmaHelper::RxEvent, pcap));
86
  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::CsmaNetDevice/Rx";
95
  oss << "TxQueue/";
87
  Config::ConnectWithoutContext (oss.str (), MakeBoundCallback (&CsmaHelper::RxEvent, pcap));
96
  matches = Config::LookupMatches (oss.str ());
88
  oss.str ("");
97
  NS_ASSERT (matches.GetN () == 1);
89
  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::CsmaNetDevice/TxQueue/Enqueue";
98
  matches.ConnectWithoutContext ("Enqueue", MakeBoundCallback (&CsmaHelper::EnqueueEvent, pcap));
90
  Config::ConnectWithoutContext (oss.str (), MakeBoundCallback (&CsmaHelper::EnqueueEvent, pcap));
91
}
99
}
92
void 
100
void 
93
CsmaHelper::EnablePcap (std::string filename, NetDeviceContainer d)
101
CsmaHelper::EnablePcap (std::string filename, NetDeviceContainer d)
 Lines 124-140    Link Here 
124
{
132
{
125
  Packet::EnablePrinting ();
133
  Packet::EnablePrinting ();
126
  std::ostringstream oss;
134
  std::ostringstream oss;
127
  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::CsmaNetDevice/Rx";
135
  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::CsmaNetDevice/";
128
  Config::Connect (oss.str (), MakeBoundCallback (&CsmaHelper::AsciiRxEvent, &os));
136
  Config::MatchContainer matches = Config::LookupMatches (oss.str ());
129
  oss.str ("");
137
  matches.Connect ("Rx", MakeBoundCallback (&CsmaHelper::AsciiRxEvent, &os));
130
  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::CsmaNetDevice/TxQueue/Enqueue";
138
  oss << "TxQueue/";
131
  Config::Connect (oss.str (), MakeBoundCallback (&CsmaHelper::AsciiEnqueueEvent, &os));
139
  matches = Config::LookupMatches (oss.str ());
132
  oss.str ("");
140
  matches.Connect ("Enqueue", MakeBoundCallback (&CsmaHelper::AsciiEnqueueEvent, &os));
133
  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::CsmaNetDevice/TxQueue/Dequeue";
141
  matches.Connect ("Dequeue", MakeBoundCallback (&CsmaHelper::AsciiDequeueEvent, &os));
134
  Config::Connect (oss.str (), MakeBoundCallback (&CsmaHelper::AsciiDequeueEvent, &os));
142
  matches.Connect ("Drop", MakeBoundCallback (&CsmaHelper::AsciiDropEvent, &os));
135
  oss.str ("");
136
  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::CsmaNetDevice/TxQueue/Drop";
137
  Config::Connect (oss.str (), MakeBoundCallback (&CsmaHelper::AsciiDropEvent, &os));
138
}
143
}
139
void 
144
void 
140
CsmaHelper::EnableAscii (std::ostream &os, NetDeviceContainer d)
145
CsmaHelper::EnableAscii (std::ostream &os, NetDeviceContainer d)

Return to bug 280