Author: toad
Date: 2008-03-18 22:49:37 +0000 (Tue, 18 Mar 2008)
New Revision: 18564
Modified:
trunk/freenet/src/freenet/node/FNPPacketMangler.java
Log:
Save some space on padding: 32 first, then increment in 64's from 64.
Modified: trunk/freenet/src/freenet/node/FNPPacketMangler.java
===================================================================
--- trunk/freenet/src/freenet/node/FNPPacketMangler.java 2008-03-18
22:03:39 UTC (rev 18563)
+++ trunk/freenet/src/freenet/node/FNPPacketMangler.java 2008-03-18
22:49:37 UTC (rev 18564)
@@ -2357,13 +2357,24 @@
// worthless) job of disguising the traffic. FIXME!!!!!
// Ideally we'd mimic the size profile - and the session bytes!
- of a common protocol.
- int REMAINING_OVERHEAD = 32;
- packetLength += REMAINING_OVERHEAD;
- int paddedLen = ((packetLength + 63) / 64) * 64;
- paddedLen += node.fastWeakRandom.nextInt(64);
- if(packetLength <= 1280 && paddedLen > 1280) paddedLen = 1280;
- paddedLen -= REMAINING_OVERHEAD;
- packetLength -= REMAINING_OVERHEAD;
+ int paddedLen;
+
+ if(packetLength < 64) {
+ // Up to 37 bytes of payload (after base overhead above
of 27 bytes), padded size 96-128 bytes.
+ // Most small messages, and most ack only packets.
+ paddedLen = 64 + node.fastWeakRandom.nextInt(32);
+ } else {
+ // Up to 69 bytes of payload, final size 128-192 bytes
(CHK request, CHK insert, opennet announcement, CHK offer, swap reply)
+ // Up to 133 bytes of payload, final size 192-256 bytes
(SSK request, get offered CHK, offer SSK[, SSKInsertRequestNew], get offered
SSK)
+ // Up to 197 bytes of payload, final size 256-320 bytes
(swap commit/complete[, SSKDataFoundNew, SSKInsertRequestAltNew])
+ // Up to 1093 bytes of payload, final size 1152-1216
bytes (bulk transmit, block transmit, time deltas, SSK pubkey[, SSKData,
SSKDataInsert])
+ packetLength += 32;
+ paddedLen = ((packetLength + 63) / 64) * 64;
+ paddedLen += node.fastWeakRandom.nextInt(64);
+ if(packetLength <= 1280 && paddedLen > 1280) paddedLen
= 1280;
+ packetLength -= 32;
+ paddedLen -= 32;
+ }
byte[] padding = new byte[paddedLen - packetLength];
node.fastWeakRandom.nextBytes(padding);