22 #include "ns3/simulator.h"
23 #include "ns3/object-factory.h"
24 #include "ns3/names.h"
25 #include "ns3/queue.h"
26 #include "ns3/emu-net-device.h"
27 #include "ns3/config.h"
28 #include "ns3/packet.h"
30 #include "ns3/trace-helper.h"
31 #include "emu-helper.h"
37 EmuHelper::EmuHelper ()
40 m_queueFactory.
SetTypeId (
"ns3::DropTailQueue");
41 m_deviceFactory.
SetTypeId (
"ns3::EmuNetDevice");
54 m_queueFactory.
Set (n1, v1);
55 m_queueFactory.
Set (n2, v2);
56 m_queueFactory.
Set (n3, v3);
57 m_queueFactory.
Set (n4, v4);
64 m_deviceFactory.
Set (n1, v1);
78 NS_LOG_INFO (
"EmuHelper::EnablePcapInternal(): Device " << device <<
" not of type ns3::EmuNetDevice");
110 bool explicitFilename)
120 NS_LOG_INFO (
"EmuHelper::EnableAsciiInternal(): Device " << device <<
" not of type ns3::EmuNetDevice");
145 std::string filename;
146 if (explicitFilename)
186 uint32_t nodeid = nd->GetNode ()->GetId ();
187 uint32_t deviceid = nd->GetIfIndex ();
188 std::ostringstream oss;
190 oss <<
"/NodeList/" << nd->GetNode ()->GetId () <<
"/DeviceList/" << deviceid <<
"/$ns3::EmuNetDevice/MacRx";
191 Config::Connect (oss.str (), MakeBoundCallback (&AsciiTraceHelper::DefaultReceiveSinkWithContext, stream));
194 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::EmuNetDevice/TxQueue/Enqueue";
195 Config::Connect (oss.str (), MakeBoundCallback (&AsciiTraceHelper::DefaultEnqueueSinkWithContext, stream));
198 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::EmuNetDevice/TxQueue/Dequeue";
199 Config::Connect (oss.str (), MakeBoundCallback (&AsciiTraceHelper::DefaultDequeueSinkWithContext, stream));
202 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::EmuNetDevice/TxQueue/Drop";
203 Config::Connect (oss.str (), MakeBoundCallback (&AsciiTraceHelper::DefaultDropSinkWithContext, stream));
215 Ptr<Node> node = Names::Find<Node> (nodeName);
224 for (NodeContainer::Iterator i = c.
Begin (); i != c.
End (); i++)
226 devs.
Add (InstallPriv (*i));
233 EmuHelper::InstallPriv (
Ptr<Node> node)
const
239 device->SetQueue (queue);
virtual void EnableAsciiInternal(Ptr< OutputStreamWrapper > stream, std::string prefix, Ptr< NetDevice > nd, bool explicitFilename)
Enable ascii trace output on the indicated net device.
Manage ASCII trace files for device models.
smart pointer class similar to boost::intrusive_ptr
Ptr< PcapFileWrapper > CreateFile(std::string filename, std::ios::openmode filemode, uint32_t dataLinkType, uint32_t snapLen=65535, int32_t tzCorrection=0)
Create and initialize a pcap file.
void HookDefaultDropSinkWithoutContext(Ptr< T > object, std::string traceName, Ptr< OutputStreamWrapper > stream)
Hook a trace source to the default drop operation trace sink that does not accept nor log a trace con...
Hold a value for an Attribute.
Manage pcap files for device models.
Ptr< Queue > GetQueue(void) const
#define NS_LOG_COMPONENT_DEFINE(name)
void SetTypeId(TypeId tid)
void SetAttribute(std::string n1, const AttributeValue &v1)
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container.
#define NS_LOG_FUNCTION_NOARGS()
Ptr< OutputStreamWrapper > CreateFileStream(std::string filename, std::ios::openmode filemode=std::ios::out)
Create and initialize an output stream object we'll use to write the traced bits. ...
void Connect(std::string path, const CallbackBase &cb)
void HookDefaultEnqueueSinkWithoutContext(Ptr< T > object, std::string traceName, Ptr< OutputStreamWrapper > stream)
Hook a trace source to the default enqueue operation trace sink that does not accept nor log a trace ...
std::string GetFilenameFromDevice(std::string prefix, Ptr< NetDevice > device, bool useObjectNames=true)
Let the ascii trace helper figure out a reasonable filename to use for an ascii trace file associated...
Abstract base class for packet Queues.
std::string GetFilenameFromDevice(std::string prefix, Ptr< NetDevice > device, bool useObjectNames=true)
Let the pcap helper figure out a reasonable filename to use for a pcap file associated with a device...
static Mac48Address Allocate(void)
static void EnablePrinting(void)
Ptr< Object > Create(void) const
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
holds a vector of ns3::NetDevice pointers
keep track of a set of node pointers.
Iterator Begin(void) const
Get an iterator which refers to the first Node in the container.
void Set(std::string name, const AttributeValue &value)
void HookDefaultReceiveSinkWithoutContext(Ptr< T > object, std::string traceName, Ptr< OutputStreamWrapper > stream)
Hook a trace source to the default receive operation trace sink that does not accept nor log a trace ...
uint32_t AddDevice(Ptr< NetDevice > device)
virtual void EnablePcapInternal(std::string prefix, Ptr< NetDevice > nd, bool promiscuous, bool explicitFilename)
Enable pcap output the indicated net device.
NetDeviceContainer Install(Ptr< Node > node) const
void SetQueue(std::string type, std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue())
A Device for an Emu Network Link.
void HookDefaultSink(Ptr< T > object, std::string traceName, Ptr< PcapFileWrapper > file)
Hook a trace source to the default trace sink.
void HookDefaultDequeueSinkWithoutContext(Ptr< T > object, std::string traceName, Ptr< OutputStreamWrapper > stream)
Hook a trace source to the default dequeue operation trace sink that does not accept nor log a trace ...