Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 17th, 2012  |  syntax: None  |  size: 0.62 KB  |  hits: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. public Boolean fake(String what) {
  2.  
  3.                 int randomNumber = this.generator.nextInt( 99 );
  4.                 randomNumber++; // want to start from 1, not 0
  5.                
  6.                 if (what.equals("checksum")) { // 5%
  7.                         if (randomNumber <= 5) {
  8.                                 return true;
  9.                         }
  10.                 } else if(what.equals("packetloss")) { // 10%
  11.                         if (randomNumber > 5 && randomNumber <= 15) {
  12.                                 return true;
  13.                         }
  14.                 } else if(what.equals("ackloss")) { // 20%
  15.                         if (randomNumber > 15 && randomNumber <= 35) {
  16.                                 return true;
  17.                         }                      
  18.                 } else if(what.equals("timeout")) { // 25%
  19.                         if (randomNumber > 35 && randomNumber <= 75) {
  20.                                 return true;
  21.                         }                      
  22.                 }
  23.  
  24.                 return false;
  25.         }