A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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  * Author: Mirko Banchi <mk.banchi@gmail.com>
19  * Author: Tommaso Pecorella <tommaso.pecorella@unifi.it>
20  */
22 
23 namespace ns3 {
24 
26  : BlockAckAgreement (),
27  m_state (PENDING),
28  m_sentMpdus (0),
29  m_needBlockAckReq (false)
30 {
31 }
33  : BlockAckAgreement (recipient, tid),
34  m_state (PENDING),
35  m_sentMpdus (0),
36  m_needBlockAckReq (false)
37 {
38 }
40 {
41 }
42 void
44 {
45  m_state = state;
46  if (state == INACTIVE)
47  {
48  m_needBlockAckReq = false;
49  m_sentMpdus = 0;
50  }
51 }
52 bool
54 {
55  return (m_state == PENDING) ? true : false;
56 }
57 bool
59 {
60  return (m_state == ESTABLISHED) ? true : false;
61 }
62 bool
64 {
65  return (m_state == INACTIVE) ? true : false;
66 }
67 bool
69 {
70  return (m_state == UNSUCCESSFUL) ? true : false;
71 }
72 void
74 {
76  m_sentMpdus++;
77  uint16_t delta = (nextSeqNumber - m_startingSeq + 4096) % 4096;
78  uint16_t min = m_bufferSize < 64 ? m_bufferSize : 64;
79  if (delta >= min || m_sentMpdus == m_bufferSize)
80  {
81  m_needBlockAckReq = true;
82  }
83 }
84 bool
86 {
87  return m_needBlockAckReq;
88 }
89 void
91 {
92  m_needBlockAckReq = false;
93  m_sentMpdus = 0;
94 }
95 
96 } // namespace ns3
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition: assert.h:61
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...
bool IsPending(void) const
Check if the current state of this agreement is PENDING.
bool IsEstablished(void) const
Check if the current state of this agreement is ESTABLISHED.
an EUI-48 address
Definition: mac48-address.h:41
State
Represents the state for this agreement.
bool IsUnsuccessful(void) const
Check if the current state of this agreement is UNSUCCESSFUL.
Maintains information for a block ack agreement.
void NotifyMpduTransmission(uint16_t nextSeqNumber)
Notifies a packet's transmission with ack policy Block Ack.