Loading...
Searching...
No Matches
satellite-performance-memory-test.cc
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2013 Magister Solutions Ltd
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Sami Rantanen <sami.rantanen@magister.fi>
19 */
20
30
31#include "ns3/cbr-application.h"
32#include "ns3/cbr-helper.h"
33#include "ns3/config.h"
34#include "ns3/enum.h"
35#include "ns3/log.h"
36#include "ns3/packet-sink-helper.h"
37#include "ns3/packet-sink.h"
38#include "ns3/satellite-env-variables.h"
39#include "ns3/satellite-helper.h"
40#include "ns3/satellite-topology.h"
41#include "ns3/simulator.h"
42#include "ns3/singleton.h"
43#include "ns3/string.h"
44#include "ns3/test.h"
45
46using namespace ns3;
47
68class Pm1 : public TestCase
69{
70 public:
71 Pm1();
72 virtual ~Pm1();
73
74 private:
75 virtual void DoRun(void);
76};
77
78// Add some help text to this case to describe what it is intended to test
80 : TestCase("'Performance and memory tracking' tests servers as follow-up test for performance "
81 "and memory usage.")
82{
83}
84
85// This destructor does nothing but we include it as a reminder that
86// the test case should clean up after itself
88{
89}
90
91//
92// Pm1 TestCase implementation
93//
94void
96{
97 // Set simulation output details
98 SatEnvVariables::GetInstance()->DoInitialize();
99 SatEnvVariables::GetInstance()->SetOutputVariables("test-sat-perf-mem", "", true);
100
101 // Create simple scenario
102
103 // Configure a static error probability
105 Config::SetDefault("ns3::SatUtHelper::FwdLinkErrorModel", EnumValue(em));
106 Config::SetDefault("ns3::SatGwHelper::RtnLinkErrorModel", EnumValue(em));
107
108 // Creating the reference system.
109 Ptr<SatHelper> helper = CreateObject<SatHelper>(
110 SatEnvVariables::GetInstance()->LocateDataDirectory() + "/scenarios/geo-33E");
111 helper->CreatePredefinedScenario(SatHelper::FULL);
112
113 NodeContainer gwUsers = Singleton<SatTopology>::Get()->GetGwUserNodes();
114 NodeContainer utUsers = Singleton<SatTopology>::Get()->GetUtUserNodes();
115
116 uint16_t port = 9; // Discard port (RFC 863)
117 CbrHelper cbr("ns3::UdpSocketFactory",
118 Address(InetSocketAddress(helper->GetUserAddress(gwUsers.Get(0)), port)));
119 cbr.SetAttribute("Interval", StringValue("0.8s"));
120
121 // Create a packet sink to receive packet and a Cbr to sent packet in UT
122 PacketSinkHelper sink("ns3::UdpSocketFactory",
123 Address(InetSocketAddress(helper->GetUserAddress(utUsers.Get(0)), port)));
124
125 ApplicationContainer utApps = sink.Install(utUsers.Get(0));
126 utApps.Add(cbr.Install(utUsers.Get(0)));
127 utApps.Start(Seconds(1.0));
128 utApps.Stop(Seconds(2.5));
129
130 // Create a packet sink to receive packet and a Cbr to sent packet in GW
131 sink.SetAttribute(
132 "Local",
133 AddressValue(Address(InetSocketAddress(helper->GetUserAddress(gwUsers.Get(0)), port))));
134 cbr.SetAttribute(
135 "Remote",
136 AddressValue(Address(InetSocketAddress(helper->GetUserAddress(utUsers.Get(0)), port))));
137
138 ApplicationContainer gwApps = sink.Install(gwUsers.Get(0));
139 gwApps.Add(cbr.Install(gwUsers.Get(0)));
140
141 gwApps.Start(Seconds(1.0));
142 gwApps.Stop(Seconds(2.5));
143
144 Simulator::Stop(Seconds(2.5));
145 Simulator::Run();
146
147 Simulator::Destroy();
148
149 Ptr<PacketSink> utReceiver = DynamicCast<PacketSink>(utApps.Get(0));
150 Ptr<CbrApplication> utSender = DynamicCast<CbrApplication>(utApps.Get(1));
151
152 Ptr<PacketSink> gwReceiver = DynamicCast<PacketSink>(gwApps.Get(0));
153 Ptr<CbrApplication> gwSender = DynamicCast<CbrApplication>(gwApps.Get(1));
154
155 // here we check that results are as expected.
156 // * Sender has sent something
157 // * Receiver got all all data sent
158 NS_TEST_ASSERT_MSG_NE(utSender->GetSent(), (uint32_t)0, "Nothing sent by UT user!");
159 NS_TEST_ASSERT_MSG_EQ(gwReceiver->GetTotalRx(),
160 utSender->GetSent(),
161 "Packets were lost between UT and GW!");
162
163 NS_TEST_ASSERT_MSG_NE(gwSender->GetSent(), (uint32_t)0, "Nothing sent by GW user!");
164 NS_TEST_ASSERT_MSG_EQ(utReceiver->GetTotalRx(),
165 gwSender->GetSent(),
166 "Packets were lost between GW and UT!");
167
168 SatEnvVariables::GetInstance()->DoDispose();
169 // <<< End of actual test using Simple scenario <<<
170}
171
172// The TestSuite class names the TestSuite as sat-perf-mem, identifies what type of TestSuite
173// (Type::SYSTEM), and enables the TestCases to be run. Typically, only the constructor for this
174// class must be defined
175//
176class PerfMemTestSuite : public TestSuite
177{
178 public:
180};
181
183 : TestSuite("sat-perf-mem", Type::SYSTEM)
184{
185 // add pm-1 case to suite sat-perf-mem
186 AddTestCase(new Pm1, TestCase::Duration::QUICK);
187}
188
189// Allocate an instance of this TestSuite
'Performance and memory tracking' test case implementation, id: pm-1 / TN4.
virtual void DoRun(void)
static Ptr< SatEnvVariables > GetInstance()
@ FULL
FULL Full scenario used as base.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
static PerfMemTestSuite perfMemSuite