A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
wimax-mac-to-mac-header.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2010 INRIA, UDcast
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*
18
* Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
19
*
20
*/
21
#include "
wimax-mac-to-mac-header.h
"
22
#include "ns3/address-utils.h"
23
#include "ns3/uinteger.h"
24
#include "ns3/log.h"
25
namespace
ns3
{
26
27
NS_OBJECT_ENSURE_REGISTERED
(WimaxMacToMacHeader);
28
29
WimaxMacToMacHeader::WimaxMacToMacHeader
(
void
)
30
: m_len (0)
31
{
32
}
33
34
WimaxMacToMacHeader::WimaxMacToMacHeader
(uint32_t len)
35
: m_len (len)
36
{
37
}
38
39
WimaxMacToMacHeader::~WimaxMacToMacHeader
(
void
)
40
{
41
}
42
43
44
45
TypeId
46
WimaxMacToMacHeader::GetTypeId
(
void
)
47
{
48
static
TypeId
tid =
49
TypeId
(
"ns3::WimaxMacToMacHeader"
)
50
.
SetParent
<
Header
> ()
51
.SetGroupName(
"Wimax"
)
52
.AddConstructor<
WimaxMacToMacHeader
> ()
53
;
54
return
tid;
55
}
56
57
TypeId
58
WimaxMacToMacHeader::GetInstanceTypeId
(
void
)
const
59
{
60
return
GetTypeId
();
61
}
62
63
uint8_t
64
WimaxMacToMacHeader::GetSizeOfLen
(
void
)
const
65
{
66
uint8_t sizeOfLen = 1;
67
68
if
(
m_len
> 127)
69
{
70
sizeOfLen = 2;
71
uint64_t testValue = 0xFF;
72
while
(
m_len
> testValue)
73
{
74
sizeOfLen++;
75
testValue *= 0xFF;
76
}
77
}
78
return
sizeOfLen;
79
}
80
81
uint32_t
82
WimaxMacToMacHeader::GetSerializedSize
(
void
)
const
83
{
84
uint8_t sizeOfLen =
GetSizeOfLen
();
85
if
(sizeOfLen==1)
86
{
87
return
20;
88
}
89
else
90
{
91
return
20 + sizeOfLen -1;
92
}
93
//return 19+sizeOfLen;
94
}
95
96
void
97
WimaxMacToMacHeader::Serialize
(
Buffer::Iterator
i)
const
98
{
99
// The following header encoding was reverse-engineered by looking
100
// at existing live pcap traces which could be opened with wireshark
101
// i.e., we have no idea where this is coming from.
102
//
103
// 6 zeros for mac destination
104
// 6 zeros for mac source
105
// 2 bytes for length/type: 0x08f0
106
// 2 bytes for sequence number: 0x0001
107
// 2 bytes for number of tlvs: 0x0001
108
// 1 byte for type of first tlv: 0x09
109
// 1 byte to indicate the length of the length field of the tlv : 0x80 | 0x04
110
// n bytes to indicate the size of the packet (network order)
111
// n bytes for the packet data
112
113
uint8_t
zero
= 0;
114
115
116
for
(
int
j = 0; j < 12; j++)
117
{
118
i.
WriteU8
(
zero
);
119
}
120
i.
WriteU16
(0xf008);
// eth length/type
121
i.
WriteU16
(0x0100);
// sequence number
122
i.
WriteU16
(0x0100);
// number of tlvs
123
i.
WriteU8
(0x09);
// type of first tlv
124
uint8_t lenSize =
GetSizeOfLen
();
125
if
(lenSize == 1)
126
{
127
i.
WriteU8
(
m_len
);
128
}
129
else
130
{
131
i.
WriteU8
((lenSize-1) | 0x80);
132
for
(
int
j = 0; j < lenSize - 1; j++)
133
{
134
i.
WriteU8
((uint8_t)(
m_len
>> ((lenSize - 1 - 1 - j) * 8)));
135
}
136
}
137
}
138
139
uint32_t
140
WimaxMacToMacHeader::Deserialize
(
Buffer::Iterator
start
)
141
{
142
// not needed here
143
return
20;
144
}
145
146
void
147
WimaxMacToMacHeader::Print
(std::ostream &os)
const
148
{
149
}
150
};
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition:
buffer.h:99
ns3::Buffer::Iterator::WriteU8
void WriteU8(uint8_t data)
Definition:
buffer.h:869
ns3::Buffer::Iterator::WriteU16
void WriteU16(uint16_t data)
Definition:
buffer.cc:871
ns3::Header
Protocol header serialization and deserialization.
Definition:
header.h:43
ns3::Header::Deserialize
virtual uint32_t Deserialize(Buffer::Iterator start)=0
Deserialize the object from a buffer iterator.
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition:
type-id.cc:922
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:36
ns3::WimaxMacToMacHeader::~WimaxMacToMacHeader
~WimaxMacToMacHeader()
Definition:
wimax-mac-to-mac-header.cc:39
ns3::WimaxMacToMacHeader::GetSerializedSize
uint32_t GetSerializedSize(void) const
Definition:
wimax-mac-to-mac-header.cc:82
ns3::WimaxMacToMacHeader::GetInstanceTypeId
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
Definition:
wimax-mac-to-mac-header.cc:58
ns3::WimaxMacToMacHeader::Print
virtual void Print(std::ostream &os) const
Definition:
wimax-mac-to-mac-header.cc:147
ns3::WimaxMacToMacHeader::WimaxMacToMacHeader
WimaxMacToMacHeader()
Definition:
wimax-mac-to-mac-header.cc:29
ns3::WimaxMacToMacHeader::GetSizeOfLen
uint8_t GetSizeOfLen(void) const
Get size of length field.
Definition:
wimax-mac-to-mac-header.cc:64
ns3::WimaxMacToMacHeader::Serialize
void Serialize(Buffer::Iterator start) const
Definition:
wimax-mac-to-mac-header.cc:97
ns3::WimaxMacToMacHeader::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition:
wimax-mac-to-mac-header.cc:46
ns3::WimaxMacToMacHeader::m_len
uint32_t m_len
length
Definition:
wimax-mac-to-mac-header.h:63
zero
static double zero
Definition:
data-calculator.cc:30
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition:
object-base.h:45
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
visualizer.core.start
def start()
Definition:
core.py:1853
wimax-mac-to-mac-header.h
src
wimax
model
wimax-mac-to-mac-header.cc
Generated on Tue Feb 6 2024 19:21:31 for ns-3 by
1.9.1