A Discrete-Event Network Simulator
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
17namespace ns3
18{
19
20/**
21 * \ingroup uan
22 *
23 * UAN protocol descriptor
24 */
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 */
54class UanHeaderCommon : public Header
55{
56 public:
57 /** Default constructor */
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 */
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 */
iterator in a Buffer instance
Definition buffer.h:89
Protocol header serialization and deserialization.
Definition header.h:33
A class used for addressing MAC8 MAC's.
a unique identifier for an interface.
Definition type-id.h:48
Common packet header fields.
static TypeId GetTypeId()
Register this type.
void SetSrc(Mac8Address src)
Set the source address.
uint32_t Deserialize(Buffer::Iterator start) override
uint32_t GetSerializedSize() const override
Mac8Address m_dest
The destination address.
uint8_t GetType() const
Get the header type value.
Mac8Address m_src
The source address.
Mac8Address GetDest() const
Get the destination address.
UanHeaderCommon()
Default constructor.
void SetProtocolNumber(uint16_t protocolNumber)
Set the packet type.
void Serialize(Buffer::Iterator start) const override
Mac8Address GetSrc() const
Get the source address.
UanProtocolBits m_uanProtocolBits
The type and protocol bits.
void SetDest(Mac8Address dest)
Set the destination address.
void SetType(uint8_t type)
Set the header type.
~UanHeaderCommon() override
Destructor.
void Print(std::ostream &os) const override
uint16_t GetProtocolNumber() const
Get the packet type value.
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
UAN protocol descriptor.
uint8_t m_protocolNumber
protocol number (4 bits)
uint8_t m_type
type (4 bits)