author | Vedran Miletić <rivanvx@gmail.com> |
Tue, 02 Aug 2011 17:42:33 -0400 | |
changeset 7385 | 10beb0e53130 |
parent 7141 | 072fb225b714 |
child 7386 | 2310ed220a61 |
permissions | -rw-r--r-- |
7385
10beb0e53130
standardize emacs c++ mode comments
Vedran Miletić <rivanvx@gmail.com>
parents:
7141
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
4408 | 2 |
/* |
3 |
* Copyright (c) 2009 MIRKO BANCHI |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or modify |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
4408 | 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 |
*/ |
|
20 |
#include "ns3/log.h" |
|
21 |
#include "ns3/uinteger.h" |
|
22 |
||
23 |
#include "amsdu-subframe-header.h" |
|
24 |
#include "msdu-standard-aggregator.h" |
|
25 |
||
26 |
NS_LOG_COMPONENT_DEFINE ("MsduStandardAggregator"); |
|
27 |
||
28 |
namespace ns3 { |
|
29 |
||
30 |
NS_OBJECT_ENSURE_REGISTERED (MsduStandardAggregator); |
|
31 |
||
32 |
TypeId |
|
33 |
MsduStandardAggregator::GetTypeId (void) |
|
34 |
{ |
|
35 |
static TypeId tid = TypeId ("ns3::MsduStandardAggregator") |
|
36 |
.SetParent<MsduAggregator> () |
|
37 |
.AddConstructor<MsduStandardAggregator> () |
|
38 |
.AddAttribute ("MaxAmsduSize", "Max length in byte of an A-MSDU", |
|
39 |
UintegerValue (7935), |
|
40 |
MakeUintegerAccessor (&MsduStandardAggregator::m_maxAmsduLength), |
|
41 |
MakeUintegerChecker<uint32_t> ()) |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
42 |
; |
4408 | 43 |
return tid; |
44 |
} |
|
45 |
||
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
46 |
MsduStandardAggregator::MsduStandardAggregator () |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
47 |
{ |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
48 |
} |
4408 | 49 |
|
50 |
MsduStandardAggregator::~MsduStandardAggregator () |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
51 |
{ |
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
52 |
} |
4408 | 53 |
|
54 |
bool |
|
55 |
MsduStandardAggregator::Aggregate (Ptr<const Packet> packet, Ptr<Packet> aggregatedPacket, |
|
56 |
Mac48Address src, Mac48Address dest) |
|
57 |
{ |
|
58 |
NS_LOG_FUNCTION (this); |
|
59 |
Ptr<Packet> currentPacket; |
|
60 |
AmsduSubframeHeader currentHdr; |
|
61 |
||
4458
f8b83f855f67
last amsdu subframe in an A-MSDU should have no padding
Mirko Banchi <mk.banchi@gmail.com>
parents:
4408
diff
changeset
|
62 |
uint32_t padding = CalculatePadding (aggregatedPacket); |
4408 | 63 |
uint32_t actualSize = aggregatedPacket->GetSize (); |
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
64 |
|
4408 | 65 |
if ((14 + packet->GetSize () + actualSize + padding) <= m_maxAmsduLength) |
66 |
{ |
|
4458
f8b83f855f67
last amsdu subframe in an A-MSDU should have no padding
Mirko Banchi <mk.banchi@gmail.com>
parents:
4408
diff
changeset
|
67 |
if (padding) |
f8b83f855f67
last amsdu subframe in an A-MSDU should have no padding
Mirko Banchi <mk.banchi@gmail.com>
parents:
4408
diff
changeset
|
68 |
{ |
5400
56737002c3c7
Fix valgrind errors for simple-wifi-frame-aggregation example.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4458
diff
changeset
|
69 |
Ptr<Packet> pad = Create<Packet> (padding); |
56737002c3c7
Fix valgrind errors for simple-wifi-frame-aggregation example.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4458
diff
changeset
|
70 |
aggregatedPacket->AddAtEnd (pad); |
4458
f8b83f855f67
last amsdu subframe in an A-MSDU should have no padding
Mirko Banchi <mk.banchi@gmail.com>
parents:
4408
diff
changeset
|
71 |
} |
4408 | 72 |
currentHdr.SetDestinationAddr (dest); |
73 |
currentHdr.SetSourceAddr (src); |
|
74 |
currentHdr.SetLength (packet->GetSize ()); |
|
75 |
currentPacket = packet->Copy (); |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
76 |
|
4408 | 77 |
currentPacket->AddHeader (currentHdr); |
78 |
aggregatedPacket->AddAtEnd (currentPacket); |
|
79 |
return true; |
|
80 |
} |
|
81 |
return false; |
|
82 |
} |
|
83 |
||
84 |
uint32_t |
|
85 |
MsduStandardAggregator::CalculatePadding (Ptr<const Packet> packet) |
|
86 |
{ |
|
7141
072fb225b714
run check-style.py on src/wifi
Nicola Baldo <nicola@baldo.biz>
parents:
6852
diff
changeset
|
87 |
return (4 - (packet->GetSize () % 4 )) % 4; |
4408 | 88 |
} |
89 |
||
90 |
} //namespace ns3 |