This directory contains files to measure the sizes of Snowflake rendezvous
messages, upstream and downstream, with and without gzip compression, as a
reference for the numbers reported in the paper.

There is code for measuring message sizes both at the client (in the
snowflake-client program) and at the proxy (in snowflake-webext). Measuring at
the client, you get a single client but diverse proxies; measuring at the
proxy, you get a single proxy but diverse clients.

See these links for newer measurements:

* https://gitlab.torproject.org/dcf/snowflake-rendezvous-zlib
* https://lists.torproject.org/mailman3/hyperkitty/list/anti-censorship-team@lists.torproject.org/thread/ZK3KJ6F3BCJRVNS55BMB6MXQNTTEFRTB/

## Client measurements

snowflake-client-log-data.patch is a patch to snowflake-client v2.12.1 that
makes it emit distinguished "DATA" log line with the data we want. The log
lines look like:

```
YYYY/MM/DD hh:mm:ss DATA type=[offer|answer] size=X gzip_size=Y
```

To apply the patch:

```
git clone -b v2.12.1 https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
cd snowflake
git apply ../snowflake-client-log-data.patch
cd client
go build
tor -f ../../torrc.data
```

The torrc.data configuration file will cause tor to log to a file data.log. Run
the tor command a few times (terminating it with Ctrl-C after each bootstrap),
or just let it run for a while to accumulate re-rendezvouses at their natural
pace. Extract the data from the log file as CSV:

```
perl -ne 'BEGIN { print("date,source,location,type,size,gzip_size\n"); } if (/^(....)\/(..)\/(..) (..:..:..) DATA type=(\w+) size=(\w+) gzip_size=(\w+)/) {print("$1-$2-$3 $4,snowflake-client,location,$5,$6,$7\n")}' data.log
```

The "location" column is meant to let you separate samples that come from
different network conditions.

## Proxy measurements

snowflake-webext-log-data.patch is a patch to snowflake-webext 0.9.8 that makes
it emit distinguished "DATA" log lines to the console with the data we want.

To apply the patch:

```
git clone -b webext-0.9.8 https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake-webext.git
cd snowflake-webext
git submodule update --init
git apply ../snowflake-webext-log-data.patch
npm install
npm run webext chromium_v3
```

Load the newly built WebExtension into Chromium. Go to about:extensions. Click
the "Load unpacked" button. Select to the snowflake-webext/build-webext
directory. Click the "I consent" button on the initial screen. Go back to
about:extensions and click the Snowflake "Details" button. Click the
offscreen.html link under "Inspect views". Now you have a console.

Let the extension run for a while, then right-click on the console and
"Save as...".

Extract the data from the console log using the command below. Edit
`YYYY-MM-DD` to the date of the data collection.

```
perl -ne 'BEGIN { print("date,source,location,type,size,gzip_size\n"); } if (/^(..:..:..)\.\d\d\d .*:\d+ DATA type=(\w+) size=(\w+) gzip_size=(\w+)/) {print("YYYY-MM-DD $1,snowflake-webext,location,$2,$3,$4\n")}' console.log
```

After you're done, you can remove the Snowflake extension.

## Calculating summary statistics

Run the snowflake-message-size.r program to generate a graph
(snowflake-message-size.png) and summary statistics.

```
Rscript snowflake-message-size.r > snowflake-message-size.txt
```
