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 (),
28  m_state (PENDING),
29  m_sentMpdus (0),
30  m_needBlockAckReq (false)
31 {
32 }
33 
35  : BlockAckAgreement (recipient, tid),
36  m_state (PENDING),
37  m_sentMpdus (0),
38  m_needBlockAckReq (false)
39 {
40 }
41 
43 {
44 }
45 
46 void
48 {
49  m_state = state;
50  if (state == INACTIVE)
51  {
52  m_needBlockAckReq = false;
53  m_sentMpdus = 0;
54  }
55 }
56 
57 bool
59 {
60  return (m_state == PENDING) ? true : false;
61 }
62 
63 bool
65 {
66  return (m_state == ESTABLISHED) ? true : false;
67 }
68 
69 bool
71 {
72  return (m_state == INACTIVE) ? true : false;
73 }
74 
75 bool
77 {
78  return (m_state == UNSUCCESSFUL) ? true : false;
79 }
80 
81 void
83 {
85  m_sentMpdus++;
86  uint16_t delta = (nextSeqNumber - m_startingSeq + 4096) % 4096;
87  uint16_t min = m_bufferSize < 64 ? m_bufferSize : 64;
88  if (delta >= min || m_sentMpdus == m_bufferSize)
89  {
90  m_needBlockAckReq = true;
91  }
92 }
93 
94 bool
96 {
97  return m_needBlockAckReq;
98 }
99 
100 void
102 {
103  m_needBlockAckReq = false;
104  m_sentMpdus = 0;
105 }
106 
107 } //namespace ns3
#define min(a, b)
Definition: 80211b.c:44
#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 IsBlockAckRequestNeeded(void) const
Returns true if all packets for which a block ack was negotiated have been transmitted so a block ack...
uint16_t m_bufferSize
Buffer size.
void SetState(State state)
Set the current state.
bool IsPending(void) const
Check if the current state of this agreement is PENDING.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
bool IsEstablished(void) const
Check if the current state of this agreement is ESTABLISHED.
an EUI-48 address
Definition: mac48-address.h:43
bool IsUnsuccessful(void) const
Check if the current state of this agreement is UNSUCCESSFUL.
Maintains information for a block ack agreement.
State
Represents the state for this agreement.
void NotifyMpduTransmission(uint16_t nextSeqNumber)
Notifies a packet's transmission with ack policy Block Ack.
bool m_needBlockAckReq
flag whether it needs a Block ACK request
void CompleteExchange(void)
Complete exchange function.