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
32
TypeId
33
MsduAggregator::GetTypeId
(
void
)
34
{
35
static
TypeId
tid =
TypeId
(
"ns3::MsduAggregator"
)
36
.
SetParent
<
Object
> ()
37
;
38
return
tid;
39
}
40
41
MsduAggregator::DeaggregatedMsdus
42
MsduAggregator::Deaggregate
(
Ptr<Packet>
aggregatedPacket)
43
{
44
NS_LOG_FUNCTION_NOARGS
();
45
DeaggregatedMsdus
set;
46
47
AmsduSubframeHeader
hdr;
48
Ptr<Packet>
extractedMsdu = Create<Packet> ();
49
uint32_t maxSize = aggregatedPacket->
GetSize
();
50
uint16_t extractedLength;
51
uint32_t padding;
52
uint32_t deserialized = 0;
53
54
while
(deserialized < maxSize)
55
{
56
deserialized += aggregatedPacket->
RemoveHeader
(hdr);
57
extractedLength = hdr.
GetLength
();
58
extractedMsdu = aggregatedPacket->
CreateFragment
(0, static_cast<uint32_t> (extractedLength));
59
aggregatedPacket->
RemoveAtStart
(extractedLength);
60
deserialized += extractedLength;
61
62
padding = (4 - ((extractedLength + 14) % 4 )) % 4;
63
64
if
(padding > 0 && deserialized < maxSize)
65
{
66
aggregatedPacket->
RemoveAtStart
(padding);
67
deserialized += padding;
68
}
69
70
std::pair<Ptr<Packet>,
AmsduSubframeHeader
> packetHdr (extractedMsdu, hdr);
71
set.push_back (packetHdr);
72
}
73
NS_LOG_INFO
(
"Deaggreated A-MSDU: extracted "
<< set.size () <<
" MSDUs"
);
74
return
set;
75
}
76
77
}
// namespace ns3
ns3::Packet::RemoveHeader
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Definition:
packet.cc:268
ns3::Ptr< Packet >
ns3::NS_OBJECT_ENSURE_REGISTERED
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
ns3::Packet::GetSize
uint32_t GetSize(void) const
Definition:
packet.h:650
NS_LOG_COMPONENT_DEFINE
NS_LOG_COMPONENT_DEFINE("MsduAggregator")
ns3::MsduAggregator::Deaggregate
static DeaggregatedMsdus Deaggregate(Ptr< Packet > aggregatedPacket)
Definition:
msdu-aggregator.cc:42
NS_LOG_INFO
#define NS_LOG_INFO(msg)
Definition:
log.h:298
NS_LOG_FUNCTION_NOARGS
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
Definition:
log.h:309
ns3::Packet::CreateFragment
Ptr< Packet > CreateFragment(uint32_t start, uint32_t length) const
Create a new packet which contains a fragment of the original packet.
Definition:
packet.cc:228
ns3::Packet::RemoveAtStart
void RemoveAtStart(uint32_t size)
Remove size bytes from the start of the current packet.
Definition:
packet.cc:353
msdu-aggregator.h
wifi-mac-header.h
ns3::MsduAggregator::GetTypeId
static TypeId GetTypeId(void)
Definition:
msdu-aggregator.cc:33
ns3::MsduAggregator::DeaggregatedMsdus
std::list< std::pair< Ptr< Packet >, AmsduSubframeHeader > > DeaggregatedMsdus
Definition:
msdu-aggregator.h:42
ns3::AmsduSubframeHeader
Doxygen introspection did not find any typical Config paths.
Definition:
amsdu-subframe-header.h:33
ns3::Object
a base class which provides memory management and object aggregation
Definition:
object.h:63
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:49
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Definition:
type-id.cc:611
ns3::AmsduSubframeHeader::GetLength
uint16_t GetLength(void) const
Definition:
amsdu-subframe-header.cc:128
src
wifi
model
msdu-aggregator.cc
Generated on Sat Apr 19 2014 14:07:11 for ns-3 by
1.8.6