A Discrete-Event Network Simulator
API
originator-block-ack-agreement.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2009, 2010 MIRKO BANCHI
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  * Authors: Mirko Banchi <mk.banchi@gmail.com>
19  * Tommaso Pecorella <tommaso.pecorella@unifi.it>
20  */
21 
23 
24 namespace ns3 {
25 
27  : BlockAckAgreement (recipient, tid),
28  m_state (PENDING),
29  m_sentMpdus (0),
30  m_needBlockAckReq (false)
31 {
32 }
33 
35 {
36 }
37 
38 void
40 {
41  m_state = state;
42  if (state == INACTIVE)
43  {
44  m_needBlockAckReq = false;
45  m_sentMpdus = 0;
46  }
47 }
48 
49 bool
51 {
52  return (m_state == PENDING) ? true : false;
53 }
54 
55 bool
57 {
58  return (m_state == ESTABLISHED) ? true : false;
59 }
60 
61 bool
63 {
64  return (m_state == INACTIVE) ? true : false;
65 }
66 
67 bool
69 {
70  return (m_state == UNSUCCESSFUL) ? true : false;
71 }
72 
73 void
75 {
77  m_sentMpdus++;
78  uint16_t delta = (nextSeqNumber - m_startingSeq + 4096) % 4096;
79  uint16_t min = m_bufferSize < 64 ? m_bufferSize : 64;
80  if (delta >= min || m_sentMpdus == m_bufferSize)
81  {
82  m_needBlockAckReq = true;
83  }
84 }
85 
86 bool
88 {
89  return m_needBlockAckReq;
90 }
91 
92 void
94 {
95  m_needBlockAckReq = false;
96  m_sentMpdus = 0;
97 }
98 
99 } //namespace ns3
bool IsBlockAckRequestNeeded(void) const
Returns true if all packets for which a block ack was negotiated have been transmitted so a block ack...
#define min(a, b)
Definition: 80211b.c:42
OriginatorBlockAckAgreement(Mac48Address recipient, uint8_t tid)
Constructor.
bool IsEstablished(void) const
Check if the current state of this agreement is ESTABLISHED.
bool IsPending(void) const
Check if the current state of this agreement is PENDING.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition: assert.h:67
uint16_t m_startingSeq
Starting squence control.
bool IsInactive(void) const
Check if the current state of this agreement is INACTIVE.
bool IsUnsuccessful(void) const
Check if the current state of this agreement is UNSUCCESSFUL.
uint16_t m_bufferSize
Buffer size.
void SetState(State state)
Set the current state.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
an EUI-48 address
Definition: mac48-address.h:43
State
Represents the state for this agreement.
Maintains information for a block ack agreement.
void NotifyMpduTransmission(uint16_t nextSeqNumber)
Notifies a packet&#39;s transmission with ack policy Block Ack.
bool m_needBlockAckReq
flag whether it needs a Block ACK request
void CompleteExchange(void)
Complete exchange function.