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-cw.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_CW_H
22
#define UAN_MAC_CW_H
23
24
#include "ns3/uan-mac.h"
25
#include "ns3/nstime.h"
26
#include "ns3/simulator.h"
27
#include "ns3/uan-phy.h"
28
#include "ns3/uan-tx-mode.h"
29
#include "ns3/uan-address.h"
30
#include "ns3/random-variable-stream.h"
31
32
namespace
ns3 {
33
43
class
UanMacCw
:
public
UanMac
,
44
public
UanPhyListener
45
{
46
public
:
47
UanMacCw
();
48
virtual
~UanMacCw
();
49
static
TypeId
GetTypeId
(
void
);
50
54
virtual
void
SetCw
(uint32_t cw);
58
virtual
void
SetSlotTime
(
Time
duration);
62
virtual
uint32_t
GetCw
(
void
);
66
virtual
Time
GetSlotTime
(
void
);
67
68
// Inherited methods
69
virtual
Address
GetAddress
();
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
77
// PHY listeners
79
virtual
void
NotifyRxStart
(
void
);
81
virtual
void
NotifyRxEndOk
(
void
);
83
virtual
void
NotifyRxEndError
(
void
);
85
virtual
void
NotifyCcaStart
(
void
);
87
virtual
void
NotifyCcaEnd
(
void
);
89
virtual
void
NotifyTxStart
(
Time
duration);
90
99
int64_t
AssignStreams
(int64_t stream);
100
101
private
:
102
typedef
enum
{
103
IDLE
,
CCABUSY
,
RUNNING
,
TX
104
}
State
;
105
106
Callback <void, Ptr<Packet>
,
const
UanAddress
& >
m_forwardUpCb
;
107
UanAddress
m_address
;
108
Ptr<UanPhy>
m_phy
;
109
TracedCallback<Ptr<const Packet>
,
UanTxMode
>
m_rxLogger
;
110
TracedCallback<Ptr<const Packet>
, uint16_t >
m_enqueueLogger
;
111
TracedCallback<Ptr<const Packet>
, uint16_t >
m_dequeueLogger
;
112
113
// Mac parameters
114
uint32_t
m_cw
;
115
Time
m_slotTime
;
116
117
// State variables
118
Time
m_sendTime
;
119
Time
m_savedDelayS
;
120
Ptr<Packet>
m_pktTx
;
121
uint16_t
m_pktTxProt
;
122
EventId
m_sendEvent
;
123
EventId
m_txEndEvent
;
124
State
m_state
;
125
126
bool
m_cleared
;
127
129
Ptr<UniformRandomVariable>
m_rv
;
130
131
void
PhyRxPacketGood
(
Ptr<Packet>
packet,
double
sinr,
UanTxMode
mode);
132
void
PhyRxPacketError
(
Ptr<Packet>
packet,
double
sinr);
133
void
SaveTimer
(
void
);
134
void
StartTimer
(
void
);
135
void
SendPacket
(
void
);
136
void
EndTx
(
void
);
137
protected
:
138
virtual
void
DoDispose
();
139
};
140
141
}
142
143
#endif
/* UAN_MAC_CW_H */
src
uan
model
uan-mac-cw.h
Generated on Tue Oct 9 2012 16:45:47 for ns-3 by
1.8.1.2