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
ethernet-trailer.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2007 Emmanuelle Laprise
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
7
*/
8
9
#ifndef ETHERNET_TRAILER_H
10
#define ETHERNET_TRAILER_H
11
12
#include "ns3/packet.h"
13
#include "ns3/trailer.h"
14
15
#include <string>
16
17
namespace
ns3
18
{
19
20
/**
21
* \ingroup network
22
*
23
* \brief Packet trailer for Ethernet
24
*
25
* This class can be used to add and verify the FCS at the end of an
26
* Ethernet packet.
27
*/
28
class
EthernetTrailer
:
public
Trailer
29
{
30
public
:
31
/**
32
* \brief Construct a null ethernet trailer
33
*/
34
EthernetTrailer
();
35
36
/**
37
* \brief Enable or disable FCS checking and calculations
38
* \param enable If true, enables FCS calculations.
39
*/
40
void
EnableFcs
(
bool
enable);
41
42
/**
43
* \brief Updates the Fcs Field to the correct FCS
44
* \param p Reference to a packet on which the FCS should be
45
* calculated. The packet should not currently contain an
46
* EthernetTrailer.
47
*/
48
void
CalcFcs
(
Ptr<const Packet>
p);
49
50
/**
51
* \brief Sets the FCS to a new value
52
* \param fcs New FCS value
53
*/
54
void
SetFcs
(
uint32_t
fcs);
55
56
/**
57
* \return the FCS contained in this trailer
58
*/
59
uint32_t
GetFcs
()
const
;
60
61
/**
62
* Calculate an FCS on the provided packet and check this value against
63
* the FCS found when the trailer was deserialized (the one in the transmitted
64
* packet).
65
*
66
* If FCS checking is disabled, this method will always
67
* return true.
68
*
69
* \param p Reference to the packet on which the FCS should be
70
* calculated. The packet should not contain an EthernetTrailer.
71
*
72
* \return Returns true if the Packet FCS matches the FCS in the trailer,
73
* false otherwise.
74
*/
75
bool
CheckFcs
(
Ptr<const Packet>
p)
const
;
76
77
/**
78
* \return Returns the size of the trailer
79
*/
80
uint32_t
GetTrailerSize
()
const
;
81
82
/**
83
* \brief Get the type ID.
84
* \return the object TypeId
85
*/
86
static
TypeId
GetTypeId
();
87
TypeId
GetInstanceTypeId
()
const override
;
88
void
Print
(std::ostream& os)
const override
;
89
uint32_t
GetSerializedSize
()
const override
;
90
void
Serialize
(
Buffer::Iterator
end)
const override
;
91
uint32_t
Deserialize
(
Buffer::Iterator
end)
override
;
92
93
private
:
94
/**
95
* Enabled FCS calculations. If false, m_fcs is set to 0 and CheckFcs
96
* returns true.
97
*/
98
bool
m_calcFcs
;
99
uint32_t
m_fcs
;
//!< Value of the fcs contained in the trailer
100
};
101
102
}
// namespace ns3
103
104
#endif
/* ETHERNET_TRAILER_H */
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition
buffer.h:89
ns3::EthernetTrailer
Packet trailer for Ethernet.
Definition
ethernet-trailer.h:29
ns3::EthernetTrailer::GetFcs
uint32_t GetFcs() const
Definition
ethernet-trailer.cc:84
ns3::EthernetTrailer::Deserialize
uint32_t Deserialize(Buffer::Iterator end) override
Definition
ethernet-trailer.cc:138
ns3::EthernetTrailer::Print
void Print(std::ostream &os) const override
Definition
ethernet-trailer.cc:114
ns3::EthernetTrailer::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition
ethernet-trailer.cc:108
ns3::EthernetTrailer::CheckFcs
bool CheckFcs(Ptr< const Packet > p) const
Calculate an FCS on the provided packet and check this value against the FCS found when the trailer w...
Definition
ethernet-trailer.cc:39
ns3::EthernetTrailer::GetSerializedSize
uint32_t GetSerializedSize() const override
Definition
ethernet-trailer.cc:121
ns3::EthernetTrailer::Serialize
void Serialize(Buffer::Iterator end) const override
Definition
ethernet-trailer.cc:128
ns3::EthernetTrailer::GetTrailerSize
uint32_t GetTrailerSize() const
Definition
ethernet-trailer.cc:91
ns3::EthernetTrailer::EnableFcs
void EnableFcs(bool enable)
Enable or disable FCS checking and calculations.
Definition
ethernet-trailer.cc:32
ns3::EthernetTrailer::EthernetTrailer
EthernetTrailer()
Construct a null ethernet trailer.
Definition
ethernet-trailer.cc:24
ns3::EthernetTrailer::m_calcFcs
bool m_calcFcs
Enabled FCS calculations.
Definition
ethernet-trailer.h:98
ns3::EthernetTrailer::CalcFcs
void CalcFcs(Ptr< const Packet > p)
Updates the Fcs Field to the correct FCS.
Definition
ethernet-trailer.cc:59
ns3::EthernetTrailer::m_fcs
uint32_t m_fcs
Value of the fcs contained in the trailer.
Definition
ethernet-trailer.h:99
ns3::EthernetTrailer::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
ethernet-trailer.cc:98
ns3::EthernetTrailer::SetFcs
void SetFcs(uint32_t fcs)
Sets the FCS to a new value.
Definition
ethernet-trailer.cc:77
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
uint32_t
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
network
utils
ethernet-trailer.h
Generated on Fri Nov 8 2024 13:59:05 for ns-3 by
1.11.0