A Discrete-Event Network Simulator
main-simple.cc File Reference
#include <iostream>
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/internet-module.h"
+ Include dependency graph for main-simple.cc:

Go to the source code of this file.


static void GenerateTraffic (Ptr< Socket > socket, int32_t size)
 Generates traffic. More...
static void SocketPrinter (Ptr< Socket > socket)
 Prints the packets received by a socket. More...

Detailed Description


$ ./ns3 run "main-simple"

Definition in file main-simple.cc.

Function Documentation

◆ GenerateTraffic()

static void GenerateTraffic ( Ptr< Socket socket,
int32_t  size 

Generates traffic.

The first call sends a packet of the specified size, and then the function is scheduled to send a packet of (size-50) after 0.5s. The process is iterated until the packet size is zero.

socketoutput socket
sizepacket size

Definition at line 40 of file main-simple.cc.

References ns3::Socket::Close(), GenerateTraffic(), ns3::Time::GetSeconds(), ns3::Now(), ns3::Seconds(), and ns3::Socket::Send().

Referenced by GenerateTraffic().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SocketPrinter()

static void SocketPrinter ( Ptr< Socket socket)

Prints the packets received by a socket.

socketinput socket

Definition at line 58 of file main-simple.cc.

References ns3::Time::GetSeconds(), ns3::Packet::GetSize(), ns3::Now(), and ns3::Socket::Recv().

+ Here is the call graph for this function: