Appendix A. Pseudocode for Index Determination
Appendix A. Pseudocode for Index Determination
The following is an example of pseudo-code for the algorithm to determine the index i of an SRTP packet with sequence number SEQ. In the following, signed arithmetic is assumed.
if (s_l < 32,768)
if (SEQ - s_l > 32,768)
set v to (ROC-1) mod 2^32
else
set v to ROC
endif
else
if (s_l - 32,768 > SEQ)
set v to (ROC+1) mod 2^32
else
set v to ROC
endif
endif
return SEQ + v*65,536