A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
uan-mac-rc.h
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2009 University of Washington
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: Leonard Tracy <lentracy@gmail.com>
19
*/
20
21
#ifndef UAN_MAC_RC_H
22
#define UAN_MAC_RC_H
23
24
#include "
uan-mac.h
"
25
#include "
uan-address.h
"
26
27
#include "ns3/nstime.h"
28
#include "ns3/trace-source-accessor.h"
29
#include "ns3/traced-callback.h"
30
#include "ns3/event-id.h"
31
#include "ns3/random-variable-stream.h"
32
33
#include <list>
34
#include <utility>
35
#include <vector>
36
37
38
namespace
ns3 {
39
40
class
Address;
41
class
UanTxMode;
42
class
UanHeaderRcRts;
43
class
UanHeaderRcCts;
44
class
UanHeaderRcCtsGlobal;
45
class
UanPhy;
46
47
52
class
Reservation
53
{
54
public
:
58
Reservation
();
65
Reservation
(
std::list
<std::pair <
Ptr<Packet>
,
UanAddress
> > &
list
, uint8_t frameNo, uint32_t maxPkts = 0);
66
~Reservation
();
70
uint32_t
GetNoFrames
()
const
;
74
uint32_t
GetLength
()
const
;
78
const
std::list<std::pair <Ptr<Packet>,
UanAddress
> > &
GetPktList
(
void
)
const
;
82
uint8_t
GetFrameNo
()
const
;
86
uint8_t
GetRetryNo
()
const
;
91
Time
GetTimestamp
(uint8_t n)
const
;
95
bool
IsTransmitted
()
const
;
99
void
SetFrameNo
(uint8_t fn);
103
void
AddTimestamp
(
Time
t);
107
void
IncrementRetry
();
112
void
SetTransmitted
(
bool
t =
true
);
113
private
:
114
std::list<std::pair <Ptr<Packet>,
UanAddress
> >
m_pktList
;
115
uint32_t
m_length
;
116
uint8_t
m_frameNo
;
117
std::vector<Time>
m_timestamp
;
118
uint8_t
m_retryNo
;
119
bool
m_transmitted
;
120
121
};
122
123
137
class
UanMacRc
:
public
UanMac
138
{
139
public
:
140
enum
{
141
TYPE_DATA
,
TYPE_GWPING
,
TYPE_RTS
,
TYPE_CTS
,
TYPE_ACK
142
};
143
UanMacRc
();
144
virtual
~UanMacRc
();
145
146
static
TypeId
GetTypeId
(
void
);
147
148
// Inherited virtual functions
149
virtual
Address
GetAddress
(
void
);
150
virtual
void
SetAddress
(
UanAddress
addr);
151
virtual
bool
Enqueue
(
Ptr<Packet>
pkt,
const
Address
&dest, uint16_t protocolNumber);
152
virtual
void
SetForwardUpCb
(
Callback
<
void
,
Ptr<Packet>
,
const
UanAddress
&> cb);
153
virtual
void
AttachPhy
(
Ptr<UanPhy>
phy);
154
virtual
Address
GetBroadcast
(
void
)
const
;
155
virtual
void
Clear
(
void
);
156
165
int64_t
AssignStreams
(int64_t stream);
166
167
private
:
168
enum
State
{
169
UNASSOCIATED
,
GWPSENT
,
IDLE
,
RTSSENT
,
DATATX
170
};
171
172
State
m_state
;
173
bool
m_rtsBlocked
;
174
175
EventId
m_startAgain
;
176
UanAddress
m_address
;
177
double
m_retryRate
;
178
UanAddress
m_assocAddr
;
179
Ptr<UanPhy>
m_phy
;
180
uint32_t
m_numRates
;
181
uint32_t
m_currentRate
;
182
uint32_t
m_maxFrames
;
183
uint32_t
m_queueLimit
;
184
uint8_t
m_frameNo
;
185
Time
m_sifs
;
186
Time
m_learnedProp
;
187
188
uint16_t
m_numRetryRates
;
189
double
m_minRetryRate
;
190
double
m_retryStep
;
191
192
uint32_t
m_ctsSizeN
;
193
uint32_t
m_ctsSizeG
;
194
195
bool
m_cleared
;
196
197
std::list<std::pair <Ptr<Packet>,
UanAddress
> >
m_pktQueue
;
198
std::list<Reservation>
m_resList
;
199
200
Callback<void, Ptr<Packet>
,
const
UanAddress
& >
m_forwardUpCb
;
201
202
TracedCallback<Ptr<const Packet>
,
UanTxMode
>
m_rxLogger
;
203
TracedCallback<Ptr<const Packet>
, uint16_t >
m_enqueueLogger
;
204
TracedCallback<Ptr<const Packet>
, uint16_t >
m_dequeueLogger
;
205
206
EventId
m_rtsEvent
;
207
void
ReceiveOkFromPhy
(
Ptr<Packet>
,
double
sinr,
UanTxMode
mode);
208
209
void
Associate
(
void
);
210
void
AssociateTimeout
(
void
);
211
void
SendRts
(
void
);
212
void
RtsTimeout
(
void
);
213
UanHeaderRcRts
CreateRtsHeader
(
const
Reservation
&res);
214
void
ScheduleData
(
const
UanHeaderRcCts
&ctsh,
const
UanHeaderRcCtsGlobal
&ctsg, uint32_t ctsBytes);
215
void
ProcessAck
(
Ptr<Packet>
ack);
216
void
SendPacket
(
Ptr<Packet>
pkt, uint32_t rate);
217
bool
IsPhy1Ok
(
void
);
218
void
BlockRtsing
(
void
);
219
220
static
uint32_t
m_cntrlSends
;
221
223
Ptr<ExponentialRandomVariable>
m_ev
;
224
225
protected
:
226
void
DoDispose
();
227
};
228
229
}
230
231
#endif
/* UAN_MAC_RC_H */
src
uan
model
uan-mac-rc.h
Generated on Tue Oct 9 2012 16:45:47 for ns-3 by
1.8.1.2