24 #include <ns3/packet.h>
43 .SetGroupName (
"LrWpan")
58 os <<
" FCS = " <<
m_fcs;
95 uint8_t *serial_packet =
new uint8_t[size];
100 delete[] serial_packet;
117 uint8_t *serial_packet =
new uint8_t[size];
122 delete[] serial_packet;
123 return (checkFcs ==
GetFcs ());
147 uint16_t accumulator = 0;
149 for (i = 0; i < length; ++i)
151 accumulator ^= *
data;
152 accumulator = (accumulator >> 8) | (accumulator << 8);
153 accumulator ^= (accumulator & 0xff00) << 4;
154 accumulator ^= (accumulator >> 8) >> 4;
155 accumulator ^= (accumulator & 0xff00) >> 5;
iterator in a Buffer instance
Represent the Mac Trailer with the Frame Check Sequence field.
bool IsFcsEnabled(void)
Query if FCS calculation is enabled for this trailer.
virtual uint32_t Deserialize(Buffer::Iterator start)
bool m_calcFcs
Only if m_calcFcs is true, FCS values will be calculated and used in the trailer.
LrWpanMacTrailer(void)
Default constructor for a MAC trailer with disabled FCS calculation.
virtual uint32_t GetSerializedSize(void) const
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
static const uint16_t LR_WPAN_MAC_FCS_LENGTH
The length in octets of the IEEE 802.15.4 MAC FCS field.
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.
virtual void Print(std::ostream &os) const
virtual void Serialize(Buffer::Iterator start) const
void SetFcs(Ptr< const Packet > p)
Calculate and set the FCS value based on the given packet.
uint16_t GetFcs(void) const
Get this trailers FCS value.
bool CheckFcs(Ptr< const Packet > p)
Check the FCS of a given packet against the FCS value stored in the trailer.
void EnableFcs(bool enable)
Enable or disable FCS calculation for this trailer.
static TypeId GetTypeId(void)
Get the type ID.
uint32_t CopyData(uint8_t *buffer, uint32_t size) const
Copy the packet contents to a byte buffer.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
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.