highfidelity/hifi — pull request #3002 by wangyix (2014-06-09 20:13:28+00:00)
Title: added code to nack and re-send dropped octree data packets

Cause: UDP packets occasionally get lost.

Fix: Added a new packet type OctreeDataNack which contains an integer N followed by N sequence numbers. Added the SentPacketHistory class to store the last N packets sent. Added a QSet to OctreeSceneStats that stores missing sequence numbers to be nacked. Added code to periodically assemble nack packets from OctreeSceneStats and send them to octree servers in Application.cpp. Added code to OctreeServer and OctreeQueryNode to parse nack packets and append them to a queue of nacked sequence numbers. Added code to the OctreeSendThread process() loop to look up nacked sequence numbers in OctreeQueryNode's packet history and re-send them.

Testing: Added test code to only send 80% of octree packets in OctreeSendThread to simulate packet loss. Through additional debug-prints and the octree server statistics, it was observed that all lost packets from each AC were properly recovered and that each AC received nack packets indeed contained the correct sequence numbers.