EMANE
1.2.1
idletxstate.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2013-2014 - Adjacent Link LLC, Bridgewater, New Jersey
3
* Copyright (c) 2008 - DRS CenGen, LLC, Columbia, Maryland
4
* All rights reserved.
5
*
6
* Redistribution and use in source and binary forms, with or without
7
* modification, are permitted provided that the following conditions
8
* are met:
9
*
10
* * Redistributions of source code must retain the above copyright
11
* notice, this list of conditions and the following disclaimer.
12
* * Redistributions in binary form must reproduce the above copyright
13
* notice, this list of conditions and the following disclaimer in
14
* the documentation and/or other materials provided with the
15
* distribution.
16
* * Neither the name of DRS CenGen, LLC nor the names of its
17
* contributors may be used to endorse or promote products derived
18
* from this software without specific prior written permission.
19
*
20
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
* POSSIBILITY OF SUCH DAMAGE.
32
*/
33
34
#include "
emane/types.h
"
35
36
#include "
idletxstate.h
"
37
38
#include "
broadcastpretxstate.h
"
39
#include "
unicastpretxstate.h
"
40
#include "
unicastrtsctspretxstate.h
"
41
42
#include "
modetimingparameters.h
"
43
#include "
maclayer.h
"
44
#include "
macstatistics.h
"
45
46
EMANE::Models::IEEE80211ABG::IdleTxState::IdleTxState
()
47
{ }
48
49
EMANE::Models::IEEE80211ABG::IdleTxState::~IdleTxState
()
50
{ }
51
52
53
bool
54
EMANE::Models::IEEE80211ABG::IdleTxState::process
(
MACLayer
* pMgr,
DownstreamQueueEntry
& entry)
55
{
56
TimePoint
beginTime{Clock::now()};
57
58
// broadcast
59
if
(entry.
pkt_
.
getPacketInfo
().
getDestination
() ==
EMANE::NEM_BROADCAST_MAC_ADDRESS
)
60
{
61
// packet txop timed out
62
if
((entry.
txOpMicroseconds_
.count() != 0) && (entry.
txOpMicroseconds_
+ entry.
acquireTime_
) < beginTime)
63
{
64
// set discard due to txop timeout
65
pMgr->
getStatistics
().
incrementDownstreamBroadcastDataDiscardDueToTxop
();
66
67
// get next packet
68
return
false
;
69
}
70
else
71
{
72
// set pre/post tx delay time
73
pMgr->
setDelayTime
(entry);
74
75
// change state to broadcast pre tx state
76
changeState
(pMgr,
BroadcastPreTxStateSingleton::instance
());
77
78
// continue to process
79
return
true
;
80
}
81
}
82
// unicast
83
else
84
{
85
// packet txop timed out
86
if
((entry.
txOpMicroseconds_
.count() != 0) && (entry.
txOpMicroseconds_
+ entry.
acquireTime_
) < beginTime)
87
{
88
// set discard due to txop timeout
89
pMgr->
getStatistics
().
incrementDownstreamUnicastDataDiscardDueToTxop
();
90
91
// get next packet
92
return
false
;
93
}
94
else
95
{
96
// set pre/post tx delay time
97
pMgr->
setDelayTime
(entry);
98
99
// check rts cts enable
100
if
(entry.
bRtsCtsEnable_
==
true
)
101
{
102
// change state to unicast rts cts pre tx state
103
changeState
(pMgr,
UnicastRtsCtsPreTxStateSingleton::instance
());
104
}
105
else
106
{
107
// change state to unicast pre tx state
108
changeState
(pMgr,
UnicastPreTxStateSingleton::instance
());
109
}
110
111
// continue to process
112
return
true
;
113
}
114
}
115
}
116
117
118
119
std::pair<EMANE::TimePoint,bool>
120
EMANE::Models::IEEE80211ABG::IdleTxState::getWaitTime
(
DownstreamQueueEntry
&)
121
{
122
// no wait time
123
return
{
TimePoint
{},
false
};
124
}
125
126
127
const
char
*
128
EMANE::Models::IEEE80211ABG::IdleTxState::statename
()
129
{
130
return
"IdleTxState"
;
131
}
macstatistics.h
EMANE::DownstreamPacket::getPacketInfo
const PacketInfo & getPacketInfo() const
Definition:
downstreampacket.cc:199
types.h
unicastpretxstate.h
EMANE::Models::IEEE80211ABG::IdleTxState::IdleTxState
IdleTxState()
Definition:
idletxstate.cc:46
EMANE::Models::IEEE80211ABG::DownstreamQueueEntry::pkt_
EMANE::DownstreamPacket pkt_
Definition:
downstreamqueueentry.h:54
EMANE::Models::IEEE80211ABG::IdleTxState::process
bool process(MACLayer *, DownstreamQueueEntry &)
Definition:
idletxstate.cc:54
EMANE::Models::IEEE80211ABG::DownstreamQueueEntry::bRtsCtsEnable_
bool bRtsCtsEnable_
Definition:
downstreamqueueentry.h:65
EMANE::Models::IEEE80211ABG::MACLayer::setDelayTime
void setDelayTime(IEEE80211ABG::DownstreamQueueEntry &entry)
Definition:
models/mac/ieee80211abg/maclayer.cc:1429
EMANE::Models::IEEE80211ABG::IdleTxState::~IdleTxState
~IdleTxState()
Definition:
idletxstate.cc:49
EMANE::PacketInfo::getDestination
NEMId getDestination() const
Definition:
packetinfo.inl:70
EMANE::Models::IEEE80211ABG::DownstreamQueueEntry
structure defines the mac downstream packet queue entry
Definition:
downstreamqueueentry.h:52
EMANE::NEM_BROADCAST_MAC_ADDRESS
constexpr NEMId NEM_BROADCAST_MAC_ADDRESS
Definition:
types.h:69
idletxstate.h
EMANE::Models::IEEE80211ABG::TransmissionTxState::changeState
void changeState(MACLayer *, TransmissionTxState *)
Definition:
transmissiontxstate.cc:47
EMANE::Models::IEEE80211ABG::IdleTxState::getWaitTime
std::pair< TimePoint, bool > getWaitTime(DownstreamQueueEntry &)
Definition:
idletxstate.cc:120
EMANE::Models::IEEE80211ABG::IdleTxState::statename
const char * statename()
Definition:
idletxstate.cc:128
unicastrtsctspretxstate.h
maclayer.h
broadcastpretxstate.h
EMANE::Models::IEEE80211ABG::DownstreamQueueEntry::txOpMicroseconds_
Microseconds txOpMicroseconds_
Definition:
downstreamqueueentry.h:56
EMANE::TimePoint
Clock::time_point TimePoint
Definition:
types.h:50
EMANE::Models::IEEE80211ABG::MACStatistics::incrementDownstreamUnicastDataDiscardDueToTxop
void incrementDownstreamUnicastDataDiscardDueToTxop()
increment unicast data discard due to txop expired
Definition:
macstatistics.cc:301
modetimingparameters.h
EMANE::Models::IEEE80211ABG::MACLayer::getStatistics
MACStatistics & getStatistics()
Definition:
models/mac/ieee80211abg/maclayer.cc:2070
EMANE::Models::IEEE80211ABG::MACStatistics::incrementDownstreamBroadcastDataDiscardDueToTxop
void incrementDownstreamBroadcastDataDiscardDueToTxop()
increment unicast data discard due to txop expired
Definition:
macstatistics.cc:315
EMANE::Utils::Singleton< BroadcastPreTxState >::instance
static BroadcastPreTxState * instance()
Definition:
singleton.h:56
EMANE::Models::IEEE80211ABG::DownstreamQueueEntry::acquireTime_
TimePoint acquireTime_
Definition:
downstreamqueueentry.h:55
EMANE::Models::IEEE80211ABG::MACLayer
IEEE 80211 ABG MAC implementation.
Definition:
models/mac/ieee80211abg/maclayer.h:104
src
models
mac
ieee80211abg
idletxstate.cc
Generated by
1.8.13