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" 23 #include "ns3/stats-module.h" 73 static TypeId GetTypeId (
void);
77 virtual void StartApplication (
void);
78 virtual void StopApplication (
void);
80 void ScheduleTx (
void);
85 uint32_t m_packetSize;
90 uint32_t m_packetsSent;
115 .SetGroupName (
"Tutorial")
116 .AddConstructor<
MyApp> ()
136 if (InetSocketAddress::IsMatchingType (
m_peer))
201 main (
int argc,
char *argv[])
206 cmd.AddValue (
"useIpv6",
"Use Ipv6", useV6);
207 cmd.Parse (argc, argv);
226 uint16_t sinkPort = 8080;
229 std::string probeType;
230 std::string tracePath;
234 address.SetBase (
"10.1.1.0",
"255.255.255.0");
238 probeType =
"ns3::Ipv4PacketProbe";
239 tracePath =
"/NodeList/*/$ns3::Ipv4L3Protocol/Tx";
248 probeType =
"ns3::Ipv6PacketProbe";
249 tracePath =
"/NodeList/*/$ns3::Ipv6L3Protocol/Tx";
257 Ptr<Socket> ns3TcpSocket = Socket::CreateSocket (
nodes.Get (0), TcpSocketFactory::GetTypeId ());
260 app->Setup (ns3TcpSocket, sinkAddress, 1040, 1000,
DataRate (
"1Mbps"));
261 nodes.Get (0)->AddApplication (app);
262 app->SetStartTime (
Seconds (1.));
263 app->SetStopTime (
Seconds (20.));
280 "Packet Byte Count vs. Time",
282 "Packet Byte Count");
292 GnuplotAggregator::KEY_BELOW);
299 FileAggregator::FORMATTED);
302 fileHelper.
Set2dFormat (
"Time (Seconds) = %.3e\tPacket Byte Count = %.0f");
310 Simulator::Stop (
Seconds (20));
312 Simulator::Destroy ();
holds a vector of ns3::Application pointers.
Simulation virtual time values and global simulation resolution.
Manage ASCII trace files for device models.
Keep track of a set of IPv6 interfaces.
holds a vector of std::pair of Ptr<Ipv4> and interface index.
virtual int Bind6()=0
Allocate a local IPv6 endpoint for this socket.
Hold variables of type string.
void PlotProbe(const std::string &typeId, const std::string &path, const std::string &probeTraceSource, const std::string &title, enum GnuplotAggregator::KeyLocation keyLocation=GnuplotAggregator::KEY_INSIDE)
Manage pcap files for device models.
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
aggregate IP/TCP/UDP functionality to existing Nodes.
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. ...
Build a set of PointToPointNetDevice objects.
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.
uint64_t GetBitRate() const
Get the underlying bitrate.
a polymophic address class
static void CwndChange(Ptr< OutputStreamWrapper > stream, uint32_t oldCwnd, uint32_t newCwnd)
Class for representing data rates.
void ConfigurePlot(const std::string &outputFileNameWithoutExtension, const std::string &title, const std::string &xLegend, const std::string &yLegend, const std::string &terminalType="png")
void Setup(Ptr< Socket > socket, Address address, uint32_t packetSize, uint32_t nPackets, DataRate dataRate)
The base class for all ns3 applications.
holds a vector of ns3::NetDevice pointers
Helper class used to put data values into a file.
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 arguments.
virtual int Connect(const Address &address)=0
Initiate a connection to a remote host.
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
Helper class used to make gnuplot plots.
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
Hold objects of type Ptr<T>.
#define NS_LOG_UNCOND(msg)
Output the requested message unconditionally.
void ConfigureFile(const std::string &outputFileNameWithoutExtension, enum FileAggregator::FileType fileType=FileAggregator::SPACE_SEPARATED)
virtual void StopApplication(void)
Application specific shutdown code.
virtual void StartApplication(void)
Application specific startup code.
void SendPacket(Ptr< NetDevice > sourceDevice, Address &destination)
This example (inspired from tv-trans-example) enables to generate the transmitted spectra of Wi-Fi st...
Helper class to auto-assign global IPv6 unicast addresses.
void Stop(Time stop)
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter...
An identifier for simulation events.
static TypeId GetTypeId(void)
Register this type.
Time Seconds(double value)
Construct a Time in the indicated unit.
bool IsRunning(void) const
This method is syntactic sugar for !IsExpired().
Describes an IPv6 prefix.
void WriteProbe(const std::string &typeId, const std::string &path, const std::string &probeTraceSource)
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
static const uint32_t packetSize
virtual int Send(Ptr< Packet > p, uint32_t flags)=0
Send data (or dummy data) to the remote host.
virtual int Close(void)=0
Close a socket.
This class can be used to hold variables of floating point type such as 'double' or 'float'...
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
static void RxDrop(Ptr< PcapFileWrapper > file, Ptr< const Packet > p)
std::ostream * GetStream(void)
Return a pointer to an ostream previously set in the wrapper.
void Set2dFormat(const std::string &format)
Sets the 2D format string for the C-style sprintf() function.