A Discrete-Event Network Simulator
QKDNetSim v2.0 (NS-3 v3.41) @ (+)
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Main Page
Related Pages
Modules
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
Functions
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
y
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
Typedefs
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
Enumerations
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
v
w
Enumerator
a
b
c
d
e
f
h
i
l
m
n
o
p
q
r
s
t
u
v
w
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
:
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
Enumerations
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
Enumerator
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Properties
Related Functions
:
a
b
c
d
e
g
h
i
j
l
m
n
o
p
q
r
s
t
u
w
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
v
w
Variables
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
Enumerations
Enumerator
c
e
i
l
o
r
s
t
v
Macros
_
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
u
v
w
Examples
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Modules
Pages
first.cc
Go to the documentation of this file.
1
/*
2
* This program is free software; you can redistribute it and/or modify
3
* it under the terms of the GNU General Public License version 2 as
4
* published by the Free Software Foundation;
5
*
6
* This program is distributed in the hope that it will be useful,
7
* but WITHOUT ANY WARRANTY; without even the implied warranty of
8
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9
* GNU General Public License for more details.
10
*
11
* You should have received a copy of the GNU General Public License
12
* along with this program; if not, write to the Free Software
13
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14
*/
15
16
#include "ns3/applications-module.h"
17
#include "ns3/core-module.h"
18
#include "ns3/internet-module.h"
19
#include "ns3/network-module.h"
20
#include "ns3/point-to-point-module.h"
21
22
// Default Network Topology
23
//
24
// 10.1.1.0
25
// n0 -------------- n1
26
// point-to-point
27
//
28
29
using namespace
ns3
;
30
31
NS_LOG_COMPONENT_DEFINE
(
"FirstScriptExample"
);
32
33
int
34
main(
int
argc,
char
* argv[])
35
{
36
CommandLine
cmd
(__FILE__);
37
cmd
.Parse(argc, argv);
38
39
Time::SetResolution
(
Time::NS
);
40
LogComponentEnable
(
"UdpEchoClientApplication"
,
LOG_LEVEL_INFO
);
41
LogComponentEnable
(
"UdpEchoServerApplication"
,
LOG_LEVEL_INFO
);
42
43
NodeContainer
nodes
;
44
nodes
.
Create
(2);
45
46
PointToPointHelper
pointToPoint
;
47
pointToPoint
.SetDeviceAttribute(
"DataRate"
,
StringValue
(
"5Mbps"
));
48
pointToPoint
.SetChannelAttribute(
"Delay"
,
StringValue
(
"2ms"
));
49
50
NetDeviceContainer
devices
;
51
devices
=
pointToPoint
.Install(
nodes
);
52
53
InternetStackHelper
stack
;
54
stack
.Install(
nodes
);
55
56
Ipv4AddressHelper
address
;
57
address
.SetBase(
"10.1.1.0"
,
"255.255.255.0"
);
58
59
Ipv4InterfaceContainer
interfaces
=
address
.Assign(
devices
);
60
61
UdpEchoServerHelper
echoServer
(9);
62
63
ApplicationContainer
serverApps
=
echoServer
.Install(
nodes
.
Get
(1));
64
serverApps
.Start(
Seconds
(1.0));
65
serverApps
.Stop(
Seconds
(10.0));
66
67
UdpEchoClientHelper
echoClient
(
interfaces
.GetAddress(1), 9);
68
echoClient
.SetAttribute(
"MaxPackets"
,
UintegerValue
(1));
69
echoClient
.SetAttribute(
"Interval"
,
TimeValue
(
Seconds
(1.0)));
70
echoClient
.SetAttribute(
"PacketSize"
,
UintegerValue
(1024));
71
72
ApplicationContainer
clientApps
=
echoClient
.Install(
nodes
.
Get
(0));
73
clientApps
.Start(
Seconds
(2.0));
74
clientApps
.Stop(
Seconds
(10.0));
75
76
Simulator::Run
();
77
Simulator::Destroy
();
78
return
0;
79
}
ns3::ApplicationContainer
holds a vector of ns3::Application pointers.
Definition:
application-container.h:44
ns3::CommandLine
Parse command-line arguments.
Definition:
command-line.h:232
ns3::InternetStackHelper
aggregate IP/TCP/UDP functionality to existing Nodes.
Definition:
internet-stack-helper.h:92
ns3::Ipv4AddressHelper
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
Definition:
ipv4-address-helper.h:49
ns3::Ipv4InterfaceContainer
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Definition:
ipv4-interface-container.h:56
ns3::NetDeviceContainer
holds a vector of ns3::NetDevice pointers
Definition:
net-device-container.h:43
ns3::NodeContainer
keep track of a set of node pointers.
Definition:
node-container.h:40
ns3::NodeContainer::Create
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Definition:
node-container.cc:84
ns3::NodeContainer::Get
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
Definition:
node-container.cc:78
ns3::PointToPointHelper
Build a set of PointToPointNetDevice objects.
Definition:
point-to-point-helper.h:44
ns3::Simulator::Destroy
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition:
simulator.cc:142
ns3::Simulator::Run
static void Run()
Run the simulation.
Definition:
simulator.cc:178
ns3::StringValue
Hold variables of type string.
Definition:
string.h:56
ns3::Time::NS
@ NS
nanosecond
Definition:
nstime.h:119
ns3::Time::SetResolution
static void SetResolution(Unit resolution)
Definition:
time.cc:213
ns3::TimeValue
Definition:
nstime.h:1413
ns3::UdpEchoClientHelper
Create an application which sends a UDP packet and waits for an echo of this packet.
Definition:
udp-echo-helper.h:108
ns3::UdpEchoServerHelper
Create a server application which waits for input UDP packets and sends them back to the original sen...
Definition:
udp-echo-helper.h:39
ns3::UintegerValue
Hold an unsigned integer type.
Definition:
uinteger.h:45
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:202
ns3::Seconds
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition:
nstime.h:1326
nodes
NodeContainer nodes
Definition:
lr-wpan-bootstrap.cc:53
first.echoClient
echoClient
Definition:
first.py:59
first.address
address
Definition:
first.py:47
first.serverApps
serverApps
Definition:
first.py:54
first.pointToPoint
pointToPoint
Definition:
first.py:38
first.echoServer
echoServer
Definition:
first.py:52
first.clientApps
clientApps
Definition:
first.py:64
first.devices
devices
Definition:
first.py:42
first.stack
stack
Definition:
first.py:44
first.interfaces
interfaces
Definition:
first.py:50
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::LogComponentEnable
void LogComponentEnable(const std::string &name, LogLevel level)
Enable the logging output associated with that log component.
Definition:
log.cc:302
ns3::LOG_LEVEL_INFO
@ LOG_LEVEL_INFO
LOG_INFO and above.
Definition:
log.h:104
second.cmd
cmd
Definition:
second.py:40
examples
tutorial
first.cc
Generated on Sun Mar 3 2024 17:10:52 for ns-3 by
1.9.1