24 #include <ns3/packet.h>
45 .SetGroupName(
"LrWpan")
59 os <<
" FCS = " <<
m_fcs;
96 auto serial_packet =
new uint8_t[size];
101 delete[] serial_packet;
118 auto serial_packet =
new uint8_t[size];
123 delete[] serial_packet;
124 return (checkFcs ==
GetFcs());
148 uint16_t accumulator = 0;
150 for (i = 0; i < length; ++i)
152 accumulator ^= *
data;
153 accumulator = (accumulator >> 8) | (accumulator << 8);
154 accumulator ^= (accumulator & 0xff00) << 4;
155 accumulator ^= (accumulator >> 8) >> 4;
156 accumulator ^= (accumulator & 0xff00) >> 5;
iterator in a Buffer instance
Represent the Mac Trailer with the Frame Check Sequence field.
bool m_calcFcs
Only if m_calcFcs is true, FCS values will be calculated and used in the trailer.
uint32_t GetSerializedSize() const override
static TypeId GetTypeId()
Get the type ID.
uint16_t GenerateCrc16(uint8_t *data, int length)
Calculate the 16-bit FCS value.
uint16_t m_fcs
The FCS value stored in this trailer.
LrWpanMacTrailer()
Default constructor for a MAC trailer with disabled FCS calculation.
uint32_t Deserialize(Buffer::Iterator start) override
uint16_t GetFcs() const
Get this trailers FCS value.
void SetFcs(Ptr< const Packet > p)
Calculate and set the FCS value based on the given packet.
void Serialize(Buffer::Iterator start) const override
bool CheckFcs(Ptr< const Packet > p)
Check the FCS of a given packet against the FCS value stored in the trailer.
void Print(std::ostream &os) const override
void EnableFcs(bool enable)
Enable or disable FCS calculation for this trailer.
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
bool IsFcsEnabled() const
Query if FCS calculation is enabled for this trailer.
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
uint32_t CopyData(uint8_t *buffer, uint32_t size) const
Copy the packet contents to a byte buffer.
Protocol trailer serialization and deserialization.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
constexpr uint16_t LR_WPAN_MAC_FCS_LENGTH
The length in octets of the IEEE 802.15.4 MAC FCS field.