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
internet-stack-helper-test-suite.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2023 Universita' di Firenze
3
*
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 2 as
6
* published by the Free Software Foundation;
7
*
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
12
*
13
* You should have received a copy of the GNU General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
*
17
* Author: Tommaso Pecorella <tommaso.pecorella@unifi.it>
18
*/
19
20
#include "ns3/internet-stack-helper.h"
21
#include "ns3/log.h"
22
#include "ns3/node.h"
23
#include "ns3/test.h"
24
25
#include <string>
26
27
using namespace
ns3
;
28
29
NS_LOG_COMPONENT_DEFINE
(
"InternetStackHelperTestSuite"
);
30
36
class
InternetStackHelperTestCase
:
public
TestCase
37
{
38
public
:
39
InternetStackHelperTestCase
();
40
41
private
:
42
void
DoRun()
override
;
43
void
DoTeardown()
override
;
44
};
45
46
InternetStackHelperTestCase::InternetStackHelperTestCase
()
47
:
TestCase
(
"InternetStackHelperTestCase"
)
48
{
49
}
50
51
void
52
InternetStackHelperTestCase::DoRun
()
53
{
54
// Checks:
55
// 1. IPv4 only, add IPv4 + IPv6 (result, IPv4 + IPv6)
56
// 2. IPv6 only, add IPv4 + IPv6 (result, IPv4 + IPv6)
57
// 3. IPv4 + IPv6, add IPv4 + IPv6 (result, IPv4 + IPv6)
58
59
Ptr<Node>
nodeIpv4Only = CreateObject<Node>();
60
Ptr<Node>
nodeIpv6Only = CreateObject<Node>();
61
Ptr<Node>
nodeIpv46 = CreateObject<Node>();
62
63
InternetStackHelper
internet
;
64
65
internet
.SetIpv4StackInstall(
true
);
66
internet
.SetIpv6StackInstall(
false
);
67
internet
.Install(nodeIpv4Only);
68
69
internet
.SetIpv4StackInstall(
false
);
70
internet
.SetIpv6StackInstall(
true
);
71
internet
.Install(nodeIpv6Only);
72
73
internet
.SetIpv4StackInstall(
true
);
74
internet
.SetIpv6StackInstall(
true
);
75
internet
.Install(nodeIpv46);
76
77
// Check that the three nodes have only the intended IP stack.
78
NS_TEST_EXPECT_MSG_NE
(nodeIpv4Only->
GetObject
<
Ipv4
>(),
79
nullptr
,
80
"IPv4 not found on IPv4-only node (should have been there)"
);
81
NS_TEST_EXPECT_MSG_EQ
(nodeIpv4Only->
GetObject
<
Ipv6
>(),
82
nullptr
,
83
"IPv6 found on IPv4-only node (should not have been there)"
);
84
85
NS_TEST_EXPECT_MSG_EQ
(nodeIpv6Only->
GetObject
<
Ipv4
>(),
86
nullptr
,
87
"IPv4 found on IPv6-only node (should not have been there)"
);
88
NS_TEST_EXPECT_MSG_NE
(nodeIpv6Only->
GetObject
<
Ipv6
>(),
89
nullptr
,
90
"IPv6 not found on IPv6-only node (should have been there)"
);
91
92
NS_TEST_EXPECT_MSG_NE
(nodeIpv46->
GetObject
<
Ipv4
>(),
93
nullptr
,
94
"IPv4 not found on dual stack node (should have been there)"
);
95
NS_TEST_EXPECT_MSG_NE
(nodeIpv46->
GetObject
<
Ipv6
>(),
96
nullptr
,
97
"IPv6 not found on dual stack node (should have been there)"
);
98
99
// Now we install IPv4 and IPv6 on the IPv4-only node
100
// IPv4 is already there, no error should happen.
101
internet
.Install(nodeIpv4Only);
102
// Now we install IPv4 and IPv6 on the IPv6-only node,
103
// IPv6 is already there, no error should happen.
104
internet
.Install(nodeIpv6Only);
105
// Now we install IPv4 and IPv6 on the dual stack node
106
// IPv4 and IPv6 are already there, no error should happen.
107
internet
.Install(nodeIpv46);
108
109
// Check that the three nodes have both IPv4 and IPv6.
110
NS_TEST_EXPECT_MSG_NE
(
111
nodeIpv4Only->
GetObject
<
Ipv4
>(),
112
nullptr
,
113
"IPv4 not found on IPv4-only, now dual stack node (should have been there)"
);
114
NS_TEST_EXPECT_MSG_NE
(
115
nodeIpv4Only->
GetObject
<
Ipv6
>(),
116
nullptr
,
117
"IPv6 not found on IPv4-only, now dual stack node (should have been there)"
);
118
119
NS_TEST_EXPECT_MSG_NE
(
120
nodeIpv6Only->
GetObject
<
Ipv4
>(),
121
nullptr
,
122
"IPv4 not found on IPv6-only, now dual stack node (should have been there)"
);
123
NS_TEST_EXPECT_MSG_NE
(
124
nodeIpv6Only->
GetObject
<
Ipv6
>(),
125
nullptr
,
126
"IPv6 not found on IPv6-only, now dual stack node (should have been there)"
);
127
128
NS_TEST_EXPECT_MSG_NE
(nodeIpv46->
GetObject
<
Ipv4
>(),
129
nullptr
,
130
"IPv4 not found on dual stack node (should have been there)"
);
131
NS_TEST_EXPECT_MSG_NE
(nodeIpv46->
GetObject
<
Ipv6
>(),
132
nullptr
,
133
"IPv6 not found on dual stack node (should have been there)"
);
134
}
135
136
void
137
InternetStackHelperTestCase::DoTeardown
()
138
{
139
Simulator::Destroy();
140
}
141
147
class
InternetStackHelperTestSuite
:
public
TestSuite
148
{
149
public
:
150
InternetStackHelperTestSuite
()
151
:
TestSuite
(
"internet-stack-helper"
,
UNIT
)
152
{
153
AddTestCase
(
new
InternetStackHelperTestCase
(), TestCase::QUICK);
154
}
155
};
156
157
static
InternetStackHelperTestSuite
158
g_internetStackHelperTestSuite
;
InternetStackHelperTestCase
InternetStackHelper Test.
Definition:
internet-stack-helper-test-suite.cc:37
InternetStackHelperTestCase::DoTeardown
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
Definition:
internet-stack-helper-test-suite.cc:137
InternetStackHelperTestCase::InternetStackHelperTestCase
InternetStackHelperTestCase()
Definition:
internet-stack-helper-test-suite.cc:46
InternetStackHelperTestCase::DoRun
void DoRun() override
Implementation to actually run this TestCase.
Definition:
internet-stack-helper-test-suite.cc:52
InternetStackHelperTestSuite
InternetStackHelper TestSuite.
Definition:
internet-stack-helper-test-suite.cc:148
InternetStackHelperTestSuite::InternetStackHelperTestSuite
InternetStackHelperTestSuite()
Definition:
internet-stack-helper-test-suite.cc:150
ns3::InternetStackHelper
aggregate IP/TCP/UDP functionality to existing Nodes.
Definition:
internet-stack-helper.h:92
ns3::Ipv4
Access to the IPv4 forwarding table, interfaces, and configuration.
Definition:
ipv4.h:80
ns3::Ipv6
Access to the IPv6 forwarding table, interfaces, and configuration.
Definition:
ipv6.h:82
ns3::Object::GetObject
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Definition:
object.h:471
ns3::Ptr< Node >
ns3::TestCase
encapsulates test code
Definition:
test.h:1060
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition:
test.cc:301
ns3::TestSuite
A suite of tests to run.
Definition:
test.h:1256
ns3::TestSuite::UNIT
@ UNIT
This test suite implements a Unit Test.
Definition:
test.h:1265
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:202
NS_TEST_EXPECT_MSG_NE
#define NS_TEST_EXPECT_MSG_NE(actual, limit, msg)
Test that an actual and expected (limit) value are not equal and report if not.
Definition:
test.h:666
NS_TEST_EXPECT_MSG_EQ
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Definition:
test.h:251
g_internetStackHelperTestSuite
static InternetStackHelperTestSuite g_internetStackHelperTestSuite
Static variable for test initialization.
Definition:
internet-stack-helper-test-suite.cc:158
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
nsclick-simple-lan.internet
internet
Definition:
nsclick-simple-lan.py:45
src
internet
test
internet-stack-helper-test-suite.cc
Generated on Sun Mar 3 2024 17:10:59 for ns-3 by
1.9.1