A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
src
wifi
model
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
22
#include "
originator-block-ack-agreement.h
"
23
24
namespace
ns3
{
25
26
OriginatorBlockAckAgreement::OriginatorBlockAckAgreement
(
Mac48Address
recipient, uint8_t tid)
27
:
BlockAckAgreement
(recipient, tid),
28
m_state (PENDING),
29
m_sentMpdus (0),
30
m_needBlockAckReq (false)
31
{
32
}
33
34
OriginatorBlockAckAgreement::~OriginatorBlockAckAgreement
()
35
{
36
}
37
38
void
39
OriginatorBlockAckAgreement::SetState
(
State
state)
40
{
41
m_state
= state;
42
if
(state ==
INACTIVE
)
43
{
44
m_needBlockAckReq
=
false
;
45
m_sentMpdus
= 0;
46
}
47
}
48
49
bool
50
OriginatorBlockAckAgreement::IsPending
(
void
)
const
51
{
52
return
(
m_state
==
PENDING
) ? true :
false
;
53
}
54
55
bool
56
OriginatorBlockAckAgreement::IsEstablished
(
void
)
const
57
{
58
return
(
m_state
==
ESTABLISHED
) ? true :
false
;
59
}
60
61
bool
62
OriginatorBlockAckAgreement::IsInactive
(
void
)
const
63
{
64
return
(
m_state
==
INACTIVE
) ? true :
false
;
65
}
66
67
bool
68
OriginatorBlockAckAgreement::IsUnsuccessful
(
void
)
const
69
{
70
return
(
m_state
==
UNSUCCESSFUL
) ? true :
false
;
71
}
72
73
void
74
OriginatorBlockAckAgreement::NotifyMpduTransmission
(uint16_t nextSeqNumber)
75
{
76
NS_ASSERT
(
m_sentMpdus
<
m_bufferSize
);
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
87
OriginatorBlockAckAgreement::IsBlockAckRequestNeeded
(
void
)
const
88
{
89
return
m_needBlockAckReq
;
90
}
91
92
void
93
OriginatorBlockAckAgreement::CompleteExchange
(
void
)
94
{
95
m_needBlockAckReq
=
false
;
96
m_sentMpdus
= 0;
97
}
98
99
}
//namespace ns3
ns3::OriginatorBlockAckAgreement::m_sentMpdus
uint16_t m_sentMpdus
sent MPDUs
Definition:
originator-block-ack-agreement.h:159
ns3::OriginatorBlockAckAgreement::IsBlockAckRequestNeeded
bool IsBlockAckRequestNeeded(void) const
Returns true if all packets for which a block ack was negotiated have been transmitted so a block ack...
Definition:
originator-block-ack-agreement.cc:87
min
#define min(a, b)
Definition:
80211b.c:42
ns3::OriginatorBlockAckAgreement::OriginatorBlockAckAgreement
OriginatorBlockAckAgreement(Mac48Address recipient, uint8_t tid)
Constructor.
Definition:
originator-block-ack-agreement.cc:26
ns3::OriginatorBlockAckAgreement::IsEstablished
bool IsEstablished(void) const
Check if the current state of this agreement is ESTABLISHED.
Definition:
originator-block-ack-agreement.cc:56
ns3::OriginatorBlockAckAgreement::IsPending
bool IsPending(void) const
Check if the current state of this agreement is PENDING.
Definition:
originator-block-ack-agreement.cc:50
NS_ASSERT
#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
ns3::OriginatorBlockAckAgreement::PENDING
Definition:
originator-block-ack-agreement.h:100
ns3::BlockAckAgreement::m_startingSeq
uint16_t m_startingSeq
Starting squence control.
Definition:
block-ack-agreement.h:169
ns3::OriginatorBlockAckAgreement::IsInactive
bool IsInactive(void) const
Check if the current state of this agreement is INACTIVE.
Definition:
originator-block-ack-agreement.cc:62
ns3::OriginatorBlockAckAgreement::~OriginatorBlockAckAgreement
~OriginatorBlockAckAgreement()
Definition:
originator-block-ack-agreement.cc:34
ns3::OriginatorBlockAckAgreement::IsUnsuccessful
bool IsUnsuccessful(void) const
Check if the current state of this agreement is UNSUCCESSFUL.
Definition:
originator-block-ack-agreement.cc:68
ns3::BlockAckAgreement::m_bufferSize
uint16_t m_bufferSize
Buffer size.
Definition:
block-ack-agreement.h:167
ns3::OriginatorBlockAckAgreement::SetState
void SetState(State state)
Set the current state.
Definition:
originator-block-ack-agreement.cc:39
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::OriginatorBlockAckAgreement::INACTIVE
Definition:
originator-block-ack-agreement.h:102
ns3::Mac48Address
an EUI-48 address
Definition:
mac48-address.h:43
ns3::OriginatorBlockAckAgreement::State
State
Represents the state for this agreement.
Definition:
originator-block-ack-agreement.h:98
ns3::BlockAckAgreement
Maintains information for a block ack agreement.
Definition:
block-ack-agreement.h:32
ns3::OriginatorBlockAckAgreement::NotifyMpduTransmission
void NotifyMpduTransmission(uint16_t nextSeqNumber)
Notifies a packet's transmission with ack policy Block Ack.
Definition:
originator-block-ack-agreement.cc:74
ns3::OriginatorBlockAckAgreement::m_state
State m_state
state
Definition:
originator-block-ack-agreement.h:158
ns3::OriginatorBlockAckAgreement::ESTABLISHED
Definition:
originator-block-ack-agreement.h:101
ns3::OriginatorBlockAckAgreement::UNSUCCESSFUL
Definition:
originator-block-ack-agreement.h:103
ns3::OriginatorBlockAckAgreement::m_needBlockAckReq
bool m_needBlockAckReq
flag whether it needs a Block ACK request
Definition:
originator-block-ack-agreement.h:160
originator-block-ack-agreement.h
ns3::OriginatorBlockAckAgreement::CompleteExchange
void CompleteExchange(void)
Complete exchange function.
Definition:
originator-block-ack-agreement.cc:93
Generated on Wed Nov 7 2018 10:02:14 for ns-3 by
1.8.14