<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><blockquote type="cite"><div>I would like to simulate packet loss of RTP packets on the network, and I would like to use Live555 to do this. In fact, there already is some code in MultiFramedRTPSink (in the MultiFramedRTPSink::sendPacketIfNecessary() function) which is contained in a "TEST_LOSS" macro, and is hardcoded to simulate 10% loss:<br><br>#ifdef TEST_LOSS<br> if ((our_random()%10) != 0) // simulate 10% packet loss #####<br>#endif<br><br>I would like to do some more sophisticated testing (e.g. change the packet loss to 5% or 25%). What is the "right" way to do this?</div></blockquote><div><br></div>Normally I don't advise modifying the supplied code. However, because you just want to simulate packet loss for testing (i.e., I presume you don't plan on building a product that loses packets :-), you might as well just modify the (#ifdef'd out) code that's already there.</div><div><br></div><div>E.g., if you want to simulate N% packet loss (where N is an integer in the range [0,100], then you could change the "if" condition above to</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>if ((our_random()%100 >= N) // simulate N% packet loss</div><div><br></div><div apple-content-edited="true">
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; ">Ross Finlayson<br>Live Networks, Inc.<br><a href="http://www.live555.com/">http://www.live555.com/</a></span></span>
</div>
<br></body></html>