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;
void EnableFcs(bool enable)
Enable or disable FCS calculation for this trailer.
bool IsFcsEnabled(void)
Query if FCS calculation is enabled for this trailer.
virtual uint32_t GetSerializedSize(void) const
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
iterator in a Buffer instance
virtual uint32_t Deserialize(Buffer::Iterator start)
uint16_t GetFcs(void) const
Get this trailers FCS value.
LrWpanMacTrailer(void)
Default constructor for a MAC trailer with disabled FCS calculation.
void SetFcs(Ptr< const Packet > p)
Calculate and set the FCS value based on the given packet.
Protocol trailer serialization and deserialization.
bool m_calcFcs
Only if m_calcFcs is true, FCS values will be calculated and used in the trailer. ...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static const uint16_t LR_WPAN_MAC_FCS_LENGTH
The length in octets of the IEEE 802.15.4 MAC FCS field.
Represent the Mac Trailer with the Frame Check Sequence field.
uint32_t CopyData(uint8_t *buffer, uint32_t size) const
Copy the packet contents to a byte buffer.
virtual void Serialize(Buffer::Iterator start) const
uint16_t GenerateCrc16(uint8_t *data, int length)
Calculate the 16-bit FCS value.
bool CheckFcs(Ptr< const Packet > p)
Check the FCS of a given packet against the FCS value stored in the trailer.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
virtual void Print(std::ostream &os) const
uint16_t m_fcs
The FCS value stored in this trailer.
static TypeId GetTypeId(void)
Get the type ID.