A Discrete-Event Network Simulator
API
 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"
25 
26 NS_LOG_COMPONENT_DEFINE ("MsduStandardAggregator");
27 
28 namespace ns3 {
29 
30 NS_OBJECT_ENSURE_REGISTERED (MsduStandardAggregator)
31  ;
32 
33 TypeId
35 {
36  static TypeId tid = TypeId ("ns3::MsduStandardAggregator")
38  .AddConstructor<MsduStandardAggregator> ()
39  .AddAttribute ("MaxAmsduSize", "Max length in byte of an A-MSDU",
40  UintegerValue (7935),
41  MakeUintegerAccessor (&MsduStandardAggregator::m_maxAmsduLength),
42  MakeUintegerChecker<uint32_t> ())
43  ;
44  return tid;
45 }
46 
48 {
49 }
50 
52 {
53 }
54 
55 bool
57  Mac48Address src, Mac48Address dest)
58 {
59  NS_LOG_FUNCTION (this);
60  Ptr<Packet> currentPacket;
61  AmsduSubframeHeader currentHdr;
62 
63  uint32_t padding = CalculatePadding (aggregatedPacket);
64  uint32_t actualSize = aggregatedPacket->GetSize ();
65 
66  if ((14 + packet->GetSize () + actualSize + padding) <= m_maxAmsduLength)
67  {
68  if (padding)
69  {
70  Ptr<Packet> pad = Create<Packet> (padding);
71  aggregatedPacket->AddAtEnd (pad);
72  }
73  currentHdr.SetDestinationAddr (dest);
74  currentHdr.SetSourceAddr (src);
75  currentHdr.SetLength (packet->GetSize ());
76  currentPacket = packet->Copy ();
77 
78  currentPacket->AddHeader (currentHdr);
79  aggregatedPacket->AddAtEnd (currentPacket);
80  return true;
81  }
82  return false;
83 }
84 
85 uint32_t
87 {
88  return (4 - (packet->GetSize () % 4 )) % 4;
89 }
90 
91 } // namespace ns3
#define NS_LOG_FUNCTION(parameters)
Definition: log.h:345
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
uint32_t GetSize(void) const
Definition: packet.h:650
virtual bool Aggregate(Ptr< const Packet > packet, Ptr< Packet > aggregatedPacket, Mac48Address src, Mac48Address dest)
void SetSourceAddr(Mac48Address to)
void AddAtEnd(Ptr< const Packet > packet)
Concatenate the input packet at the end of the current packet.
Definition: packet.cc:317
Hold an unsigned integer type.
Definition: uinteger.h:46
NS_LOG_COMPONENT_DEFINE("MsduStandardAggregator")
Ptr< Packet > Copy(void) const
Definition: packet.cc:122
an EUI-48 address
Definition: mac48-address.h:41
Doxygen introspection did not find any typical Config paths.
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...
void SetDestinationAddr(Mac48Address to)
Abstract class that concrete msdu aggregators have to implement.
a unique identifier for an interface.
Definition: type-id.h:49
TypeId SetParent(TypeId tid)
Definition: type-id.cc:611
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:253