class Traffic
{ private InputStream in; private OutputStream out;
// // By default, traffic streams are predictable and what comes // in is compared with what it's expected to be. // staticprivatebyte fixedSeed [] = { 1, 2, 3, 4};
// optionally provide PRNG for "truly" random data. publicvoid setPRNG (SecureRandom prng)
{ this.prng = prng;
compareRandom = false;
}
// // Basic half-duplex testing, as used for RPC-style systems like // HTTP, RMI, CORBA, ONC, etc. // // parameter 'n' is "0" for some fixed data tests, else is the // number of passes of random data to send. //
if (n == 0)
initiateConst (); elseif (n < 0)
System.out.println ("** ERROR: initiate forever ??"); else for ( ; n > 0; n -= 1) {
initiateRandom ();
}
}
publicvoid respond (int n) throws IOException
{ if (n == 0)
respondConst (); elseif (n < 0) // n < 0 == respond forever while (true)
respondRandom (); else while (n-- > 0)
respondRandom ();
}
// // Test passing of fixed size (and content) data. // // For SSL, one test goal is to ensure that all the basic // block cipher padding sizes get banged on. SSLv3 ciphers // are all the same block size, but there are larger sizes // coming along. (Big blocks in hardware can be fast!!) //
privatevoid initiateConst () throws IOException
{ for (int i = 1; i <= MAX_BLOCKSIZE; i++) {
writeConstData (i);
readConstData (i);
}
}
privatevoid respondConst () throws IOException
{ for (int i = 1; i <= MAX_BLOCKSIZE; i++) {
readConstData (i);
writeConstData (i);
}
}
// // Test passing of random size (and content) data. // // For SSL, one test goal is to ensure that all the basic // record sizes get banged on. Traffic will normally // be bimodal (small packets, and big ones) and we give // a half-hearted effort at emulating that -- no real // statistics to back up this particular distribution. //
privatestaticfinalint MAX_RECORDSIZE = 16384 * 2;
privateint nextRecordSize ()
{ double d = prng.nextGaussian (); int n;
// assume 1/3 traffic is "big", less variance if ((prng.nextInt () % 3) == 0) {
n = (int) (d * 2048);
n += 15 * 1024;
// ... and the rest is smaller, much variance
} else {
n = (int) (d * 4096);
n += 1024;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.