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-gw.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_GW_H
22
#define UAN_MAC_RC_GW_H
23
24
#include "
uan-mac.h
"
25
#include "
uan-address.h
"
26
27
#include "ns3/nstime.h"
28
#include "ns3/traced-callback.h"
29
30
31
32
33
#include <set>
34
#include <map>
35
36
namespace
ns3 {
37
38
class
UanTxMode;
39
60
class
UanMacRcGw
:
public
UanMac
61
{
62
public
:
63
UanMacRcGw
();
64
virtual
~UanMacRcGw
();
65
66
static
TypeId
GetTypeId
(
void
);
67
68
// Inherited virtual functions
69
virtual
Address
GetAddress
(
void
);
70
virtual
void
SetAddress
(
UanAddress
addr);
71
virtual
bool
Enqueue
(
Ptr<Packet>
pkt,
const
Address
&dest, uint16_t protocolNumber);
72
virtual
void
SetForwardUpCb
(
Callback
<
void
,
Ptr<Packet>
,
const
UanAddress
&> cb);
73
virtual
void
AttachPhy
(
Ptr<UanPhy>
phy);
74
virtual
Address
GetBroadcast
(
void
)
const
;
75
virtual
void
Clear
(
void
);
76
85
int64_t
AssignStreams
(int64_t stream);
86
87
private
:
88
enum
State
{
89
IDLE
,
INCYCLE
,
CTSING
90
};
91
State
m_state
;
92
93
struct
Request
94
{
95
uint8_t
numFrames
;
96
uint8_t
frameNo
;
97
uint8_t
retryNo
;
98
uint16_t
length
;
99
Time
rxTime
;
100
};
101
102
struct
AckData
103
{
104
uint8_t
frameNo
;
105
std::set<uint8_t>
rxFrames
;
106
uint8_t
expFrames
;
107
};
108
Callback<void, Ptr<Packet>
,
const
UanAddress
& >
m_forwardUpCb
;
109
Ptr<UanPhy>
m_phy
;
110
UanAddress
m_address
;
111
Time
m_maxDelta
;
112
Time
m_sifs
;
113
uint32_t
m_maxRes
;
114
uint32_t
m_numRates
;
115
uint32_t
m_rtsSize
;
116
uint32_t
m_ctsSizeN
;
117
uint32_t
m_ctsSizeG
;
118
uint32_t
m_ackSize
;
119
double
m_retryRate
;
120
uint16_t
m_currentRetryRate
;
121
uint32_t
m_currentRateNum
;
122
uint32_t
m_numNodes
;
123
uint32_t
m_totalRate
;
124
uint32_t
m_rateStep
;
125
uint32_t
m_frameSize
;
126
127
uint16_t
m_numRetryRates
;
128
double
m_minRetryRate
;
129
double
m_retryStep
;
130
131
std::map<UanAddress, Time>
m_propDelay
;
132
133
std::map<UanAddress, AckData>
m_ackData
;
134
135
136
std::map<UanAddress, Request>
m_requests
;
137
std::set<std::pair<Time, UanAddress> >
m_sortedRes
;
138
139
bool
m_cleared
;
140
141
TracedCallback<Ptr<const Packet>
,
UanTxMode
>
m_rxLogger
;
142
143
// Start time, min p-delay, reservations, frames, bytes, window size, ctl rate, retry rate
144
TracedCallback<Time, Time, uint32_t, uint32_t, double, uint32_t, double>
m_cycleLogger
;
145
146
void
ReceivePacket
(
Ptr<Packet>
pkt,
double
sinr,
UanTxMode
mode);
147
void
StartCycle
(
void
);
148
void
EndCycle
(
void
);
149
void
SendPacket
(
Ptr<Packet>
pkt, uint32_t rate);
150
void
CycleStarted
(
void
);
151
void
ReceiveError
(
Ptr<Packet>
pkt,
double
sinr);
152
153
// Stuff for computing exp throughput
154
double
ComputeAlpha
(uint32_t totalFrames, uint32_t totalBytes, uint32_t n, uint32_t a,
double
deltaK);
155
std::vector<double>
GetExpPdk
(
void
);
156
double
ComputeExpS
(uint32_t a, uint32_t ld, std::vector<double> exppdk);
157
double
ComputeExpS
(uint32_t a, uint32_t ld);
158
uint32_t
CompExpMinIndex
(uint32_t n, uint32_t k);
159
double
ComputePiK
(uint32_t a, uint32_t n, uint32_t k);
160
double
ComputeExpBOverA
(uint32_t n, uint32_t a, uint32_t ldlh, std::vector<double> deltaK);
161
uint64_t
NchooseK
(uint32_t n, uint32_t k);
162
uint32_t
FindOptA
(
void
);
163
protected
:
164
virtual
void
DoDispose
();
165
166
};
167
173
bool
operator <
(
UanAddress
&a,
UanAddress
&b);
174
175
}
176
177
#endif
/* UAN_MAC_RC_GW_H */
src
uan
model
uan-mac-rc-gw.h
Generated on Tue Oct 9 2012 16:45:47 for ns-3 by
1.8.1.2