Index: src/helper/emu-helper.h |
=================================================================== |
--- a/src/helper/emu-helper.h |
+++ b/src/helper/emu-helper.h |
@@ -21,22 +21,29 @@ |
#include <string> |
#include <ostream> |
+ |
#include "ns3/attribute.h" |
#include "ns3/object-factory.h" |
#include "ns3/net-device-container.h" |
#include "ns3/node-container.h" |
#include "ns3/emu-net-device.h" |
+#include "trace-helper.h" |
+ |
namespace ns3 { |
class Packet; |
-class PcapWriter; |
-class AsciiWriter; |
/** |
* \brief build a set of EmuNetDevice 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 EmuHelper |
+class EmuHelper : public TraceHelperForDevice |
{ |
public: |
/* |
@@ -75,113 +82,6 @@ |
void SetAttribute (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 Indicates net device on which you want to enable tracing. |
- * \param promiscuous If true capture all possible packets available at the device. |
- * |
- * Enable pcap output on each input device which is of the |
- * ns3::EmuNetDevice type. |
- */ |
- static void EnablePcap (std::string filename, Ptr<NetDevice> nd, bool promiscuous); |
- |
- /** |
- * \param filename filename prefix to use for pcap files. |
- * \param ndName Name of net device on which you want to enable tracing. |
- * \param promiscuous If true capture all possible packets available at the device. |
- * |
- * Enable pcap output on each input device which is of the |
- * ns3::EmuNetDevice type. |
- */ |
- 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::EmuNetDevice |
- * \param promiscuous If true capture all possible packets available at the device. |
- * |
- * Enable pcap output on each input device which is of the |
- * ns3::EmuNetDevice 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::EmuNetDevice 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::EmuNetDevice 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::EmuNetDevice 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::EmuNetDevice 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::EmuNetDevice 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::EmuNetDevice type and dump that to the specified |
- * stdc++ output stream. |
- */ |
- static void EnableAsciiAll (std::ostream &os); |
- |
- /** |
* This method creates an ns3::EmuNetDevice with the attributes configured by |
* EmuHelper::SetDeviceAttribute and then adds the device to the node. |
* |
@@ -215,30 +115,30 @@ |
*/ |
Ptr<NetDevice> InstallPriv (Ptr<Node> node) const; |
- /* |
+ /** |
+ * \brief Enable pcap output the indicated net device. |
+ * |
+ * 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. |
+ */ |
+ virtual void EnablePcapInternal (std::string prefix, Ptr<NetDevice> nd, bool promiscuous = false); |
+ |
+ /** |
+ * \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 SniffEvent (Ptr<PcapWriter> writer, Ptr<const Packet> packet); |
- |
- /* |
- * \internal |
- */ |
- static void AsciiRxEvent (Ptr<AsciiWriter> writer, std::string path, Ptr<const Packet> packet); |
- |
- /* |
- * \internal |
- */ |
- 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; |