{
  "nbformat": 4,
  "nbformat_minor": 5,
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "name": "python",
      "version": "3.12.14"
    },
    "research_runtime": {
      "engine": "pyodide",
      "packages": [],
      "assets": [
        "experiment.py",
        "figure_generation.py"
      ],
      "generated_assets": [
        "results.json",
        "figure.svg"
      ],
      "display_assets": [
        "figure.svg"
      ],
      "filesystem_root": ".",
      "network_required": false,
      "validation_engine": "CPython standard-library execution"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# How can congestion feedback protect short requests from large transfers?\n\nEquation-level smoothing and once-per-round marked-event reduction for a prescribed fraction sequence; additive increase and the network feedback loop are intentionally outside this component.\n\nThis notebook runs the complete saved experiment, checks its assertions, and regenerates the SVG from the computed results. Python 3.10+ and standard-library modules only. Place experiment.py and figure_generation.py beside the notebook. The exact loaded assets are recorded in notebook metadata.\n"
      ],
      "id": "cell-1"
    },
    {
      "cell_type": "code",
      "metadata": {},
      "execution_count": 1,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "gain=0.0625\n",
            "  round=1 F=0.00 alpha=0.000000 cwnd=100.000\n",
            "  round=2 F=0.25 alpha=0.015625 cwnd=99.219\n",
            "  round=3 F=1.00 alpha=0.077148 cwnd=95.391\n",
            "  round=4 F=0.00 alpha=0.072327 cwnd=95.391\n",
            "  round=5 F=0.00 alpha=0.067806 cwnd=95.391\n",
            "  round=6 F=0.50 alpha=0.094818 cwnd=90.869\n",
            "gain=0.5000\n",
            "  round=1 F=0.00 alpha=0.000000 cwnd=100.000\n",
            "  round=2 F=0.25 alpha=0.125000 cwnd=93.750\n",
            "  round=3 F=1.00 alpha=0.562500 cwnd=67.383\n",
            "  round=4 F=0.00 alpha=0.281250 cwnd=67.383\n",
            "  round=5 F=0.00 alpha=0.140625 cwnd=67.383\n",
            "  round=6 F=0.50 alpha=0.320312 cwnd=56.591\n",
            "Constant-fraction recurrence check: passed, alpha=0.400000\n",
            "gain=0.015625: 90% step response in 147 observation windows; half-life=44.014 windows\n",
            "gain=0.062500: 90% step response in 36 observation windows; half-life=10.740 windows\n",
            "gain=0.250000: 90% step response in 9 observation windows; half-life=2.409 windows\n",
            "gain=0.500000: 90% step response in 4 observation windows; half-life=1.000 windows\n"
          ]
        }
      ],
      "source": [
        "import runpy\n_ = runpy.run_path('experiment.py', run_name='__main__')\n"
      ],
      "id": "cell-2"
    },
    {
      "cell_type": "code",
      "metadata": {},
      "execution_count": 2,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Regenerated figure.svg from results.json.\n"
          ]
        }
      ],
      "source": [
        "runpy.run_path('figure_generation.py', run_name='__main__')\n",
        "print('Regenerated figure.svg from results.json.')\n",
        "\n",
        "import base64\n",
        "print('__NOTEBOOK_IMAGE__svg+xml:' + base64.b64encode(open('figure.svg','rb').read()).decode())\n"
      ],
      "id": "cell-3"
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Inspect the saved result\n\nThe article's static figure is available before running code. The regenerated figure.svg uses results.json, and every plotted quantity comes from the experiment.\n\n![Computed figure](figure.svg)\n\nChange an input in experiment.py, rerun both code cells, then compare the saved result and figure.\n"
      ],
      "id": "cell-4"
    }
  ]
}
