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 
25 namespace ns3 {
26 
27 NS_LOG_COMPONENT_DEFINE ("HigherLayerTxVectorTag");
28 
29 NS_OBJECT_ENSURE_REGISTERED (HigherLayerTxVectorTag);
30 
31 TypeId
33 {
34  static TypeId tid = TypeId ("ns3::HigherLayerTxVectorTag")
35  .SetParent<Tag> ()
36  .SetGroupName ("Wave")
37  .AddConstructor<HigherLayerTxVectorTag> ()
38  ;
39  return tid;
40 }
41 
42 TypeId
44 {
45  NS_LOG_FUNCTION (this);
46  return GetTypeId ();
47 }
48 
50  : m_adaptable (false)
51 {
52  NS_LOG_FUNCTION (this);
53 }
54 
56  : m_txVector (txVector),
57  m_adaptable (adaptable)
58 {
59  NS_LOG_FUNCTION (this);
60 }
61 
64 {
65  NS_LOG_FUNCTION (this);
66  return m_txVector;
67 }
68 
69 bool
71 {
72  NS_LOG_FUNCTION (this);
73  return m_adaptable;
74 }
75 
76 uint32_t
78 {
79  NS_LOG_FUNCTION (this);
80  return (sizeof (WifiTxVector) + 1);
81 }
82 
83 void
85 {
86  NS_LOG_FUNCTION (this << &i);
87  i.Write ((uint8_t *)&m_txVector, sizeof (WifiTxVector));
88  i.WriteU8 (static_cast<uint8_t> (m_adaptable));
89 }
90 
91 void
93 {
94  NS_LOG_FUNCTION (this << &i);
95  i.Read ((uint8_t *)&m_txVector, sizeof (WifiTxVector));
96  m_adaptable = i.ReadU8 ();
97 }
98 
99 void
100 HigherLayerTxVectorTag::Print (std::ostream &os) const
101 {
102  NS_LOG_FUNCTION (this << &os);
103  os << " TxVector=" << m_txVector << "; Adapter=" << m_adaptable;
104 }
105 
106 } // namespace ns3
virtual void Print(std::ostream &os) const
void Write(const uint8_t *buffer, uint32_t size)
Definition: tag-buffer.cc:125
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:44
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
TAG_BUFFER_INLINE uint8_t ReadU8(void)
Definition: tag-buffer.h:195
This tag will be used to support higher layer control DataRate and TxPwr_Level for transmission...
Definition: higher-tx-tag.h:45
virtual void Deserialize(TagBuffer i)
bool IsAdaptable(void) const
virtual uint32_t GetSerializedSize(void) const
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
WifiTxVector GetTxVector(void) const
tag a set of bytes in a packet
Definition: tag.h:36
Every class exported by the ns3 library is enclosed in the ns3 namespace.
TAG_BUFFER_INLINE void WriteU8(uint8_t v)
Definition: tag-buffer.h:172
read and write tag data
Definition: tag-buffer.h:51
static TypeId GetTypeId(void)
void Read(uint8_t *buffer, uint32_t size)
Definition: tag-buffer.cc:176
a unique identifier for an interface.
Definition: type-id.h:58
virtual void Serialize(TagBuffer i) const
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:904