A Discrete-Event Network Simulator
API
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 
21 #include "ns3/log.h"
22 #include "ns3/uinteger.h"
24 
25 namespace ns3 {
26 
27 NS_LOG_COMPONENT_DEFINE ("MsduStandardAggregator");
28 
29 NS_OBJECT_ENSURE_REGISTERED (MsduStandardAggregator);
30 
31 TypeId
33 {
34  static TypeId tid = TypeId ("ns3::MsduStandardAggregator")
36  .SetGroupName ("Wifi")
37  .AddConstructor<MsduStandardAggregator> ()
38  .AddAttribute ("MaxAmsduSize", "Max length in byte of an A-MSDU (Deprecated!)",
39  UintegerValue (7935),
41  MakeUintegerChecker<uint32_t> ())
42  ;
43  return tid;
44 }
45 
47 {
48 }
49 
51 {
52 }
53 
54 void
56 {
57  m_maxAmsduLength = maxSize;
58 }
59 
60 uint32_t
62 {
63  return m_maxAmsduLength;
64 }
65 
66 bool
68  Mac48Address src, Mac48Address dest) const
69 {
70  NS_LOG_FUNCTION (this);
71  Ptr<Packet> currentPacket;
72  AmsduSubframeHeader currentHdr;
73 
74  uint32_t padding = CalculatePadding (aggregatedPacket);
75  uint32_t actualSize = aggregatedPacket->GetSize ();
76 
77  if ((14 + packet->GetSize () + actualSize + padding) <= m_maxAmsduLength)
78  {
79  if (padding)
80  {
81  Ptr<Packet> pad = Create<Packet> (padding);
82  aggregatedPacket->AddAtEnd (pad);
83  }
84  currentHdr.SetDestinationAddr (dest);
85  currentHdr.SetSourceAddr (src);
86  currentHdr.SetLength (packet->GetSize ());
87  currentPacket = packet->Copy ();
88 
89  currentPacket->AddHeader (currentHdr);
90  aggregatedPacket->AddAtEnd (currentPacket);
91  return true;
92  }
93  return false;
94 }
95 
96 uint32_t
98 {
99  return (4 - (packet->GetSize () % 4 )) % 4;
100 }
101 
102 } //namespace ns3
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
void SetMaxAmsduSize(uint32_t maxSize)
Sets the maximum A-MSDU size in bytes.
static TypeId GetTypeId(void)
Get the type ID.
uint32_t CalculatePadding(Ptr< const Packet > packet) const
Calculates how much padding must be added to the end of aggregated packet, after that a new packet is...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:796
void SetSourceAddr(Mac48Address to)
Set source address function.
void AddAtEnd(Ptr< const Packet > packet)
Concatenate the input packet at the end of the current packet.
Definition: packet.cc:312
uint32_t GetMaxAmsduSize(void) const
Returns the maximum A-MSDU size in bytes.
Hold an unsigned integer type.
Definition: uinteger.h:44
void SetLength(uint16_t length)
Set length function.
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
Definition: packet.cc:121
Every class exported by the ns3 library is enclosed in the ns3 namespace.
an EUI-48 address
Definition: mac48-address.h:43
Introspection did not find any typical Config paths.
void SetDestinationAddr(Mac48Address to)
Set destination address function.
bool Aggregate(Ptr< const Packet > packet, Ptr< Packet > aggregatedPacket, Mac48Address src, Mac48Address dest) const
Abstract class that concrete msdu aggregators have to implement.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: uinteger.h:45
uint32_t m_maxAmsduLength
maximum AMSDU length
a unique identifier for an interface.
Definition: type-id.h:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:914
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:256
Standard MSDU aggregator.