A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
src
lte
model
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
32
namespace
ns3
{
33
34
36
class
SequenceNumber10
37
{
38
public
:
39
SequenceNumber10
()
40
:
m_value
(0),
41
m_modulusBase
(0)
42
{}
43
49
explicit
SequenceNumber10
(uint16_t value)
50
:
m_value
(value % 1024),
51
m_modulusBase
(0)
52
{}
53
59
SequenceNumber10
(
SequenceNumber10
const
&value)
60
:
m_value
(value.
m_value
),
61
m_modulusBase
(value.
m_modulusBase
)
62
{}
63
70
SequenceNumber10
&
operator=
(uint16_t value)
71
{
72
m_value
= value % 1024;
73
return
*
this
;
74
}
75
76
81
uint16_t
GetValue
()
const
82
{
83
return
m_value
;
84
}
85
90
void
SetModulusBase
(
SequenceNumber10
modulusBase)
91
{
92
m_modulusBase
= modulusBase.
m_value
;
93
}
94
99
void
SetModulusBase
(uint16_t modulusBase)
100
{
101
m_modulusBase
= modulusBase;
102
}
103
108
SequenceNumber10
operator++
(
int
)
109
{
110
SequenceNumber10
retval (
m_value
);
111
m_value
= ((uint32_t)
m_value
+ 1) % 1024;
112
retval.
SetModulusBase
(
m_modulusBase
);
113
return
retval;
114
}
115
121
SequenceNumber10
operator +
(uint16_t delta)
const
122
{
123
SequenceNumber10
ret ((
m_value
+ delta) % 1024);
124
ret.
SetModulusBase
(
m_modulusBase
);
125
return
ret;
126
}
127
133
SequenceNumber10
operator -
(uint16_t delta)
const
134
{
135
SequenceNumber10
ret ((
m_value
- delta) % 1024);
136
ret.
SetModulusBase
(
m_modulusBase
);
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
{
158
NS_ASSERT
(
m_modulusBase
== other.
m_modulusBase
);
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
217
private
:
218
uint16_t
m_value
;
219
uint16_t
m_modulusBase
;
220
};
221
222
223
}
// namespace ns3
224
225
#endif // LTE_RLC_SEQUENCE_NUMBER_H
ns3::SequenceNumber10::GetValue
uint16_t GetValue() const
Extracts the numeric value of the sequence number.
Definition:
lte-rlc-sequence-number.h:81
ns3::SequenceNumber10::operator==
bool operator==(const SequenceNumber10 &other) const
equality operator
Definition:
lte-rlc-sequence-number.h:169
ns3::SequenceNumber10::SequenceNumber10
SequenceNumber10()
Definition:
lte-rlc-sequence-number.h:39
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::m_value
uint16_t m_value
the value
Definition:
lte-rlc-sequence-number.h:218
ns3::SequenceNumber10::operator!=
bool operator!=(const SequenceNumber10 &other) const
inequality operator
Definition:
lte-rlc-sequence-number.h:179
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:67
ns3::SequenceNumber10::operator++
SequenceNumber10 operator++(int)
postfix ++ operator
Definition:
lte-rlc-sequence-number.h:108
ns3::SequenceNumber10::operator+
SequenceNumber10 operator+(uint16_t delta) const
addition operator
Definition:
lte-rlc-sequence-number.h:121
ns3::SequenceNumber10::SetModulusBase
void SetModulusBase(SequenceNumber10 modulusBase)
Set modulus base.
Definition:
lte-rlc-sequence-number.h:90
ns3::SequenceNumber10::operator<
bool operator<(const SequenceNumber10 &other) const
less than operator
Definition:
lte-rlc-sequence-number.h:209
ns3::SequenceNumber10::operator<=
bool operator<=(const SequenceNumber10 &other) const
less than or equal operator
Definition:
lte-rlc-sequence-number.h:189
ns3::SequenceNumber10::operator=
SequenceNumber10 & operator=(uint16_t value)
Assignment operator.
Definition:
lte-rlc-sequence-number.h:70
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::SequenceNumber10::SequenceNumber10
SequenceNumber10(uint16_t value)
Constructor.
Definition:
lte-rlc-sequence-number.h:49
ns3::SequenceNumber10::operator-
SequenceNumber10 operator-(uint16_t delta) const
subtraction operator
Definition:
lte-rlc-sequence-number.h:133
ns3::SequenceNumber10::operator>
bool operator>(const SequenceNumber10 &other) const
greater than operator
Definition:
lte-rlc-sequence-number.h:156
ns3::SequenceNumber10
SequenceNumber10 class.
Definition:
lte-rlc-sequence-number.h:36
ns3::SequenceNumber10::operator>=
bool operator>=(const SequenceNumber10 &other) const
greater than or equal operator
Definition:
lte-rlc-sequence-number.h:199
ns3::SequenceNumber10::m_modulusBase
uint16_t m_modulusBase
the modulus base
Definition:
lte-rlc-sequence-number.h:219
ns3::SequenceNumber10::SetModulusBase
void SetModulusBase(uint16_t modulusBase)
Set modulus base.
Definition:
lte-rlc-sequence-number.h:99
ns3::SequenceNumber10::SequenceNumber10
SequenceNumber10(SequenceNumber10 const &value)
Constructor.
Definition:
lte-rlc-sequence-number.h:59
Generated on Wed Nov 7 2018 10:02:01 for ns-3 by
1.8.14