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
wimax-mac-to-mac-header.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2010 INRIA, UDcast
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
7
*
8
*/
9
#include "
wimax-mac-to-mac-header.h
"
10
11
#include "ns3/address-utils.h"
12
#include "ns3/log.h"
13
#include "ns3/uinteger.h"
14
15
namespace
ns3
16
{
17
18
NS_OBJECT_ENSURE_REGISTERED
(WimaxMacToMacHeader);
19
20
WimaxMacToMacHeader::WimaxMacToMacHeader
()
21
: m_len(0)
22
{
23
}
24
25
WimaxMacToMacHeader::WimaxMacToMacHeader
(
uint32_t
len)
26
: m_len(len)
27
{
28
}
29
30
WimaxMacToMacHeader::~WimaxMacToMacHeader
()
31
{
32
}
33
34
TypeId
35
WimaxMacToMacHeader::GetTypeId
()
36
{
37
static
TypeId
tid =
TypeId
(
"ns3::WimaxMacToMacHeader"
)
38
.
SetParent
<
Header
>()
39
.SetGroupName(
"Wimax"
)
40
.AddConstructor<
WimaxMacToMacHeader
>();
41
return
tid;
42
}
43
44
TypeId
45
WimaxMacToMacHeader::GetInstanceTypeId
()
const
46
{
47
return
GetTypeId
();
48
}
49
50
uint8_t
51
WimaxMacToMacHeader::GetSizeOfLen
()
const
52
{
53
uint8_t sizeOfLen = 1;
54
55
if
(
m_len
> 127)
56
{
57
sizeOfLen = 2;
58
uint64_t testValue = 0xFF;
59
while
(
m_len
> testValue)
60
{
61
sizeOfLen++;
62
testValue *= 0xFF;
63
}
64
}
65
return
sizeOfLen;
66
}
67
68
uint32_t
69
WimaxMacToMacHeader::GetSerializedSize
()
const
70
{
71
uint8_t sizeOfLen =
GetSizeOfLen
();
72
if
(sizeOfLen == 1)
73
{
74
return
20;
75
}
76
else
77
{
78
return
20 + sizeOfLen - 1;
79
}
80
// return 19+sizeOfLen;
81
}
82
83
void
84
WimaxMacToMacHeader::Serialize
(
Buffer::Iterator
i)
const
85
{
86
// The following header encoding was reverse-engineered by looking
87
// at existing live pcap traces which could be opened with wireshark
88
// i.e., we have no idea where this is coming from.
89
//
90
// 6 zeros for mac destination
91
// 6 zeros for mac source
92
// 2 bytes for length/type: 0x08f0
93
// 2 bytes for sequence number: 0x0001
94
// 2 bytes for number of tlvs: 0x0001
95
// 1 byte for type of first tlv: 0x09
96
// 1 byte to indicate the length of the length field of the tlv : 0x80 | 0x04
97
// n bytes to indicate the size of the packet (network order)
98
// n bytes for the packet data
99
100
uint8_t
zero
= 0;
101
102
for
(
int
j = 0; j < 12; j++)
103
{
104
i.
WriteU8
(
zero
);
105
}
106
i.
WriteU16
(0xf008);
// eth length/type
107
i.
WriteU16
(0x0100);
// sequence number
108
i.
WriteU16
(0x0100);
// number of tlvs
109
i.
WriteU8
(0x09);
// type of first tlv
110
uint8_t lenSize =
GetSizeOfLen
();
111
if
(lenSize == 1)
112
{
113
i.
WriteU8
(
m_len
);
114
}
115
else
116
{
117
i.
WriteU8
((lenSize - 1) | 0x80);
118
for
(
int
j = 0; j < lenSize - 1; j++)
119
{
120
i.
WriteU8
((uint8_t)(
m_len
>> ((lenSize - 1 - 1 - j) * 8)));
121
}
122
}
123
}
124
125
uint32_t
126
WimaxMacToMacHeader::Deserialize
(
Buffer::Iterator
start)
127
{
128
// not needed here
129
return
20;
130
}
131
132
void
133
WimaxMacToMacHeader::Print
(std::ostream& os)
const
134
{
135
}
136
};
// namespace ns3
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition
buffer.h:89
ns3::Buffer::Iterator::WriteU8
void WriteU8(uint8_t data)
Definition
buffer.h:870
ns3::Buffer::Iterator::WriteU16
void WriteU16(uint16_t data)
Definition
buffer.cc:848
ns3::Header
Protocol header serialization and deserialization.
Definition
header.h:33
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition
type-id.cc:1001
ns3::WimaxMacToMacHeader
this class implements the mac to mac header needed to dump a wimax pcap file The header format was re...
Definition
wimax-mac-to-mac-header.h:26
ns3::WimaxMacToMacHeader::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
wimax-mac-to-mac-header.cc:35
ns3::WimaxMacToMacHeader::GetSizeOfLen
uint8_t GetSizeOfLen() const
Get size of length field.
Definition
wimax-mac-to-mac-header.cc:51
ns3::WimaxMacToMacHeader::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition
wimax-mac-to-mac-header.cc:45
ns3::WimaxMacToMacHeader::Serialize
void Serialize(Buffer::Iterator start) const override
Definition
wimax-mac-to-mac-header.cc:84
ns3::WimaxMacToMacHeader::Deserialize
uint32_t Deserialize(Buffer::Iterator start) override
Definition
wimax-mac-to-mac-header.cc:126
ns3::WimaxMacToMacHeader::WimaxMacToMacHeader
WimaxMacToMacHeader()
Definition
wimax-mac-to-mac-header.cc:20
ns3::WimaxMacToMacHeader::~WimaxMacToMacHeader
~WimaxMacToMacHeader() override
Definition
wimax-mac-to-mac-header.cc:30
ns3::WimaxMacToMacHeader::Print
void Print(std::ostream &os) const override
Definition
wimax-mac-to-mac-header.cc:133
ns3::WimaxMacToMacHeader::m_len
uint32_t m_len
length
Definition
wimax-mac-to-mac-header.h:54
ns3::WimaxMacToMacHeader::GetSerializedSize
uint32_t GetSerializedSize() const override
Definition
wimax-mac-to-mac-header.cc:69
uint32_t
zero
static double zero
Definition
data-calculator.cc:18
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition
object-base.h:35
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
wimax-mac-to-mac-header.h
src
wimax
model
wimax-mac-to-mac-header.cc
Generated on Fri Nov 8 2024 13:59:09 for ns-3 by
1.11.0