A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
uan-header-common.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2009 University of Washington
3
*
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 2 as
6
* published by the Free Software Foundation;
7
*
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
12
*
13
* You should have received a copy of the GNU General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
*
17
* Author: Leonard Tracy <lentracy@gmail.com>
18
*/
19
20
#ifndef UAN_HEADER_COMMON_H
21
#define UAN_HEADER_COMMON_H
22
23
#include "ns3/header.h"
24
#include "ns3/mac8-address.h"
25
#include "ns3/nstime.h"
26
#include "ns3/simulator.h"
27
28
namespace
ns3
29
{
30
31
/**
32
* \ingroup uan
33
*
34
* UAN protocol descriptor
35
*/
36
struct
UanProtocolBits
37
{
38
uint8_t
m_type
: 4;
//!< type (4 bits)
39
uint8_t
m_protocolNumber
: 4;
//!< protocol number (4 bits)
40
};
41
42
/**
43
* \ingroup uan
44
*
45
* Common packet header fields.
46
*
47
* 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8
48
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
49
* | src addr | dst addr | prtcl | type |
50
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
51
*
52
*
53
* src addr: The MAC8 source address
54
*
55
* dst addr: The MAC8 destination address
56
*
57
* prtcl: The layer 3 protocol
58
* prtcl=1 (IPv4)
59
* prtcl=2 (ARP)
60
* prtcl=3 (IPv6)
61
* prtcl=4 (6LoWPAN)
62
*
63
* type: The type field is MAC protocol specific
64
*/
65
class
UanHeaderCommon
:
public
Header
66
{
67
public
:
68
/** Default constructor */
69
UanHeaderCommon
();
70
/**
71
* Create UanHeaderCommon object with given source and destination
72
* address and header type
73
*
74
* \param src Source address defined in header.
75
* \param dest Destination address defined in header.
76
* \param type Header type.
77
* \param protocolNumber the layer 3 protocol number
78
*/
79
UanHeaderCommon
(
const
Mac8Address
src,
80
const
Mac8Address
dest,
81
uint8_t type,
82
uint8_t protocolNumber);
83
/** Destructor */
84
~UanHeaderCommon
()
override
;
85
86
/**
87
* Register this type.
88
* \return The TypeId.
89
*/
90
static
TypeId
GetTypeId
();
91
92
/**
93
* Set the destination address.
94
*
95
* \param dest Address of destination node.
96
*/
97
void
SetDest
(
Mac8Address
dest);
98
/**
99
* Set the source address.
100
*
101
* \param src Address of packet source node.
102
*/
103
void
SetSrc
(
Mac8Address
src);
104
/**
105
* Set the header type.
106
*
107
* Use of this value is protocol specific.
108
* \param type The type value.
109
*/
110
void
SetType
(uint8_t type);
111
/**
112
* Set the packet type.
113
*
114
* Used to indicate the layer 3 protocol
115
* \param protocolNumber The layer 3 protocol number value.
116
*/
117
void
SetProtocolNumber
(uint16_t protocolNumber);
118
119
/**
120
* Get the destination address.
121
*
122
* \return Mac8Address in destination field.
123
*/
124
Mac8Address
GetDest
()
const
;
125
/**
126
* Get the source address
127
*
128
* \return Mac8Address in source field.
129
*/
130
Mac8Address
GetSrc
()
const
;
131
/**
132
* Get the header type value.
133
*
134
* \return value of type field.
135
*/
136
uint8_t
GetType
()
const
;
137
/**
138
* Get the packet type value.
139
*
140
* \return value of protocolNumber field.
141
*/
142
uint16_t
GetProtocolNumber
()
const
;
143
144
// Inherited methods
145
uint32_t
GetSerializedSize
()
const override
;
146
void
Serialize
(
Buffer::Iterator
start)
const override
;
147
uint32_t
Deserialize
(
Buffer::Iterator
start)
override
;
148
void
Print
(std::ostream& os)
const override
;
149
TypeId
GetInstanceTypeId
()
const override
;
150
151
private
:
152
Mac8Address
m_dest
;
//!< The destination address.
153
Mac8Address
m_src
;
//!< The source address.
154
UanProtocolBits
m_uanProtocolBits
{0};
//!< The type and protocol bits
155
156
};
// class UanHeaderCommon
157
158
}
// namespace ns3
159
160
#endif
/* UAN_HEADER_COMMON_H */
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition:
buffer.h:100
ns3::Header
Protocol header serialization and deserialization.
Definition:
header.h:44
ns3::Mac8Address
A class used for addressing MAC8 MAC's.
Definition:
mac8-address.h:44
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
ns3::UanHeaderCommon
Common packet header fields.
Definition:
uan-header-common.h:66
ns3::UanHeaderCommon::GetTypeId
static TypeId GetTypeId()
Register this type.
Definition:
uan-header-common.cc:51
ns3::UanHeaderCommon::SetSrc
void SetSrc(Mac8Address src)
Set the source address.
Definition:
uan-header-common.cc:77
ns3::UanHeaderCommon::Deserialize
uint32_t Deserialize(Buffer::Iterator start) override
Definition:
uan-header-common.cc:180
ns3::UanHeaderCommon::GetSerializedSize
uint32_t GetSerializedSize() const override
Definition:
uan-header-common.cc:160
ns3::UanHeaderCommon::m_dest
Mac8Address m_dest
The destination address.
Definition:
uan-header-common.h:152
ns3::UanHeaderCommon::GetType
uint8_t GetType() const
Get the header type value.
Definition:
uan-header-common.cc:130
ns3::UanHeaderCommon::m_src
Mac8Address m_src
The source address.
Definition:
uan-header-common.h:153
ns3::UanHeaderCommon::GetDest
Mac8Address GetDest() const
Get the destination address.
Definition:
uan-header-common.cc:118
ns3::UanHeaderCommon::UanHeaderCommon
UanHeaderCommon()
Default constructor.
Definition:
uan-header-common.cc:34
ns3::UanHeaderCommon::SetProtocolNumber
void SetProtocolNumber(uint16_t protocolNumber)
Set the packet type.
Definition:
uan-header-common.cc:89
ns3::UanHeaderCommon::Serialize
void Serialize(Buffer::Iterator start) const override
Definition:
uan-header-common.cc:166
ns3::UanHeaderCommon::GetSrc
Mac8Address GetSrc() const
Get the source address.
Definition:
uan-header-common.cc:124
ns3::UanHeaderCommon::m_uanProtocolBits
UanProtocolBits m_uanProtocolBits
The type and protocol bits.
Definition:
uan-header-common.h:154
ns3::UanHeaderCommon::SetDest
void SetDest(Mac8Address dest)
Set the destination address.
Definition:
uan-header-common.cc:71
ns3::UanHeaderCommon::SetType
void SetType(uint8_t type)
Set the header type.
Definition:
uan-header-common.cc:83
ns3::UanHeaderCommon::~UanHeaderCommon
~UanHeaderCommon() override
Destructor.
Definition:
uan-header-common.cc:66
ns3::UanHeaderCommon::Print
void Print(std::ostream &os) const override
Definition:
uan-header-common.cc:194
ns3::UanHeaderCommon::GetProtocolNumber
uint16_t GetProtocolNumber() const
Get the packet type value.
Definition:
uan-header-common.cc:136
ns3::UanHeaderCommon::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition:
uan-header-common.cc:61
uint32_t
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::UanProtocolBits
UAN protocol descriptor.
Definition:
uan-header-common.h:37
ns3::UanProtocolBits::m_protocolNumber
uint8_t m_protocolNumber
protocol number (4 bits)
Definition:
uan-header-common.h:39
ns3::UanProtocolBits::m_type
uint8_t m_type
type (4 bits)
Definition:
uan-header-common.h:38
src
uan
model
uan-header-common.h
Generated on Tue May 28 2024 23:39:52 for ns-3 by
1.9.6