A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
lte-rlc-sequence-number.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
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: Manuel Requena <manuel.requena@cttc.es>
18
*/
19
20
#ifndef LTE_RLC_SEQUENCE_NUMBER_H
21
#define LTE_RLC_SEQUENCE_NUMBER_H
22
23
#include <ns3/assert.h>
24
25
#include <iostream>
26
#include <limits>
27
#include <stdint.h>
28
29
namespace
ns3
30
{
31
33
class
SequenceNumber10
34
{
35
public
:
36
SequenceNumber10
()
37
:
m_value
(0),
38
m_modulusBase
(0)
39
{
40
}
41
47
explicit
SequenceNumber10
(uint16_t value)
48
:
m_value
(value % 1024),
49
m_modulusBase
(0)
50
{
51
}
52
58
SequenceNumber10
(
const
SequenceNumber10
& value)
59
:
m_value
(value.
m_value
),
60
m_modulusBase
(value.
m_modulusBase
)
61
{
62
}
63
70
SequenceNumber10
&
operator=
(uint16_t value)
71
{
72
m_value
= value % 1024;
73
return
*
this
;
74
}
75
80
uint16_t
GetValue
()
const
81
{
82
return
m_value
;
83
}
84
89
void
SetModulusBase
(
SequenceNumber10
modulusBase)
90
{
91
m_modulusBase
= modulusBase.
m_value
;
92
}
93
98
void
SetModulusBase
(uint16_t modulusBase)
99
{
100
m_modulusBase
= modulusBase;
101
}
102
107
SequenceNumber10
operator++
(
int
)
108
{
109
SequenceNumber10
retval(
m_value
);
110
m_value
= ((uint32_t)
m_value
+ 1) % 1024;
111
retval.
SetModulusBase
(
m_modulusBase
);
112
return
retval;
113
}
114
120
SequenceNumber10
operator+
(uint16_t
delta
)
const
121
{
122
SequenceNumber10
ret((
m_value
+
delta
) % 1024);
123
ret.
SetModulusBase
(
m_modulusBase
);
124
return
ret;
125
}
126
132
SequenceNumber10
operator-
(uint16_t
delta
)
const
133
{
134
SequenceNumber10
ret((
m_value
-
delta
) % 1024);
135
ret.
SetModulusBase
(
m_modulusBase
);
136
return
ret;
137
}
138
144
uint16_t
operator-
(
const
SequenceNumber10
& other)
const
145
{
146
uint16_t diff =
m_value
- other.
m_value
;
147
return
diff;
148
}
149
155
bool
operator>
(
const
SequenceNumber10
& other)
const
156
{
157
NS_ASSERT
(
m_modulusBase
== other.
m_modulusBase
);
158
uint16_t v1 = (
m_value
-
m_modulusBase
) % 1024;
159
uint16_t v2 = (other.
m_value
- other.
m_modulusBase
) % 1024;
160
return
v1 > v2;
161
}
162
168
bool
operator==
(
const
SequenceNumber10
& other)
const
169
{
170
return
(
m_value
== other.
m_value
);
171
}
172
178
bool
operator!=
(
const
SequenceNumber10
& other)
const
179
{
180
return
(
m_value
!= other.
m_value
);
181
}
182
188
bool
operator<=
(
const
SequenceNumber10
& other)
const
189
{
190
return
(!this->
operator
>(other));
191
}
192
198
bool
operator>=
(
const
SequenceNumber10
& other)
const
199
{
200
return
(this->
operator
>(other) || this->
operator
==(other));
201
}
202
208
bool
operator<
(
const
SequenceNumber10
& other)
const
209
{
210
return
!this->
operator>
(other) &&
m_value
!= other.
m_value
;
211
}
212
213
friend
std::ostream&
operator<<
(std::ostream& os,
const
SequenceNumber10
& val);
214
215
private
:
216
uint16_t
m_value
;
217
uint16_t
m_modulusBase
;
218
};
219
220
}
// namespace ns3
221
222
#endif
// LTE_RLC_SEQUENCE_NUMBER_H
ns3::SequenceNumber10
SequenceNumber10 class.
Definition:
lte-rlc-sequence-number.h:34
ns3::SequenceNumber10::m_modulusBase
uint16_t m_modulusBase
the modulus base
Definition:
lte-rlc-sequence-number.h:217
ns3::SequenceNumber10::operator==
bool operator==(const SequenceNumber10 &other) const
equality operator
Definition:
lte-rlc-sequence-number.h:168
ns3::SequenceNumber10::operator-
uint16_t operator-(const SequenceNumber10 &other) const
subtraction operator
Definition:
lte-rlc-sequence-number.h:144
ns3::SequenceNumber10::SequenceNumber10
SequenceNumber10(const SequenceNumber10 &value)
Constructor.
Definition:
lte-rlc-sequence-number.h:58
ns3::SequenceNumber10::operator<
bool operator<(const SequenceNumber10 &other) const
less than operator
Definition:
lte-rlc-sequence-number.h:208
ns3::SequenceNumber10::SetModulusBase
void SetModulusBase(uint16_t modulusBase)
Set modulus base.
Definition:
lte-rlc-sequence-number.h:98
ns3::SequenceNumber10::SequenceNumber10
SequenceNumber10()
Definition:
lte-rlc-sequence-number.h:36
ns3::SequenceNumber10::GetValue
uint16_t GetValue() const
Extracts the numeric value of the sequence number.
Definition:
lte-rlc-sequence-number.h:80
ns3::SequenceNumber10::operator!=
bool operator!=(const SequenceNumber10 &other) const
inequality operator
Definition:
lte-rlc-sequence-number.h:178
ns3::SequenceNumber10::m_value
uint16_t m_value
the value
Definition:
lte-rlc-sequence-number.h:216
ns3::SequenceNumber10::SequenceNumber10
SequenceNumber10(uint16_t value)
Constructor.
Definition:
lte-rlc-sequence-number.h:47
ns3::SequenceNumber10::operator+
SequenceNumber10 operator+(uint16_t delta) const
addition operator
Definition:
lte-rlc-sequence-number.h:120
ns3::SequenceNumber10::operator-
SequenceNumber10 operator-(uint16_t delta) const
subtraction operator
Definition:
lte-rlc-sequence-number.h:132
ns3::SequenceNumber10::operator=
SequenceNumber10 & operator=(uint16_t value)
Assignment operator.
Definition:
lte-rlc-sequence-number.h:70
ns3::SequenceNumber10::operator++
SequenceNumber10 operator++(int)
postfix ++ operator
Definition:
lte-rlc-sequence-number.h:107
ns3::SequenceNumber10::operator>=
bool operator>=(const SequenceNumber10 &other) const
greater than or equal operator
Definition:
lte-rlc-sequence-number.h:198
ns3::SequenceNumber10::operator>
bool operator>(const SequenceNumber10 &other) const
greater than operator
Definition:
lte-rlc-sequence-number.h:155
ns3::SequenceNumber10::operator<<
friend std::ostream & operator<<(std::ostream &os, const SequenceNumber10 &val)
Ostream output function.
Definition:
lte-rlc-sequence-number.cc:32
ns3::SequenceNumber10::operator<=
bool operator<=(const SequenceNumber10 &other) const
less than or equal operator
Definition:
lte-rlc-sequence-number.h:188
ns3::SequenceNumber10::SetModulusBase
void SetModulusBase(SequenceNumber10 modulusBase)
Set modulus base.
Definition:
lte-rlc-sequence-number.h:89
NS_ASSERT
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition:
assert.h:66
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
two-ray-to-three-gpp-ch-calibration.delta
delta
Definition:
two-ray-to-three-gpp-ch-calibration.py:521
src
lte
model
lte-rlc-sequence-number.h
Generated on Sun Mar 3 2024 17:11:02 for ns-3 by
1.9.1