18 #include "ns3/core-module.h"
19 #include "ns3/network-module.h"
20 #include "ns3/internet-module.h"
21 #include "ns3/point-to-point-module.h"
22 #include "ns3/applications-module.h"
84 uint32_t m_packetSize;
89 uint32_t m_packetsSent;
114 .SetGroupName (
"Tutorial")
115 .AddConstructor<
MyApp> ()
193 main (
int argc,
char *argv[])
196 cmd.Parse (argc, argv);
216 address.SetBase (
"10.1.1.0",
"255.255.255.252");
219 uint16_t sinkPort = 8080;
226 Ptr<Socket> ns3TcpSocket = Socket::CreateSocket (
nodes.Get (0), TcpSocketFactory::GetTypeId ());
229 app->Setup (ns3TcpSocket, sinkAddress, 1040, 1000,
DataRate (
"1Mbps"));
230 nodes.Get (0)->AddApplication (app);
231 app->SetStartTime (
Seconds (1.));
232 app->SetStopTime (
Seconds (20.));
242 Simulator::Stop (
Seconds (20));
244 Simulator::Destroy ();
void Setup(Ptr< Socket > socket, Address address, uint32_t packetSize, uint32_t nPackets, DataRate dataRate)
static TypeId GetTypeId(void)
Register this type.
virtual void StopApplication(void)
Application specific shutdown code.
virtual void StopApplication(void)
Application specific shutdown code.
virtual void StartApplication(void)
Application specific startup code.
static TypeId GetTypeId(void)
Register this type.
virtual void StartApplication(void)
Application specific startup code.
a polymophic address class
holds a vector of ns3::Application pointers.
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter.
void Stop(Time stop)
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter.
The base class for all ns3 applications.
Manage ASCII trace files for device models.
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.
Parse command-line arguments.
Class for representing data rates.
uint64_t GetBitRate() const
Get the underlying bitrate.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
An identifier for simulation events.
bool IsRunning(void) const
This method is syntactic sugar for !IsExpired().
aggregate IP/TCP/UDP functionality to existing Nodes.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
holds a vector of std::pair of Ptr<Ipv4> and interface index.
holds a vector of ns3::NetDevice pointers
keep track of a set of node pointers.
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
std::ostream * GetStream(void)
Return a pointer to an ostream previously set in the wrapper.
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes.
Manage pcap files for device models.
Ptr< PcapFileWrapper > CreateFile(std::string filename, std::ios::openmode filemode, DataLinkType dataLinkType, uint32_t snapLen=std::numeric_limits< uint32_t >::max(), int32_t tzCorrection=0)
Create and initialize a pcap file.
Build a set of PointToPointNetDevice objects.
Hold objects of type Ptr<T>.
virtual int Send(Ptr< Packet > p, uint32_t flags)=0
Send data (or dummy data) to the remote host.
virtual int Connect(const Address &address)=0
Initiate a connection to a remote host.
virtual int Close(void)=0
Close a socket.
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
Hold variables of type string.
Simulation virtual time values and global simulation resolution.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
#define NS_LOG_UNCOND(msg)
Output the requested message unconditionally.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument.
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static void CwndChange(Ptr< OutputStreamWrapper > stream, uint32_t oldCwnd, uint32_t newCwnd)
static void RxDrop(Ptr< PcapFileWrapper > file, Ptr< const Packet > p)
static const uint32_t packetSize