A Discrete-Event Network Simulator
API
lte-rlc-sequence-number.h
Go to the documentation of this file.
1/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
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: Manuel Requena <manuel.requena@cttc.es>
19 */
20
21#ifndef LTE_RLC_SEQUENCE_NUMBER_H
22#define LTE_RLC_SEQUENCE_NUMBER_H
23
24#include <ns3/assert.h>
25
26#include <limits>
27#include <iostream>
28#include <stdint.h>
29
30// #include "ns3/lte-rlc.h"
31
32namespace ns3 {
33
34
37{
38public:
40 : m_value (0),
42 {}
43
49 explicit SequenceNumber10 (uint16_t value)
50 : m_value (value % 1024),
52 {}
53
60 : m_value (value.m_value),
62 {}
63
71 {
72 m_value = value % 1024;
73 return *this;
74 }
75
76
81 uint16_t GetValue () const
82 {
83 return m_value;
84 }
85
91 {
92 m_modulusBase = modulusBase.m_value;
93 }
94
99 void SetModulusBase (uint16_t modulusBase)
100 {
101 m_modulusBase = modulusBase;
102 }
103
109 {
110 SequenceNumber10 retval (m_value);
111 m_value = ((uint32_t)m_value + 1) % 1024;
113 return retval;
114 }
115
121 SequenceNumber10 operator + (uint16_t delta) const
122 {
123 SequenceNumber10 ret ((m_value + delta) % 1024);
125 return ret;
126 }
127
133 SequenceNumber10 operator - (uint16_t delta) const
134 {
135 SequenceNumber10 ret ((m_value - delta) % 1024);
137 return ret;
138 }
139
145 uint16_t operator - (const SequenceNumber10 &other) const
146 {
147 uint16_t diff = m_value - other.m_value;
148 return (diff);
149 }
150
156 bool operator > (const SequenceNumber10 &other) const
157 {
159 uint16_t v1 = (m_value - m_modulusBase) % 1024;
160 uint16_t v2 = (other.m_value - other.m_modulusBase) % 1024;
161 return v1 > v2;
162 }
163
169 bool operator == (const SequenceNumber10 &other) const
170 {
171 return (m_value == other.m_value);
172 }
173
179 bool operator != (const SequenceNumber10 &other) const
180 {
181 return (m_value != other.m_value);
182 }
183
189 bool operator <= (const SequenceNumber10 &other) const
190 {
191 return (!this->operator> (other));
192 }
193
199 bool operator >= (const SequenceNumber10 &other) const
200 {
201 return (this->operator> (other) || this->operator== (other));
202 }
203
209 bool operator < (const SequenceNumber10 &other) const
210 {
211 return !this->operator> (other) && m_value != other.m_value;
212 }
213
214
215 friend std::ostream & operator<< (std::ostream& os, const SequenceNumber10 &val);
216
217private:
218 uint16_t m_value;
219 uint16_t m_modulusBase;
220};
221
222
223} // namespace ns3
224
225#endif // LTE_RLC_SEQUENCE_NUMBER_H
SequenceNumber10 class.
uint16_t m_modulusBase
the modulus base
bool operator==(const SequenceNumber10 &other) const
equality operator
SequenceNumber10(SequenceNumber10 const &value)
Constructor.
bool operator<(const SequenceNumber10 &other) const
less than operator
void SetModulusBase(uint16_t modulusBase)
Set modulus base.
uint16_t GetValue() const
Extracts the numeric value of the sequence number.
bool operator!=(const SequenceNumber10 &other) const
inequality operator
SequenceNumber10(uint16_t value)
Constructor.
SequenceNumber10 operator+(uint16_t delta) const
addition operator
SequenceNumber10 operator-(uint16_t delta) const
subtraction operator
SequenceNumber10 & operator=(uint16_t value)
Assignment operator.
SequenceNumber10 operator++(int)
postfix ++ operator
bool operator>=(const SequenceNumber10 &other) const
greater than or equal operator
bool operator>(const SequenceNumber10 &other) const
greater than operator
friend std::ostream & operator<<(std::ostream &os, const SequenceNumber10 &val)
Ostream output function.
bool operator<=(const SequenceNumber10 &other) const
less than or equal operator
void SetModulusBase(SequenceNumber10 modulusBase)
Set modulus base.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:67
Every class exported by the ns3 library is enclosed in the ns3 namespace.