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