CC2420 Data Sequence Numbers
The 802.15.4 specification identifies a Data Sequence Number (DSN) byte in the message header to filter out duplicate packets.
The UniqueSend interface at the top of the CC2420 radio stack is responsible for setting the DSN byte. Upon boot, an initial DSN byte is generated using a pseudo-random number generator with a maximum of 8-bits (256) values. This number is incremented on each outgoing packet transmission. Even if lower levels such as PacketLink or LowPowerListening retransmit the packet, the DSN byte stays the same for that packet.
The UniqueReceive interface at the bottom of the CC2420 radio stack is responsible for filtering out duplicate messages based on source address and DSN. The UniqueReceive interface is not meant to stop sophisticated replay attacks.
As packets are received, DSN and source address information is placed into elements of an array. Each subsequent message from previously logged addresses overwrite information in the element allocated to that source address. This prevents UniqueReceive's history from losing DSN byte information from sources that are not able to access the channel as often. If the number of elements in the history array runs out, UniqueReceive uses a best effort method to avoid replacing recently updated DSN/Source information entries.