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-standard-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
#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> ())
42
;
43
return
tid;
44
}
45
46
MsduStandardAggregator::MsduStandardAggregator
()
47
{
48
}
49
50
MsduStandardAggregator::~MsduStandardAggregator
()
51
{
52
}
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
62
uint32_t padding =
CalculatePadding
(aggregatedPacket);
63
uint32_t actualSize = aggregatedPacket->
GetSize
();
64
65
if
((14 + packet->
GetSize
() + actualSize + padding) <=
m_maxAmsduLength
)
66
{
67
if
(padding)
68
{
69
Ptr<Packet>
pad = Create<Packet> (padding);
70
aggregatedPacket->
AddAtEnd
(pad);
71
}
72
currentHdr.
SetDestinationAddr
(dest);
73
currentHdr.
SetSourceAddr
(src);
74
currentHdr.
SetLength
(packet->
GetSize
());
75
currentPacket = packet->
Copy
();
76
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
{
87
return
(4 - (packet->
GetSize
() % 4 )) % 4;
88
}
89
90
}
// namespace ns3
ns3::Ptr< const Packet >
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
Definition:
log-macros-enabled.h:207
amsdu-subframe-header.h
ns3::AmsduSubframeHeader::SetLength
void SetLength(uint16_t)
Definition:
amsdu-subframe-header.cc:106
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register the class in the ns-3 factory.
Definition:
object-base.h:38
ns3::MsduStandardAggregator::GetTypeId
static TypeId GetTypeId(void)
Definition:
msdu-standard-aggregator.cc:33
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:170
ns3::Packet::GetSize
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition:
packet.h:744
ns3::MsduStandardAggregator::Aggregate
virtual bool Aggregate(Ptr< const Packet > packet, Ptr< Packet > aggregatedPacket, Mac48Address src, Mac48Address dest)
Definition:
msdu-standard-aggregator.cc:55
ns3::MsduStandardAggregator::MsduStandardAggregator
MsduStandardAggregator()
Definition:
msdu-standard-aggregator.cc:46
ns3::AmsduSubframeHeader::SetSourceAddr
void SetSourceAddr(Mac48Address to)
Definition:
amsdu-subframe-header.cc:99
ns3::Packet::AddAtEnd
void AddAtEnd(Ptr< const Packet > packet)
Concatenate the input packet at the end of the current packet.
Definition:
packet.cc:317
ns3::UintegerValue
Hold an unsigned integer type.
Definition:
uinteger.h:46
msdu-standard-aggregator.h
ns3::MsduStandardAggregator::~MsduStandardAggregator
~MsduStandardAggregator()
Definition:
msdu-standard-aggregator.cc:50
ns3::Packet::Copy
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
Definition:
packet.cc:122
ns3::Mac48Address
an EUI-48 address
Definition:
mac48-address.h:41
ns3::AmsduSubframeHeader
Doxygen introspection did not find any typical Config paths.
Definition:
amsdu-subframe-header.h:33
ns3::MsduStandardAggregator::CalculatePadding
uint32_t CalculatePadding(Ptr< const Packet > packet)
Calculates how much padding must be added to the end of aggregated packet, after that a new packet is...
Definition:
msdu-standard-aggregator.cc:85
ns3::AmsduSubframeHeader::SetDestinationAddr
void SetDestinationAddr(Mac48Address to)
Definition:
amsdu-subframe-header.cc:92
ns3::MsduAggregator
Abstract class that concrete msdu aggregators have to implement.
Definition:
msdu-aggregator.h:39
ns3::MsduStandardAggregator::m_maxAmsduLength
uint32_t m_maxAmsduLength
Definition:
msdu-standard-aggregator.h:61
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:49
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Definition:
type-id.cc:610
ns3::Packet::AddHeader
void AddHeader(const Header &header)
Add header to this packet.
Definition:
packet.cc:253
src
wifi
model
msdu-standard-aggregator.cc
Generated on Wed Sep 17 2014 23:33:43 for ns-3 by
1.8.6