35 #include "ns3/core-module.h"
36 #include "ns3/network-module.h"
37 #include "ns3/csma-module.h"
38 #include "ns3/applications-module.h"
49 g_os << p->
GetSize () << std::endl;
53 main (
int argc,
char *argv[])
60 cmd.
Parse (argc, argv);
62 g_os.open (
"csma-packet-socket-sink.tr",std::ios_base::binary | std::ios_base::out);
87 socket.SetSingleDevice (devs.
Get (0)->GetIfIndex ());
88 socket.SetPhysicalAddress (devs.
Get (1)->GetAddress ());
89 socket.SetProtocol (2);
91 onoff.SetConstantRate (
DataRate (
"500kb/s"));
96 socket.SetSingleDevice (devs.
Get (3)->GetIfIndex ());
97 socket.SetPhysicalAddress (devs.
Get (0)->GetAddress ());
98 socket.SetProtocol (3);
100 apps = onoff.Install (nodes.
Get (3));
holds a vector of ns3::Application pointers.
Manage ASCII trace files for device models.
hold variables of type string
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
an address for a packet socket
#define NS_LOG_COMPONENT_DEFINE(name)
uint32_t GetSize(void) const
NetDeviceContainer Install(Ptr< Node > node) const
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes...
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)
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
Give ns3::PacketSocket powers to ns3::Node.
a polymophic address class
Class for representing data rates.
hold objects of type ns3::Time
holds a vector of ns3::NetDevice pointers
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter...
parse command-line argumentsInstances of this class can be used to parse command-line arguments: user...
static void Destroy(void)
keep track of a set of node pointers.
void Install(Ptr< Node > node) const
build a set of CsmaNetDevice objects
void SetDeviceAttribute(std::string n1, const AttributeValue &v1)
hold objects of type ns3::Address
void Stop(Time stop)
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter...
Time Seconds(double seconds)
create ns3::Time instances in units of seconds.
hold objects of type ns3::DataRate
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
void Parse(int argc, char *argv[]) const
ApplicationContainer Install(NodeContainer c) const
Time MilliSeconds(uint64_t ms)
create ns3::Time instances in units of milliseconds.
void EnableAsciiAll(std::string prefix)
Enable ascii trace output on each device (which is of the appropriate type) in the set of all nodes c...
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
void LogComponentEnable(char const *name, enum LogLevel level)