Index: src/helper/csma-helper.h |
=================================================================== |
--- a/src/helper/csma-helper.h |
+++ b/src/helper/csma-helper.h |
@@ -21,23 +21,29 @@ |
#define CSMA_HELPER_H |
#include <string> |
+ |
#include "ns3/attribute.h" |
#include "ns3/object-factory.h" |
#include "ns3/net-device-container.h" |
#include "ns3/node-container.h" |
#include "ns3/csma-channel.h" |
#include "ns3/deprecated.h" |
+#include "trace-helper.h" |
namespace ns3 { |
class Packet; |
-class PcapWriter; |
-class AsciiWriter; |
/** |
* \brief build a set of CsmaNetDevice objects |
+ * |
+ * Normally we eschew multiple inheritance, however, the classes |
+ * PcapUserHelperForDevice and AsciiTraceUserHelperForDevice are |
+ * treated as "mixins". A mixin is a self-contained class that |
+ * encapsulates a general attribute or a set of functionality that |
+ * may be of interest to many other classes. |
*/ |
-class CsmaHelper |
+class CsmaHelper : public TraceHelperForDevice |
{ |
public: |
/** |
@@ -84,106 +90,6 @@ |
void SetChannelAttribute (std::string n1, const AttributeValue &v1); |
/** |
- * \param filename filename prefix to use for pcap files. |
- * \param nodeid the id of the node to generate pcap output for. |
- * \param deviceid the id of the device to generate pcap output for. |
- * \param promiscuous If true capture all possible packets available at the device. |
- * |
- * Generate a pcap file which contains the link-level data observed |
- * by the specified deviceid within the specified nodeid. The pcap |
- * data is stored in the file prefix-nodeid-deviceid.pcap. |
- * |
- * This method should be invoked after the network topology has |
- * been fully constructed. |
- */ |
- static void EnablePcap (std::string filename, uint32_t nodeid, uint32_t deviceid, bool promiscuous); |
- |
- /** |
- * \param filename filename prefix to use for pcap files. |
- * \param nd Net device in which you want to enable tracing. |
- * \param promiscuous If true capture all possible packets available at the device. |
- * |
- * Enable pcap output the indicated net device. |
- */ |
- static void EnablePcap (std::string filename, Ptr<NetDevice> nd, bool promiscuous); |
- |
- /** |
- * \param filename filename prefix to use for pcap files. |
- * \param ndName The name of the net device in which you want to enable tracing. |
- * \param promiscuous If true capture all possible packets available at the device. |
- * |
- * Enable pcap output the indicated net device. |
- */ |
- static void EnablePcap (std::string filename, std::string ndName, bool promiscuous); |
- |
- /** |
- * \param filename filename prefix to use for pcap files. |
- * \param d container of devices of type ns3::CsmaNetDevice |
- * \param promiscuous If true capture all possible packets available at the device. |
- * |
- * Enable pcap output on each input device which is of the ns3::CsmaNetDevice type. |
- */ |
- static void EnablePcap (std::string filename, NetDeviceContainer d, bool promiscuous); |
- |
- /** |
- * \param filename filename prefix to use for pcap files. |
- * \param n container of nodes. |
- * \param promiscuous If true capture all possible packets available at the device. |
- * |
- * Enable pcap output on each device which is of the |
- * ns3::CsmaNetDevice type and which is located in one of the |
- * input nodes. |
- */ |
- static void EnablePcap (std::string filename, NodeContainer n, bool promiscuous); |
- /** |
- * \param filename filename prefix to use for pcap files. |
- * \param promiscuous If true capture all possible packets available at the device. |
- * |
- * Enable pcap output on each device which is of the |
- * ns3::CsmaNetDevice type |
- */ |
- static void EnablePcapAll (std::string filename, bool promiscuous); |
- |
- /** |
- * \param os output stream |
- * \param nodeid the id of the node to generate ascii output for. |
- * \param deviceid the id of the device to generate ascii output for. |
- * |
- * Enable ascii output on the specified deviceid within the |
- * specified nodeid if it is of type ns3::CsmaNetDevice and dump |
- * that to the specified stdc++ output stream. |
- */ |
- static void EnableAscii (std::ostream &os, uint32_t nodeid, uint32_t deviceid); |
- /** |
- * \param os output stream |
- * \param d device container |
- * |
- * Enable ascii output on each device which is of the |
- * ns3::CsmaNetDevice type and which is located in the input |
- * device container and dump that to the specified |
- * stdc++ output stream. |
- */ |
- static void EnableAscii (std::ostream &os, NetDeviceContainer d); |
- /** |
- * \param os output stream |
- * \param n node container |
- * |
- * Enable ascii output on each device which is of the |
- * ns3::CsmaNetDevice type and which is located in one |
- * of the input node and dump that to the specified |
- * stdc++ output stream. |
- */ |
- static void EnableAscii (std::ostream &os, NodeContainer n); |
- /** |
- * \param os output stream |
- * |
- * Enable ascii output on each device which is of the |
- * ns3::CsmaNetDevice type and dump that to the specified |
- * stdc++ output stream. |
- */ |
- static void EnableAsciiAll (std::ostream &os); |
- |
- /** |
* This method creates an ns3::CsmaChannel with the attributes configured by |
* CsmaHelper::SetChannelAttribute, an ns3::CsmaNetDevice with the attributes |
* configured by CsmaHelper::SetDeviceAttribute and then adds the device |
@@ -291,26 +197,31 @@ |
*/ |
Ptr<NetDevice> InstallPriv (Ptr<Node> node, Ptr<CsmaChannel> channel) const; |
- /* |
+ /** |
+ * \brief Enable pcap output on the indicated net device. |
* \internal |
+ * |
+ * NetDevice-specific implementation mechanism for hooking the trace and |
+ * writing to the trace file. |
+ * |
+ * \param prefix Filename prefix to use for pcap files. |
+ * \param nd Net device for which you want to enable tracing. |
+ * \param promiscuous If true capture all possible packets available at the device. |
*/ |
- static void SniffEvent (Ptr<PcapWriter> writer, Ptr<const Packet> packet); |
+ virtual void EnablePcapInternal (std::string prefix, Ptr<NetDevice> nd, bool promiscuous = false); |
- static void AsciiRxEvent (Ptr<AsciiWriter> writer, std::string path, Ptr<const Packet> packet); |
- /* |
+ /** |
+ * \brief Enable ascii trace output on the indicated net device. |
* \internal |
+ * |
+ * NetDevice-specific implementation mechanism for hooking the trace and |
+ * writing to the trace file. |
+ * |
+ * \param stream The output stream object to use when logging ascii traces. |
+ * \param prefix Filename prefix to use for ascii trace files. |
+ * \param nd Net device for which you want to enable tracing. |
*/ |
- static void AsciiEnqueueEvent (Ptr<AsciiWriter> writer, std::string path, Ptr<const Packet> packet); |
- |
- /* |
- * \internal |
- */ |
- static void AsciiDequeueEvent (Ptr<AsciiWriter> writer, std::string path, Ptr<const Packet> packet); |
- |
- /* |
- * \internal |
- */ |
- static void AsciiDropEvent (Ptr<AsciiWriter> writer, std::string path, Ptr<const Packet> packet); |
+ virtual void EnableAsciiInternal (Ptr<OutputStreamObject> stream, std::string prefix, Ptr<NetDevice> nd); |
ObjectFactory m_queueFactory; |
ObjectFactory m_deviceFactory; |