author | Kirill Andreev <andreev@iitp.ru> |
Mon, 03 Aug 2009 19:13:46 +0400 | |
changeset 5145 | 7f50ab7ce59d |
parent 4499 | 3b5ef83fae25 |
permissions | -rw-r--r-- |
4408 | 1 |
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
2 |
/* |
|
3 |
* Copyright (c) 2009 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 |
*/ |
|
20 |
#include "ns3/log.h" |
|
21 |
||
22 |
#include "msdu-aggregator.h" |
|
23 |
#include "wifi-mac-header.h" |
|
24 |
||
25 |
NS_LOG_COMPONENT_DEFINE ("MsduAggregator"); |
|
26 |
||
27 |
namespace ns3 { |
|
28 |
||
29 |
NS_OBJECT_ENSURE_REGISTERED (MsduAggregator); |
|
30 |
||
31 |
TypeId |
|
32 |
MsduAggregator::GetTypeId (void) |
|
33 |
{ |
|
34 |
static TypeId tid = TypeId ("ns3::MsduAggregator") |
|
35 |
.SetParent<Object> () |
|
36 |
; |
|
37 |
return tid; |
|
38 |
} |
|
39 |
||
40 |
MsduAggregator::DeaggregatedMsdus |
|
41 |
MsduAggregator::Deaggregate (Ptr<Packet> aggregatedPacket) |
|
42 |
{ |
|
43 |
NS_LOG_FUNCTION_NOARGS (); |
|
44 |
DeaggregatedMsdus set; |
|
45 |
||
46 |
AmsduSubframeHeader hdr; |
|
4499
3b5ef83fae25
aggregated MSDUs must not lose their tags
Mirko Banchi <mk.banchi@gmail.com>
parents:
4458
diff
changeset
|
47 |
Ptr<Packet> extractedMsdu = Create<Packet> (); |
4408 | 48 |
uint32_t maxSize = aggregatedPacket->GetSize (); |
4499
3b5ef83fae25
aggregated MSDUs must not lose their tags
Mirko Banchi <mk.banchi@gmail.com>
parents:
4458
diff
changeset
|
49 |
uint16_t extractedLength; |
4408 | 50 |
uint32_t padding; |
51 |
uint32_t deserialized = 0; |
|
52 |
||
53 |
while (deserialized < maxSize) |
|
54 |
{ |
|
55 |
deserialized += aggregatedPacket->RemoveHeader (hdr); |
|
4499
3b5ef83fae25
aggregated MSDUs must not lose their tags
Mirko Banchi <mk.banchi@gmail.com>
parents:
4458
diff
changeset
|
56 |
extractedLength = hdr.GetLength (); |
3b5ef83fae25
aggregated MSDUs must not lose their tags
Mirko Banchi <mk.banchi@gmail.com>
parents:
4458
diff
changeset
|
57 |
extractedMsdu = aggregatedPacket->CreateFragment (0, static_cast<uint32_t>(extractedLength)); |
3b5ef83fae25
aggregated MSDUs must not lose their tags
Mirko Banchi <mk.banchi@gmail.com>
parents:
4458
diff
changeset
|
58 |
aggregatedPacket->RemoveAtStart (extractedLength); |
3b5ef83fae25
aggregated MSDUs must not lose their tags
Mirko Banchi <mk.banchi@gmail.com>
parents:
4458
diff
changeset
|
59 |
deserialized += extractedLength; |
4408 | 60 |
|
4499
3b5ef83fae25
aggregated MSDUs must not lose their tags
Mirko Banchi <mk.banchi@gmail.com>
parents:
4458
diff
changeset
|
61 |
padding = (4 - ((extractedLength + 14) %4 )) % 4; |
4408 | 62 |
|
4458
f8b83f855f67
last amsdu subframe in an A-MSDU should have no padding
Mirko Banchi <mk.banchi@gmail.com>
parents:
4408
diff
changeset
|
63 |
if (padding > 0 && deserialized < maxSize) |
4408 | 64 |
{ |
65 |
aggregatedPacket->RemoveAtStart (padding); |
|
66 |
deserialized += padding; |
|
67 |
} |
|
68 |
||
4499
3b5ef83fae25
aggregated MSDUs must not lose their tags
Mirko Banchi <mk.banchi@gmail.com>
parents:
4458
diff
changeset
|
69 |
std::pair<Ptr<Packet>, AmsduSubframeHeader> packetHdr (extractedMsdu, hdr); |
4408 | 70 |
set.push_back (packetHdr); |
71 |
} |
|
72 |
NS_LOG_INFO ("Deaggreated A-MSDU: extracted "<< set.size () << " MSDUs"); |
|
73 |
return set; |
|
74 |
} |
|
75 |
||
76 |
} //namespace ns3 |