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
lr-wpan-mac-trailer.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2011 The Boeing Company
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:
18
* kwong yin <kwong-sang.yin@boeing.com>
19
* Sascha Alexander Jopen <jopen@cs.uni-bonn.de>
20
* Erwan Livolant <erwan.livolant@inria.fr>
21
*/
22
23
#ifndef LR_WPAN_MAC_TRAILER_H
24
#define LR_WPAN_MAC_TRAILER_H
25
26
#include <ns3/trailer.h>
27
28
namespace
ns3
29
{
30
31
class
Packet;
32
33
namespace
lrwpan
34
{
35
36
/**
37
* \ingroup lr-wpan
38
*
39
* Represent the Mac Trailer with the Frame Check Sequence field.
40
*/
41
class
LrWpanMacTrailer
:
public
Trailer
42
{
43
public
:
44
/**
45
* Get the type ID.
46
*
47
* \return the object TypeId
48
*/
49
static
TypeId
GetTypeId
();
50
51
/**
52
* Default constructor for a MAC trailer with disabled FCS calculation.
53
*/
54
LrWpanMacTrailer
();
55
56
// Inherited from the Trailer class.
57
TypeId
GetInstanceTypeId
()
const override
;
58
void
Print
(std::ostream& os)
const override
;
59
uint32_t
GetSerializedSize
()
const override
;
60
void
Serialize
(
Buffer::Iterator
start)
const override
;
61
uint32_t
Deserialize
(
Buffer::Iterator
start)
override
;
62
63
/**
64
* Get this trailers FCS value. If FCS calculation is disabled for this
65
* trailer, the returned value is always 0.
66
*
67
* \return the FCS value.
68
*/
69
uint16_t
GetFcs
()
const
;
70
71
/**
72
* Calculate and set the FCS value based on the given packet.
73
*
74
* \param p the packet for which the FCS should be calculated
75
*/
76
void
SetFcs
(
Ptr<const Packet>
p);
77
78
/**
79
* Check the FCS of a given packet against the FCS value stored in the
80
* trailer. The packet itself should contain no trailer. If FCS calculation is
81
* disabled for this trailer, CheckFcs() will always return true.
82
*
83
* \param p the packet to be checked
84
* \return false, if the FCS values do not match, true otherwise
85
*/
86
bool
CheckFcs
(
Ptr<const Packet>
p);
87
88
/**
89
* Enable or disable FCS calculation for this trailer.
90
*
91
* \param enable flag, indicating if FCS calculation should be enabled or not
92
*/
93
void
EnableFcs
(
bool
enable);
94
95
/**
96
* Query if FCS calculation is enabled for this trailer.
97
*
98
* \return true, if FCS calculation is enabled, false otherwise.
99
*/
100
bool
IsFcsEnabled
()
const
;
101
102
private
:
103
/**
104
* Calculate the 16-bit FCS value.
105
* CRC16-CCITT with a generator polynomial = ^16 + ^12 + ^5 + 1, LSB first and
106
* initial value = 0x0000.
107
*
108
* \param data the checksum will be calculated over this data
109
* \param length the length of the data
110
* \return the checksum
111
*/
112
uint16_t
GenerateCrc16
(uint8_t*
data
,
int
length);
113
114
/**
115
* The FCS value stored in this trailer.
116
*/
117
uint16_t
m_fcs
;
118
119
/**
120
* Only if m_calcFcs is true, FCS values will be calculated and used in the
121
* trailer
122
*/
123
bool
m_calcFcs
;
124
};
125
126
}
// namespace lrwpan
127
}
// namespace ns3
128
129
#endif
/* LR_WPAN_MAC_TRAILER_H */
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition:
buffer.h:100
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition:
ptr.h:77
ns3::Trailer
Protocol trailer serialization and deserialization.
Definition:
trailer.h:41
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
ns3::lrwpan::LrWpanMacTrailer
Represent the Mac Trailer with the Frame Check Sequence field.
Definition:
lr-wpan-mac-trailer.h:42
ns3::lrwpan::LrWpanMacTrailer::Serialize
void Serialize(Buffer::Iterator start) const override
Definition:
lr-wpan-mac-trailer.cc:71
ns3::lrwpan::LrWpanMacTrailer::IsFcsEnabled
bool IsFcsEnabled() const
Query if FCS calculation is enabled for this trailer.
Definition:
lr-wpan-mac-trailer.cc:141
ns3::lrwpan::LrWpanMacTrailer::EnableFcs
void EnableFcs(bool enable)
Enable or disable FCS calculation for this trailer.
Definition:
lr-wpan-mac-trailer.cc:131
ns3::lrwpan::LrWpanMacTrailer::Deserialize
uint32_t Deserialize(Buffer::Iterator start) override
Definition:
lr-wpan-mac-trailer.cc:78
ns3::lrwpan::LrWpanMacTrailer::SetFcs
void SetFcs(Ptr< const Packet > p)
Calculate and set the FCS value based on the given packet.
Definition:
lr-wpan-mac-trailer.cc:93
ns3::lrwpan::LrWpanMacTrailer::GetSerializedSize
uint32_t GetSerializedSize() const override
Definition:
lr-wpan-mac-trailer.cc:65
ns3::lrwpan::LrWpanMacTrailer::CheckFcs
bool CheckFcs(Ptr< const Packet > p)
Check the FCS of a given packet against the FCS value stored in the trailer.
Definition:
lr-wpan-mac-trailer.cc:110
ns3::lrwpan::LrWpanMacTrailer::m_calcFcs
bool m_calcFcs
Only if m_calcFcs is true, FCS values will be calculated and used in the trailer.
Definition:
lr-wpan-mac-trailer.h:123
ns3::lrwpan::LrWpanMacTrailer::m_fcs
uint16_t m_fcs
The FCS value stored in this trailer.
Definition:
lr-wpan-mac-trailer.h:117
ns3::lrwpan::LrWpanMacTrailer::LrWpanMacTrailer
LrWpanMacTrailer()
Default constructor for a MAC trailer with disabled FCS calculation.
Definition:
lr-wpan-mac-trailer.cc:36
ns3::lrwpan::LrWpanMacTrailer::GetFcs
uint16_t GetFcs() const
Get this trailers FCS value.
Definition:
lr-wpan-mac-trailer.cc:87
ns3::lrwpan::LrWpanMacTrailer::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition:
lr-wpan-mac-trailer.cc:43
ns3::lrwpan::LrWpanMacTrailer::GenerateCrc16
uint16_t GenerateCrc16(uint8_t *data, int length)
Calculate the 16-bit FCS value.
Definition:
lr-wpan-mac-trailer.cc:147
ns3::lrwpan::LrWpanMacTrailer::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition:
lr-wpan-mac-trailer.cc:53
ns3::lrwpan::LrWpanMacTrailer::Print
void Print(std::ostream &os) const override
Definition:
lr-wpan-mac-trailer.cc:59
uint32_t
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
data
uint8_t data[writeSize]
Definition:
socket-bound-tcp-static-routing.cc:52
src
lr-wpan
model
lr-wpan-mac-trailer.h
Generated on Tue May 28 2024 23:36:53 for ns-3 by
1.9.6