A Discrete-Event Network Simulator
API
higher-tx-tag.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2008 INRIA
4  * Copyright (c) 2013 Dalian University of Technology
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation;
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
20  * Junling Bu <linlinjavaer@gmail.com>
21  */
22 #include "higher-tx-tag.h"
23 #include "ns3/log.h"
24 #include "ns3/abort.h"
25 
26 namespace ns3 {
27 
28 NS_LOG_COMPONENT_DEFINE ("HigherLayerTxVectorTag");
29 
30 NS_OBJECT_ENSURE_REGISTERED (HigherLayerTxVectorTag);
31 
32 TypeId
34 {
35  static TypeId tid = TypeId ("ns3::HigherLayerTxVectorTag")
36  .SetParent<Tag> ()
37  .SetGroupName ("Wave")
38  .AddConstructor<HigherLayerTxVectorTag> ()
39  ;
40  return tid;
41 }
42 
43 TypeId
45 {
46  NS_LOG_FUNCTION (this);
47  return GetTypeId ();
48 }
49 
51  : m_adaptable (false)
52 {
53  NS_LOG_FUNCTION (this);
54 }
55 
57  : m_txVector (txVector),
58  m_adaptable (adaptable)
59 {
60  NS_LOG_FUNCTION (this);
61  NS_ABORT_MSG_IF (txVector.GetPreambleType () == WIFI_PREAMBLE_HE_MU, "HE MU is not compatible with this tag");
62 }
63 
66 {
67  NS_LOG_FUNCTION (this);
68  return m_txVector;
69 }
70 
71 bool
73 {
74  NS_LOG_FUNCTION (this);
75  return m_adaptable;
76 }
77 
78 uint32_t
80 {
81  NS_LOG_FUNCTION (this);
82  return (sizeof (WifiTxVector) + 1);
83 }
84 
85 void
87 {
88  NS_LOG_FUNCTION (this << &i);
89  i.Write ((uint8_t *)&m_txVector, sizeof (WifiTxVector));
90  i.WriteU8 (static_cast<uint8_t> (m_adaptable));
91 }
92 
93 void
95 {
96  NS_LOG_FUNCTION (this << &i);
97  i.Read ((uint8_t *)&m_txVector, sizeof (WifiTxVector));
98  m_adaptable = i.ReadU8 ();
99 }
100 
101 void
102 HigherLayerTxVectorTag::Print (std::ostream &os) const
103 {
104  NS_LOG_FUNCTION (this << &os);
105  os << " TxVector=" << m_txVector << "; Adapter=" << m_adaptable;
106 }
107 
108 } // namespace ns3
This tag will be used to support higher layer control DataRate and TxPwr_Level for transmission.
Definition: higher-tx-tag.h:48
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
WifiTxVector GetTxVector(void) const
bool IsAdaptable(void) const
virtual uint32_t GetSerializedSize(void) const
WifiTxVector m_txVector
transmit vector
Definition: higher-tx-tag.h:80
virtual void Print(std::ostream &os) const
virtual void Serialize(TagBuffer i) const
static TypeId GetTypeId(void)
Get the type ID.
virtual void Deserialize(TagBuffer i)
read and write tag data
Definition: tag-buffer.h:52
void Read(uint8_t *buffer, uint32_t size)
Definition: tag-buffer.cc:176
TAG_BUFFER_INLINE void WriteU8(uint8_t v)
Definition: tag-buffer.h:172
void Write(const uint8_t *buffer, uint32_t size)
Definition: tag-buffer.cc:125
TAG_BUFFER_INLINE uint8_t ReadU8(void)
Definition: tag-buffer.h:195
tag a set of bytes in a packet
Definition: tag.h:37
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
WifiPreamble GetPreambleType(void) const
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition: abort.h:108
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#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
@ WIFI_PREAMBLE_HE_MU
Every class exported by the ns3 library is enclosed in the ns3 namespace.