Loading...
Searching...
No Matches
satellite-arq-seqno-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: Jani Puttonen <jani.puttonen@magister.fi>
19 */
20
26
29
30#include "ns3/log.h"
31#include "ns3/ptr.h"
32#include "ns3/singleton.h"
33#include "ns3/test.h"
34
35#include <deque>
36#include <vector>
37
38using namespace ns3;
39
45class SatSeqNoTestCase : public TestCase
46{
47 public:
49 virtual ~SatSeqNoTestCase();
50
51 private:
52 virtual void DoRun(void);
53};
54
56 : TestCase("Test ARQ sequence numbers.")
57{
58}
59
63
64void
66{
67 // Set simulation output details
68 SatEnvVariables::GetInstance()->DoInitialize();
69 SatEnvVariables::GetInstance()->SetOutputVariables("test-sat-arq-seqno", "", true);
70
71 uint32_t windowSize(10);
72 Ptr<SatArqSequenceNumber> seqNo = Create<SatArqSequenceNumber>(windowSize);
73
74 std::deque<uint32_t> seqNoWindow;
75 std::vector<uint32_t> allSeqNos;
76
77 for (uint32_t i = 0; i < 550; ++i)
78 {
79 if (seqNo->SeqNoAvailable())
80 {
81 uint32_t sn = uint32_t(seqNo->NextSequenceNumber());
82 allSeqNos.push_back(sn);
83 seqNoWindow.push_back(sn);
84 }
85 else
86 {
87 uint32_t oldest = seqNoWindow.front();
88 seqNo->Release(oldest);
89 seqNoWindow.pop_front();
90 }
91 }
92
93 for (uint32_t i = 0; i < allSeqNos.size(); ++i)
94 {
95 std::cout << "SN: " << allSeqNos[i] << std::endl;
96 }
97
98 SatEnvVariables::GetInstance()->DoDispose();
99}
100
105class SatArqSeqNoTraceSuite : public TestSuite
106{
107 public:
109};
110
112 : TestSuite("sat-arq-seqno-test", Type::UNIT)
113{
114 AddTestCase(new SatSeqNoTestCase, TestCase::Duration::QUICK);
115}
116
117// Do allocate an instance of this TestSuite
static Ptr< SatEnvVariables > GetInstance()
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
static SatArqSeqNoTraceSuite SatSeqNoTestSuite