A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
msdu-aggregator.cc
Go to the documentation of this file.
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;
47
Ptr<Packet>
extractedMsdu = Create<Packet> ();
48
uint32_t maxSize = aggregatedPacket->
GetSize
();
49
uint16_t extractedLength;
50
uint32_t padding;
51
uint32_t deserialized = 0;
52
53
while
(deserialized < maxSize)
54
{
55
deserialized += aggregatedPacket->
RemoveHeader
(hdr);
56
extractedLength = hdr.
GetLength
();
57
extractedMsdu = aggregatedPacket->
CreateFragment
(0, static_cast<uint32_t> (extractedLength));
58
aggregatedPacket->
RemoveAtStart
(extractedLength);
59
deserialized += extractedLength;
60
61
padding = (4 - ((extractedLength + 14) % 4 )) % 4;
62
63
if
(padding > 0 && deserialized < maxSize)
64
{
65
aggregatedPacket->
RemoveAtStart
(padding);
66
deserialized += padding;
67
}
68
69
std::pair<Ptr<Packet>,
AmsduSubframeHeader
> packetHdr (extractedMsdu, hdr);
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
src
wifi
model
msdu-aggregator.cc
Generated on Tue Oct 9 2012 16:45:48 for ns-3 by
1.8.1.2