1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2009, 2010 MIRKO BANCHI
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Authors: Mirko Banchi <mk.banchi@gmail.com>
* Tommaso Pecorella <tommaso.pecorella@unifi.it>
*/
#include "originator-block-ack-agreement.h"
namespace ns3 {
OriginatorBlockAckAgreement::OriginatorBlockAckAgreement ()
: BlockAckAgreement (),
m_state (PENDING),
m_sentMpdus (0),
m_needBlockAckReq (false)
{
}
OriginatorBlockAckAgreement::OriginatorBlockAckAgreement (Mac48Address recipient, uint8_t tid)
: BlockAckAgreement (recipient, tid),
m_state (PENDING),
m_sentMpdus (0),
m_needBlockAckReq (false)
{
}
OriginatorBlockAckAgreement::~OriginatorBlockAckAgreement ()
{
//NS_LOG_FUNCTION (this);
//std::cout<<"destructor for OriginatorBlockAckAgreement is called, destroy event is canceled, destroy agreement with="<<m_peer<<"\n";
m_OriginatorInactivityEvent.Cancel ();
}
void
OriginatorBlockAckAgreement::SetState (enum State state)
{
m_state = state;
if (state == INACTIVE)
{
m_needBlockAckReq = false;
m_sentMpdus = 0;
}
}
bool
OriginatorBlockAckAgreement::IsPending (void) const
{
return (m_state == PENDING) ? true : false;
}
bool
OriginatorBlockAckAgreement::IsEstablished (void) const
{
return (m_state == ESTABLISHED) ? true : false;
}
bool
OriginatorBlockAckAgreement::IsInactive (void) const
{
return (m_state == INACTIVE) ? true : false;
}
bool
OriginatorBlockAckAgreement::IsUnsuccessful (void) const
{
return (m_state == UNSUCCESSFUL) ? true : false;
}
void
OriginatorBlockAckAgreement::NotifyMpduTransmission (uint16_t nextSeqNumber)
{
NS_ASSERT (m_sentMpdus < m_bufferSize);
m_sentMpdus++;
uint16_t delta = (nextSeqNumber - m_startingSeq + 4096) % 4096;
uint16_t min = m_bufferSize < 64 ? m_bufferSize : 64;
if (delta >= min || m_sentMpdus == m_bufferSize)
{
m_needBlockAckReq = true;
}
}
bool
OriginatorBlockAckAgreement::IsBlockAckRequestNeeded (void) const
{
return m_needBlockAckReq;
}
void
OriginatorBlockAckAgreement::CompleteExchange (void)
{
m_needBlockAckReq = false;
m_sentMpdus = 0;
}
} //namespace ns3
|