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"
41 
42 #include "modetimingparameters.h"
43 #include "maclayer.h"
44 #include "macstatistics.h"
45 
47 { }
48 
50 { }
51 
52 
53 bool
55 {
56  TimePoint beginTime{Clock::now()};
57 
58  // broadcast
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
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
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
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
104  }
105  else
106  {
107  // change state to unicast pre tx state
109  }
110 
111  // continue to process
112  return true;
113  }
114  }
115 }
116 
117 
118 
119 std::pair<EMANE::TimePoint,bool>
121 {
122  // no wait time
123  return {TimePoint{},false};
124 }
125 
126 
127 const char *
129 {
130  return "IdleTxState";
131 }
const PacketInfo & getPacketInfo() const
bool process(MACLayer *, DownstreamQueueEntry &)
Definition: idletxstate.cc:54
void setDelayTime(IEEE80211ABG::DownstreamQueueEntry &entry)
NEMId getDestination() const
Definition: packetinfo.inl:70
structure defines the mac downstream packet queue entry
constexpr NEMId NEM_BROADCAST_MAC_ADDRESS
Definition: types.h:69
void changeState(MACLayer *, TransmissionTxState *)
std::pair< TimePoint, bool > getWaitTime(DownstreamQueueEntry &)
Definition: idletxstate.cc:120
Clock::time_point TimePoint
Definition: types.h:50
void incrementDownstreamUnicastDataDiscardDueToTxop()
increment unicast data discard due to txop expired
void incrementDownstreamBroadcastDataDiscardDueToTxop()
increment unicast data discard due to txop expired
static BroadcastPreTxState * instance()
Definition: singleton.h:56