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
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Leonard Tracy <lentracy@gmail.com>
7
*/
8
9
#ifndef UAN_HEADER_COMMON_H
10
#define UAN_HEADER_COMMON_H
11
12
#include "ns3/header.h"
13
#include "ns3/mac8-address.h"
14
#include "ns3/nstime.h"
15
#include "ns3/simulator.h"
16
17
namespace
ns3
18
{
19
20
/**
21
* \ingroup uan
22
*
23
* UAN protocol descriptor
24
*/
25
struct
UanProtocolBits
26
{
27
uint8_t
m_type
: 4;
//!< type (4 bits)
28
uint8_t
m_protocolNumber
: 4;
//!< protocol number (4 bits)
29
};
30
31
/**
32
* \ingroup uan
33
*
34
* Common packet header fields.
35
*
36
* 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8
37
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
38
* | src addr | dst addr | prtcl | type |
39
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
40
*
41
*
42
* src addr: The MAC8 source address
43
*
44
* dst addr: The MAC8 destination address
45
*
46
* prtcl: The layer 3 protocol
47
* prtcl=1 (IPv4)
48
* prtcl=2 (ARP)
49
* prtcl=3 (IPv6)
50
* prtcl=4 (6LoWPAN)
51
*
52
* type: The type field is MAC protocol specific
53
*/
54
class
UanHeaderCommon
:
public
Header
55
{
56
public
:
57
/** Default constructor */
58
UanHeaderCommon
();
59
/**
60
* Create UanHeaderCommon object with given source and destination
61
* address and header type
62
*
63
* \param src Source address defined in header.
64
* \param dest Destination address defined in header.
65
* \param type Header type.
66
* \param protocolNumber the layer 3 protocol number
67
*/
68
UanHeaderCommon
(
const
Mac8Address
src,
69
const
Mac8Address
dest,
70
uint8_t type,
71
uint8_t protocolNumber);
72
/** Destructor */
73
~UanHeaderCommon
()
override
;
74
75
/**
76
* Register this type.
77
* \return The TypeId.
78
*/
79
static
TypeId
GetTypeId
();
80
81
/**
82
* Set the destination address.
83
*
84
* \param dest Address of destination node.
85
*/
86
void
SetDest
(
Mac8Address
dest);
87
/**
88
* Set the source address.
89
*
90
* \param src Address of packet source node.
91
*/
92
void
SetSrc
(
Mac8Address
src);
93
/**
94
* Set the header type.
95
*
96
* Use of this value is protocol specific.
97
* \param type The type value.
98
*/
99
void
SetType
(uint8_t type);
100
/**
101
* Set the packet type.
102
*
103
* Used to indicate the layer 3 protocol
104
* \param protocolNumber The layer 3 protocol number value.
105
*/
106
void
SetProtocolNumber
(uint16_t protocolNumber);
107
108
/**
109
* Get the destination address.
110
*
111
* \return Mac8Address in destination field.
112
*/
113
Mac8Address
GetDest
()
const
;
114
/**
115
* Get the source address
116
*
117
* \return Mac8Address in source field.
118
*/
119
Mac8Address
GetSrc
()
const
;
120
/**
121
* Get the header type value.
122
*
123
* \return value of type field.
124
*/
125
uint8_t
GetType
()
const
;
126
/**
127
* Get the packet type value.
128
*
129
* \return value of protocolNumber field.
130
*/
131
uint16_t
GetProtocolNumber
()
const
;
132
133
// Inherited methods
134
uint32_t
GetSerializedSize
()
const override
;
135
void
Serialize
(
Buffer::Iterator
start)
const override
;
136
uint32_t
Deserialize
(
Buffer::Iterator
start)
override
;
137
void
Print
(std::ostream& os)
const override
;
138
TypeId
GetInstanceTypeId
()
const override
;
139
140
private
:
141
Mac8Address
m_dest
;
//!< The destination address.
142
Mac8Address
m_src
;
//!< The source address.
143
UanProtocolBits
m_uanProtocolBits
{0};
//!< The type and protocol bits
144
145
};
// class UanHeaderCommon
146
147
}
// namespace ns3
148
149
#endif
/* UAN_HEADER_COMMON_H */
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition
buffer.h:89
ns3::Header
Protocol header serialization and deserialization.
Definition
header.h:33
ns3::Mac8Address
A class used for addressing MAC8 MAC's.
Definition
mac8-address.h:33
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
ns3::UanHeaderCommon
Common packet header fields.
Definition
uan-header-common.h:55
ns3::UanHeaderCommon::GetTypeId
static TypeId GetTypeId()
Register this type.
Definition
uan-header-common.cc:40
ns3::UanHeaderCommon::SetSrc
void SetSrc(Mac8Address src)
Set the source address.
Definition
uan-header-common.cc:66
ns3::UanHeaderCommon::Deserialize
uint32_t Deserialize(Buffer::Iterator start) override
Definition
uan-header-common.cc:169
ns3::UanHeaderCommon::GetSerializedSize
uint32_t GetSerializedSize() const override
Definition
uan-header-common.cc:149
ns3::UanHeaderCommon::m_dest
Mac8Address m_dest
The destination address.
Definition
uan-header-common.h:141
ns3::UanHeaderCommon::GetType
uint8_t GetType() const
Get the header type value.
Definition
uan-header-common.cc:119
ns3::UanHeaderCommon::m_src
Mac8Address m_src
The source address.
Definition
uan-header-common.h:142
ns3::UanHeaderCommon::GetDest
Mac8Address GetDest() const
Get the destination address.
Definition
uan-header-common.cc:107
ns3::UanHeaderCommon::UanHeaderCommon
UanHeaderCommon()
Default constructor.
Definition
uan-header-common.cc:23
ns3::UanHeaderCommon::SetProtocolNumber
void SetProtocolNumber(uint16_t protocolNumber)
Set the packet type.
Definition
uan-header-common.cc:78
ns3::UanHeaderCommon::Serialize
void Serialize(Buffer::Iterator start) const override
Definition
uan-header-common.cc:155
ns3::UanHeaderCommon::GetSrc
Mac8Address GetSrc() const
Get the source address.
Definition
uan-header-common.cc:113
ns3::UanHeaderCommon::m_uanProtocolBits
UanProtocolBits m_uanProtocolBits
The type and protocol bits.
Definition
uan-header-common.h:143
ns3::UanHeaderCommon::SetDest
void SetDest(Mac8Address dest)
Set the destination address.
Definition
uan-header-common.cc:60
ns3::UanHeaderCommon::SetType
void SetType(uint8_t type)
Set the header type.
Definition
uan-header-common.cc:72
ns3::UanHeaderCommon::~UanHeaderCommon
~UanHeaderCommon() override
Destructor.
Definition
uan-header-common.cc:55
ns3::UanHeaderCommon::Print
void Print(std::ostream &os) const override
Definition
uan-header-common.cc:183
ns3::UanHeaderCommon::GetProtocolNumber
uint16_t GetProtocolNumber() const
Get the packet type value.
Definition
uan-header-common.cc:125
ns3::UanHeaderCommon::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition
uan-header-common.cc:50
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:26
ns3::UanProtocolBits::m_protocolNumber
uint8_t m_protocolNumber
protocol number (4 bits)
Definition
uan-header-common.h:28
ns3::UanProtocolBits::m_type
uint8_t m_type
type (4 bits)
Definition
uan-header-common.h:27
src
uan
model
uan-header-common.h
Generated on Fri Nov 8 2024 13:59:06 for ns-3 by
1.11.0