[
  {
    "path": ".github/FUNDING.yml",
    "content": "# These are supported funding model platforms\n\ngithub: [imsnif]\npatreon: # Replace with a single Patreon username\nopen_collective: # Replace with a single Open Collective username\nko_fi: # Replace with a single Ko-fi username\ntidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel\ncommunity_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry\nliberapay: # Replace with a single Liberapay username\nissuehunt: # Replace with a single IssueHunt username\notechie: # Replace with a single Otechie username\nlfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry\ncustom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']\n"
  },
  {
    "path": ".github/dependabot.yml",
    "content": "version: 2\nupdates:\n  - package-ecosystem: cargo\n    directory: \"/\"\n    schedule:\n      interval: monthly\n    open-pull-requests-limit: 30\n    groups:\n      dependencies:\n        patterns:\n          - \"*\"\n  - package-ecosystem: github-actions\n    directory: \"/\"\n    schedule:\n      interval: monthly\n    open-pull-requests-limit: 30\n    groups:\n      github-actions:\n        patterns:\n          - \"*\"\n      \n"
  },
  {
    "path": ".github/workflows/ci.yaml",
    "content": "name: ci\non:\n  pull_request:\n  push:\n    branches:\n      - main\n  workflow_dispatch:\njobs:\n  get-msrv:\n    name: Get declared MSRV from Cargo.toml\n    runs-on: ubuntu-latest\n    outputs:\n      msrv: ${{ steps.get_msrv.outputs.msrv }}\n    steps:\n      - name: Install ripgrep\n        run: sudo apt-get install -y ripgrep\n\n      - name: Checkout repository\n        uses: actions/checkout@v6\n\n      - name: Get MSRV\n        id: get_msrv\n        run: rg '^\\s*rust-version\\s*=\\s*\"(\\d+(\\.\\d+){0,2})\"' --replace 'msrv=$1' Cargo.toml >> \"$GITHUB_OUTPUT\"\n\n  check-fmt:\n    name: Check code formatting\n    runs-on: ubuntu-latest\n    needs: get-msrv\n    strategy:\n      fail-fast: false\n      matrix:\n        rust:\n          - ${{ needs.get-msrv.outputs.msrv }}\n          - stable\n          - nightly\n    steps:\n      - name: Checkout repository\n        uses: actions/checkout@v6\n\n      - name: Install Rust\n        uses: dtolnay/rust-toolchain@master\n        with:\n          toolchain: ${{ matrix.rust }}\n          components: rustfmt\n      \n      - name: Check formatting\n        run: cargo fmt --all -- --check\n\n  test:\n    name: Test on each target\n    needs: get-msrv\n    env:\n      # use sccache\n      # It's too much of a hassle to set up sccache in cross.\n      # See https://github.com/cross-rs/cross/wiki/Recipes#sccache.\n      SCCACHE_GHA_ENABLED: ${{ matrix.cargo == 'cargo' && 'true' || 'false'}}\n      RUSTC_WRAPPER: ${{ matrix.cargo == 'cargo' && 'sccache' || '' }}\n      # Emit backtraces on panics.\n      RUST_BACKTRACE: 1\n    runs-on: ${{ matrix.os }}\n    strategy:\n      fail-fast: false\n      matrix:\n        build:\n          - android-aarch64\n          - linux-aarch64-gnu\n          - linux-aarch64-musl\n          - linux-armv7-gnueabihf\n          - linux-armv7-musleabihf\n          - linux-x64-gnu\n          - linux-x64-musl\n          - macos-aarch64\n          - macos-x64\n          - windows-x64-msvc\n        rust:\n          - ${{ needs.get-msrv.outputs.msrv }}\n          - stable\n          - nightly\n        include:\n          - os: ubuntu-latest # default\n          - cargo: cargo # default; overwrite with `cross` if necessary\n          - build: android-aarch64\n            target: aarch64-linux-android\n            cargo: cross\n          - build: linux-aarch64-gnu\n            target: aarch64-unknown-linux-gnu\n            cargo: cross\n          - build: linux-aarch64-musl\n            target: aarch64-unknown-linux-musl\n            cargo: cross\n          - build: linux-armv7-gnueabihf \n            target: armv7-unknown-linux-gnueabihf\n            cargo: cross\n          - build: linux-armv7-musleabihf\n            target: armv7-unknown-linux-musleabihf\n            cargo: cross\n          - build: linux-x64-gnu\n            target: x86_64-unknown-linux-gnu\n          - build: linux-x64-musl\n            target: x86_64-unknown-linux-musl\n          - build: macos-aarch64\n            # Go back ot `macos-latest` after migration is complete\n            # See https://github.blog/changelog/2024-04-01-macos-14-sonoma-is-generally-available-and-the-latest-macos-runner-image/.\n            os: macos-14\n            target: aarch64-apple-darwin\n          - build: macos-x64\n            os: macos-14\n            target: x86_64-apple-darwin\n          - build: windows-x64-msvc\n            os: windows-latest\n            target: x86_64-pc-windows-msvc\n    steps:\n      - name: Checkout repository\n        uses: actions/checkout@v6\n\n      - name: Install Rust\n        uses: dtolnay/rust-toolchain@master\n        with:\n          toolchain: ${{ matrix.rust }}\n          targets: ${{ matrix.target }}\n          components: clippy\n      \n      - name: Set up sccache\n        # It's too much of a hassle to set up sccache in cross.\n        # See https://github.com/cross-rs/cross/wiki/Recipes#sccache.\n        if: matrix.cargo == 'cargo'\n        uses: mozilla-actions/sccache-action@v0.0.9\n\n      - name: Install cross\n        if: matrix.cargo == 'cross'\n        # The latest release of `cross` is not able to build/link for `aarch64-linux-android`\n        # See: https://github.com/cross-rs/cross/issues/1222\n        # This is fixed on `main` but not yet released. To avoid a breakage somewhen in the future\n        # pin the cross revision used to the latest HEAD at 04/2024. \n        # Go back to taiki-e/install-action once cross 0.3 is released.\n        uses: taiki-e/cache-cargo-install-action@v3\n        with:\n          tool: cross\n          git: https://github.com/cross-rs/cross.git\n          rev: 085092c\n\n      - name: Build\n        id: build\n        run: ${{ matrix.cargo }} build --verbose --target ${{ matrix.target }}\n\n      # This is useful for debugging problems when the expected build artifacts\n      # (like shell completions and man pages) aren't generated.\n      - name: Show build.rs stderr\n        shell: bash\n        run: |\n          # it's probably okay to assume no spaces?\n          STDERR_FILES=$(find \"./target/debug\" -name stderr | grep bandwhich || true)\n          for FILE in $STDERR_FILES; do\n            echo \"::group::$FILE\"\n            cat \"$FILE\"\n            echo \"::endgroup::\"\n          done\n\n      - name: Run clippy\n        run: ${{ matrix.cargo }} clippy --all-targets --target ${{ matrix.target }} -- -D warnings\n\n      - name: Install npcap on Windows\n        # PRs from other repositories cannot be trusted with repository secrets\n        if: matrix.os == 'windows-latest' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)\n        env:\n          NPCAP_OEM_URL: ${{ secrets.NPCAP_OEM_URL }}\n        run: |\n          Invoke-WebRequest -Uri \"$env:NPCAP_OEM_URL\" -OutFile \"$env:TEMP/npcap-oem.exe\"\n          # for this ridiculous `&` syntax alone, I'd rather use COBOL than Powershell\n          # see https://stackoverflow.com/a/1674950/5637701\n          & \"$env:TEMP/npcap-oem.exe\" /S\n\n      - name: Run tests\n        id: run_tests\n        # npcap is needed to run tests on Windows, so unfortunately we cannot run tests\n        # on PRs from other repositories\n        if: matrix.os != 'windows-latest' || github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository\n        env:\n          # make insta generate new snapshots in CI\n          INSTA_UPDATE: new\n        run: ${{ matrix.cargo }} test --all-targets --target ${{ matrix.target }}\n\n      - name: Upload snapshots of failed tests\n        if: ${{ failure() && steps.run_tests.outcome == 'failure' }}\n        uses: actions/upload-artifact@v6\n        with:\n          name: ${{ matrix.os }}-${{ matrix.rust }}-failed_snapshots\n          path: '**/*.snap.new'\n\n      - name: Upload binaries\n        if: ${{ success() || steps.build.outcome == 'success' }}\n        uses: actions/upload-artifact@v6\n        with:\n          name: ${{ matrix.target }}-${{ matrix.rust }}\n          path: |\n            target/${{ matrix.target }}/debug/bandwhich\n            target/${{ matrix.target }}/debug/bandwhich.exe\n            target/${{ matrix.target }}/debug/bandwhich.pdb\n"
  },
  {
    "path": ".github/workflows/publish-crate.yaml",
    "content": "# This workflow triggers when a stable release is published on GitHub.\n#\n# The crates.io token used for publishing was created under the account of\n# cyqsimon <28627918+cyqsimon@users.noreply.github.com> and was added to this\n# repository's secrets by Aram Drevekenin <aram@poor.dev>.\n\nname: publish-crate\non:\n  release:\n    types:\n      - released\n  workflow_dispatch:\n\njobs:\n  publish-to-crates-io:\n    name: Publish to crates.io\n    runs-on: ubuntu-latest\n    steps:\n      - name: Checkout repository\n        uses: actions/checkout@v6\n\n      - name: Install Rust\n        uses: dtolnay/rust-toolchain@master\n        with:\n          toolchain: stable\n\n      - name: Run cargo publish\n        uses: katyo/publish-crates@v2\n        with:\n          registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}\n"
  },
  {
    "path": ".github/workflows/release.yaml",
    "content": "# The way this works is the following:\n#\n# - create-release job runs purely to initialize the GitHub release itself\n# and to output upload_url for the following job.\n#\n# - build-release job runs only once create-release is finished. It gets\n# the release upload URL from create-release job outputs, then builds\n# the release executables for each supported platform and attaches them\n# as release assets to the previously created release.\n#\n# Reference:\n# - https://eugene-babichenko.github.io/blog/2020/05/09/github-actions-cross-platform-auto-releases/\n#\n# Currently this workflow only ever creates drafts; the draft should be checked\n# and then released manually.\n\nname: release\non:\n  push:\n    tags:\n      - \"v[0-9]+.[0-9]+.[0-9]+\"\n  workflow_dispatch:\n\njobs:\n  create-release:\n    name: create-release\n    runs-on: ubuntu-latest\n    outputs:\n      upload_url: ${{ steps.create_release.outputs.upload_url }}\n    steps:\n      - name: create_release\n        id: create_release\n        uses: actions/create-release@v1\n        env:\n          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n        with:\n          tag_name: ${{ github.ref_name }}\n          release_name: Release ${{ github.ref_name }}\n          # draft: ${{ github.event_name == 'workflow_dispatch' }}\n          draft: true\n          prerelease: false\n\n  build-release:\n    name: build-release\n    needs: create-release\n    runs-on: ${{ matrix.os }}\n    env:\n      # Emit backtraces on panics.\n      RUST_BACKTRACE: 1\n      BANDWHICH_GEN_DIR: assets\n      PKGDIR: github-actions-pkg\n    strategy:\n      matrix:\n        build:\n          - android-aarch64\n          - linux-aarch64-gnu\n          - linux-aarch64-musl\n          - linux-armv7-gnueabihf\n          - linux-armv7-musleabihf\n          - linux-x64-gnu\n          - linux-x64-musl\n          - macos-aarch64\n          - macos-x64\n          - windows-x64-msvc\n        include:\n          - os: ubuntu-latest # default\n          - cargo: cargo # default; overwrite with `cross` if necessary\n          - build: android-aarch64\n            target: aarch64-linux-android\n            cargo: cross\n          - build: linux-aarch64-gnu\n            target: aarch64-unknown-linux-gnu\n            cargo: cross\n          - build: linux-aarch64-musl\n            target: aarch64-unknown-linux-musl\n            cargo: cross\n          - build: linux-armv7-gnueabihf\n            target: armv7-unknown-linux-gnueabihf\n            cargo: cross\n          - build: linux-armv7-musleabihf\n            target: armv7-unknown-linux-musleabihf\n            cargo: cross\n          - build: linux-x64-gnu\n            target: x86_64-unknown-linux-gnu\n          - build: linux-x64-musl\n            target: x86_64-unknown-linux-musl\n          - build: macos-aarch64\n            # Go back ot `macos-latest` after migration is complete\n            # See https://github.blog/changelog/2024-04-01-macos-14-sonoma-is-generally-available-and-the-latest-macos-runner-image/.\n            os: macos-14\n            target: aarch64-apple-darwin\n          - build: macos-x64\n            os: macos-14\n            target: x86_64-apple-darwin\n          - build: windows-x64-msvc\n            os: windows-latest\n            target: x86_64-pc-windows-msvc\n\n    steps:\n      - name: Checkout repository\n        uses: actions/checkout@v6\n\n      - name: Install Rust\n        uses: dtolnay/rust-toolchain@master\n        with:\n          toolchain: stable\n          targets: ${{ matrix.target }}\n\n      - name: Install cross\n        if: matrix.cargo == 'cross'\n        # The latest release of `cross` is not able to build/link for `aarch64-linux-android`\n        # See: https://github.com/cross-rs/cross/issues/1222\n        # This is fixed on `main` but not yet released. To avoid a breakage somewhen in the future\n        # pin the cross revision used to the latest HEAD at 04/2024.\n        # Go back to taiki-e/install-action once cross 0.3 is released.\n        uses: taiki-e/cache-cargo-install-action@v3\n        with:\n          tool: cross\n          git: https://github.com/cross-rs/cross.git\n          rev: 085092c\n\n      - name: Build release binary\n        shell: bash\n        env:\n          RUSTFLAGS: \"-C strip=symbols\"\n        run: |\n          mkdir -p \"$BANDWHICH_GEN_DIR\"\n          ${{ matrix.cargo }} build --verbose --release --target ${{ matrix.target }}\n\n      - name: Collect build artifacts\n        shell: bash\n        env:\n          BANDWHICH_BIN: ${{ contains(matrix.os, 'windows') && 'bandwhich.exe' || 'bandwhich' }}\n        run: |\n          mkdir \"$PKGDIR\"\n          mv \"target/${{ matrix.target }}/release/$BANDWHICH_BIN\" \"$PKGDIR\"\n          mv \"$BANDWHICH_GEN_DIR\" \"$PKGDIR\"\n\n      - name: Tar release (Unix)\n        if: ${{ !contains(matrix.os, 'windows') }}\n        working-directory: ${{ env.PKGDIR }}\n        run: tar cvfz bandwhich-${{ github.ref_name }}-${{ matrix.target }}.tar.gz *\n\n      - name: Zip release (Windows)\n        if: contains(matrix.os, 'windows')\n        working-directory: ${{ env.PKGDIR }}\n        run: Compress-Archive -Path * -DestinationPath bandwhich-${{ github.ref_name }}-${{ matrix.target }}.zip\n\n      - name: Upload release archive\n        uses: actions/upload-release-asset@v1\n        env:\n          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n          ARCHIVE_EXT: ${{ contains(matrix.os, 'windows') && 'zip' || 'tar.gz' }}\n        with:\n          upload_url: ${{ needs.create-release.outputs.upload_url }}\n          asset_path: ${{ env.PKGDIR }}/bandwhich-${{ github.ref_name }}-${{ matrix.target }}.${{ env.ARCHIVE_EXT }}\n          asset_name: bandwhich-${{ github.ref_name }}-${{ matrix.target }}.${{ env.ARCHIVE_EXT }}\n          asset_content_type: application/octet-stream\n"
  },
  {
    "path": ".github/workflows/require-changelog-for-PRs.yml",
    "content": "name: Changelog\n\non:\n  pull_request:\n\nenv:\n  PR_NUMBER: ${{ github.event.number }}\n  PR_BASE: ${{ github.base_ref }}\n\njobs:\n  get-submitter:\n    name: Get the username of the PR submitter\n    runs-on: ubuntu-latest\n    outputs:\n      submitter: ${{ steps.get-submitter.outputs.submitter }}\n    steps:\n      # cannot use `github.actor`: the triggering commit may be authored by a maintainer\n      - name: Get PR submitter\n        id: get-submitter\n        run: curl -sSfL https://api.github.com/repos/imsnif/bandwhich/pulls/${PR_NUMBER} | jq -r '\"submitter=\" + .user.login' | tee -a $GITHUB_OUTPUT  \n\n  check-changelog:\n    name: Check for changelog entry\n    needs: get-submitter\n    env:\n      PR_SUBMITTER: ${{ needs.get-submitter.outputs.submitter }}\n    runs-on: ubuntu-latest\n    # allow dependabot PRs to have no changelog\n    if: ${{ needs.get-submitter.outputs.submitter != 'dependabot[bot]' }}\n    steps:\n      - uses: actions/checkout@v6\n\n      - name: Fetch PR base\n        run: git fetch --no-tags --prune --depth=1 origin\n\n      - name: Search for added line in changelog\n        run: |\n          ADDED=$(git diff -U0 \"origin/${PR_BASE}\" HEAD -- CHANGELOG.md | grep -P '^\\+[^\\+].+$')\n          echo \"Added lines in CHANGELOG.md:\"\n          echo \"$ADDED\"\n          echo \"Grepping for PR info:\"\n          grep -P \"(#|pull/)${PR_NUMBER}\\\\b.*@${PR_SUBMITTER}\\\\b\" <<< \"$ADDED\"\n"
  },
  {
    "path": ".gitignore",
    "content": "target/\n"
  },
  {
    "path": "CHANGELOG.md",
    "content": "# Changelog\n\nAll notable changes to this project will be documented in this file.\n\nThe format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)\n\n## [Unreleased]\n\n### Fixed\n\n* Fix Ctrl+C handling to use SIGINT signal instead of keypress #491 - @chiranjeevi-max\n* Update CONTRIBUTING information #438 - @YJDoc2 @cyqsimon\n* Fix new clippy lint #457 - @cyqsimon\n* Apply new clippy lints #468 - @cyqsimon\n\n### Changed\n\n* Bump msrv to 1.75.0 #439 - @YJDoc2\n* Replace `derivative` with `derive_more` #439 - @YJDoc2\n* Add build optimizations for release binary #434 - @pando85\n* Minor cleanup and optimisations #435 - @cyqsimon\n* Bump `pnet` & `packet-builder` #444 - @cyqsimon\n* Switch from anyhow to eyre #450 - @cyqsimon\n* Manually bump all dependencies #456 - @cyqsimon\n* Bump MSRV to 1.82.0 - @cyqsimon\n\n## [0.23.1] - 2024-10-09\n\n### Fixed\n\n* CI: Use Powershell Compress-Archive to create Windows binary zip #424 - @cyqsimon\n* Exit gracefully when there is a broken pipe error #429 - @sigmaSd\n* Fix breaking changes of sysinfo crate #431 - @cyqsimon\n* Fix `clippy::needless_lifetimes` warnings on nightly #432 - @cyqsimon\n\n## [0.23.0] - 2024-08-17\n\n### Fixed\n\n* Remove redundant imports #377 - @cyqsimon\n* CI: use GitHub API to exempt dependabot from changelog requirement #378 - @cyqsimon\n* Remove unnecessary logging synchronisation #381 - @cyqsimon\n* Apply suggestions from new clippy lint clippy::assigning_clones #382 - @cyqsimon\n* Fix IPv6 socket detect logic #383 - @cyqsimon\n* Support build for `target_os` `android` #384 - @flxo\n* Fix Windows FP discrepancy issue in test #400 - @cyqsimon\n\n### Added\n\n* CI: include generated assets in release archive #359 - @cyqsimon\n* Add PID column to the process table #379 - @notjedi\n* CI: add builds for target `aarch64-linux-android` #384 - @flxo\n* CI: Keep GitHub Actions up to date with GitHub's Dependabot #403 - @cclauss\n* CI: Enable more cross-compiled builds #401 - @cyqsimon\n* CI: use sccache to speed up CI #408 - @cyqsimon\n\n### Changed\n\n* CI: strip release binaries for all targets #358 - @cyqsimon\n* Bump MSRV to 1.74 (required by clap 4.5; see #373)\n* CI: Configure dependabot grouping #395 - @cyqsimon\n* CI refactor #399 - @cyqsimon\n* CI: Temporarily disable UI tests #406 - @cyqsimon\n* Update README #407 - @cyqsimon\n* Update usage in README #409 - @cyqsimon\n\n### Removed\n\n* CI: Remove musl-tools install step #402 - @cyqsimon\n\n## [0.22.2] - 2024-01-28\n\n### Added\n\n* Generate completion & manpage #357 - @cyqsimon\n\n## [0.22.1] - 2024-01-28\n\n### Fixed\n\n* Hot fix a Windows compile issue #356 - @cyqsimon\n\n## [0.22.0] - 2024-01-28\n\n### Added\n\n* Log unresolved processes in more detail + general refactor #318 - @cyqsimon\n* Display bandwidth in different unit families #328 - @cyqsimon\n* CI: ensure a changelog entry exists for each PR #331 - @cyqsimon\n* Show interface names #340 - @ilyes-ced\n\n### Changed\n\n* Table formatting logic overhaul #305 - @cyqsimon\n* Refactor OsInputOutput (combine interfaces & frames into single Vec) #310 - @cyqsimon\n\n### Removed\n\n* Reorganise & cleanup packaging code/resources #329 - @cyqsimon\n\n### Fixed\n\n* Make logging race-free using a global lock & macro #309 - @cyqsimon\n* Use once_cell::sync::Lazy to make regex usage more ergonomic #313 - @cyqsimon\n* Fix vague CLI option documentation; closes #314 #316 - @cyqsimon\n\n## [0.21.1] - 2023-10-16\n\n### Fixed\n* Ignore connections that fail parsing instead of panicking on BSD (https://github.com/imsnif/bandwhich/pull/288) - [@cyqsimon](https://github.com/cyqsimon)\n* Add missing version flag to CLI (https://github.com/imsnif/bandwhich/pull/290) - [@tranzystorek-io](https://github.com/tranzystorek-io)\n* Various minor codestyle changes - [@cyqsimon](https://github.com/cyqsimon)\n* Handle IPv4-mapped IPv6 addresses when resolving connection owner (https://github.com/imsnif/bandwhich/commit/76956cf) - [@cyqsimon](https://github.com/cyqsimon)\n* Bump `rustix` dependencies to fix a memory leak (https://github.com/imsnif/bandwhich/commit/bc10c07) - [@cyqsimon](https://github.com/cyqsimon)\n\n### Added\n* Logging infrastrure (https://github.com/imsnif/bandwhich/pull/302) - [@cyqsimon](https://github.com/cyqsimon)\n\n## [0.21.0] - 2023-09-19\n\n### Fixed\n* Fixed resolv.conf errors on systems with trust-ad (https://github.com/imsnif/bandwhich/pull/201) - [@JoshLambda](https://github.com/JoshLambda)\n* Fixed build issues by updating various dependencies\n* migrate out-of-date dependency `structopt` to `clap` (https://github.com/imsnif/bandwhich/pull/285) - [@Liyixin95](https://github.com/Liyixin95)\n\n## [0.20.0] - 2020-10-15\n\n### Added\n* New command line argument to explicitly specify a DNS server to use (https://github.com/imsnif/bandwhich/pull/193) - [@imsnif](https://github.com/imsnif)\n\n## [0.19.0] - 2020-09-29\n\n### Fixed\n* Fixed resolv.conf parsing for rDNS in some cases (https://github.com/imsnif/bandwhich/pull/184) - [@Ma27](https://github.com/Ma27)\n* Cross platform window resizing (fixes momentary UI break when resizing window on Windows) (https://github.com/imsnif/bandwhich/pull/186) - [@remgodow](https://github.com/remgodow)\n* CI: build binaries using github actions (https://github.com/imsnif/bandwhich/pull/181) - [@remgodow](https://github.com/remgodow)\n* Fix build on FreeBSD (https://github.com/imsnif/bandwhich/pull/189) - [@imsnif](https://github.com/imsnif)\n* Upgrade TUI to latest version (https://github.com/imsnif/bandwhich/pull/190) - [@imsnif](https://github.com/imsnif)\n* Try to reconnect to disconnected interfaces (https://github.com/imsnif/bandwhich/pull/191) - [@thepacketgeek](https://github.com/thepacketgeek)\n\n## [0.18.1] - 2020-09-11\n\n* HOTFIX: do not build windows build-dependencies on other platforms\n\n## [0.18.0] - 2020-09-11\n\n### Added\n* Future windows infrastructure support (should not have any user facing effect) (https://github.com/imsnif/bandwhich/pull/179) - [@remgodow](https://github.com/remgodow)\n* Windows build and run support (https://github.com/imsnif/bandwhich/pull/180) - [@remgodow](https://github.com/remgodow)\n\n### Fixed\n* Update and improve MAN page (https://github.com/imsnif/bandwhich/pull/182) - [@Nudin](https://github.com/Nudin)\n\n## [0.17.0] - 2020-09-02\n\n### Added\n* Add delimiters between refreshes in raw mode for easier parsing (https://github.com/imsnif/bandwhich/pull/175) - [@sigmaSd](https://github.com/sigmaSd)\n\n### Fixed\n* Truncate Chinese characters properly (https://github.com/imsnif/bandwhich/pull/177) - [@zxlzy](https://github.com/zxlzy)\n* Moved to mebi/gibi/tibi bytes to improve bandwidth accuracy and reduce ambiguity (https://github.com/imsnif/bandwhich/pull/178) - [@imsnif](https://github.com/imsnif)\n\n## [0.16.0] - 2020-07-13\n\n### Fixed\n* Allow filtering by processes/connections/remote-ips in raw-mode (https://github.com/imsnif/bandwhich/pull/174) - [@sigmaSd](https://github.com/sigmaSd)\n* Changed repository trunk branch to \"main\" instead of \"master\".\n\n## [0.15.0] - 2020-05-23\n\n### Added\n* Ability to change the window layout with <TAB> (https://github.com/imsnif/bandwhich/pull/118) - [@Louis-Lesage](https://github.com/Louis-Lesage)\n* Show duration of current capture when running in \"total utilization\" mode. - [@Eosis](https://github.com/Eosis)\n\n### Fixed\n* Add terabytes as a display unit (for cumulative mode) (https://github.com/imsnif/bandwhich/pull/168) - [@TheLostLambda](https://github.com/TheLostLambda)\n\n## [0.14.0] - 2020-05-03\n\n### Fixed\n* HOTFIX: remove pnet_bandwhich_fork dependency and upgrade to working version of pnet + packet_builder instead (this should hopefully not change anything)\n\n## [0.13.0] - 2020-04-05\n\n### Added\n* Hide DNS queries by default. This can be overridden with `-s, --show-dns` (https://github.com/imsnif/bandwhich/pull/161) - [@olesh0](https://github.com/olehs0)\n* Show cumulative utilization in \"total utilization\" mode. Trigger with `-t, --total-utilization` (https://github.com/imsnif/bandwhich/pull/155) - [@TheLostLambda](https://github.com/TheLostLambda)\n\n### Fixed\n*  Fix the loss of large, merged packets (https://github.com/imsnif/bandwhich/pull/158) - [@TheLostLambda](https://github.com/TheLostLambda)\n\n## [0.12.0] - 2020-03-01\n\n### Added\n* Add custom error handling (https://github.com/imsnif/bandwhich/pull/104) - [@captain-yossarian](https://github.com/captain-yossarian)\n\n## [0.11.0] - 2020-01-25\n\n### Added\n* List unknown processes in processes table as well (https://github.com/imsnif/bandwhich/pull/132) - [@jcfvalente](https://github.com/jcfvalente)\n* New layout (https://github.com/imsnif/bandwhich/pull/139) - [@imsnif](https://github.com/imsnif)\n\n## [0.10.0] - 2020-01-18\n\n### Added\n* Support Ipv6 (https://github.com/imsnif/bandwhich/pull/70) - [@zhangxp1998](https://github.com/zhangxp1998)\n* Select tables to render from the CLI (https://github.com/imsnif/bandwhich/pull/107) - [@chobeat](https://github.com/chobeat)\n\n### Fixed\n* VPN traffic sniffing on mac (https://github.com/imsnif/bandwhich/pull/129) - [@zhangxp1998](https://github.com/zhangxp1998)\n\n## [0.9.0] - 2020-01-14\n\n### Added\n\n* Paused UI by pressing <SPACE> key. Does not affect raw mode. (https://github.com/imsnif/bandwhich/pull/106) - [@zhangxp1998](https://github.com/zhangxp1998)\n* Mention setcap option in linux permission error. (https://github.com/imsnif/bandwhich/pull/108) - [@Ma27](https://github.com/Ma27)\n* Display weighted average bandwidth for the past 5 seconds. (https://github.com/imsnif/bandwhich/pull/77) - [@zhangxp1998](https://github.com/zhangxp1998) + [@imsnif](https://github.com/imsnif)\n* FreeBSD support. (https://github.com/imsnif/bandwhich/pull/110) - [@Erk-](https://github.com/Erk-)\n* Pause help text. (https://github.com/imsnif/bandwhich/pull/111) - [@imsnif](https://github.com/imsnif)\n\n### Fixed\n\n* Upgrade trust-dns-resolver. (https://github.com/imsnif/bandwhich/pull/105) - [@bigtoast](https://github.com/bigtoast)\n* Do not listen on inactive interfaces. (https://github.com/imsnif/bandwhich/pull/116) - [@zhangxp1998](https://github.com/zhangxp1998)\n\n## [0.8.0] - 2020-01-09\n\n### Added\n- Brew formula and installation instructions for macOS (https://github.com/imsnif/bandwhich/pull/75) - [@imbsky](https://github.com/imbsky)\n- UI change: add spacing between up and down rates for readability (https://github.com/imsnif/bandwhich/pull/58) - [@Calinou](https://github.com/Calinou)\n- Support for wireguard interfaces (eg. for VPNs) (https://github.com/imsnif/bandwhich/pull/98) - [@Ma27](https://github.com/Ma27)\n- Void linux installation instructions (https://github.com/imsnif/bandwhich/pull/102) - [@jcgruenhage](https://github.com/jcgruenhage)\n- Arch installation with pacman (https://github.com/imsnif/bandwhich/pull/103) - [@kpcyrd](https://github.com/kpcyrd)\n\n### Fixed\n\n- Fix string conversion error on macOS (https://github.com/imsnif/bandwhich/pull/79) - [@zhangxp1998](https://github.com/zhangxp1998)\n- Proper fix for macos no-screen-of-death (https://github.com/imsnif/bandwhich/pull/83) - [@zhangxp1998](https://github.com/zhangxp1998) + [@imsnif](https://github.com/imsnif)\n- Fix UDP traffic not displayed issue #81 with (https://github.com/imsnif/bandwhich/pull/82) - [@zhangxp1998](https://github.com/zhangxp1998)\n- Fix mac build (https://github.com/imsnif/bandwhich/pull/93) - [@imsnif](https://github.com/imsnif)\n- Better procfs error handling (https://github.com/imsnif/bandwhich/pull/88) - [@zhangxp1998](https://github.com/zhangxp1998)\n\n\n## [0.7.0] - 2020-01-05\n\n### Added\n\n- Running instructions (sudo) for a cargo installation (https://github.com/imsnif/bandwhich/pull/42) - [@LoyVanBeek](https://github.com/LoyVanBeek) + [@filalex77](https://github.com/filalex77)\n- `setcap` instructions for linux instead of using sudo (https://github.com/imsnif/bandwhich/pull/57) - [@Calinou](https://github.com/Calinou)\n- Installation instructions for Nix/NixOS (https://github.com/imsnif/bandwhich/pull/32) - [@filalex77](https://github.com/filalex77)\n- MSRV and cargo installation instructions (https://github.com/imsnif/bandwhich/pull/66) - [@ebroto](https://github.com/ebroto)\n\n### Fixed\n\n- Repository URLs in Cargo.toml (https://github.com/imsnif/bandwhich/pull/43) - [@MatthieuBizien](https://github.com/MatthieuBizien)\n- Skip interfaces with error (https://github.com/imsnif/bandwhich/pull/49) - [@Grishy](https://github.com/Grishy)\n- MacOS no-screen-of-death workaround (https://github.com/imsnif/bandwhich/pull/56) - [@zhangxp1998](https://github.com/zhangxp1998)\n- Reduce CPU utilization on linux (https://github.com/imsnif/bandwhich/pull/68) - [@ebroto](https://github.com/ebroto)\n- Informative sudo error message (https://github.com/imsnif/bandwhich/pull/67) - [@Tobbeman](https://github.com/Tobbeman)\n- Foreground text color for non-black terminals (https://github.com/imsnif/bandwhich/pull/65) - [@niiiil](https://github.com/niiiil)\n- Do not truncate process names on MacOS (https://github.com/imsnif/bandwhich/pull/63) - [@zhangxp1998](https://github.com/zhangxp1998)\n- Refactor tests into shared functionality (https://github.com/imsnif/bandwhich/pull/55) - [@chobeat](https://github.com/chobeat)\n- Error on 0 interfaces found (https://github.com/imsnif/bandwhich/pull/69) - [@imsnif](https://github.com/imsnif)\n"
  },
  {
    "path": "CODE_OF_CONDUCT.md",
    "content": "# Contributor Covenant Code of Conduct\n\n## Our Pledge\n\nIn the interest of fostering an open and welcoming environment, we as\ncontributors and maintainers pledge to making participation in our project and\nour community a harassment-free experience for everyone, regardless of age, body\nsize, disability, ethnicity, sex characteristics, gender identity and expression,\nlevel of experience, education, socio-economic status, nationality, personal\nappearance, race, religion, or sexual identity and orientation.\n\n## Our Standards\n\nExamples of behavior that contributes to creating a positive environment\ninclude:\n\n* Using welcoming and inclusive language\n* Being respectful of differing viewpoints and experiences\n* Gracefully accepting constructive criticism\n* Focusing on what is best for the community\n* Showing empathy towards other community members\n\nExamples of unacceptable behavior by participants include:\n\n* The use of sexualized language or imagery and unwelcome sexual attention or\n advances\n* Trolling, insulting/derogatory comments, and personal or political attacks\n* Public or private harassment\n* Publishing others' private information, such as a physical or electronic\n address, without explicit permission\n* Other conduct which could reasonably be considered inappropriate in a\n professional setting\n\n## Our Responsibilities\n\nProject maintainers are responsible for clarifying the standards of acceptable\nbehavior and are expected to take appropriate and fair corrective action in\nresponse to any instances of unacceptable behavior.\n\nProject maintainers have the right and responsibility to remove, edit, or\nreject comments, commits, code, wiki edits, issues, and other contributions\nthat are not aligned to this Code of Conduct, or to ban temporarily or\npermanently any contributor for other behaviors that they deem inappropriate,\nthreatening, offensive, or harmful.\n\n## Scope\n\nThis Code of Conduct applies both within project spaces and in public spaces\nwhen an individual is representing the project or its community. Examples of\nrepresenting a project or community include using an official project e-mail\naddress, posting via an official social media account, or acting as an appointed\nrepresentative at an online or offline event. Representation of a project may be\nfurther defined and clarified by project maintainers.\n\n## Enforcement\n\nInstances of abusive, harassing, or otherwise unacceptable behavior may be\nreported by contacting the project team at aram@poor.dev. All\ncomplaints will be reviewed and investigated and will result in a response that\nis deemed necessary and appropriate to the circumstances. The project team is\nobligated to maintain confidentiality with regard to the reporter of an incident.\nFurther details of specific enforcement policies may be posted separately.\n\nProject maintainers who do not follow or enforce the Code of Conduct in good\nfaith may face temporary or permanent repercussions as determined by other\nmembers of the project's leadership.\n\n## Attribution\n\nThis Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,\navailable at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html\n\n[homepage]: https://www.contributor-covenant.org\n\nFor answers to common questions about this code of conduct, see\nhttps://www.contributor-covenant.org/faq\n"
  },
  {
    "path": "CONTRIBUTING.md",
    "content": "Contributions of any kind are very welcome. If you'd like a new feature (or found a bug), please open an issue or a PR.\n\nTo set up your development environment:\n1. Clone the project\n2. `cargo run`, or if you prefer `cargo run -- -i <network interface name>` (you can often find out the name with `ifconfig` or `iwconfig`). You might need root privileges to run this application, so be sure to use (for example) sudo.\n\nTo run tests: `cargo test`\n\nAfter tests, check the formatting: `cargo fmt -- --check`\n\nNote that at the moment the tests do not test the os layer (anything in the `os` folder).\n\nIf you are stuck, unsure about how to approach an issue or would like some guidance,\nyou are welcome to [open an issue](https://github.com/imsnif/bandwhich/issues/new);\n"
  },
  {
    "path": "Cargo.toml",
    "content": "[package]\nname = \"bandwhich\"\nversion = \"0.23.1\"\nauthors = [\n  \"Aram Drevekenin <aram@poor.dev>\",\n  \"Eduardo Toledo <etoledom@icloud.com>\",\n  \"Eduardo Broto <ebroto@tutanota.com>\",\n  \"Kelvin Zhang <zhangxp1998@gmail.com>\",\n  \"Brooks Rady <b.j.rady@gmail.com>\",\n  \"cyqsimon <28627918+cyqsimon@users.noreply.github.com>\",\n]\ncategories = [\"network-programming\", \"command-line-utilities\"]\nedition = \"2021\"\nexclude = [\"src/tests/*\", \"demo.gif\"]\nhomepage = \"https://github.com/imsnif/bandwhich\"\nkeywords = [\"networking\", \"utilization\", \"cli\"]\nlicense = \"MIT\"\nreadme = \"README.md\"\nrepository = \"https://github.com/imsnif/bandwhich\"\nrust-version = \"1.82.0\"\ndescription = \"Display current network utilization by process, connection and remote IP/hostname\"\n\n[features]\ndefault = []\n# UI tests temporarily disabled by default, until big refactor is done\nui_test = []\n\n[dependencies]\nasync-trait = \"0.1.88\"\nchrono = \"0.4\"\nclap-verbosity-flag = \"3.0.3\"\nclap = { version = \"4.5.41\", features = [\"derive\"] }\ncrossterm = \"0.29.0\"\nctrlc = \"3.4\"\nderive_more = { version = \"2.0.1\", features = [\"debug\"] }\neyre = \"0.6.12\"\nitertools = \"0.14.0\"\nlog = \"0.4.27\"\nonce_cell = \"1.21.3\"\npnet = \"0.35.0\"\npnet_macros_support = \"0.35.0\"\nratatui = \"0.29.0\"\nresolv-conf = \"0.7.4\"\nsimplelog = \"0.12.2\"\nthiserror = \"2.0.12\"\ntokio = { version = \"1.46\", features = [\"rt\", \"sync\"] }\ntrust-dns-resolver = \"0.23.2\"\nunicode-width = \"0.2.0\"\nstrum = { version = \"0.27.1\", features = [\"derive\"] }\n\n\n[target.'cfg(any(target_os = \"android\", target_os = \"linux\"))'.dependencies]\nprocfs = \"0.17.0\"\n\n[target.'cfg(any(target_os = \"macos\", target_os = \"freebsd\"))'.dependencies]\nregex = \"1.11.1\"\n\n[target.'cfg(target_os = \"windows\")'.dependencies]\nnetstat2 = \"0.11.1\"\nsysinfo = \"0.35.2\"\n\n[dev-dependencies]\ninsta = \"1.43.1\"\npacket-builder = { version = \"0.7.0\", git = \"https://github.com/cyqsimon/packet_builder.git\", branch = \"patch-pnet-0.35\" }\npnet_base = \"0.35.0\"\nregex = \"1.11.1\"\nrstest = \"0.25.0\"\n\n[build-dependencies]\nclap = { version = \"4.5.41\", features = [\"derive\"] }\nclap-verbosity-flag = \"3.0.3\"\nclap_complete = \"4.5.55\"\nclap_mangen = \"0.2.28\"\nderive_more = { version = \"2.0.1\", features = [\"debug\"] }\neyre = \"0.6.12\"\nstrum = { version = \"0.27.1\", features = [\"derive\"] }\n\n[target.'cfg(target_os = \"windows\")'.build-dependencies]\nhttp_req = \"0.14.0\"\nzip = \"2.4.2\"\n\n[profile.release]\ncodegen-units = 1\nopt-level = 3\nlto = \"fat\"\npanic = \"abort\"\nstrip = \"symbols\"\n"
  },
  {
    "path": "Cross.toml",
    "content": "[build.env]\npassthrough = [\"BANDWHICH_GEN_DIR\"]\n"
  },
  {
    "path": "INSTALL.md",
    "content": "# Installation\n\n- [Installation](#installation)\n  - [Arch Linux](#arch-linux)\n  - [Exherbo Linux](#exherbo-linux)\n  - [Nix/NixOS](#nixnixos)\n  - [Void Linux](#void-linux)\n  - [Fedora](#fedora)\n  - [macOS/Linux (using Homebrew)](#macoslinux-using-homebrew)\n  - [macOS (using MacPorts)](#macos-using-macports)\n  - [FreeBSD](#freebsd)\n  - [Cargo](#cargo)\n\n## Arch Linux\n\n```\npacman -S bandwhich\n```\n\n## Exherbo Linux\n\n`bandwhich` is available in [rust repository](https://gitlab.exherbo.org/exherbo/rust/-/tree/master/packages/sys-apps/bandwhich), and can be installed via `cave`:\n\n```\ncave resolve -x repository/rust\ncave resolve -x bandwhich\n```\n\n## Nix/NixOS\n\n`bandwhich` is available in [`nixpkgs`](https://github.com/nixos/nixpkgs/blob/master/pkgs/tools/networking/bandwhich/default.nix), and can be installed, for example, with `nix-env`:\n\n```\nnix-env -iA nixpkgs.bandwhich\n```\n\n## Void Linux\n\n```\nxbps-install -S bandwhich\n```\n\n## Fedora\n\n`bandwhich` is available in [COPR](https://copr.fedorainfracloud.org/coprs/atim/bandwhich/), and can be installed via DNF:\n\n```\nsudo dnf copr enable atim/bandwhich -y && sudo dnf install bandwhich\n```\n\n## macOS/Linux (using Homebrew)\n\n```\nbrew install bandwhich\n```\n\n## macOS (using MacPorts)\n\n```\nsudo port selfupdate\nsudo port install bandwhich\n```\n\n## FreeBSD\n\n```\npkg install bandwhich\n```\n\nor\n\n```\ncd /usr/ports/net-mgmt/bandwhich && make install clean\n```\n\n## Cargo\n\nRegardless of OS, you can always fallback to the Rust package manager, `cargo`.\nFor installation instructions of the Rust toolchain, see [here](https://www.rust-lang.org/tools/install).\n\n```\ncargo install bandwhich\n```\n"
  },
  {
    "path": "LICENSE.md",
    "content": "MIT License\n\nCopyright (c) 2019 Aram Drevekenin\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "# bandwhich\n\n![demo](res/demo.gif)\n\nThis is a CLI utility for displaying current network utilization by process, connection and remote IP/hostname\n\n## Table of contents\n\n- [bandwhich](#bandwhich)\n  - [Table of contents](#table-of-contents)\n  - [Project status](#project-status)\n  - [How does it work?](#how-does-it-work)\n  - [Installation](#installation)\n    - [Downstream packaging status](#downstream-packaging-status)\n    - [Download a prebuilt binary](#download-a-prebuilt-binary)\n  - [Building from source](#building-from-source)\n    - [Cross-compiling](#cross-compiling)\n      - [Android](#android)\n  - [Post install (Linux)](#post-install-linux)\n    - [1. `setcap`](#1-setcap)\n      - [Capabilities explained](#capabilities-explained)\n    - [2. `sudo` (or alternative)](#2-sudo-or-alternative)\n  - [Post install (Windows)](#post-install-windows)\n  - [Usage](#usage)\n  - [Contributing](#contributing)\n  - [License](#license)\n\n## Project status\n\nThis project is in passive maintenance. Critical issues will be addressed, but\nno new features are being worked on. However, this is due to a lack of funding\nand/or manpower more than anything else, so pull requests are more than welcome.\nIn addition, if you are able and willing to contribute to this project long-term,\nwe would like to invite you to apply for co-maintainership.\n\nFor more details, see [The Future of Bandwhich #275](https://github.com/imsnif/bandwhich/issues/275).\n\n## How does it work?\n\n`bandwhich` sniffs a given network interface and records IP packet size, cross referencing it with the `/proc` filesystem on linux, `lsof` on macOS, or using WinApi on windows. It is responsive to the terminal window size, displaying less info if there is no room for it. It will also attempt to resolve ips to their host name in the background using reverse DNS on a best effort basis.\n\n## Installation\n\n### Downstream packaging status\n\nFor detailed instructions for each platform, see [INSTALL.md](INSTALL.md).\n\n<a href=\"https://repology.org/project/bandwhich/versions\">\n  <img src=\"https://repology.org/badge/vertical-allrepos/bandwhich.svg?columns=3\" alt=\"Packaging status\">\n</a>\n\n### Download a prebuilt binary\n\nWe offer several generic binaries in [releases](https://github.com/imsnif/bandwhich/releases) for various OSes.\n\n<table>\n  <thead>\n    <th>OS</th><th>Architecture</th><th>Support</th><th>Usage</th>\n  </thead>\n  <tbody>\n    <tr>\n      <td>Android</td><td>aarch64</td><td>Best effort</td>\n      <td>\n        <p>All modern Android devices.</p>\n        <p>Note that this is a pure binary file, not an APK suitable for general usage.</p>\n      </td>\n    </tr>\n    <tr>\n      <td rowspan=\"3\">Linux</td><td>aarch64</td><td>Full</td>\n      <td>64-bit ARMv8+ (servers, some modern routers, RPi-4+).</td>\n    </tr>\n    <tr>\n      <td>armv7hf</td><td>Best effort</td><td>32-bit ARMv7 (older routers, pre-RPi-4).</td>\n    </tr>\n    <tr>\n      <td>x64</td><td>Full</td>\n      <td>Most Linux desktops & servers.</td>\n    </tr>\n    <tr>\n      <td rowspan=\"2\">MacOS</td><td>aarch64</td><td rowspan=\"2\">Full</td>\n      <td>Apple silicon Macs (2021+).</td>\n    </tr>\n    <tr>\n      <td>x64</td>\n      <td>Intel Macs (pre-2021).</td>\n    </tr>\n    <tr>\n      <td>Windows</td><td>x64</td><td>Full</td>\n      <td>Most Windows desktops & servers.</td>\n    </tr>\n  </tbody>\n</table>\n\n## Building from source\n\n```sh\ngit clone https://github.com/imsnif/bandwhich.git\ncd bandwhich\ncargo build --release\n```\n\nFor the up-to-date minimum supported Rust version, please refer to the `rust-version` field in [Cargo.toml](Cargo.toml).\n\n### Cross-compiling\n\nCross-compiling for alternate targets is supported via [cross](https://github.com/cross-rs/cross). Here's the rough procedure:\n\n1. Check the target architecture. If on Linux, you can use `uname -m`.\n2. Lookup [rustc platform support](https://doc.rust-lang.org/rustc/platform-support.html) for the corresponding target triple.\n3. [Install `cross`](https://github.com/cross-rs/cross#installation).\n4. Run `cross build --release --target <TARGET_TRIPLE>`.\n\n#### Android\n\nUntil [cross-rs/cross#1222](https://github.com/cross-rs/cross/issues/1222) is solved, use the latest HEAD:\n\n```sh\ncargo install --git https://github.com/cross-rs/cross.git cross\ncross build --release --target aarch64-linux-android\n```\n\n## Post install (Linux)\n\nSince `bandwhich` sniffs network packets, it requires elevated privileges.\nOn Linux, there are two main ways to accomplish this:\n\n### 1. `setcap`\n\n- Permanently allow the `bandwhich` binary its required privileges (called \"capabilities\" in Linux).\n- Do this if you want to give all unprivileged users full access to bandwhich's monitoring capabilities.\n    - This is the **recommended** setup **for single user machines**, or **if all users are trusted**.\n    - This is **not recommended** if you want to **ensure users cannot see others' traffic**.\n\n```sh\n# assign capabilities\nsudo setcap cap_sys_ptrace,cap_dac_read_search,cap_net_raw,cap_net_admin+ep $(command -v bandwhich)\n# run as unprivileged user\nbandwhich\n```\n\n#### Capabilities explained\n- `cap_sys_ptrace,cap_dac_read_search`: allow access to `/proc/<pid>/fd/`, so that `bandwhich` can determine which open port belongs to which process.\n- `cap_net_raw,cap_net_admin`: allow capturing packets on your system.\n\n### 2. `sudo` (or alternative)\n\n- Require privilege escalation every time.\n- Do this if you are an administrator of a multi-user environment.\n\n```sh\nsudo bandwhich\n```\n\nNote that if your installation method installed `bandwhich` to somewhere in\nyour home directory (you can check with `command -v bandwhich`), you may get a\n`command not found` error. This is because in many distributions, `sudo` by\ndefault does not keep your user's `$PATH` for safety concerns.\n\nTo overcome this, you can do any one of the following:\n1. [make `sudo` preserve your `$PATH` environment variable](https://unix.stackexchange.com/q/83191/375550);\n2. explicitly set `$PATH` while running `bandwhich`: `sudo env \"PATH=$PATH\" bandwhich`;\n3. pass the full path to `sudo`: `sudo $(command -v bandwhich)`.\n\n## Post install (Windows)\n\nYou might need to first install [npcap](https://npcap.com/#download) for capturing packets on Windows.\n\n## Usage\n\n```\nUsage: bandwhich [OPTIONS]\n\nOptions:\n  -i, --interface <INTERFACE>      The network interface to listen on, eg. eth0\n  -r, --raw                        Machine friendlier output\n  -n, --no-resolve                 Do not attempt to resolve IPs to their hostnames\n  -s, --show-dns                   Show DNS queries\n  -d, --dns-server <DNS_SERVER>    A dns server ip to use instead of the system default\n      --log-to <LOG_TO>            Enable debug logging to a file\n  -v, --verbose...                 Increase logging verbosity\n  -q, --quiet...                   Decrease logging verbosity\n  -p, --processes                  Show processes table only\n  -c, --connections                Show connections table only\n  -a, --addresses                  Show remote addresses table only\n  -u, --unit-family <UNIT_FAMILY>  Choose a specific family of units [default: bin-bytes] [possible values: bin-bytes, bin-bits, si-bytes, si-bits]\n  -t, --total-utilization          Show total (cumulative) usages\n  -h, --help                       Print help (see more with '--help')\n  -V, --version                    Print version\n```\n\n## Contributing\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md).\n\n## License\n\nMIT\n"
  },
  {
    "path": "build.rs",
    "content": "use std::{env, fs::File};\n\nuse clap::CommandFactory;\nuse clap_complete::Shell;\nuse clap_mangen::Man;\nuse eyre::eyre;\n\nfn main() {\n    build_completion_manpage().unwrap();\n\n    #[cfg(target_os = \"windows\")]\n    download_windows_npcap_sdk().unwrap();\n}\n\ninclude!(\"src/cli.rs\");\n\nfn build_completion_manpage() -> eyre::Result<()> {\n    let mut cmd = Opt::command();\n\n    // build into `BANDWHICH_GEN_DIR` with a fallback to `OUT_DIR`\n    let gen_dir: PathBuf = env::var_os(\"BANDWHICH_GEN_DIR\")\n        .or_else(|| env::var_os(\"OUT_DIR\"))\n        .ok_or(eyre!(\"OUT_DIR is unset\"))?\n        .into();\n\n    // completion\n    for &shell in Shell::value_variants() {\n        clap_complete::generate_to(shell, &mut cmd, \"bandwhich\", &gen_dir)?;\n    }\n\n    // manpage\n    let mut manpage_out = File::create(gen_dir.join(\"bandwhich.1\"))?;\n    let manpage = Man::new(cmd);\n    manpage.render(&mut manpage_out)?;\n\n    Ok(())\n}\n\n#[cfg(target_os = \"windows\")]\nfn download_windows_npcap_sdk() -> eyre::Result<()> {\n    use std::{\n        fs,\n        io::{self, Write},\n    };\n\n    use http_req::request;\n    use zip::ZipArchive;\n\n    println!(\"cargo:rerun-if-changed=build.rs\");\n\n    // get npcap SDK\n    const NPCAP_SDK: &str = \"npcap-sdk-1.13.zip\";\n\n    let npcap_sdk_download_url = format!(\"https://npcap.com/dist/{NPCAP_SDK}\");\n    let cache_dir = PathBuf::from(env::var(\"CARGO_MANIFEST_DIR\")?).join(\"target\");\n    let npcap_sdk_cache_path = cache_dir.join(NPCAP_SDK);\n\n    let npcap_zip = match fs::read(&npcap_sdk_cache_path) {\n        // use cached\n        Ok(zip_data) => {\n            eprintln!(\"Found cached npcap SDK\");\n            zip_data\n        }\n        // download SDK\n        Err(_) => {\n            eprintln!(\"Downloading npcap SDK\");\n\n            // download\n            let mut zip_data = vec![];\n            let _res = request::get(npcap_sdk_download_url, &mut zip_data)?;\n\n            // write cache\n            fs::create_dir_all(cache_dir)?;\n            let mut cache = fs::File::create(npcap_sdk_cache_path)?;\n            cache.write_all(&zip_data)?;\n\n            zip_data\n        }\n    };\n\n    // extract DLL\n    let lib_path = if cfg!(target_arch = \"aarch64\") {\n        \"Lib/ARM64/Packet.lib\"\n    } else if cfg!(target_arch = \"x86_64\") {\n        \"Lib/x64/Packet.lib\"\n    } else if cfg!(target_arch = \"x86\") {\n        \"Lib/Packet.lib\"\n    } else {\n        panic!(\"Unsupported target!\")\n    };\n    let mut archive = ZipArchive::new(io::Cursor::new(npcap_zip))?;\n    let mut npcap_lib = archive.by_name(lib_path)?;\n\n    // write DLL\n    let lib_dir = PathBuf::from(env::var(\"OUT_DIR\")?).join(\"npcap_sdk\");\n    let lib_path = lib_dir.join(\"Packet.lib\");\n    fs::create_dir_all(&lib_dir)?;\n    let mut lib_file = fs::File::create(lib_path)?;\n    io::copy(&mut npcap_lib, &mut lib_file)?;\n\n    println!(\n        \"cargo:rustc-link-search=native={}\",\n        lib_dir\n            .to_str()\n            .ok_or(eyre!(\"{lib_dir:?} is not valid UTF-8\"))?\n    );\n\n    Ok(())\n}\n"
  },
  {
    "path": "rustfmt.toml",
    "content": ""
  },
  {
    "path": "src/cli.rs",
    "content": "use std::{net::Ipv4Addr, path::PathBuf};\n\nuse clap::{Args, Parser, ValueEnum, ValueHint};\nuse clap_verbosity_flag::{InfoLevel, Verbosity};\nuse derive_more::Debug;\nuse strum::EnumIter;\n\n#[derive(Clone, Debug, Parser, Default)]\n#[command(name = \"bandwhich\", version)]\npub struct Opt {\n    #[arg(short, long)]\n    /// The network interface to listen on, eg. eth0\n    pub interface: Option<String>,\n\n    #[arg(short, long)]\n    /// Machine friendlier output\n    pub raw: bool,\n\n    #[arg(short, long)]\n    /// Do not attempt to resolve IPs to their hostnames\n    pub no_resolve: bool,\n\n    #[arg(short, long)]\n    /// Show DNS queries\n    pub show_dns: bool,\n\n    #[arg(short, long)]\n    /// A dns server ip to use instead of the system default\n    pub dns_server: Option<Ipv4Addr>,\n\n    #[arg(long, value_hint = ValueHint::FilePath)]\n    /// Enable debug logging to a file\n    pub log_to: Option<PathBuf>,\n\n    #[command(flatten)]\n    pub verbosity: Verbosity<InfoLevel>,\n\n    #[command(flatten)]\n    pub render_opts: RenderOpts,\n}\n\n#[derive(Copy, Clone, Debug, Default, Args)]\npub struct RenderOpts {\n    #[arg(short, long)]\n    /// Show processes table only\n    pub processes: bool,\n\n    #[arg(short, long)]\n    /// Show connections table only\n    pub connections: bool,\n\n    #[arg(short, long)]\n    /// Show remote addresses table only\n    pub addresses: bool,\n\n    #[arg(short, long, value_enum, default_value_t)]\n    /// Choose a specific family of units\n    pub unit_family: UnitFamily,\n\n    #[arg(short, long)]\n    /// Show total (cumulative) usages\n    pub total_utilization: bool,\n}\n\n// IMPRV: it would be nice if we can `#[cfg_attr(not(build), derive(strum::EnumIter))]` this\n// unfortunately there is no configuration option for build script detection\n#[derive(Copy, Clone, Debug, Default, Eq, PartialEq, ValueEnum, EnumIter)]\npub enum UnitFamily {\n    #[default]\n    /// bytes, in powers of 2^10\n    BinBytes,\n    /// bits, in powers of 2^10\n    BinBits,\n    /// bytes, in powers of 10^3\n    SiBytes,\n    /// bits, in powers of 10^3\n    SiBits,\n}\n"
  },
  {
    "path": "src/display/components/display_bandwidth.rs",
    "content": "use std::fmt;\n\nuse derive_more::Debug;\n\nuse crate::cli::UnitFamily;\n\n#[derive(Copy, Clone, Debug)]\npub struct DisplayBandwidth {\n    // Custom format for reduced precision.\n    // Workaround for FP calculation discrepancy between Unix and Windows.\n    // See https://github.com/rust-lang/rust/issues/111405#issuecomment-2055964223.\n    #[debug(\"{bandwidth:.10e}\")]\n    pub bandwidth: f64,\n    pub unit_family: BandwidthUnitFamily,\n}\n\nimpl fmt::Display for DisplayBandwidth {\n    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\n        let (div, suffix) = self.unit_family.get_unit_for(self.bandwidth);\n        write!(f, \"{:.2}{suffix}\", self.bandwidth / div)\n    }\n}\n\n/// Type wrapper around [`UnitFamily`] to provide extra functionality.\n#[derive(Copy, Clone, Debug, Default, Eq, PartialEq)]\n#[debug(\"{_0:?}\")]\npub struct BandwidthUnitFamily(UnitFamily);\nimpl From<UnitFamily> for BandwidthUnitFamily {\n    fn from(value: UnitFamily) -> Self {\n        Self(value)\n    }\n}\nimpl BandwidthUnitFamily {\n    #[inline]\n    /// Returns an array of tuples, corresponding to the steps of this unit family.\n    ///\n    /// Each step contains a divisor, an upper bound, and a unit suffix.\n    fn steps(&self) -> [(f64, f64, &'static str); 6] {\n        /// The fraction of the next unit the value has to meet to step up.\n        const STEP_UP_FRAC: f64 = 0.95;\n        /// Binary base: 2^10.\n        const BB: f64 = 1024.0;\n\n        use UnitFamily as F;\n        // probably could macro this stuff, but I'm too lazy\n        match self.0 {\n            F::BinBytes => [\n                (1.0, BB * STEP_UP_FRAC, \"B\"),\n                (BB, BB.powi(2) * STEP_UP_FRAC, \"KiB\"),\n                (BB.powi(2), BB.powi(3) * STEP_UP_FRAC, \"MiB\"),\n                (BB.powi(3), BB.powi(4) * STEP_UP_FRAC, \"GiB\"),\n                (BB.powi(4), BB.powi(5) * STEP_UP_FRAC, \"TiB\"),\n                (BB.powi(5), f64::MAX, \"PiB\"),\n            ],\n            F::BinBits => [\n                (1.0 / 8.0, BB / 8.0 * STEP_UP_FRAC, \"b\"),\n                (BB / 8.0, BB.powi(2) / 8.0 * STEP_UP_FRAC, \"Kib\"),\n                (BB.powi(2) / 8.0, BB.powi(3) / 8.0 * STEP_UP_FRAC, \"Mib\"),\n                (BB.powi(3) / 8.0, BB.powi(4) / 8.0 * STEP_UP_FRAC, \"Gib\"),\n                (BB.powi(4) / 8.0, BB.powi(5) / 8.0 * STEP_UP_FRAC, \"Tib\"),\n                (BB.powi(5) / 8.0, f64::MAX, \"Pib\"),\n            ],\n            F::SiBytes => [\n                (1.0, 1e3 * STEP_UP_FRAC, \"B\"),\n                (1e3, 1e6 * STEP_UP_FRAC, \"kB\"),\n                (1e6, 1e9 * STEP_UP_FRAC, \"MB\"),\n                (1e9, 1e12 * STEP_UP_FRAC, \"GB\"),\n                (1e12, 1e15 * STEP_UP_FRAC, \"TB\"),\n                (1e15, f64::MAX, \"PB\"),\n            ],\n            F::SiBits => [\n                (1.0 / 8.0, 1e3 / 8.0 * STEP_UP_FRAC, \"b\"),\n                (1e3 / 8.0, 1e6 / 8.0 * STEP_UP_FRAC, \"kb\"),\n                (1e6 / 8.0, 1e9 / 8.0 * STEP_UP_FRAC, \"Mb\"),\n                (1e9 / 8.0, 1e12 / 8.0 * STEP_UP_FRAC, \"Gb\"),\n                (1e12 / 8.0, 1e15 / 8.0 * STEP_UP_FRAC, \"Tb\"),\n                (1e15 / 8.0, f64::MAX, \"Pb\"),\n            ],\n        }\n    }\n\n    /// Select a unit for a given value, returning its divisor and suffix.\n    fn get_unit_for(&self, bytes: f64) -> (f64, &'static str) {\n        let Some((div, _, suffix)) = self\n            .steps()\n            .into_iter()\n            .find(|&(_, bound, _)| bound >= bytes)\n        else {\n            panic!(\"Cannot select an appropriate unit for {bytes:.2}B.\")\n        };\n\n        (div, suffix)\n    }\n}\n\n#[cfg(test)]\nmod tests {\n    use std::fmt::Write;\n\n    use insta::assert_snapshot;\n    use itertools::Itertools;\n    use strum::IntoEnumIterator;\n\n    use crate::{cli::UnitFamily, display::DisplayBandwidth};\n\n    #[test]\n    fn bandwidth_formatting() {\n        let test_bandwidths_formatted = UnitFamily::iter()\n            .map_into()\n            .cartesian_product(\n                // I feel like this is a decent selection of values\n                (-6..60)\n                    .map(|exp| 2f64.powi(exp))\n                    .chain((-5..45).map(|exp| 2.5f64.powi(exp)))\n                    .chain((-4..38).map(|exp| 3f64.powi(exp)))\n                    .chain((-3..26).map(|exp| 5f64.powi(exp))),\n            )\n            .map(|(unit_family, bandwidth)| DisplayBandwidth {\n                bandwidth,\n                unit_family,\n            })\n            .fold(String::new(), |mut buf, b| {\n                let _ = writeln!(buf, \"{b:?}: {b}\");\n                buf\n            });\n\n        assert_snapshot!(test_bandwidths_formatted);\n    }\n}\n"
  },
  {
    "path": "src/display/components/header_details.rs",
    "content": "use std::time::{Duration, Instant};\n\nuse ratatui::{\n    layout::{Alignment, Rect},\n    style::{Color, Modifier, Style},\n    text::Span,\n    widgets::Paragraph,\n    Frame,\n};\nuse unicode_width::UnicodeWidthStr;\n\nuse crate::display::{DisplayBandwidth, UIState};\n\npub fn elapsed_time(last_start_time: Instant, cumulative_time: Duration, paused: bool) -> Duration {\n    if paused {\n        cumulative_time\n    } else {\n        cumulative_time + last_start_time.elapsed()\n    }\n}\n\nfn format_duration(d: Duration) -> String {\n    let s = d.as_secs();\n    let days = match s / 86400 {\n        0 => \"\".to_string(),\n        1 => \"1 day, \".to_string(),\n        n => format!(\"{n} days, \"),\n    };\n    format!(\n        \"{days}{:02}:{:02}:{:02}\",\n        (s / 3600) % 24,\n        (s / 60) % 60,\n        s % 60,\n    )\n}\n\npub struct HeaderDetails<'a> {\n    pub state: &'a UIState,\n    pub elapsed_time: Duration,\n    pub paused: bool,\n}\n\nimpl HeaderDetails<'_> {\n    pub fn render(&self, frame: &mut Frame, rect: Rect) {\n        let bandwidth = self.bandwidth_string();\n        let color = if self.paused {\n            Color::Yellow\n        } else {\n            Color::Green\n        };\n\n        // do not render time in tests, otherwise the output becomes non-deterministic\n        // see: https://github.com/imsnif/bandwhich/issues/303\n        if cfg!(not(test)) && self.state.cumulative_mode {\n            let elapsed_time = format_duration(self.elapsed_time);\n            // only render if there is enough width\n            if bandwidth.width() + 1 + elapsed_time.width() <= rect.width as usize {\n                self.render_elapsed_time(frame, rect, &elapsed_time, color);\n            }\n        }\n\n        self.render_bandwidth(frame, rect, &bandwidth, color);\n    }\n\n    fn render_bandwidth(&self, frame: &mut Frame, rect: Rect, bandwidth: &str, color: Color) {\n        let bandwidth_text = Span::styled(\n            bandwidth,\n            Style::default().fg(color).add_modifier(Modifier::BOLD),\n        );\n\n        let paragraph = Paragraph::new(bandwidth_text).alignment(Alignment::Left);\n        frame.render_widget(paragraph, rect);\n    }\n\n    fn bandwidth_string(&self) -> String {\n        let intrf = self.state.interface_name.as_deref().unwrap_or(\"all\");\n        let t = if self.state.cumulative_mode {\n            \"Data\"\n        } else {\n            \"Rate\"\n        };\n        let unit_family = self.state.unit_family;\n        let up = DisplayBandwidth {\n            bandwidth: self.state.total_bytes_uploaded as f64,\n            unit_family,\n        };\n        let down = DisplayBandwidth {\n            bandwidth: self.state.total_bytes_downloaded as f64,\n            unit_family,\n        };\n        let paused = if self.paused { \" [PAUSED]\" } else { \"\" };\n        format!(\"IF: {intrf} | Total {t} (Up / Down): {up} / {down}{paused}\")\n    }\n\n    fn render_elapsed_time(&self, frame: &mut Frame, rect: Rect, elapsed_time: &str, color: Color) {\n        let elapsed_time_text = Span::styled(\n            elapsed_time,\n            Style::default().fg(color).add_modifier(Modifier::BOLD),\n        );\n        let paragraph = Paragraph::new(elapsed_time_text).alignment(Alignment::Right);\n        frame.render_widget(paragraph, rect);\n    }\n}\n"
  },
  {
    "path": "src/display/components/help_text.rs",
    "content": "use ratatui::{\n    layout::{Alignment, Rect},\n    style::{Modifier, Style},\n    text::Span,\n    widgets::Paragraph,\n    Frame,\n};\n\npub struct HelpText {\n    pub paused: bool,\n    pub show_dns: bool,\n}\n\nconst FIRST_WIDTH_BREAKPOINT: u16 = 76;\nconst SECOND_WIDTH_BREAKPOINT: u16 = 54;\n\nconst TEXT_WHEN_PAUSED: &str = \" Press <SPACE> to resume.\";\nconst TEXT_WHEN_NOT_PAUSED: &str = \" Press <SPACE> to pause.\";\nconst TEXT_WHEN_DNS_NOT_SHOWN: &str = \" (DNS queries hidden).\";\nconst TEXT_WHEN_DNS_SHOWN: &str = \" (DNS queries shown).\";\nconst TEXT_TAB_TIP: &str = \" Use <TAB> to rearrange tables.\";\n\nimpl HelpText {\n    pub fn render(&self, frame: &mut Frame, rect: Rect) {\n        let pause_content = if self.paused {\n            TEXT_WHEN_PAUSED\n        } else {\n            TEXT_WHEN_NOT_PAUSED\n        };\n\n        let dns_content = if rect.width <= FIRST_WIDTH_BREAKPOINT {\n            \"\"\n        } else if self.show_dns {\n            TEXT_WHEN_DNS_SHOWN\n        } else {\n            TEXT_WHEN_DNS_NOT_SHOWN\n        };\n\n        let tab_text = if rect.width <= SECOND_WIDTH_BREAKPOINT {\n            \"\"\n        } else {\n            TEXT_TAB_TIP\n        };\n\n        let text = Span::styled(\n            [pause_content, tab_text, dns_content].concat(),\n            Style::default().add_modifier(Modifier::BOLD),\n        );\n        let paragraph = Paragraph::new(text).alignment(Alignment::Left);\n        frame.render_widget(paragraph, rect);\n    }\n}\n"
  },
  {
    "path": "src/display/components/layout.rs",
    "content": "use ratatui::{\n    layout::{Constraint, Direction, Rect},\n    Frame,\n};\n\nuse crate::display::{HeaderDetails, HelpText, Table};\n\nconst FIRST_HEIGHT_BREAKPOINT: u16 = 30;\nconst FIRST_WIDTH_BREAKPOINT: u16 = 120;\n\nfn top_app_and_bottom_split(rect: Rect) -> (Rect, Rect, Rect) {\n    let parts = ratatui::layout::Layout::default()\n        .direction(Direction::Vertical)\n        .margin(0)\n        .constraints(\n            [\n                Constraint::Length(1),\n                Constraint::Length(rect.height - 2),\n                Constraint::Length(1),\n            ]\n            .as_ref(),\n        )\n        .split(rect);\n    (parts[0], parts[1], parts[2])\n}\n\npub struct Layout<'a> {\n    pub header: HeaderDetails<'a>,\n    pub children: Vec<Table>,\n    pub footer: HelpText,\n}\n\nimpl Layout<'_> {\n    fn progressive_split(&self, rect: Rect, splits: Vec<Direction>) -> Vec<Rect> {\n        splits\n            .into_iter()\n            .fold(vec![rect], |mut layout, direction| {\n                let last_rect = layout.pop().unwrap();\n                let halves = ratatui::layout::Layout::default()\n                    .direction(direction)\n                    .margin(0)\n                    .constraints([Constraint::Percentage(50), Constraint::Percentage(50)].as_ref())\n                    .split(last_rect);\n                layout.append(&mut halves.to_vec());\n                layout\n            })\n    }\n\n    fn build_two_children_layout(&self, rect: Rect) -> Vec<Rect> {\n        // if there are two elements\n        if rect.height < FIRST_HEIGHT_BREAKPOINT && rect.width < FIRST_WIDTH_BREAKPOINT {\n            // if the space is not enough, we drop one element\n            vec![rect]\n        } else if rect.width < FIRST_WIDTH_BREAKPOINT {\n            // if the horizontal space is not enough, we drop one element and we split horizontally\n            self.progressive_split(rect, vec![Direction::Vertical])\n        } else {\n            // by default we display two elements splitting vertically\n            self.progressive_split(rect, vec![Direction::Horizontal])\n        }\n    }\n\n    fn build_three_children_layout(&self, rect: Rect) -> Vec<Rect> {\n        // if there are three elements\n        if rect.height < FIRST_HEIGHT_BREAKPOINT && rect.width < FIRST_WIDTH_BREAKPOINT {\n            //if the space is not enough, we drop two elements\n            vec![rect]\n        } else if rect.height < FIRST_HEIGHT_BREAKPOINT {\n            // if the vertical space is not enough, we drop one element and we split vertically\n            self.progressive_split(rect, vec![Direction::Horizontal])\n        } else if rect.width < FIRST_WIDTH_BREAKPOINT {\n            // if the horizontal space is not enough, we drop one element and we split horizontally\n            self.progressive_split(rect, vec![Direction::Vertical])\n        } else {\n            // default layout\n            let halves = ratatui::layout::Layout::default()\n                .direction(Direction::Vertical)\n                .margin(0)\n                .constraints([Constraint::Percentage(50), Constraint::Percentage(50)].as_ref())\n                .split(rect);\n            let top_quarters = ratatui::layout::Layout::default()\n                .direction(Direction::Horizontal)\n                .margin(0)\n                .constraints([Constraint::Percentage(50), Constraint::Percentage(50)].as_ref())\n                .split(halves[0]);\n\n            vec![top_quarters[0], top_quarters[1], halves[1]]\n        }\n    }\n\n    fn build_layout(&self, rect: Rect) -> Vec<Rect> {\n        if self.children.len() == 1 {\n            // if there's only one element to render, it can take the whole frame\n            vec![rect]\n        } else if self.children.len() == 2 {\n            self.build_two_children_layout(rect)\n        } else {\n            self.build_three_children_layout(rect)\n        }\n    }\n\n    pub fn render(&self, frame: &mut Frame, rect: Rect, table_cycle_offset: usize) {\n        let (top, app, bottom) = top_app_and_bottom_split(rect);\n        let layout_slots = self.build_layout(app);\n        for i in 0..layout_slots.len() {\n            if let Some(rect) = layout_slots.get(i) {\n                if let Some(child) = self\n                    .children\n                    .get((i + table_cycle_offset) % self.children.len())\n                {\n                    child.render(frame, *rect);\n                }\n            }\n        }\n        self.header.render(frame, top);\n        self.footer.render(frame, bottom);\n    }\n}\n"
  },
  {
    "path": "src/display/components/mod.rs",
    "content": "mod display_bandwidth;\nmod header_details;\nmod help_text;\nmod layout;\nmod table;\n\npub use display_bandwidth::*;\npub use header_details::*;\npub use help_text::*;\npub use layout::*;\npub use table::*;\n"
  },
  {
    "path": "src/display/components/snapshots/bandwhich__display__components__display_bandwidth__tests__bandwidth_formatting.snap",
    "content": "---\nsource: src/display/components/display_bandwidth.rs\nexpression: test_bandwidths_formatted\n---\nDisplayBandwidth { bandwidth: 1.5625000000e-2, unit_family: BinBytes }: 0.02B\nDisplayBandwidth { bandwidth: 3.1250000000e-2, unit_family: BinBytes }: 0.03B\nDisplayBandwidth { bandwidth: 6.2500000000e-2, unit_family: BinBytes }: 0.06B\nDisplayBandwidth { bandwidth: 1.2500000000e-1, unit_family: BinBytes }: 0.12B\nDisplayBandwidth { bandwidth: 2.5000000000e-1, unit_family: BinBytes }: 0.25B\nDisplayBandwidth { bandwidth: 5.0000000000e-1, unit_family: BinBytes }: 0.50B\nDisplayBandwidth { bandwidth: 1.0000000000e0, unit_family: BinBytes }: 1.00B\nDisplayBandwidth { bandwidth: 2.0000000000e0, unit_family: BinBytes }: 2.00B\nDisplayBandwidth { bandwidth: 4.0000000000e0, unit_family: BinBytes }: 4.00B\nDisplayBandwidth { bandwidth: 8.0000000000e0, unit_family: BinBytes }: 8.00B\nDisplayBandwidth { bandwidth: 1.6000000000e1, unit_family: BinBytes }: 16.00B\nDisplayBandwidth { bandwidth: 3.2000000000e1, unit_family: BinBytes }: 32.00B\nDisplayBandwidth { bandwidth: 6.4000000000e1, unit_family: BinBytes }: 64.00B\nDisplayBandwidth { bandwidth: 1.2800000000e2, unit_family: BinBytes }: 128.00B\nDisplayBandwidth { bandwidth: 2.5600000000e2, unit_family: BinBytes }: 256.00B\nDisplayBandwidth { bandwidth: 5.1200000000e2, unit_family: BinBytes }: 512.00B\nDisplayBandwidth { bandwidth: 1.0240000000e3, unit_family: BinBytes }: 1.00KiB\nDisplayBandwidth { bandwidth: 2.0480000000e3, unit_family: BinBytes }: 2.00KiB\nDisplayBandwidth { bandwidth: 4.0960000000e3, unit_family: BinBytes }: 4.00KiB\nDisplayBandwidth { bandwidth: 8.1920000000e3, unit_family: BinBytes }: 8.00KiB\nDisplayBandwidth { bandwidth: 1.6384000000e4, unit_family: BinBytes }: 16.00KiB\nDisplayBandwidth { bandwidth: 3.2768000000e4, unit_family: BinBytes }: 32.00KiB\nDisplayBandwidth { bandwidth: 6.5536000000e4, unit_family: BinBytes }: 64.00KiB\nDisplayBandwidth { bandwidth: 1.3107200000e5, unit_family: BinBytes }: 128.00KiB\nDisplayBandwidth { bandwidth: 2.6214400000e5, unit_family: BinBytes }: 256.00KiB\nDisplayBandwidth { bandwidth: 5.2428800000e5, unit_family: BinBytes }: 512.00KiB\nDisplayBandwidth { bandwidth: 1.0485760000e6, unit_family: BinBytes }: 1.00MiB\nDisplayBandwidth { bandwidth: 2.0971520000e6, unit_family: BinBytes }: 2.00MiB\nDisplayBandwidth { bandwidth: 4.1943040000e6, unit_family: BinBytes }: 4.00MiB\nDisplayBandwidth { bandwidth: 8.3886080000e6, unit_family: BinBytes }: 8.00MiB\nDisplayBandwidth { bandwidth: 1.6777216000e7, unit_family: BinBytes }: 16.00MiB\nDisplayBandwidth { bandwidth: 3.3554432000e7, unit_family: BinBytes }: 32.00MiB\nDisplayBandwidth { bandwidth: 6.7108864000e7, unit_family: BinBytes }: 64.00MiB\nDisplayBandwidth { bandwidth: 1.3421772800e8, unit_family: BinBytes }: 128.00MiB\nDisplayBandwidth { bandwidth: 2.6843545600e8, unit_family: BinBytes }: 256.00MiB\nDisplayBandwidth { bandwidth: 5.3687091200e8, unit_family: BinBytes }: 512.00MiB\nDisplayBandwidth { bandwidth: 1.0737418240e9, unit_family: BinBytes }: 1.00GiB\nDisplayBandwidth { bandwidth: 2.1474836480e9, unit_family: BinBytes }: 2.00GiB\nDisplayBandwidth { bandwidth: 4.2949672960e9, unit_family: BinBytes }: 4.00GiB\nDisplayBandwidth { bandwidth: 8.5899345920e9, unit_family: BinBytes }: 8.00GiB\nDisplayBandwidth { bandwidth: 1.7179869184e10, unit_family: BinBytes }: 16.00GiB\nDisplayBandwidth { bandwidth: 3.4359738368e10, unit_family: BinBytes }: 32.00GiB\nDisplayBandwidth { bandwidth: 6.8719476736e10, unit_family: BinBytes }: 64.00GiB\nDisplayBandwidth { bandwidth: 1.3743895347e11, unit_family: BinBytes }: 128.00GiB\nDisplayBandwidth { bandwidth: 2.7487790694e11, unit_family: BinBytes }: 256.00GiB\nDisplayBandwidth { bandwidth: 5.4975581389e11, unit_family: BinBytes }: 512.00GiB\nDisplayBandwidth { bandwidth: 1.0995116278e12, unit_family: BinBytes }: 1.00TiB\nDisplayBandwidth { bandwidth: 2.1990232556e12, unit_family: BinBytes }: 2.00TiB\nDisplayBandwidth { bandwidth: 4.3980465111e12, unit_family: BinBytes }: 4.00TiB\nDisplayBandwidth { bandwidth: 8.7960930222e12, unit_family: BinBytes }: 8.00TiB\nDisplayBandwidth { bandwidth: 1.7592186044e13, unit_family: BinBytes }: 16.00TiB\nDisplayBandwidth { bandwidth: 3.5184372089e13, unit_family: BinBytes }: 32.00TiB\nDisplayBandwidth { bandwidth: 7.0368744178e13, unit_family: BinBytes }: 64.00TiB\nDisplayBandwidth { bandwidth: 1.4073748836e14, unit_family: BinBytes }: 128.00TiB\nDisplayBandwidth { bandwidth: 2.8147497671e14, unit_family: BinBytes }: 256.00TiB\nDisplayBandwidth { bandwidth: 5.6294995342e14, unit_family: BinBytes }: 512.00TiB\nDisplayBandwidth { bandwidth: 1.1258999068e15, unit_family: BinBytes }: 1.00PiB\nDisplayBandwidth { bandwidth: 2.2517998137e15, unit_family: BinBytes }: 2.00PiB\nDisplayBandwidth { bandwidth: 4.5035996274e15, unit_family: BinBytes }: 4.00PiB\nDisplayBandwidth { bandwidth: 9.0071992547e15, unit_family: BinBytes }: 8.00PiB\nDisplayBandwidth { bandwidth: 1.8014398509e16, unit_family: BinBytes }: 16.00PiB\nDisplayBandwidth { bandwidth: 3.6028797019e16, unit_family: BinBytes }: 32.00PiB\nDisplayBandwidth { bandwidth: 7.2057594038e16, unit_family: BinBytes }: 64.00PiB\nDisplayBandwidth { bandwidth: 1.4411518808e17, unit_family: BinBytes }: 128.00PiB\nDisplayBandwidth { bandwidth: 2.8823037615e17, unit_family: BinBytes }: 256.00PiB\nDisplayBandwidth { bandwidth: 5.7646075230e17, unit_family: BinBytes }: 512.00PiB\nDisplayBandwidth { bandwidth: 1.0240000000e-2, unit_family: BinBytes }: 0.01B\nDisplayBandwidth { bandwidth: 2.5600000000e-2, unit_family: BinBytes }: 0.03B\nDisplayBandwidth { bandwidth: 6.4000000000e-2, unit_family: BinBytes }: 0.06B\nDisplayBandwidth { bandwidth: 1.6000000000e-1, unit_family: BinBytes }: 0.16B\nDisplayBandwidth { bandwidth: 4.0000000000e-1, unit_family: BinBytes }: 0.40B\nDisplayBandwidth { bandwidth: 1.0000000000e0, unit_family: BinBytes }: 1.00B\nDisplayBandwidth { bandwidth: 2.5000000000e0, unit_family: BinBytes }: 2.50B\nDisplayBandwidth { bandwidth: 6.2500000000e0, unit_family: BinBytes }: 6.25B\nDisplayBandwidth { bandwidth: 1.5625000000e1, unit_family: BinBytes }: 15.62B\nDisplayBandwidth { bandwidth: 3.9062500000e1, unit_family: BinBytes }: 39.06B\nDisplayBandwidth { bandwidth: 9.7656250000e1, unit_family: BinBytes }: 97.66B\nDisplayBandwidth { bandwidth: 2.4414062500e2, unit_family: BinBytes }: 244.14B\nDisplayBandwidth { bandwidth: 6.1035156250e2, unit_family: BinBytes }: 610.35B\nDisplayBandwidth { bandwidth: 1.5258789062e3, unit_family: BinBytes }: 1.49KiB\nDisplayBandwidth { bandwidth: 3.8146972656e3, unit_family: BinBytes }: 3.73KiB\nDisplayBandwidth { bandwidth: 9.5367431641e3, unit_family: BinBytes }: 9.31KiB\nDisplayBandwidth { bandwidth: 2.3841857910e4, unit_family: BinBytes }: 23.28KiB\nDisplayBandwidth { bandwidth: 5.9604644775e4, unit_family: BinBytes }: 58.21KiB\nDisplayBandwidth { bandwidth: 1.4901161194e5, unit_family: BinBytes }: 145.52KiB\nDisplayBandwidth { bandwidth: 3.7252902985e5, unit_family: BinBytes }: 363.80KiB\nDisplayBandwidth { bandwidth: 9.3132257462e5, unit_family: BinBytes }: 909.49KiB\nDisplayBandwidth { bandwidth: 2.3283064365e6, unit_family: BinBytes }: 2.22MiB\nDisplayBandwidth { bandwidth: 5.8207660913e6, unit_family: BinBytes }: 5.55MiB\nDisplayBandwidth { bandwidth: 1.4551915228e7, unit_family: BinBytes }: 13.88MiB\nDisplayBandwidth { bandwidth: 3.6379788071e7, unit_family: BinBytes }: 34.69MiB\nDisplayBandwidth { bandwidth: 9.0949470177e7, unit_family: BinBytes }: 86.74MiB\nDisplayBandwidth { bandwidth: 2.2737367544e8, unit_family: BinBytes }: 216.84MiB\nDisplayBandwidth { bandwidth: 5.6843418861e8, unit_family: BinBytes }: 542.10MiB\nDisplayBandwidth { bandwidth: 1.4210854715e9, unit_family: BinBytes }: 1.32GiB\nDisplayBandwidth { bandwidth: 3.5527136788e9, unit_family: BinBytes }: 3.31GiB\nDisplayBandwidth { bandwidth: 8.8817841970e9, unit_family: BinBytes }: 8.27GiB\nDisplayBandwidth { bandwidth: 2.2204460493e10, unit_family: BinBytes }: 20.68GiB\nDisplayBandwidth { bandwidth: 5.5511151231e10, unit_family: BinBytes }: 51.70GiB\nDisplayBandwidth { bandwidth: 1.3877787808e11, unit_family: BinBytes }: 129.25GiB\nDisplayBandwidth { bandwidth: 3.4694469520e11, unit_family: BinBytes }: 323.12GiB\nDisplayBandwidth { bandwidth: 8.6736173799e11, unit_family: BinBytes }: 807.79GiB\nDisplayBandwidth { bandwidth: 2.1684043450e12, unit_family: BinBytes }: 1.97TiB\nDisplayBandwidth { bandwidth: 5.4210108624e12, unit_family: BinBytes }: 4.93TiB\nDisplayBandwidth { bandwidth: 1.3552527156e13, unit_family: BinBytes }: 12.33TiB\nDisplayBandwidth { bandwidth: 3.3881317890e13, unit_family: BinBytes }: 30.81TiB\nDisplayBandwidth { bandwidth: 8.4703294725e13, unit_family: BinBytes }: 77.04TiB\nDisplayBandwidth { bandwidth: 2.1175823681e14, unit_family: BinBytes }: 192.59TiB\nDisplayBandwidth { bandwidth: 5.2939559203e14, unit_family: BinBytes }: 481.48TiB\nDisplayBandwidth { bandwidth: 1.3234889801e15, unit_family: BinBytes }: 1.18PiB\nDisplayBandwidth { bandwidth: 3.3087224502e15, unit_family: BinBytes }: 2.94PiB\nDisplayBandwidth { bandwidth: 8.2718061255e15, unit_family: BinBytes }: 7.35PiB\nDisplayBandwidth { bandwidth: 2.0679515314e16, unit_family: BinBytes }: 18.37PiB\nDisplayBandwidth { bandwidth: 5.1698788285e16, unit_family: BinBytes }: 45.92PiB\nDisplayBandwidth { bandwidth: 1.2924697071e17, unit_family: BinBytes }: 114.79PiB\nDisplayBandwidth { bandwidth: 3.2311742678e17, unit_family: BinBytes }: 286.99PiB\nDisplayBandwidth { bandwidth: 1.2345679012e-2, unit_family: BinBytes }: 0.01B\nDisplayBandwidth { bandwidth: 3.7037037037e-2, unit_family: BinBytes }: 0.04B\nDisplayBandwidth { bandwidth: 1.1111111111e-1, unit_family: BinBytes }: 0.11B\nDisplayBandwidth { bandwidth: 3.3333333333e-1, unit_family: BinBytes }: 0.33B\nDisplayBandwidth { bandwidth: 1.0000000000e0, unit_family: BinBytes }: 1.00B\nDisplayBandwidth { bandwidth: 3.0000000000e0, unit_family: BinBytes }: 3.00B\nDisplayBandwidth { bandwidth: 9.0000000000e0, unit_family: BinBytes }: 9.00B\nDisplayBandwidth { bandwidth: 2.7000000000e1, unit_family: BinBytes }: 27.00B\nDisplayBandwidth { bandwidth: 8.1000000000e1, unit_family: BinBytes }: 81.00B\nDisplayBandwidth { bandwidth: 2.4300000000e2, unit_family: BinBytes }: 243.00B\nDisplayBandwidth { bandwidth: 7.2900000000e2, unit_family: BinBytes }: 729.00B\nDisplayBandwidth { bandwidth: 2.1870000000e3, unit_family: BinBytes }: 2.14KiB\nDisplayBandwidth { bandwidth: 6.5610000000e3, unit_family: BinBytes }: 6.41KiB\nDisplayBandwidth { bandwidth: 1.9683000000e4, unit_family: BinBytes }: 19.22KiB\nDisplayBandwidth { bandwidth: 5.9049000000e4, unit_family: BinBytes }: 57.67KiB\nDisplayBandwidth { bandwidth: 1.7714700000e5, unit_family: BinBytes }: 173.00KiB\nDisplayBandwidth { bandwidth: 5.3144100000e5, unit_family: BinBytes }: 518.99KiB\nDisplayBandwidth { bandwidth: 1.5943230000e6, unit_family: BinBytes }: 1.52MiB\nDisplayBandwidth { bandwidth: 4.7829690000e6, unit_family: BinBytes }: 4.56MiB\nDisplayBandwidth { bandwidth: 1.4348907000e7, unit_family: BinBytes }: 13.68MiB\nDisplayBandwidth { bandwidth: 4.3046721000e7, unit_family: BinBytes }: 41.05MiB\nDisplayBandwidth { bandwidth: 1.2914016300e8, unit_family: BinBytes }: 123.16MiB\nDisplayBandwidth { bandwidth: 3.8742048900e8, unit_family: BinBytes }: 369.47MiB\nDisplayBandwidth { bandwidth: 1.1622614670e9, unit_family: BinBytes }: 1.08GiB\nDisplayBandwidth { bandwidth: 3.4867844010e9, unit_family: BinBytes }: 3.25GiB\nDisplayBandwidth { bandwidth: 1.0460353203e10, unit_family: BinBytes }: 9.74GiB\nDisplayBandwidth { bandwidth: 3.1381059609e10, unit_family: BinBytes }: 29.23GiB\nDisplayBandwidth { bandwidth: 9.4143178827e10, unit_family: BinBytes }: 87.68GiB\nDisplayBandwidth { bandwidth: 2.8242953648e11, unit_family: BinBytes }: 263.03GiB\nDisplayBandwidth { bandwidth: 8.4728860944e11, unit_family: BinBytes }: 789.10GiB\nDisplayBandwidth { bandwidth: 2.5418658283e12, unit_family: BinBytes }: 2.31TiB\nDisplayBandwidth { bandwidth: 7.6255974850e12, unit_family: BinBytes }: 6.94TiB\nDisplayBandwidth { bandwidth: 2.2876792455e13, unit_family: BinBytes }: 20.81TiB\nDisplayBandwidth { bandwidth: 6.8630377365e13, unit_family: BinBytes }: 62.42TiB\nDisplayBandwidth { bandwidth: 2.0589113209e14, unit_family: BinBytes }: 187.26TiB\nDisplayBandwidth { bandwidth: 6.1767339628e14, unit_family: BinBytes }: 561.77TiB\nDisplayBandwidth { bandwidth: 1.8530201889e15, unit_family: BinBytes }: 1.65PiB\nDisplayBandwidth { bandwidth: 5.5590605666e15, unit_family: BinBytes }: 4.94PiB\nDisplayBandwidth { bandwidth: 1.6677181700e16, unit_family: BinBytes }: 14.81PiB\nDisplayBandwidth { bandwidth: 5.0031545099e16, unit_family: BinBytes }: 44.44PiB\nDisplayBandwidth { bandwidth: 1.5009463530e17, unit_family: BinBytes }: 133.31PiB\nDisplayBandwidth { bandwidth: 4.5028390589e17, unit_family: BinBytes }: 399.93PiB\nDisplayBandwidth { bandwidth: 8.0000000000e-3, unit_family: BinBytes }: 0.01B\nDisplayBandwidth { bandwidth: 4.0000000000e-2, unit_family: BinBytes }: 0.04B\nDisplayBandwidth { bandwidth: 2.0000000000e-1, unit_family: BinBytes }: 0.20B\nDisplayBandwidth { bandwidth: 1.0000000000e0, unit_family: BinBytes }: 1.00B\nDisplayBandwidth { bandwidth: 5.0000000000e0, unit_family: BinBytes }: 5.00B\nDisplayBandwidth { bandwidth: 2.5000000000e1, unit_family: BinBytes }: 25.00B\nDisplayBandwidth { bandwidth: 1.2500000000e2, unit_family: BinBytes }: 125.00B\nDisplayBandwidth { bandwidth: 6.2500000000e2, unit_family: BinBytes }: 625.00B\nDisplayBandwidth { bandwidth: 3.1250000000e3, unit_family: BinBytes }: 3.05KiB\nDisplayBandwidth { bandwidth: 1.5625000000e4, unit_family: BinBytes }: 15.26KiB\nDisplayBandwidth { bandwidth: 7.8125000000e4, unit_family: BinBytes }: 76.29KiB\nDisplayBandwidth { bandwidth: 3.9062500000e5, unit_family: BinBytes }: 381.47KiB\nDisplayBandwidth { bandwidth: 1.9531250000e6, unit_family: BinBytes }: 1.86MiB\nDisplayBandwidth { bandwidth: 9.7656250000e6, unit_family: BinBytes }: 9.31MiB\nDisplayBandwidth { bandwidth: 4.8828125000e7, unit_family: BinBytes }: 46.57MiB\nDisplayBandwidth { bandwidth: 2.4414062500e8, unit_family: BinBytes }: 232.83MiB\nDisplayBandwidth { bandwidth: 1.2207031250e9, unit_family: BinBytes }: 1.14GiB\nDisplayBandwidth { bandwidth: 6.1035156250e9, unit_family: BinBytes }: 5.68GiB\nDisplayBandwidth { bandwidth: 3.0517578125e10, unit_family: BinBytes }: 28.42GiB\nDisplayBandwidth { bandwidth: 1.5258789062e11, unit_family: BinBytes }: 142.11GiB\nDisplayBandwidth { bandwidth: 7.6293945312e11, unit_family: BinBytes }: 710.54GiB\nDisplayBandwidth { bandwidth: 3.8146972656e12, unit_family: BinBytes }: 3.47TiB\nDisplayBandwidth { bandwidth: 1.9073486328e13, unit_family: BinBytes }: 17.35TiB\nDisplayBandwidth { bandwidth: 9.5367431641e13, unit_family: BinBytes }: 86.74TiB\nDisplayBandwidth { bandwidth: 4.7683715820e14, unit_family: BinBytes }: 433.68TiB\nDisplayBandwidth { bandwidth: 2.3841857910e15, unit_family: BinBytes }: 2.12PiB\nDisplayBandwidth { bandwidth: 1.1920928955e16, unit_family: BinBytes }: 10.59PiB\nDisplayBandwidth { bandwidth: 5.9604644775e16, unit_family: BinBytes }: 52.94PiB\nDisplayBandwidth { bandwidth: 2.9802322388e17, unit_family: BinBytes }: 264.70PiB\nDisplayBandwidth { bandwidth: 1.5625000000e-2, unit_family: BinBits }: 0.12b\nDisplayBandwidth { bandwidth: 3.1250000000e-2, unit_family: BinBits }: 0.25b\nDisplayBandwidth { bandwidth: 6.2500000000e-2, unit_family: BinBits }: 0.50b\nDisplayBandwidth { bandwidth: 1.2500000000e-1, unit_family: BinBits }: 1.00b\nDisplayBandwidth { bandwidth: 2.5000000000e-1, unit_family: BinBits }: 2.00b\nDisplayBandwidth { bandwidth: 5.0000000000e-1, unit_family: BinBits }: 4.00b\nDisplayBandwidth { bandwidth: 1.0000000000e0, unit_family: BinBits }: 8.00b\nDisplayBandwidth { bandwidth: 2.0000000000e0, unit_family: BinBits }: 16.00b\nDisplayBandwidth { bandwidth: 4.0000000000e0, unit_family: BinBits }: 32.00b\nDisplayBandwidth { bandwidth: 8.0000000000e0, unit_family: BinBits }: 64.00b\nDisplayBandwidth { bandwidth: 1.6000000000e1, unit_family: BinBits }: 128.00b\nDisplayBandwidth { bandwidth: 3.2000000000e1, unit_family: BinBits }: 256.00b\nDisplayBandwidth { bandwidth: 6.4000000000e1, unit_family: BinBits }: 512.00b\nDisplayBandwidth { bandwidth: 1.2800000000e2, unit_family: BinBits }: 1.00Kib\nDisplayBandwidth { bandwidth: 2.5600000000e2, unit_family: BinBits }: 2.00Kib\nDisplayBandwidth { bandwidth: 5.1200000000e2, unit_family: BinBits }: 4.00Kib\nDisplayBandwidth { bandwidth: 1.0240000000e3, unit_family: BinBits }: 8.00Kib\nDisplayBandwidth { bandwidth: 2.0480000000e3, unit_family: BinBits }: 16.00Kib\nDisplayBandwidth { bandwidth: 4.0960000000e3, unit_family: BinBits }: 32.00Kib\nDisplayBandwidth { bandwidth: 8.1920000000e3, unit_family: BinBits }: 64.00Kib\nDisplayBandwidth { bandwidth: 1.6384000000e4, unit_family: BinBits }: 128.00Kib\nDisplayBandwidth { bandwidth: 3.2768000000e4, unit_family: BinBits }: 256.00Kib\nDisplayBandwidth { bandwidth: 6.5536000000e4, unit_family: BinBits }: 512.00Kib\nDisplayBandwidth { bandwidth: 1.3107200000e5, unit_family: BinBits }: 1.00Mib\nDisplayBandwidth { bandwidth: 2.6214400000e5, unit_family: BinBits }: 2.00Mib\nDisplayBandwidth { bandwidth: 5.2428800000e5, unit_family: BinBits }: 4.00Mib\nDisplayBandwidth { bandwidth: 1.0485760000e6, unit_family: BinBits }: 8.00Mib\nDisplayBandwidth { bandwidth: 2.0971520000e6, unit_family: BinBits }: 16.00Mib\nDisplayBandwidth { bandwidth: 4.1943040000e6, unit_family: BinBits }: 32.00Mib\nDisplayBandwidth { bandwidth: 8.3886080000e6, unit_family: BinBits }: 64.00Mib\nDisplayBandwidth { bandwidth: 1.6777216000e7, unit_family: BinBits }: 128.00Mib\nDisplayBandwidth { bandwidth: 3.3554432000e7, unit_family: BinBits }: 256.00Mib\nDisplayBandwidth { bandwidth: 6.7108864000e7, unit_family: BinBits }: 512.00Mib\nDisplayBandwidth { bandwidth: 1.3421772800e8, unit_family: BinBits }: 1.00Gib\nDisplayBandwidth { bandwidth: 2.6843545600e8, unit_family: BinBits }: 2.00Gib\nDisplayBandwidth { bandwidth: 5.3687091200e8, unit_family: BinBits }: 4.00Gib\nDisplayBandwidth { bandwidth: 1.0737418240e9, unit_family: BinBits }: 8.00Gib\nDisplayBandwidth { bandwidth: 2.1474836480e9, unit_family: BinBits }: 16.00Gib\nDisplayBandwidth { bandwidth: 4.2949672960e9, unit_family: BinBits }: 32.00Gib\nDisplayBandwidth { bandwidth: 8.5899345920e9, unit_family: BinBits }: 64.00Gib\nDisplayBandwidth { bandwidth: 1.7179869184e10, unit_family: BinBits }: 128.00Gib\nDisplayBandwidth { bandwidth: 3.4359738368e10, unit_family: BinBits }: 256.00Gib\nDisplayBandwidth { bandwidth: 6.8719476736e10, unit_family: BinBits }: 512.00Gib\nDisplayBandwidth { bandwidth: 1.3743895347e11, unit_family: BinBits }: 1.00Tib\nDisplayBandwidth { bandwidth: 2.7487790694e11, unit_family: BinBits }: 2.00Tib\nDisplayBandwidth { bandwidth: 5.4975581389e11, unit_family: BinBits }: 4.00Tib\nDisplayBandwidth { bandwidth: 1.0995116278e12, unit_family: BinBits }: 8.00Tib\nDisplayBandwidth { bandwidth: 2.1990232556e12, unit_family: BinBits }: 16.00Tib\nDisplayBandwidth { bandwidth: 4.3980465111e12, unit_family: BinBits }: 32.00Tib\nDisplayBandwidth { bandwidth: 8.7960930222e12, unit_family: BinBits }: 64.00Tib\nDisplayBandwidth { bandwidth: 1.7592186044e13, unit_family: BinBits }: 128.00Tib\nDisplayBandwidth { bandwidth: 3.5184372089e13, unit_family: BinBits }: 256.00Tib\nDisplayBandwidth { bandwidth: 7.0368744178e13, unit_family: BinBits }: 512.00Tib\nDisplayBandwidth { bandwidth: 1.4073748836e14, unit_family: BinBits }: 1.00Pib\nDisplayBandwidth { bandwidth: 2.8147497671e14, unit_family: BinBits }: 2.00Pib\nDisplayBandwidth { bandwidth: 5.6294995342e14, unit_family: BinBits }: 4.00Pib\nDisplayBandwidth { bandwidth: 1.1258999068e15, unit_family: BinBits }: 8.00Pib\nDisplayBandwidth { bandwidth: 2.2517998137e15, unit_family: BinBits }: 16.00Pib\nDisplayBandwidth { bandwidth: 4.5035996274e15, unit_family: BinBits }: 32.00Pib\nDisplayBandwidth { bandwidth: 9.0071992547e15, unit_family: BinBits }: 64.00Pib\nDisplayBandwidth { bandwidth: 1.8014398509e16, unit_family: BinBits }: 128.00Pib\nDisplayBandwidth { bandwidth: 3.6028797019e16, unit_family: BinBits }: 256.00Pib\nDisplayBandwidth { bandwidth: 7.2057594038e16, unit_family: BinBits }: 512.00Pib\nDisplayBandwidth { bandwidth: 1.4411518808e17, unit_family: BinBits }: 1024.00Pib\nDisplayBandwidth { bandwidth: 2.8823037615e17, unit_family: BinBits }: 2048.00Pib\nDisplayBandwidth { bandwidth: 5.7646075230e17, unit_family: BinBits }: 4096.00Pib\nDisplayBandwidth { bandwidth: 1.0240000000e-2, unit_family: BinBits }: 0.08b\nDisplayBandwidth { bandwidth: 2.5600000000e-2, unit_family: BinBits }: 0.20b\nDisplayBandwidth { bandwidth: 6.4000000000e-2, unit_family: BinBits }: 0.51b\nDisplayBandwidth { bandwidth: 1.6000000000e-1, unit_family: BinBits }: 1.28b\nDisplayBandwidth { bandwidth: 4.0000000000e-1, unit_family: BinBits }: 3.20b\nDisplayBandwidth { bandwidth: 1.0000000000e0, unit_family: BinBits }: 8.00b\nDisplayBandwidth { bandwidth: 2.5000000000e0, unit_family: BinBits }: 20.00b\nDisplayBandwidth { bandwidth: 6.2500000000e0, unit_family: BinBits }: 50.00b\nDisplayBandwidth { bandwidth: 1.5625000000e1, unit_family: BinBits }: 125.00b\nDisplayBandwidth { bandwidth: 3.9062500000e1, unit_family: BinBits }: 312.50b\nDisplayBandwidth { bandwidth: 9.7656250000e1, unit_family: BinBits }: 781.25b\nDisplayBandwidth { bandwidth: 2.4414062500e2, unit_family: BinBits }: 1.91Kib\nDisplayBandwidth { bandwidth: 6.1035156250e2, unit_family: BinBits }: 4.77Kib\nDisplayBandwidth { bandwidth: 1.5258789062e3, unit_family: BinBits }: 11.92Kib\nDisplayBandwidth { bandwidth: 3.8146972656e3, unit_family: BinBits }: 29.80Kib\nDisplayBandwidth { bandwidth: 9.5367431641e3, unit_family: BinBits }: 74.51Kib\nDisplayBandwidth { bandwidth: 2.3841857910e4, unit_family: BinBits }: 186.26Kib\nDisplayBandwidth { bandwidth: 5.9604644775e4, unit_family: BinBits }: 465.66Kib\nDisplayBandwidth { bandwidth: 1.4901161194e5, unit_family: BinBits }: 1.14Mib\nDisplayBandwidth { bandwidth: 3.7252902985e5, unit_family: BinBits }: 2.84Mib\nDisplayBandwidth { bandwidth: 9.3132257462e5, unit_family: BinBits }: 7.11Mib\nDisplayBandwidth { bandwidth: 2.3283064365e6, unit_family: BinBits }: 17.76Mib\nDisplayBandwidth { bandwidth: 5.8207660913e6, unit_family: BinBits }: 44.41Mib\nDisplayBandwidth { bandwidth: 1.4551915228e7, unit_family: BinBits }: 111.02Mib\nDisplayBandwidth { bandwidth: 3.6379788071e7, unit_family: BinBits }: 277.56Mib\nDisplayBandwidth { bandwidth: 9.0949470177e7, unit_family: BinBits }: 693.89Mib\nDisplayBandwidth { bandwidth: 2.2737367544e8, unit_family: BinBits }: 1.69Gib\nDisplayBandwidth { bandwidth: 5.6843418861e8, unit_family: BinBits }: 4.24Gib\nDisplayBandwidth { bandwidth: 1.4210854715e9, unit_family: BinBits }: 10.59Gib\nDisplayBandwidth { bandwidth: 3.5527136788e9, unit_family: BinBits }: 26.47Gib\nDisplayBandwidth { bandwidth: 8.8817841970e9, unit_family: BinBits }: 66.17Gib\nDisplayBandwidth { bandwidth: 2.2204460493e10, unit_family: BinBits }: 165.44Gib\nDisplayBandwidth { bandwidth: 5.5511151231e10, unit_family: BinBits }: 413.59Gib\nDisplayBandwidth { bandwidth: 1.3877787808e11, unit_family: BinBits }: 1.01Tib\nDisplayBandwidth { bandwidth: 3.4694469520e11, unit_family: BinBits }: 2.52Tib\nDisplayBandwidth { bandwidth: 8.6736173799e11, unit_family: BinBits }: 6.31Tib\nDisplayBandwidth { bandwidth: 2.1684043450e12, unit_family: BinBits }: 15.78Tib\nDisplayBandwidth { bandwidth: 5.4210108624e12, unit_family: BinBits }: 39.44Tib\nDisplayBandwidth { bandwidth: 1.3552527156e13, unit_family: BinBits }: 98.61Tib\nDisplayBandwidth { bandwidth: 3.3881317890e13, unit_family: BinBits }: 246.52Tib\nDisplayBandwidth { bandwidth: 8.4703294725e13, unit_family: BinBits }: 616.30Tib\nDisplayBandwidth { bandwidth: 2.1175823681e14, unit_family: BinBits }: 1.50Pib\nDisplayBandwidth { bandwidth: 5.2939559203e14, unit_family: BinBits }: 3.76Pib\nDisplayBandwidth { bandwidth: 1.3234889801e15, unit_family: BinBits }: 9.40Pib\nDisplayBandwidth { bandwidth: 3.3087224502e15, unit_family: BinBits }: 23.51Pib\nDisplayBandwidth { bandwidth: 8.2718061255e15, unit_family: BinBits }: 58.77Pib\nDisplayBandwidth { bandwidth: 2.0679515314e16, unit_family: BinBits }: 146.94Pib\nDisplayBandwidth { bandwidth: 5.1698788285e16, unit_family: BinBits }: 367.34Pib\nDisplayBandwidth { bandwidth: 1.2924697071e17, unit_family: BinBits }: 918.35Pib\nDisplayBandwidth { bandwidth: 3.2311742678e17, unit_family: BinBits }: 2295.89Pib\nDisplayBandwidth { bandwidth: 1.2345679012e-2, unit_family: BinBits }: 0.10b\nDisplayBandwidth { bandwidth: 3.7037037037e-2, unit_family: BinBits }: 0.30b\nDisplayBandwidth { bandwidth: 1.1111111111e-1, unit_family: BinBits }: 0.89b\nDisplayBandwidth { bandwidth: 3.3333333333e-1, unit_family: BinBits }: 2.67b\nDisplayBandwidth { bandwidth: 1.0000000000e0, unit_family: BinBits }: 8.00b\nDisplayBandwidth { bandwidth: 3.0000000000e0, unit_family: BinBits }: 24.00b\nDisplayBandwidth { bandwidth: 9.0000000000e0, unit_family: BinBits }: 72.00b\nDisplayBandwidth { bandwidth: 2.7000000000e1, unit_family: BinBits }: 216.00b\nDisplayBandwidth { bandwidth: 8.1000000000e1, unit_family: BinBits }: 648.00b\nDisplayBandwidth { bandwidth: 2.4300000000e2, unit_family: BinBits }: 1.90Kib\nDisplayBandwidth { bandwidth: 7.2900000000e2, unit_family: BinBits }: 5.70Kib\nDisplayBandwidth { bandwidth: 2.1870000000e3, unit_family: BinBits }: 17.09Kib\nDisplayBandwidth { bandwidth: 6.5610000000e3, unit_family: BinBits }: 51.26Kib\nDisplayBandwidth { bandwidth: 1.9683000000e4, unit_family: BinBits }: 153.77Kib\nDisplayBandwidth { bandwidth: 5.9049000000e4, unit_family: BinBits }: 461.32Kib\nDisplayBandwidth { bandwidth: 1.7714700000e5, unit_family: BinBits }: 1.35Mib\nDisplayBandwidth { bandwidth: 5.3144100000e5, unit_family: BinBits }: 4.05Mib\nDisplayBandwidth { bandwidth: 1.5943230000e6, unit_family: BinBits }: 12.16Mib\nDisplayBandwidth { bandwidth: 4.7829690000e6, unit_family: BinBits }: 36.49Mib\nDisplayBandwidth { bandwidth: 1.4348907000e7, unit_family: BinBits }: 109.47Mib\nDisplayBandwidth { bandwidth: 4.3046721000e7, unit_family: BinBits }: 328.42Mib\nDisplayBandwidth { bandwidth: 1.2914016300e8, unit_family: BinBits }: 0.96Gib\nDisplayBandwidth { bandwidth: 3.8742048900e8, unit_family: BinBits }: 2.89Gib\nDisplayBandwidth { bandwidth: 1.1622614670e9, unit_family: BinBits }: 8.66Gib\nDisplayBandwidth { bandwidth: 3.4867844010e9, unit_family: BinBits }: 25.98Gib\nDisplayBandwidth { bandwidth: 1.0460353203e10, unit_family: BinBits }: 77.94Gib\nDisplayBandwidth { bandwidth: 3.1381059609e10, unit_family: BinBits }: 233.81Gib\nDisplayBandwidth { bandwidth: 9.4143178827e10, unit_family: BinBits }: 701.42Gib\nDisplayBandwidth { bandwidth: 2.8242953648e11, unit_family: BinBits }: 2.05Tib\nDisplayBandwidth { bandwidth: 8.4728860944e11, unit_family: BinBits }: 6.16Tib\nDisplayBandwidth { bandwidth: 2.5418658283e12, unit_family: BinBits }: 18.49Tib\nDisplayBandwidth { bandwidth: 7.6255974850e12, unit_family: BinBits }: 55.48Tib\nDisplayBandwidth { bandwidth: 2.2876792455e13, unit_family: BinBits }: 166.45Tib\nDisplayBandwidth { bandwidth: 6.8630377365e13, unit_family: BinBits }: 499.35Tib\nDisplayBandwidth { bandwidth: 2.0589113209e14, unit_family: BinBits }: 1.46Pib\nDisplayBandwidth { bandwidth: 6.1767339628e14, unit_family: BinBits }: 4.39Pib\nDisplayBandwidth { bandwidth: 1.8530201889e15, unit_family: BinBits }: 13.17Pib\nDisplayBandwidth { bandwidth: 5.5590605666e15, unit_family: BinBits }: 39.50Pib\nDisplayBandwidth { bandwidth: 1.6677181700e16, unit_family: BinBits }: 118.50Pib\nDisplayBandwidth { bandwidth: 5.0031545099e16, unit_family: BinBits }: 355.50Pib\nDisplayBandwidth { bandwidth: 1.5009463530e17, unit_family: BinBits }: 1066.49Pib\nDisplayBandwidth { bandwidth: 4.5028390589e17, unit_family: BinBits }: 3199.46Pib\nDisplayBandwidth { bandwidth: 8.0000000000e-3, unit_family: BinBits }: 0.06b\nDisplayBandwidth { bandwidth: 4.0000000000e-2, unit_family: BinBits }: 0.32b\nDisplayBandwidth { bandwidth: 2.0000000000e-1, unit_family: BinBits }: 1.60b\nDisplayBandwidth { bandwidth: 1.0000000000e0, unit_family: BinBits }: 8.00b\nDisplayBandwidth { bandwidth: 5.0000000000e0, unit_family: BinBits }: 40.00b\nDisplayBandwidth { bandwidth: 2.5000000000e1, unit_family: BinBits }: 200.00b\nDisplayBandwidth { bandwidth: 1.2500000000e2, unit_family: BinBits }: 0.98Kib\nDisplayBandwidth { bandwidth: 6.2500000000e2, unit_family: BinBits }: 4.88Kib\nDisplayBandwidth { bandwidth: 3.1250000000e3, unit_family: BinBits }: 24.41Kib\nDisplayBandwidth { bandwidth: 1.5625000000e4, unit_family: BinBits }: 122.07Kib\nDisplayBandwidth { bandwidth: 7.8125000000e4, unit_family: BinBits }: 610.35Kib\nDisplayBandwidth { bandwidth: 3.9062500000e5, unit_family: BinBits }: 2.98Mib\nDisplayBandwidth { bandwidth: 1.9531250000e6, unit_family: BinBits }: 14.90Mib\nDisplayBandwidth { bandwidth: 9.7656250000e6, unit_family: BinBits }: 74.51Mib\nDisplayBandwidth { bandwidth: 4.8828125000e7, unit_family: BinBits }: 372.53Mib\nDisplayBandwidth { bandwidth: 2.4414062500e8, unit_family: BinBits }: 1.82Gib\nDisplayBandwidth { bandwidth: 1.2207031250e9, unit_family: BinBits }: 9.09Gib\nDisplayBandwidth { bandwidth: 6.1035156250e9, unit_family: BinBits }: 45.47Gib\nDisplayBandwidth { bandwidth: 3.0517578125e10, unit_family: BinBits }: 227.37Gib\nDisplayBandwidth { bandwidth: 1.5258789062e11, unit_family: BinBits }: 1.11Tib\nDisplayBandwidth { bandwidth: 7.6293945312e11, unit_family: BinBits }: 5.55Tib\nDisplayBandwidth { bandwidth: 3.8146972656e12, unit_family: BinBits }: 27.76Tib\nDisplayBandwidth { bandwidth: 1.9073486328e13, unit_family: BinBits }: 138.78Tib\nDisplayBandwidth { bandwidth: 9.5367431641e13, unit_family: BinBits }: 693.89Tib\nDisplayBandwidth { bandwidth: 4.7683715820e14, unit_family: BinBits }: 3.39Pib\nDisplayBandwidth { bandwidth: 2.3841857910e15, unit_family: BinBits }: 16.94Pib\nDisplayBandwidth { bandwidth: 1.1920928955e16, unit_family: BinBits }: 84.70Pib\nDisplayBandwidth { bandwidth: 5.9604644775e16, unit_family: BinBits }: 423.52Pib\nDisplayBandwidth { bandwidth: 2.9802322388e17, unit_family: BinBits }: 2117.58Pib\nDisplayBandwidth { bandwidth: 1.5625000000e-2, unit_family: SiBytes }: 0.02B\nDisplayBandwidth { bandwidth: 3.1250000000e-2, unit_family: SiBytes }: 0.03B\nDisplayBandwidth { bandwidth: 6.2500000000e-2, unit_family: SiBytes }: 0.06B\nDisplayBandwidth { bandwidth: 1.2500000000e-1, unit_family: SiBytes }: 0.12B\nDisplayBandwidth { bandwidth: 2.5000000000e-1, unit_family: SiBytes }: 0.25B\nDisplayBandwidth { bandwidth: 5.0000000000e-1, unit_family: SiBytes }: 0.50B\nDisplayBandwidth { bandwidth: 1.0000000000e0, unit_family: SiBytes }: 1.00B\nDisplayBandwidth { bandwidth: 2.0000000000e0, unit_family: SiBytes }: 2.00B\nDisplayBandwidth { bandwidth: 4.0000000000e0, unit_family: SiBytes }: 4.00B\nDisplayBandwidth { bandwidth: 8.0000000000e0, unit_family: SiBytes }: 8.00B\nDisplayBandwidth { bandwidth: 1.6000000000e1, unit_family: SiBytes }: 16.00B\nDisplayBandwidth { bandwidth: 3.2000000000e1, unit_family: SiBytes }: 32.00B\nDisplayBandwidth { bandwidth: 6.4000000000e1, unit_family: SiBytes }: 64.00B\nDisplayBandwidth { bandwidth: 1.2800000000e2, unit_family: SiBytes }: 128.00B\nDisplayBandwidth { bandwidth: 2.5600000000e2, unit_family: SiBytes }: 256.00B\nDisplayBandwidth { bandwidth: 5.1200000000e2, unit_family: SiBytes }: 512.00B\nDisplayBandwidth { bandwidth: 1.0240000000e3, unit_family: SiBytes }: 1.02kB\nDisplayBandwidth { bandwidth: 2.0480000000e3, unit_family: SiBytes }: 2.05kB\nDisplayBandwidth { bandwidth: 4.0960000000e3, unit_family: SiBytes }: 4.10kB\nDisplayBandwidth { bandwidth: 8.1920000000e3, unit_family: SiBytes }: 8.19kB\nDisplayBandwidth { bandwidth: 1.6384000000e4, unit_family: SiBytes }: 16.38kB\nDisplayBandwidth { bandwidth: 3.2768000000e4, unit_family: SiBytes }: 32.77kB\nDisplayBandwidth { bandwidth: 6.5536000000e4, unit_family: SiBytes }: 65.54kB\nDisplayBandwidth { bandwidth: 1.3107200000e5, unit_family: SiBytes }: 131.07kB\nDisplayBandwidth { bandwidth: 2.6214400000e5, unit_family: SiBytes }: 262.14kB\nDisplayBandwidth { bandwidth: 5.2428800000e5, unit_family: SiBytes }: 524.29kB\nDisplayBandwidth { bandwidth: 1.0485760000e6, unit_family: SiBytes }: 1.05MB\nDisplayBandwidth { bandwidth: 2.0971520000e6, unit_family: SiBytes }: 2.10MB\nDisplayBandwidth { bandwidth: 4.1943040000e6, unit_family: SiBytes }: 4.19MB\nDisplayBandwidth { bandwidth: 8.3886080000e6, unit_family: SiBytes }: 8.39MB\nDisplayBandwidth { bandwidth: 1.6777216000e7, unit_family: SiBytes }: 16.78MB\nDisplayBandwidth { bandwidth: 3.3554432000e7, unit_family: SiBytes }: 33.55MB\nDisplayBandwidth { bandwidth: 6.7108864000e7, unit_family: SiBytes }: 67.11MB\nDisplayBandwidth { bandwidth: 1.3421772800e8, unit_family: SiBytes }: 134.22MB\nDisplayBandwidth { bandwidth: 2.6843545600e8, unit_family: SiBytes }: 268.44MB\nDisplayBandwidth { bandwidth: 5.3687091200e8, unit_family: SiBytes }: 536.87MB\nDisplayBandwidth { bandwidth: 1.0737418240e9, unit_family: SiBytes }: 1.07GB\nDisplayBandwidth { bandwidth: 2.1474836480e9, unit_family: SiBytes }: 2.15GB\nDisplayBandwidth { bandwidth: 4.2949672960e9, unit_family: SiBytes }: 4.29GB\nDisplayBandwidth { bandwidth: 8.5899345920e9, unit_family: SiBytes }: 8.59GB\nDisplayBandwidth { bandwidth: 1.7179869184e10, unit_family: SiBytes }: 17.18GB\nDisplayBandwidth { bandwidth: 3.4359738368e10, unit_family: SiBytes }: 34.36GB\nDisplayBandwidth { bandwidth: 6.8719476736e10, unit_family: SiBytes }: 68.72GB\nDisplayBandwidth { bandwidth: 1.3743895347e11, unit_family: SiBytes }: 137.44GB\nDisplayBandwidth { bandwidth: 2.7487790694e11, unit_family: SiBytes }: 274.88GB\nDisplayBandwidth { bandwidth: 5.4975581389e11, unit_family: SiBytes }: 549.76GB\nDisplayBandwidth { bandwidth: 1.0995116278e12, unit_family: SiBytes }: 1.10TB\nDisplayBandwidth { bandwidth: 2.1990232556e12, unit_family: SiBytes }: 2.20TB\nDisplayBandwidth { bandwidth: 4.3980465111e12, unit_family: SiBytes }: 4.40TB\nDisplayBandwidth { bandwidth: 8.7960930222e12, unit_family: SiBytes }: 8.80TB\nDisplayBandwidth { bandwidth: 1.7592186044e13, unit_family: SiBytes }: 17.59TB\nDisplayBandwidth { bandwidth: 3.5184372089e13, unit_family: SiBytes }: 35.18TB\nDisplayBandwidth { bandwidth: 7.0368744178e13, unit_family: SiBytes }: 70.37TB\nDisplayBandwidth { bandwidth: 1.4073748836e14, unit_family: SiBytes }: 140.74TB\nDisplayBandwidth { bandwidth: 2.8147497671e14, unit_family: SiBytes }: 281.47TB\nDisplayBandwidth { bandwidth: 5.6294995342e14, unit_family: SiBytes }: 562.95TB\nDisplayBandwidth { bandwidth: 1.1258999068e15, unit_family: SiBytes }: 1.13PB\nDisplayBandwidth { bandwidth: 2.2517998137e15, unit_family: SiBytes }: 2.25PB\nDisplayBandwidth { bandwidth: 4.5035996274e15, unit_family: SiBytes }: 4.50PB\nDisplayBandwidth { bandwidth: 9.0071992547e15, unit_family: SiBytes }: 9.01PB\nDisplayBandwidth { bandwidth: 1.8014398509e16, unit_family: SiBytes }: 18.01PB\nDisplayBandwidth { bandwidth: 3.6028797019e16, unit_family: SiBytes }: 36.03PB\nDisplayBandwidth { bandwidth: 7.2057594038e16, unit_family: SiBytes }: 72.06PB\nDisplayBandwidth { bandwidth: 1.4411518808e17, unit_family: SiBytes }: 144.12PB\nDisplayBandwidth { bandwidth: 2.8823037615e17, unit_family: SiBytes }: 288.23PB\nDisplayBandwidth { bandwidth: 5.7646075230e17, unit_family: SiBytes }: 576.46PB\nDisplayBandwidth { bandwidth: 1.0240000000e-2, unit_family: SiBytes }: 0.01B\nDisplayBandwidth { bandwidth: 2.5600000000e-2, unit_family: SiBytes }: 0.03B\nDisplayBandwidth { bandwidth: 6.4000000000e-2, unit_family: SiBytes }: 0.06B\nDisplayBandwidth { bandwidth: 1.6000000000e-1, unit_family: SiBytes }: 0.16B\nDisplayBandwidth { bandwidth: 4.0000000000e-1, unit_family: SiBytes }: 0.40B\nDisplayBandwidth { bandwidth: 1.0000000000e0, unit_family: SiBytes }: 1.00B\nDisplayBandwidth { bandwidth: 2.5000000000e0, unit_family: SiBytes }: 2.50B\nDisplayBandwidth { bandwidth: 6.2500000000e0, unit_family: SiBytes }: 6.25B\nDisplayBandwidth { bandwidth: 1.5625000000e1, unit_family: SiBytes }: 15.62B\nDisplayBandwidth { bandwidth: 3.9062500000e1, unit_family: SiBytes }: 39.06B\nDisplayBandwidth { bandwidth: 9.7656250000e1, unit_family: SiBytes }: 97.66B\nDisplayBandwidth { bandwidth: 2.4414062500e2, unit_family: SiBytes }: 244.14B\nDisplayBandwidth { bandwidth: 6.1035156250e2, unit_family: SiBytes }: 610.35B\nDisplayBandwidth { bandwidth: 1.5258789062e3, unit_family: SiBytes }: 1.53kB\nDisplayBandwidth { bandwidth: 3.8146972656e3, unit_family: SiBytes }: 3.81kB\nDisplayBandwidth { bandwidth: 9.5367431641e3, unit_family: SiBytes }: 9.54kB\nDisplayBandwidth { bandwidth: 2.3841857910e4, unit_family: SiBytes }: 23.84kB\nDisplayBandwidth { bandwidth: 5.9604644775e4, unit_family: SiBytes }: 59.60kB\nDisplayBandwidth { bandwidth: 1.4901161194e5, unit_family: SiBytes }: 149.01kB\nDisplayBandwidth { bandwidth: 3.7252902985e5, unit_family: SiBytes }: 372.53kB\nDisplayBandwidth { bandwidth: 9.3132257462e5, unit_family: SiBytes }: 931.32kB\nDisplayBandwidth { bandwidth: 2.3283064365e6, unit_family: SiBytes }: 2.33MB\nDisplayBandwidth { bandwidth: 5.8207660913e6, unit_family: SiBytes }: 5.82MB\nDisplayBandwidth { bandwidth: 1.4551915228e7, unit_family: SiBytes }: 14.55MB\nDisplayBandwidth { bandwidth: 3.6379788071e7, unit_family: SiBytes }: 36.38MB\nDisplayBandwidth { bandwidth: 9.0949470177e7, unit_family: SiBytes }: 90.95MB\nDisplayBandwidth { bandwidth: 2.2737367544e8, unit_family: SiBytes }: 227.37MB\nDisplayBandwidth { bandwidth: 5.6843418861e8, unit_family: SiBytes }: 568.43MB\nDisplayBandwidth { bandwidth: 1.4210854715e9, unit_family: SiBytes }: 1.42GB\nDisplayBandwidth { bandwidth: 3.5527136788e9, unit_family: SiBytes }: 3.55GB\nDisplayBandwidth { bandwidth: 8.8817841970e9, unit_family: SiBytes }: 8.88GB\nDisplayBandwidth { bandwidth: 2.2204460493e10, unit_family: SiBytes }: 22.20GB\nDisplayBandwidth { bandwidth: 5.5511151231e10, unit_family: SiBytes }: 55.51GB\nDisplayBandwidth { bandwidth: 1.3877787808e11, unit_family: SiBytes }: 138.78GB\nDisplayBandwidth { bandwidth: 3.4694469520e11, unit_family: SiBytes }: 346.94GB\nDisplayBandwidth { bandwidth: 8.6736173799e11, unit_family: SiBytes }: 867.36GB\nDisplayBandwidth { bandwidth: 2.1684043450e12, unit_family: SiBytes }: 2.17TB\nDisplayBandwidth { bandwidth: 5.4210108624e12, unit_family: SiBytes }: 5.42TB\nDisplayBandwidth { bandwidth: 1.3552527156e13, unit_family: SiBytes }: 13.55TB\nDisplayBandwidth { bandwidth: 3.3881317890e13, unit_family: SiBytes }: 33.88TB\nDisplayBandwidth { bandwidth: 8.4703294725e13, unit_family: SiBytes }: 84.70TB\nDisplayBandwidth { bandwidth: 2.1175823681e14, unit_family: SiBytes }: 211.76TB\nDisplayBandwidth { bandwidth: 5.2939559203e14, unit_family: SiBytes }: 529.40TB\nDisplayBandwidth { bandwidth: 1.3234889801e15, unit_family: SiBytes }: 1.32PB\nDisplayBandwidth { bandwidth: 3.3087224502e15, unit_family: SiBytes }: 3.31PB\nDisplayBandwidth { bandwidth: 8.2718061255e15, unit_family: SiBytes }: 8.27PB\nDisplayBandwidth { bandwidth: 2.0679515314e16, unit_family: SiBytes }: 20.68PB\nDisplayBandwidth { bandwidth: 5.1698788285e16, unit_family: SiBytes }: 51.70PB\nDisplayBandwidth { bandwidth: 1.2924697071e17, unit_family: SiBytes }: 129.25PB\nDisplayBandwidth { bandwidth: 3.2311742678e17, unit_family: SiBytes }: 323.12PB\nDisplayBandwidth { bandwidth: 1.2345679012e-2, unit_family: SiBytes }: 0.01B\nDisplayBandwidth { bandwidth: 3.7037037037e-2, unit_family: SiBytes }: 0.04B\nDisplayBandwidth { bandwidth: 1.1111111111e-1, unit_family: SiBytes }: 0.11B\nDisplayBandwidth { bandwidth: 3.3333333333e-1, unit_family: SiBytes }: 0.33B\nDisplayBandwidth { bandwidth: 1.0000000000e0, unit_family: SiBytes }: 1.00B\nDisplayBandwidth { bandwidth: 3.0000000000e0, unit_family: SiBytes }: 3.00B\nDisplayBandwidth { bandwidth: 9.0000000000e0, unit_family: SiBytes }: 9.00B\nDisplayBandwidth { bandwidth: 2.7000000000e1, unit_family: SiBytes }: 27.00B\nDisplayBandwidth { bandwidth: 8.1000000000e1, unit_family: SiBytes }: 81.00B\nDisplayBandwidth { bandwidth: 2.4300000000e2, unit_family: SiBytes }: 243.00B\nDisplayBandwidth { bandwidth: 7.2900000000e2, unit_family: SiBytes }: 729.00B\nDisplayBandwidth { bandwidth: 2.1870000000e3, unit_family: SiBytes }: 2.19kB\nDisplayBandwidth { bandwidth: 6.5610000000e3, unit_family: SiBytes }: 6.56kB\nDisplayBandwidth { bandwidth: 1.9683000000e4, unit_family: SiBytes }: 19.68kB\nDisplayBandwidth { bandwidth: 5.9049000000e4, unit_family: SiBytes }: 59.05kB\nDisplayBandwidth { bandwidth: 1.7714700000e5, unit_family: SiBytes }: 177.15kB\nDisplayBandwidth { bandwidth: 5.3144100000e5, unit_family: SiBytes }: 531.44kB\nDisplayBandwidth { bandwidth: 1.5943230000e6, unit_family: SiBytes }: 1.59MB\nDisplayBandwidth { bandwidth: 4.7829690000e6, unit_family: SiBytes }: 4.78MB\nDisplayBandwidth { bandwidth: 1.4348907000e7, unit_family: SiBytes }: 14.35MB\nDisplayBandwidth { bandwidth: 4.3046721000e7, unit_family: SiBytes }: 43.05MB\nDisplayBandwidth { bandwidth: 1.2914016300e8, unit_family: SiBytes }: 129.14MB\nDisplayBandwidth { bandwidth: 3.8742048900e8, unit_family: SiBytes }: 387.42MB\nDisplayBandwidth { bandwidth: 1.1622614670e9, unit_family: SiBytes }: 1.16GB\nDisplayBandwidth { bandwidth: 3.4867844010e9, unit_family: SiBytes }: 3.49GB\nDisplayBandwidth { bandwidth: 1.0460353203e10, unit_family: SiBytes }: 10.46GB\nDisplayBandwidth { bandwidth: 3.1381059609e10, unit_family: SiBytes }: 31.38GB\nDisplayBandwidth { bandwidth: 9.4143178827e10, unit_family: SiBytes }: 94.14GB\nDisplayBandwidth { bandwidth: 2.8242953648e11, unit_family: SiBytes }: 282.43GB\nDisplayBandwidth { bandwidth: 8.4728860944e11, unit_family: SiBytes }: 847.29GB\nDisplayBandwidth { bandwidth: 2.5418658283e12, unit_family: SiBytes }: 2.54TB\nDisplayBandwidth { bandwidth: 7.6255974850e12, unit_family: SiBytes }: 7.63TB\nDisplayBandwidth { bandwidth: 2.2876792455e13, unit_family: SiBytes }: 22.88TB\nDisplayBandwidth { bandwidth: 6.8630377365e13, unit_family: SiBytes }: 68.63TB\nDisplayBandwidth { bandwidth: 2.0589113209e14, unit_family: SiBytes }: 205.89TB\nDisplayBandwidth { bandwidth: 6.1767339628e14, unit_family: SiBytes }: 617.67TB\nDisplayBandwidth { bandwidth: 1.8530201889e15, unit_family: SiBytes }: 1.85PB\nDisplayBandwidth { bandwidth: 5.5590605666e15, unit_family: SiBytes }: 5.56PB\nDisplayBandwidth { bandwidth: 1.6677181700e16, unit_family: SiBytes }: 16.68PB\nDisplayBandwidth { bandwidth: 5.0031545099e16, unit_family: SiBytes }: 50.03PB\nDisplayBandwidth { bandwidth: 1.5009463530e17, unit_family: SiBytes }: 150.09PB\nDisplayBandwidth { bandwidth: 4.5028390589e17, unit_family: SiBytes }: 450.28PB\nDisplayBandwidth { bandwidth: 8.0000000000e-3, unit_family: SiBytes }: 0.01B\nDisplayBandwidth { bandwidth: 4.0000000000e-2, unit_family: SiBytes }: 0.04B\nDisplayBandwidth { bandwidth: 2.0000000000e-1, unit_family: SiBytes }: 0.20B\nDisplayBandwidth { bandwidth: 1.0000000000e0, unit_family: SiBytes }: 1.00B\nDisplayBandwidth { bandwidth: 5.0000000000e0, unit_family: SiBytes }: 5.00B\nDisplayBandwidth { bandwidth: 2.5000000000e1, unit_family: SiBytes }: 25.00B\nDisplayBandwidth { bandwidth: 1.2500000000e2, unit_family: SiBytes }: 125.00B\nDisplayBandwidth { bandwidth: 6.2500000000e2, unit_family: SiBytes }: 625.00B\nDisplayBandwidth { bandwidth: 3.1250000000e3, unit_family: SiBytes }: 3.12kB\nDisplayBandwidth { bandwidth: 1.5625000000e4, unit_family: SiBytes }: 15.62kB\nDisplayBandwidth { bandwidth: 7.8125000000e4, unit_family: SiBytes }: 78.12kB\nDisplayBandwidth { bandwidth: 3.9062500000e5, unit_family: SiBytes }: 390.62kB\nDisplayBandwidth { bandwidth: 1.9531250000e6, unit_family: SiBytes }: 1.95MB\nDisplayBandwidth { bandwidth: 9.7656250000e6, unit_family: SiBytes }: 9.77MB\nDisplayBandwidth { bandwidth: 4.8828125000e7, unit_family: SiBytes }: 48.83MB\nDisplayBandwidth { bandwidth: 2.4414062500e8, unit_family: SiBytes }: 244.14MB\nDisplayBandwidth { bandwidth: 1.2207031250e9, unit_family: SiBytes }: 1.22GB\nDisplayBandwidth { bandwidth: 6.1035156250e9, unit_family: SiBytes }: 6.10GB\nDisplayBandwidth { bandwidth: 3.0517578125e10, unit_family: SiBytes }: 30.52GB\nDisplayBandwidth { bandwidth: 1.5258789062e11, unit_family: SiBytes }: 152.59GB\nDisplayBandwidth { bandwidth: 7.6293945312e11, unit_family: SiBytes }: 762.94GB\nDisplayBandwidth { bandwidth: 3.8146972656e12, unit_family: SiBytes }: 3.81TB\nDisplayBandwidth { bandwidth: 1.9073486328e13, unit_family: SiBytes }: 19.07TB\nDisplayBandwidth { bandwidth: 9.5367431641e13, unit_family: SiBytes }: 95.37TB\nDisplayBandwidth { bandwidth: 4.7683715820e14, unit_family: SiBytes }: 476.84TB\nDisplayBandwidth { bandwidth: 2.3841857910e15, unit_family: SiBytes }: 2.38PB\nDisplayBandwidth { bandwidth: 1.1920928955e16, unit_family: SiBytes }: 11.92PB\nDisplayBandwidth { bandwidth: 5.9604644775e16, unit_family: SiBytes }: 59.60PB\nDisplayBandwidth { bandwidth: 2.9802322388e17, unit_family: SiBytes }: 298.02PB\nDisplayBandwidth { bandwidth: 1.5625000000e-2, unit_family: SiBits }: 0.12b\nDisplayBandwidth { bandwidth: 3.1250000000e-2, unit_family: SiBits }: 0.25b\nDisplayBandwidth { bandwidth: 6.2500000000e-2, unit_family: SiBits }: 0.50b\nDisplayBandwidth { bandwidth: 1.2500000000e-1, unit_family: SiBits }: 1.00b\nDisplayBandwidth { bandwidth: 2.5000000000e-1, unit_family: SiBits }: 2.00b\nDisplayBandwidth { bandwidth: 5.0000000000e-1, unit_family: SiBits }: 4.00b\nDisplayBandwidth { bandwidth: 1.0000000000e0, unit_family: SiBits }: 8.00b\nDisplayBandwidth { bandwidth: 2.0000000000e0, unit_family: SiBits }: 16.00b\nDisplayBandwidth { bandwidth: 4.0000000000e0, unit_family: SiBits }: 32.00b\nDisplayBandwidth { bandwidth: 8.0000000000e0, unit_family: SiBits }: 64.00b\nDisplayBandwidth { bandwidth: 1.6000000000e1, unit_family: SiBits }: 128.00b\nDisplayBandwidth { bandwidth: 3.2000000000e1, unit_family: SiBits }: 256.00b\nDisplayBandwidth { bandwidth: 6.4000000000e1, unit_family: SiBits }: 512.00b\nDisplayBandwidth { bandwidth: 1.2800000000e2, unit_family: SiBits }: 1.02kb\nDisplayBandwidth { bandwidth: 2.5600000000e2, unit_family: SiBits }: 2.05kb\nDisplayBandwidth { bandwidth: 5.1200000000e2, unit_family: SiBits }: 4.10kb\nDisplayBandwidth { bandwidth: 1.0240000000e3, unit_family: SiBits }: 8.19kb\nDisplayBandwidth { bandwidth: 2.0480000000e3, unit_family: SiBits }: 16.38kb\nDisplayBandwidth { bandwidth: 4.0960000000e3, unit_family: SiBits }: 32.77kb\nDisplayBandwidth { bandwidth: 8.1920000000e3, unit_family: SiBits }: 65.54kb\nDisplayBandwidth { bandwidth: 1.6384000000e4, unit_family: SiBits }: 131.07kb\nDisplayBandwidth { bandwidth: 3.2768000000e4, unit_family: SiBits }: 262.14kb\nDisplayBandwidth { bandwidth: 6.5536000000e4, unit_family: SiBits }: 524.29kb\nDisplayBandwidth { bandwidth: 1.3107200000e5, unit_family: SiBits }: 1.05Mb\nDisplayBandwidth { bandwidth: 2.6214400000e5, unit_family: SiBits }: 2.10Mb\nDisplayBandwidth { bandwidth: 5.2428800000e5, unit_family: SiBits }: 4.19Mb\nDisplayBandwidth { bandwidth: 1.0485760000e6, unit_family: SiBits }: 8.39Mb\nDisplayBandwidth { bandwidth: 2.0971520000e6, unit_family: SiBits }: 16.78Mb\nDisplayBandwidth { bandwidth: 4.1943040000e6, unit_family: SiBits }: 33.55Mb\nDisplayBandwidth { bandwidth: 8.3886080000e6, unit_family: SiBits }: 67.11Mb\nDisplayBandwidth { bandwidth: 1.6777216000e7, unit_family: SiBits }: 134.22Mb\nDisplayBandwidth { bandwidth: 3.3554432000e7, unit_family: SiBits }: 268.44Mb\nDisplayBandwidth { bandwidth: 6.7108864000e7, unit_family: SiBits }: 536.87Mb\nDisplayBandwidth { bandwidth: 1.3421772800e8, unit_family: SiBits }: 1.07Gb\nDisplayBandwidth { bandwidth: 2.6843545600e8, unit_family: SiBits }: 2.15Gb\nDisplayBandwidth { bandwidth: 5.3687091200e8, unit_family: SiBits }: 4.29Gb\nDisplayBandwidth { bandwidth: 1.0737418240e9, unit_family: SiBits }: 8.59Gb\nDisplayBandwidth { bandwidth: 2.1474836480e9, unit_family: SiBits }: 17.18Gb\nDisplayBandwidth { bandwidth: 4.2949672960e9, unit_family: SiBits }: 34.36Gb\nDisplayBandwidth { bandwidth: 8.5899345920e9, unit_family: SiBits }: 68.72Gb\nDisplayBandwidth { bandwidth: 1.7179869184e10, unit_family: SiBits }: 137.44Gb\nDisplayBandwidth { bandwidth: 3.4359738368e10, unit_family: SiBits }: 274.88Gb\nDisplayBandwidth { bandwidth: 6.8719476736e10, unit_family: SiBits }: 549.76Gb\nDisplayBandwidth { bandwidth: 1.3743895347e11, unit_family: SiBits }: 1.10Tb\nDisplayBandwidth { bandwidth: 2.7487790694e11, unit_family: SiBits }: 2.20Tb\nDisplayBandwidth { bandwidth: 5.4975581389e11, unit_family: SiBits }: 4.40Tb\nDisplayBandwidth { bandwidth: 1.0995116278e12, unit_family: SiBits }: 8.80Tb\nDisplayBandwidth { bandwidth: 2.1990232556e12, unit_family: SiBits }: 17.59Tb\nDisplayBandwidth { bandwidth: 4.3980465111e12, unit_family: SiBits }: 35.18Tb\nDisplayBandwidth { bandwidth: 8.7960930222e12, unit_family: SiBits }: 70.37Tb\nDisplayBandwidth { bandwidth: 1.7592186044e13, unit_family: SiBits }: 140.74Tb\nDisplayBandwidth { bandwidth: 3.5184372089e13, unit_family: SiBits }: 281.47Tb\nDisplayBandwidth { bandwidth: 7.0368744178e13, unit_family: SiBits }: 562.95Tb\nDisplayBandwidth { bandwidth: 1.4073748836e14, unit_family: SiBits }: 1.13Pb\nDisplayBandwidth { bandwidth: 2.8147497671e14, unit_family: SiBits }: 2.25Pb\nDisplayBandwidth { bandwidth: 5.6294995342e14, unit_family: SiBits }: 4.50Pb\nDisplayBandwidth { bandwidth: 1.1258999068e15, unit_family: SiBits }: 9.01Pb\nDisplayBandwidth { bandwidth: 2.2517998137e15, unit_family: SiBits }: 18.01Pb\nDisplayBandwidth { bandwidth: 4.5035996274e15, unit_family: SiBits }: 36.03Pb\nDisplayBandwidth { bandwidth: 9.0071992547e15, unit_family: SiBits }: 72.06Pb\nDisplayBandwidth { bandwidth: 1.8014398509e16, unit_family: SiBits }: 144.12Pb\nDisplayBandwidth { bandwidth: 3.6028797019e16, unit_family: SiBits }: 288.23Pb\nDisplayBandwidth { bandwidth: 7.2057594038e16, unit_family: SiBits }: 576.46Pb\nDisplayBandwidth { bandwidth: 1.4411518808e17, unit_family: SiBits }: 1152.92Pb\nDisplayBandwidth { bandwidth: 2.8823037615e17, unit_family: SiBits }: 2305.84Pb\nDisplayBandwidth { bandwidth: 5.7646075230e17, unit_family: SiBits }: 4611.69Pb\nDisplayBandwidth { bandwidth: 1.0240000000e-2, unit_family: SiBits }: 0.08b\nDisplayBandwidth { bandwidth: 2.5600000000e-2, unit_family: SiBits }: 0.20b\nDisplayBandwidth { bandwidth: 6.4000000000e-2, unit_family: SiBits }: 0.51b\nDisplayBandwidth { bandwidth: 1.6000000000e-1, unit_family: SiBits }: 1.28b\nDisplayBandwidth { bandwidth: 4.0000000000e-1, unit_family: SiBits }: 3.20b\nDisplayBandwidth { bandwidth: 1.0000000000e0, unit_family: SiBits }: 8.00b\nDisplayBandwidth { bandwidth: 2.5000000000e0, unit_family: SiBits }: 20.00b\nDisplayBandwidth { bandwidth: 6.2500000000e0, unit_family: SiBits }: 50.00b\nDisplayBandwidth { bandwidth: 1.5625000000e1, unit_family: SiBits }: 125.00b\nDisplayBandwidth { bandwidth: 3.9062500000e1, unit_family: SiBits }: 312.50b\nDisplayBandwidth { bandwidth: 9.7656250000e1, unit_family: SiBits }: 781.25b\nDisplayBandwidth { bandwidth: 2.4414062500e2, unit_family: SiBits }: 1.95kb\nDisplayBandwidth { bandwidth: 6.1035156250e2, unit_family: SiBits }: 4.88kb\nDisplayBandwidth { bandwidth: 1.5258789062e3, unit_family: SiBits }: 12.21kb\nDisplayBandwidth { bandwidth: 3.8146972656e3, unit_family: SiBits }: 30.52kb\nDisplayBandwidth { bandwidth: 9.5367431641e3, unit_family: SiBits }: 76.29kb\nDisplayBandwidth { bandwidth: 2.3841857910e4, unit_family: SiBits }: 190.73kb\nDisplayBandwidth { bandwidth: 5.9604644775e4, unit_family: SiBits }: 476.84kb\nDisplayBandwidth { bandwidth: 1.4901161194e5, unit_family: SiBits }: 1.19Mb\nDisplayBandwidth { bandwidth: 3.7252902985e5, unit_family: SiBits }: 2.98Mb\nDisplayBandwidth { bandwidth: 9.3132257462e5, unit_family: SiBits }: 7.45Mb\nDisplayBandwidth { bandwidth: 2.3283064365e6, unit_family: SiBits }: 18.63Mb\nDisplayBandwidth { bandwidth: 5.8207660913e6, unit_family: SiBits }: 46.57Mb\nDisplayBandwidth { bandwidth: 1.4551915228e7, unit_family: SiBits }: 116.42Mb\nDisplayBandwidth { bandwidth: 3.6379788071e7, unit_family: SiBits }: 291.04Mb\nDisplayBandwidth { bandwidth: 9.0949470177e7, unit_family: SiBits }: 727.60Mb\nDisplayBandwidth { bandwidth: 2.2737367544e8, unit_family: SiBits }: 1.82Gb\nDisplayBandwidth { bandwidth: 5.6843418861e8, unit_family: SiBits }: 4.55Gb\nDisplayBandwidth { bandwidth: 1.4210854715e9, unit_family: SiBits }: 11.37Gb\nDisplayBandwidth { bandwidth: 3.5527136788e9, unit_family: SiBits }: 28.42Gb\nDisplayBandwidth { bandwidth: 8.8817841970e9, unit_family: SiBits }: 71.05Gb\nDisplayBandwidth { bandwidth: 2.2204460493e10, unit_family: SiBits }: 177.64Gb\nDisplayBandwidth { bandwidth: 5.5511151231e10, unit_family: SiBits }: 444.09Gb\nDisplayBandwidth { bandwidth: 1.3877787808e11, unit_family: SiBits }: 1.11Tb\nDisplayBandwidth { bandwidth: 3.4694469520e11, unit_family: SiBits }: 2.78Tb\nDisplayBandwidth { bandwidth: 8.6736173799e11, unit_family: SiBits }: 6.94Tb\nDisplayBandwidth { bandwidth: 2.1684043450e12, unit_family: SiBits }: 17.35Tb\nDisplayBandwidth { bandwidth: 5.4210108624e12, unit_family: SiBits }: 43.37Tb\nDisplayBandwidth { bandwidth: 1.3552527156e13, unit_family: SiBits }: 108.42Tb\nDisplayBandwidth { bandwidth: 3.3881317890e13, unit_family: SiBits }: 271.05Tb\nDisplayBandwidth { bandwidth: 8.4703294725e13, unit_family: SiBits }: 677.63Tb\nDisplayBandwidth { bandwidth: 2.1175823681e14, unit_family: SiBits }: 1.69Pb\nDisplayBandwidth { bandwidth: 5.2939559203e14, unit_family: SiBits }: 4.24Pb\nDisplayBandwidth { bandwidth: 1.3234889801e15, unit_family: SiBits }: 10.59Pb\nDisplayBandwidth { bandwidth: 3.3087224502e15, unit_family: SiBits }: 26.47Pb\nDisplayBandwidth { bandwidth: 8.2718061255e15, unit_family: SiBits }: 66.17Pb\nDisplayBandwidth { bandwidth: 2.0679515314e16, unit_family: SiBits }: 165.44Pb\nDisplayBandwidth { bandwidth: 5.1698788285e16, unit_family: SiBits }: 413.59Pb\nDisplayBandwidth { bandwidth: 1.2924697071e17, unit_family: SiBits }: 1033.98Pb\nDisplayBandwidth { bandwidth: 3.2311742678e17, unit_family: SiBits }: 2584.94Pb\nDisplayBandwidth { bandwidth: 1.2345679012e-2, unit_family: SiBits }: 0.10b\nDisplayBandwidth { bandwidth: 3.7037037037e-2, unit_family: SiBits }: 0.30b\nDisplayBandwidth { bandwidth: 1.1111111111e-1, unit_family: SiBits }: 0.89b\nDisplayBandwidth { bandwidth: 3.3333333333e-1, unit_family: SiBits }: 2.67b\nDisplayBandwidth { bandwidth: 1.0000000000e0, unit_family: SiBits }: 8.00b\nDisplayBandwidth { bandwidth: 3.0000000000e0, unit_family: SiBits }: 24.00b\nDisplayBandwidth { bandwidth: 9.0000000000e0, unit_family: SiBits }: 72.00b\nDisplayBandwidth { bandwidth: 2.7000000000e1, unit_family: SiBits }: 216.00b\nDisplayBandwidth { bandwidth: 8.1000000000e1, unit_family: SiBits }: 648.00b\nDisplayBandwidth { bandwidth: 2.4300000000e2, unit_family: SiBits }: 1.94kb\nDisplayBandwidth { bandwidth: 7.2900000000e2, unit_family: SiBits }: 5.83kb\nDisplayBandwidth { bandwidth: 2.1870000000e3, unit_family: SiBits }: 17.50kb\nDisplayBandwidth { bandwidth: 6.5610000000e3, unit_family: SiBits }: 52.49kb\nDisplayBandwidth { bandwidth: 1.9683000000e4, unit_family: SiBits }: 157.46kb\nDisplayBandwidth { bandwidth: 5.9049000000e4, unit_family: SiBits }: 472.39kb\nDisplayBandwidth { bandwidth: 1.7714700000e5, unit_family: SiBits }: 1.42Mb\nDisplayBandwidth { bandwidth: 5.3144100000e5, unit_family: SiBits }: 4.25Mb\nDisplayBandwidth { bandwidth: 1.5943230000e6, unit_family: SiBits }: 12.75Mb\nDisplayBandwidth { bandwidth: 4.7829690000e6, unit_family: SiBits }: 38.26Mb\nDisplayBandwidth { bandwidth: 1.4348907000e7, unit_family: SiBits }: 114.79Mb\nDisplayBandwidth { bandwidth: 4.3046721000e7, unit_family: SiBits }: 344.37Mb\nDisplayBandwidth { bandwidth: 1.2914016300e8, unit_family: SiBits }: 1.03Gb\nDisplayBandwidth { bandwidth: 3.8742048900e8, unit_family: SiBits }: 3.10Gb\nDisplayBandwidth { bandwidth: 1.1622614670e9, unit_family: SiBits }: 9.30Gb\nDisplayBandwidth { bandwidth: 3.4867844010e9, unit_family: SiBits }: 27.89Gb\nDisplayBandwidth { bandwidth: 1.0460353203e10, unit_family: SiBits }: 83.68Gb\nDisplayBandwidth { bandwidth: 3.1381059609e10, unit_family: SiBits }: 251.05Gb\nDisplayBandwidth { bandwidth: 9.4143178827e10, unit_family: SiBits }: 753.15Gb\nDisplayBandwidth { bandwidth: 2.8242953648e11, unit_family: SiBits }: 2.26Tb\nDisplayBandwidth { bandwidth: 8.4728860944e11, unit_family: SiBits }: 6.78Tb\nDisplayBandwidth { bandwidth: 2.5418658283e12, unit_family: SiBits }: 20.33Tb\nDisplayBandwidth { bandwidth: 7.6255974850e12, unit_family: SiBits }: 61.00Tb\nDisplayBandwidth { bandwidth: 2.2876792455e13, unit_family: SiBits }: 183.01Tb\nDisplayBandwidth { bandwidth: 6.8630377365e13, unit_family: SiBits }: 549.04Tb\nDisplayBandwidth { bandwidth: 2.0589113209e14, unit_family: SiBits }: 1.65Pb\nDisplayBandwidth { bandwidth: 6.1767339628e14, unit_family: SiBits }: 4.94Pb\nDisplayBandwidth { bandwidth: 1.8530201889e15, unit_family: SiBits }: 14.82Pb\nDisplayBandwidth { bandwidth: 5.5590605666e15, unit_family: SiBits }: 44.47Pb\nDisplayBandwidth { bandwidth: 1.6677181700e16, unit_family: SiBits }: 133.42Pb\nDisplayBandwidth { bandwidth: 5.0031545099e16, unit_family: SiBits }: 400.25Pb\nDisplayBandwidth { bandwidth: 1.5009463530e17, unit_family: SiBits }: 1200.76Pb\nDisplayBandwidth { bandwidth: 4.5028390589e17, unit_family: SiBits }: 3602.27Pb\nDisplayBandwidth { bandwidth: 8.0000000000e-3, unit_family: SiBits }: 0.06b\nDisplayBandwidth { bandwidth: 4.0000000000e-2, unit_family: SiBits }: 0.32b\nDisplayBandwidth { bandwidth: 2.0000000000e-1, unit_family: SiBits }: 1.60b\nDisplayBandwidth { bandwidth: 1.0000000000e0, unit_family: SiBits }: 8.00b\nDisplayBandwidth { bandwidth: 5.0000000000e0, unit_family: SiBits }: 40.00b\nDisplayBandwidth { bandwidth: 2.5000000000e1, unit_family: SiBits }: 200.00b\nDisplayBandwidth { bandwidth: 1.2500000000e2, unit_family: SiBits }: 1.00kb\nDisplayBandwidth { bandwidth: 6.2500000000e2, unit_family: SiBits }: 5.00kb\nDisplayBandwidth { bandwidth: 3.1250000000e3, unit_family: SiBits }: 25.00kb\nDisplayBandwidth { bandwidth: 1.5625000000e4, unit_family: SiBits }: 125.00kb\nDisplayBandwidth { bandwidth: 7.8125000000e4, unit_family: SiBits }: 625.00kb\nDisplayBandwidth { bandwidth: 3.9062500000e5, unit_family: SiBits }: 3.12Mb\nDisplayBandwidth { bandwidth: 1.9531250000e6, unit_family: SiBits }: 15.62Mb\nDisplayBandwidth { bandwidth: 9.7656250000e6, unit_family: SiBits }: 78.12Mb\nDisplayBandwidth { bandwidth: 4.8828125000e7, unit_family: SiBits }: 390.62Mb\nDisplayBandwidth { bandwidth: 2.4414062500e8, unit_family: SiBits }: 1.95Gb\nDisplayBandwidth { bandwidth: 1.2207031250e9, unit_family: SiBits }: 9.77Gb\nDisplayBandwidth { bandwidth: 6.1035156250e9, unit_family: SiBits }: 48.83Gb\nDisplayBandwidth { bandwidth: 3.0517578125e10, unit_family: SiBits }: 244.14Gb\nDisplayBandwidth { bandwidth: 1.5258789062e11, unit_family: SiBits }: 1.22Tb\nDisplayBandwidth { bandwidth: 7.6293945312e11, unit_family: SiBits }: 6.10Tb\nDisplayBandwidth { bandwidth: 3.8146972656e12, unit_family: SiBits }: 30.52Tb\nDisplayBandwidth { bandwidth: 1.9073486328e13, unit_family: SiBits }: 152.59Tb\nDisplayBandwidth { bandwidth: 9.5367431641e13, unit_family: SiBits }: 762.94Tb\nDisplayBandwidth { bandwidth: 4.7683715820e14, unit_family: SiBits }: 3.81Pb\nDisplayBandwidth { bandwidth: 2.3841857910e15, unit_family: SiBits }: 19.07Pb\nDisplayBandwidth { bandwidth: 1.1920928955e16, unit_family: SiBits }: 95.37Pb\nDisplayBandwidth { bandwidth: 5.9604644775e16, unit_family: SiBits }: 476.84Pb\nDisplayBandwidth { bandwidth: 2.9802322388e17, unit_family: SiBits }: 2384.19Pb\n"
  },
  {
    "path": "src/display/components/table.rs",
    "content": "use std::{collections::HashMap, net::IpAddr, ops::Index, rc::Rc};\n\nuse derive_more::Debug;\nuse itertools::Itertools;\nuse ratatui::{\n    layout::{Constraint, Rect},\n    style::{Color, Style},\n    widgets::{Block, Borders, Row},\n    Frame,\n};\nuse unicode_width::{UnicodeWidthChar, UnicodeWidthStr};\n\nuse crate::{\n    display::{Bandwidth, BandwidthUnitFamily, DisplayBandwidth, UIState},\n    network::{display_connection_string, display_ip_or_host},\n};\n\n/// The displayed layout choice of a table.\n/// Each value in the array is the width of each column.\n///\n/// Note that this only determines how a table is displayed, not what data it contains.\n///\n/// If we intend to display different number of columns in the future,\n/// then new variants should be added.\n#[derive(Copy, Clone, Debug)]\npub enum DisplayLayout {\n    /// Show 2 columns.\n    C2([u16; 2]),\n    /// Show 3 columns.\n    C3([u16; 3]),\n    /// Show 4 columns.\n    C4([u16; 4]),\n}\n\nimpl Index<usize> for DisplayLayout {\n    type Output = u16;\n\n    fn index(&self, i: usize) -> &Self::Output {\n        match self {\n            Self::C2(arr) => &arr[i],\n            Self::C3(arr) => &arr[i],\n            Self::C4(arr) => &arr[i],\n        }\n    }\n}\n\nimpl DisplayLayout {\n    #[inline]\n    fn columns_count(&self) -> usize {\n        match self {\n            Self::C2(_) => 2,\n            Self::C3(_) => 3,\n            Self::C4(_) => 4,\n        }\n    }\n\n    #[inline]\n    fn iter(&self) -> impl Iterator<Item = &u16> {\n        match self {\n            Self::C2(ws) => ws.iter(),\n            Self::C3(ws) => ws.iter(),\n            Self::C4(ws) => ws.iter(),\n        }\n    }\n\n    #[inline]\n    fn widths_sum(&self) -> u16 {\n        self.iter().sum()\n    }\n\n    /// Returns the computed actual width and the spacer width.\n    ///\n    /// See [`Table`] for layout rules.\n    fn compute_actual_widths(&self, available: u16) -> (Self, u16) {\n        let columns_count = self.columns_count() as u16;\n        let desired_min = self.widths_sum();\n\n        // spacer max width is 2\n        let spacer = if available > desired_min {\n            ((available - desired_min) / (columns_count - 1)).min(2)\n        } else {\n            0\n        };\n        let available_without_spacers = available - spacer * (columns_count - 1);\n\n        // multiplier\n        let m = available_without_spacers as f64 / desired_min as f64;\n\n        // remainder width is arbitrarily given to column 0\n        let computed = match *self {\n            Self::C2([_w0, w1]) => {\n                let w1_new = (w1 as f64 * m).trunc() as u16;\n                Self::C2([available_without_spacers - w1_new, w1_new])\n            }\n            Self::C3([_w0, w1, w2]) => {\n                let w1_new = (w1 as f64 * m).trunc() as u16;\n                let w2_new = (w2 as f64 * m).trunc() as u16;\n                Self::C3([available_without_spacers - w1_new - w2_new, w1_new, w2_new])\n            }\n            Self::C4([_w0, w1, w2, w3]) => {\n                let w1_new = (w1 as f64 * m).trunc() as u16;\n                let w2_new = (w2 as f64 * m).trunc() as u16;\n                let w3_new = (w3 as f64 * m).trunc() as u16;\n                Self::C4([\n                    available_without_spacers - w1_new - w2_new - w3_new,\n                    w1_new,\n                    w2_new,\n                    w3_new,\n                ])\n            }\n        };\n\n        (computed, spacer)\n    }\n}\n\n/// All data of a table.\n///\n/// If tables with different number of columns are added in the future,\n/// then new variants should be added.\n#[derive(Clone, Debug)]\nenum TableData {\n    /// A table with 3 columns.\n    C3(NColsTableData<3>),\n    /// A table with 4 columns.\n    C4(NColsTableData<4>),\n}\n\nimpl From<NColsTableData<3>> for TableData {\n    fn from(data: NColsTableData<3>) -> Self {\n        Self::C3(data)\n    }\n}\n\nimpl From<NColsTableData<4>> for TableData {\n    fn from(data: NColsTableData<4>) -> Self {\n        Self::C4(data)\n    }\n}\n\nimpl TableData {\n    fn column_names(&self) -> &[&str] {\n        match self {\n            Self::C3(inner) => &inner.column_names,\n            Self::C4(inner) => &inner.column_names,\n        }\n    }\n\n    fn rows(&self) -> Vec<&[String]> {\n        match self {\n            Self::C3(inner) => inner.rows.iter().map(|r| r.as_slice()).collect(),\n            Self::C4(inner) => inner.rows.iter().map(|r| r.as_slice()).collect(),\n        }\n    }\n\n    fn column_selector(&self) -> &dyn Fn(&DisplayLayout) -> Vec<usize> {\n        match self {\n            Self::C3(inner) => inner.column_selector.as_ref(),\n            Self::C4(inner) => inner.column_selector.as_ref(),\n        }\n    }\n}\n\n/// All data of a table with `C` columns.\n///\n/// Note that the number of columns here is independent of the number of columns\n/// being actually shown. If width-constrained, we might only show some of the columns.\n#[derive(Clone, Debug)]\nstruct NColsTableData<const C: usize> {\n    /// The name of each column.\n    column_names: [&'static str; C],\n    /// All rows of data.\n    rows: Vec<[String; C]>,\n    /// Function to determine which columns to show for a given layout.\n    ///\n    /// This function should return a vector of column indices.\n    /// The indices should be less than `C`; otherwise this will cause a runtime panic.\n    #[debug(\"Rc</* function pointer */>\")]\n    column_selector: Rc<ColumnSelectorFn>,\n}\n\n/// Clippy wanted me to write this. 💢\ntype ColumnSelectorFn = dyn Fn(&DisplayLayout) -> Vec<usize>;\n\n/// A table displayed by bandwhich.\n#[derive(Clone, Debug)]\npub struct Table {\n    title: &'static str,\n    /// A layout mapping between minimum available width and the width of each column.\n    ///\n    /// Note that the width of each column here is the \"desired minimum width\".\n    ///\n    /// - Wt = available width of table\n    /// - Wd = sum of desired minimum width of each column\n    ///\n    /// - If `Wt >= Wd`, spacers with a maximum width of `2` will be inserted\n    ///   between columns; and then the columns will proportionally expand.\n    /// - If `Wt < Wd`, columns will proportionally shrink.\n    width_cutoffs: Vec<(u16, DisplayLayout)>,\n    data: TableData,\n}\n\nimpl Table {\n    pub fn create_connections_table(state: &UIState, ip_to_host: &HashMap<IpAddr, String>) -> Self {\n        use DisplayLayout as D;\n\n        let title = \"Utilization by connection\";\n        let width_cutoffs = vec![\n            (0, D::C2([32, 18])),\n            (80, D::C3([36, 12, 18])),\n            (100, D::C3([54, 18, 22])),\n            (120, D::C3([72, 24, 22])),\n        ];\n\n        let column_names = [\n            \"Connection\",\n            \"Process\",\n            if state.cumulative_mode {\n                \"Data (Up / Down)\"\n            } else {\n                \"Rate (Up / Down)\"\n            },\n        ];\n        let rows = state\n            .connections\n            .iter()\n            .map(|(connection, connection_data)| {\n                [\n                    display_connection_string(\n                        connection,\n                        ip_to_host,\n                        &connection_data.interface_name,\n                    ),\n                    connection_data.process_name.to_string(),\n                    display_upload_and_download(\n                        connection_data,\n                        state.unit_family,\n                        state.cumulative_mode,\n                    ),\n                ]\n            })\n            .collect();\n        let column_selector = Rc::new(|layout: &D| match layout {\n            D::C2(_) => vec![0, 2],\n            D::C3(_) => vec![0, 1, 2],\n            D::C4(_) => unreachable!(),\n        });\n\n        Table {\n            title,\n            width_cutoffs,\n            data: NColsTableData {\n                column_names,\n                rows,\n                column_selector,\n            }\n            .into(),\n        }\n    }\n\n    pub fn create_processes_table(state: &UIState) -> Self {\n        use DisplayLayout as D;\n\n        let title = \"Utilization by process name\";\n        let width_cutoffs = vec![\n            (0, D::C2([16, 18])),\n            (50, D::C3([16, 12, 20])),\n            (60, D::C3([24, 12, 20])),\n            (80, D::C4([28, 12, 12, 24])),\n        ];\n\n        let column_names = [\n            \"Process\",\n            \"PID\",\n            \"Connections\",\n            if state.cumulative_mode {\n                \"Data (Up / Down)\"\n            } else {\n                \"Rate (Up / Down)\"\n            },\n        ];\n        let rows = state\n            .processes\n            .iter()\n            .map(|(proc_info, data_for_process)| {\n                [\n                    proc_info.name.to_string(),\n                    proc_info.pid.to_string(),\n                    data_for_process.connection_count.to_string(),\n                    display_upload_and_download(\n                        data_for_process,\n                        state.unit_family,\n                        state.cumulative_mode,\n                    ),\n                ]\n            })\n            .collect();\n        let column_selector = Rc::new(|layout: &D| match layout {\n            D::C2(_) => vec![0, 3],\n            D::C3(_) => vec![0, 2, 3],\n            D::C4(_) => vec![0, 1, 2, 3],\n        });\n\n        Table {\n            title,\n            width_cutoffs,\n            data: NColsTableData {\n                column_names,\n                rows,\n                column_selector,\n            }\n            .into(),\n        }\n    }\n\n    pub fn create_remote_addresses_table(\n        state: &UIState,\n        ip_to_host: &HashMap<IpAddr, String>,\n    ) -> Self {\n        use DisplayLayout as D;\n\n        let title = \"Utilization by remote address\";\n        let width_cutoffs = vec![\n            (0, D::C2([16, 16])),\n            (40, D::C2([20, 16])),\n            (60, D::C3([24, 10, 20])),\n            (100, D::C3([54, 16, 24])),\n        ];\n\n        let column_names = [\n            \"Remote Address\",\n            \"Connections\",\n            if state.cumulative_mode {\n                \"Data (Up / Down)\"\n            } else {\n                \"Rate (Up / Down)\"\n            },\n        ];\n        let rows = state\n            .remote_addresses\n            .iter()\n            .map(|(remote_address, data_for_remote_address)| {\n                let remote_address = display_ip_or_host(*remote_address, ip_to_host);\n                [\n                    remote_address,\n                    data_for_remote_address.connection_count.to_string(),\n                    display_upload_and_download(\n                        data_for_remote_address,\n                        state.unit_family,\n                        state.cumulative_mode,\n                    ),\n                ]\n            })\n            .collect();\n        let column_selector = Rc::new(|layout: &D| match layout {\n            D::C2(_) => vec![0, 2],\n            D::C3(_) => vec![0, 1, 2],\n            D::C4(_) => unreachable!(),\n        });\n\n        Table {\n            title,\n            width_cutoffs,\n            data: NColsTableData {\n                column_names,\n                rows,\n                column_selector,\n            }\n            .into(),\n        }\n    }\n\n    /// See [`Table`] for layout rules.\n    pub fn render(&self, frame: &mut Frame, rect: Rect) {\n        let (computed_layout, spacer_width) = {\n            // pick the largest possible layout, constrained by the available width\n            let &(_, layout) = self\n                .width_cutoffs\n                .iter()\n                .rev()\n                .find(|(cutoff, _)| rect.width > *cutoff)\n                .unwrap(); // all cutoff tables have a 0-width entry\n            layout.compute_actual_widths(rect.width)\n        };\n\n        let columns_to_show = self.data.column_selector()(&computed_layout);\n        let column_names: Vec<_> = columns_to_show\n            .iter()\n            .copied()\n            .map(|i| self.data.column_names()[i])\n            .collect();\n\n        // text needs to react to column widths\n        let tui_rows_iter = self\n            .data\n            .rows()\n            .into_iter()\n            .map(|row_data| {\n                let shown_columns_data = columns_to_show.iter().copied().map(|i| &row_data[i]);\n                let column_widths = computed_layout.iter().copied();\n                shown_columns_data\n                    .zip_eq(column_widths)\n                    .map(|(text, width)| truncate_middle(text, width))\n                    .collect::<Vec<_>>()\n            })\n            .map(Row::new);\n\n        let widths_constraints: Vec<_> = computed_layout\n            .iter()\n            .copied()\n            .map(Constraint::Length)\n            .collect();\n\n        let table = ratatui::widgets::Table::new(tui_rows_iter, widths_constraints)\n            .block(Block::default().title(self.title).borders(Borders::ALL))\n            .header(Row::new(column_names).style(Style::default().fg(Color::Yellow)))\n            .flex(ratatui::layout::Flex::Legacy)\n            .column_spacing(spacer_width);\n        frame.render_widget(table, rect);\n    }\n}\n\nfn display_upload_and_download(\n    bandwidth: &impl Bandwidth,\n    unit_family: BandwidthUnitFamily,\n    _cumulative: bool,\n) -> String {\n    let up = DisplayBandwidth {\n        bandwidth: bandwidth.get_total_bytes_uploaded() as f64,\n        unit_family,\n    };\n    let down = DisplayBandwidth {\n        bandwidth: bandwidth.get_total_bytes_downloaded() as f64,\n        unit_family,\n    };\n    format!(\"{up} / {down}\")\n}\n\nfn collect_to_unicode_width<T>(iter: impl Iterator<Item = char>, width: usize) -> T\nwhere\n    T: FromIterator<char>,\n{\n    let mut chunk_width = 0;\n    iter.take_while(|ch| {\n        chunk_width += ch.width().unwrap_or(0);\n        chunk_width <= width\n    })\n    .collect()\n}\n\nfn truncate_middle(row: &str, max_len: u16) -> String {\n    const ELLIPSIS: &str = \"..\";\n\n    if max_len < 6 {\n        collect_to_unicode_width(row.chars(), max_len as usize)\n    } else if row.width() as u16 > max_len {\n        let suffix_len = (max_len as usize - ELLIPSIS.len()) / 2;\n        // remainder length arbitrarily given to prefix\n        let prefix_len = max_len as usize - ELLIPSIS.len() - suffix_len;\n\n        let prefix: String = collect_to_unicode_width(row.chars(), prefix_len);\n        let suffix: String = collect_to_unicode_width::<Vec<_>>(row.chars().rev(), suffix_len)\n            .into_iter()\n            .rev()\n            .collect();\n        format!(\"{prefix}{ELLIPSIS}{suffix}\")\n    } else {\n        row.to_string()\n    }\n}\n"
  },
  {
    "path": "src/display/mod.rs",
    "content": "mod components;\nmod raw_terminal_backend;\nmod ui;\nmod ui_state;\n\npub use components::*;\npub use raw_terminal_backend::*;\npub use ui::*;\npub use ui_state::*;\n"
  },
  {
    "path": "src/display/raw_terminal_backend.rs",
    "content": "// this is a bit of a hack:\n// the TUI backend used by this app changes stdout to raw byte mode.\n// this is not desired when we do not use it (in our --raw mode),\n// since it makes writing to stdout overly complex\n//\n// so what we do here is provide a fake backend (RawTerminalBackend)\n// that implements the Backend TUI trait, but does nothing\n// this way, we don't need to create the TermionBackend\n// and thus skew our stdout when we don't need it\n\nuse std::io;\n\nuse ratatui::{\n    backend::{Backend, WindowSize},\n    buffer::Cell,\n    layout::{Position, Size},\n};\n\npub struct RawTerminalBackend {}\n\nimpl Backend for RawTerminalBackend {\n    fn clear(&mut self) -> io::Result<()> {\n        Ok(())\n    }\n\n    fn hide_cursor(&mut self) -> io::Result<()> {\n        Ok(())\n    }\n\n    fn show_cursor(&mut self) -> io::Result<()> {\n        Ok(())\n    }\n\n    fn get_cursor_position(&mut self) -> io::Result<Position> {\n        Ok(Position::new(0, 0))\n    }\n\n    fn set_cursor_position<P: Into<Position>>(&mut self, _position: P) -> io::Result<()> {\n        Ok(())\n    }\n\n    fn draw<'a, I>(&mut self, _content: I) -> io::Result<()>\n    where\n        I: Iterator<Item = (u16, u16, &'a Cell)>,\n    {\n        Ok(())\n    }\n\n    fn size(&self) -> io::Result<Size> {\n        Ok(Size::new(0, 0))\n    }\n\n    fn window_size(&mut self) -> io::Result<WindowSize> {\n        Ok(WindowSize {\n            columns_rows: Size::default(),\n            pixels: Size::default(),\n        })\n    }\n\n    fn flush(&mut self) -> io::Result<()> {\n        Ok(())\n    }\n}\n"
  },
  {
    "path": "src/display/ui.rs",
    "content": "use std::{collections::HashMap, net::IpAddr, time::Duration};\n\nuse chrono::prelude::*;\nuse ratatui::{backend::Backend, Terminal};\n\nuse crate::{\n    cli::{Opt, RenderOpts},\n    display::{\n        components::{HeaderDetails, HelpText, Layout, Table},\n        UIState,\n    },\n    network::{display_connection_string, display_ip_or_host, LocalSocket, Utilization},\n    os::ProcessInfo,\n};\n\npub struct Ui<B>\nwhere\n    B: Backend,\n{\n    terminal: Terminal<B>,\n    state: UIState,\n    ip_to_host: HashMap<IpAddr, String>,\n    opts: RenderOpts,\n}\n\nimpl<B> Ui<B>\nwhere\n    B: Backend,\n{\n    pub fn new(terminal_backend: B, opts: &Opt) -> Self {\n        let mut terminal = Terminal::new(terminal_backend).unwrap();\n        terminal.clear().unwrap();\n        terminal.hide_cursor().unwrap();\n        let state = {\n            let mut state = UIState::default();\n            state.interface_name.clone_from(&opts.interface);\n            state.unit_family = opts.render_opts.unit_family.into();\n            state.cumulative_mode = opts.render_opts.total_utilization;\n            state.show_dns = opts.show_dns;\n            state\n        };\n        Ui {\n            terminal,\n            state,\n            ip_to_host: Default::default(),\n            opts: opts.render_opts,\n        }\n    }\n    pub fn output_text(&mut self, write_to_stdout: &mut (dyn FnMut(&str) + Send)) {\n        let state = &self.state;\n        let ip_to_host = &self.ip_to_host;\n        let local_time: DateTime<Local> = Local::now();\n        let timestamp = local_time.timestamp();\n        let mut no_traffic = true;\n\n        let output_process_data = |write_to_stdout: &mut (dyn FnMut(&str) + Send),\n                                   no_traffic: &mut bool| {\n            for (proc_info, process_network_data) in &state.processes {\n                write_to_stdout(&format!(\n                    \"process: <{timestamp}> \\\"{}\\\" up/down Bps: {}/{} connections: {}\",\n                    proc_info.name,\n                    process_network_data.total_bytes_uploaded,\n                    process_network_data.total_bytes_downloaded,\n                    process_network_data.connection_count\n                ));\n                *no_traffic = false;\n            }\n        };\n\n        let output_connections_data =\n            |write_to_stdout: &mut (dyn FnMut(&str) + Send), no_traffic: &mut bool| {\n                for (connection, connection_network_data) in &state.connections {\n                    write_to_stdout(&format!(\n                        \"connection: <{timestamp}> {} up/down Bps: {}/{} process: \\\"{}\\\"\",\n                        display_connection_string(\n                            connection,\n                            ip_to_host,\n                            &connection_network_data.interface_name,\n                        ),\n                        connection_network_data.total_bytes_uploaded,\n                        connection_network_data.total_bytes_downloaded,\n                        connection_network_data.process_name\n                    ));\n                    *no_traffic = false;\n                }\n            };\n\n        let output_adressess_data = |write_to_stdout: &mut (dyn FnMut(&str) + Send),\n                                     no_traffic: &mut bool| {\n            for (remote_address, remote_address_network_data) in &state.remote_addresses {\n                write_to_stdout(&format!(\n                    \"remote_address: <{timestamp}> {} up/down Bps: {}/{} connections: {}\",\n                    display_ip_or_host(*remote_address, ip_to_host),\n                    remote_address_network_data.total_bytes_uploaded,\n                    remote_address_network_data.total_bytes_downloaded,\n                    remote_address_network_data.connection_count\n                ));\n                *no_traffic = false;\n            }\n        };\n\n        // header\n        write_to_stdout(\"Refreshing:\");\n\n        // body1\n        if self.opts.processes {\n            output_process_data(write_to_stdout, &mut no_traffic);\n        }\n        if self.opts.connections {\n            output_connections_data(write_to_stdout, &mut no_traffic);\n        }\n        if self.opts.addresses {\n            output_adressess_data(write_to_stdout, &mut no_traffic);\n        }\n        if !(self.opts.processes || self.opts.connections || self.opts.addresses) {\n            output_process_data(write_to_stdout, &mut no_traffic);\n            output_connections_data(write_to_stdout, &mut no_traffic);\n            output_adressess_data(write_to_stdout, &mut no_traffic);\n        }\n\n        // body2: In case no traffic is detected\n        if no_traffic {\n            write_to_stdout(\"<NO TRAFFIC>\");\n        }\n\n        // footer\n        write_to_stdout(\"\");\n    }\n\n    pub fn draw(&mut self, paused: bool, elapsed_time: Duration, table_cycle_offset: usize) {\n        let layout = Layout {\n            header: HeaderDetails {\n                state: &self.state,\n                elapsed_time,\n                paused,\n            },\n            children: self.get_tables_to_display(),\n            footer: HelpText {\n                paused,\n                show_dns: self.state.show_dns,\n            },\n        };\n        self.terminal\n            .draw(|frame| layout.render(frame, frame.area(), table_cycle_offset))\n            .unwrap();\n    }\n\n    fn get_tables_to_display(&self) -> Vec<Table> {\n        let opts = &self.opts;\n        let mut children: Vec<Table> = Vec::new();\n        if opts.processes {\n            children.push(Table::create_processes_table(&self.state));\n        }\n        if opts.addresses {\n            children.push(Table::create_remote_addresses_table(\n                &self.state,\n                &self.ip_to_host,\n            ));\n        }\n        if opts.connections {\n            children.push(Table::create_connections_table(\n                &self.state,\n                &self.ip_to_host,\n            ));\n        }\n        if !(opts.processes || opts.addresses || opts.connections) {\n            children = vec![\n                Table::create_processes_table(&self.state),\n                Table::create_remote_addresses_table(&self.state, &self.ip_to_host),\n                Table::create_connections_table(&self.state, &self.ip_to_host),\n            ];\n        }\n        children\n    }\n\n    pub fn get_table_count(&self) -> usize {\n        self.get_tables_to_display().len()\n    }\n\n    pub fn update_state(\n        &mut self,\n        connections_to_procs: HashMap<LocalSocket, ProcessInfo>,\n        utilization: Utilization,\n        ip_to_host: HashMap<IpAddr, String>,\n    ) {\n        self.state.update(connections_to_procs, utilization);\n        self.ip_to_host.extend(ip_to_host);\n    }\n    pub fn end(&mut self) {\n        self.terminal.show_cursor().unwrap();\n    }\n}\n"
  },
  {
    "path": "src/display/ui_state.rs",
    "content": "use std::{\n    cmp,\n    collections::{HashMap, HashSet, VecDeque},\n    hash::Hash,\n    net::{IpAddr, Ipv4Addr, Ipv6Addr},\n};\n\nuse log::warn;\n\nuse crate::{\n    display::BandwidthUnitFamily,\n    network::{Connection, LocalSocket, Utilization},\n    os::ProcessInfo,\n};\n\nstatic RECALL_LENGTH: usize = 5;\nstatic MAX_BANDWIDTH_ITEMS: usize = 1000;\n\npub trait Bandwidth {\n    fn get_total_bytes_downloaded(&self) -> u128;\n    fn get_total_bytes_uploaded(&self) -> u128;\n    fn combine_bandwidth(&mut self, other: &Self);\n    fn divide_by(&mut self, amount: u128);\n}\n\n#[derive(Clone, Default)]\npub struct NetworkData {\n    pub total_bytes_downloaded: u128,\n    pub total_bytes_uploaded: u128,\n    pub connection_count: u128,\n}\n\n#[derive(Clone, Default)]\npub struct ConnectionData {\n    pub total_bytes_downloaded: u128,\n    pub total_bytes_uploaded: u128,\n    pub process_name: String,\n    pub interface_name: String,\n}\n\nimpl Bandwidth for NetworkData {\n    fn get_total_bytes_downloaded(&self) -> u128 {\n        self.total_bytes_downloaded\n    }\n    fn get_total_bytes_uploaded(&self) -> u128 {\n        self.total_bytes_uploaded\n    }\n    fn combine_bandwidth(&mut self, other: &NetworkData) {\n        self.total_bytes_downloaded += other.get_total_bytes_downloaded();\n        self.total_bytes_uploaded += other.get_total_bytes_uploaded();\n        self.connection_count = other.connection_count;\n    }\n    fn divide_by(&mut self, amount: u128) {\n        self.total_bytes_downloaded /= amount;\n        self.total_bytes_uploaded /= amount;\n    }\n}\n\nimpl Bandwidth for ConnectionData {\n    fn get_total_bytes_downloaded(&self) -> u128 {\n        self.total_bytes_downloaded\n    }\n    fn get_total_bytes_uploaded(&self) -> u128 {\n        self.total_bytes_uploaded\n    }\n    fn combine_bandwidth(&mut self, other: &ConnectionData) {\n        self.total_bytes_downloaded += other.get_total_bytes_downloaded();\n        self.total_bytes_uploaded += other.get_total_bytes_uploaded();\n    }\n    fn divide_by(&mut self, amount: u128) {\n        self.total_bytes_downloaded /= amount;\n        self.total_bytes_uploaded /= amount;\n    }\n}\n\npub struct UtilizationData {\n    connections_to_procs: HashMap<LocalSocket, ProcessInfo>,\n    network_utilization: Utilization,\n}\n\n#[derive(Default)]\npub struct UIState {\n    /// The interface name in single-interface mode. `None` means all interfaces.\n    pub interface_name: Option<String>,\n    pub processes: Vec<(ProcessInfo, NetworkData)>,\n    pub remote_addresses: Vec<(IpAddr, NetworkData)>,\n    pub connections: Vec<(Connection, ConnectionData)>,\n    pub total_bytes_downloaded: u128,\n    pub total_bytes_uploaded: u128,\n    pub cumulative_mode: bool,\n    pub show_dns: bool,\n    pub unit_family: BandwidthUnitFamily,\n    pub utilization_data: VecDeque<UtilizationData>,\n    pub processes_map: HashMap<ProcessInfo, NetworkData>,\n    pub remote_addresses_map: HashMap<IpAddr, NetworkData>,\n    pub connections_map: HashMap<Connection, ConnectionData>,\n    /// Used for reducing logging noise.\n    known_orphan_sockets: VecDeque<LocalSocket>,\n}\n\nimpl UIState {\n    pub fn update(\n        &mut self,\n        connections_to_procs: HashMap<LocalSocket, ProcessInfo>,\n        network_utilization: Utilization,\n    ) {\n        self.utilization_data.push_back(UtilizationData {\n            connections_to_procs,\n            network_utilization,\n        });\n        if self.utilization_data.len() > RECALL_LENGTH {\n            self.utilization_data.pop_front();\n        }\n        let mut processes: HashMap<ProcessInfo, NetworkData> = HashMap::new();\n        let mut remote_addresses: HashMap<IpAddr, NetworkData> = HashMap::new();\n        let mut connections: HashMap<Connection, ConnectionData> = HashMap::new();\n        let mut total_bytes_downloaded: u128 = 0;\n        let mut total_bytes_uploaded: u128 = 0;\n\n        let mut seen_connections = HashSet::new();\n        for state in self.utilization_data.iter().rev() {\n            let connections_to_procs = &state.connections_to_procs;\n            let network_utilization = &state.network_utilization;\n\n            for (connection, connection_info) in &network_utilization.connections {\n                let connection_previously_seen = !seen_connections.insert(connection);\n                let connection_data = connections.entry(*connection).or_default();\n                let data_for_remote_address = remote_addresses\n                    .entry(connection.remote_socket.ip)\n                    .or_default();\n                connection_data.total_bytes_downloaded += connection_info.total_bytes_downloaded;\n                connection_data.total_bytes_uploaded += connection_info.total_bytes_uploaded;\n                connection_data\n                    .interface_name\n                    .clone_from(&connection_info.interface_name);\n                data_for_remote_address.total_bytes_downloaded +=\n                    connection_info.total_bytes_downloaded;\n                data_for_remote_address.total_bytes_uploaded +=\n                    connection_info.total_bytes_uploaded;\n                if !connection_previously_seen {\n                    data_for_remote_address.connection_count += 1;\n                }\n                total_bytes_downloaded += connection_info.total_bytes_downloaded;\n                total_bytes_uploaded += connection_info.total_bytes_uploaded;\n\n                let data_for_process = {\n                    let local_socket = connection.local_socket;\n                    let proc_info = get_proc_info(connections_to_procs, &local_socket);\n\n                    // only log each orphan connection once\n                    if proc_info.is_none() && !self.known_orphan_sockets.contains(&local_socket) {\n                        // newer connections go in the front so that searches are faster\n                        // basically recency bias\n                        self.known_orphan_sockets.push_front(local_socket);\n                        self.known_orphan_sockets.truncate(10_000); // arbitrary maximum backlog\n\n                        match connections_to_procs\n                            .iter()\n                            .find(|(&LocalSocket { port, protocol, .. }, _)| {\n                                port == local_socket.port && protocol == local_socket.protocol\n                            })\n                            .and_then(|(local_conn_lookalike, info)| {\n                                network_utilization\n                                    .connections\n                                    .keys()\n                                    .find(|conn| &conn.local_socket == local_conn_lookalike)\n                                    .map(|conn| (conn, info))\n                            }) {\n                            Some((lookalike, proc_info)) => {\n                                warn!(\n                                    r#\"\"{0}\" owns a similar looking connection, but its local ip doesn't match.\"#,\n                                    proc_info.name\n                                );\n                                warn!(\"Looking for: {connection:?}; found: {lookalike:?}\");\n                            }\n                            None => {\n                                warn!(\"Cannot determine which process owns {connection:?}\");\n                            }\n                        };\n                    }\n\n                    let proc_info = proc_info\n                        .cloned()\n                        .unwrap_or_else(|| ProcessInfo::new(\"<UNKNOWN>\", 0));\n                    connection_data.process_name.clone_from(&proc_info.name);\n                    processes.entry(proc_info).or_default()\n                };\n\n                data_for_process.total_bytes_downloaded += connection_info.total_bytes_downloaded;\n                data_for_process.total_bytes_uploaded += connection_info.total_bytes_uploaded;\n                if !connection_previously_seen {\n                    data_for_process.connection_count += 1;\n                }\n            }\n        }\n        let divide_by = if self.utilization_data.is_empty() {\n            1_u128\n        } else {\n            self.utilization_data.len() as u128\n        };\n        for (_, network_data) in processes.iter_mut() {\n            network_data.divide_by(divide_by)\n        }\n        for (_, network_data) in remote_addresses.iter_mut() {\n            network_data.divide_by(divide_by)\n        }\n        for (_, connection_data) in connections.iter_mut() {\n            connection_data.divide_by(divide_by)\n        }\n\n        if self.cumulative_mode {\n            merge_bandwidth(&mut self.processes_map, processes);\n            merge_bandwidth(&mut self.remote_addresses_map, remote_addresses);\n            merge_bandwidth(&mut self.connections_map, connections);\n            self.total_bytes_downloaded += total_bytes_downloaded / divide_by;\n            self.total_bytes_uploaded += total_bytes_uploaded / divide_by;\n        } else {\n            self.processes_map = processes;\n            self.remote_addresses_map = remote_addresses;\n            self.connections_map = connections;\n            self.total_bytes_downloaded = total_bytes_downloaded / divide_by;\n            self.total_bytes_uploaded = total_bytes_uploaded / divide_by;\n        }\n        self.processes = sort_and_prune(&mut self.processes_map);\n        self.remote_addresses = sort_and_prune(&mut self.remote_addresses_map);\n        self.connections = sort_and_prune(&mut self.connections_map);\n    }\n}\n\nfn get_proc_info<'a>(\n    connections_to_procs: &'a HashMap<LocalSocket, ProcessInfo>,\n    local_socket: &LocalSocket,\n) -> Option<&'a ProcessInfo> {\n    connections_to_procs\n        // direct match\n        .get(local_socket)\n        // IPv4-mapped IPv6 addresses\n        .or_else(|| {\n            let swapped: IpAddr = match local_socket.ip {\n                IpAddr::V4(v4) => v4.to_ipv6_mapped().into(),\n                IpAddr::V6(v6) => v6.to_ipv4_mapped()?.into(),\n            };\n            connections_to_procs.get(&LocalSocket {\n                ip: swapped,\n                ..*local_socket\n            })\n        })\n        // address unspecified\n        .or_else(|| {\n            connections_to_procs.get(&LocalSocket {\n                ip: Ipv4Addr::UNSPECIFIED.into(),\n                ..*local_socket\n            })\n        })\n        .or_else(|| {\n            connections_to_procs.get(&LocalSocket {\n                ip: Ipv6Addr::UNSPECIFIED.into(),\n                ..*local_socket\n            })\n        })\n}\n\nfn merge_bandwidth<K, V>(self_map: &mut HashMap<K, V>, other_map: HashMap<K, V>)\nwhere\n    K: Eq + Hash,\n    V: Bandwidth,\n{\n    for (key, b_other) in other_map {\n        self_map\n            .entry(key)\n            .and_modify(|b_self| b_self.combine_bandwidth(&b_other))\n            .or_insert(b_other);\n    }\n}\n\nfn sort_and_prune<K, V>(map: &mut HashMap<K, V>) -> Vec<(K, V)>\nwhere\n    K: Eq + Hash + Clone,\n    V: Bandwidth + Clone,\n{\n    let mut bandwidth_list = Vec::from_iter(map.clone());\n    bandwidth_list.sort_by_key(|(_, b)| {\n        cmp::Reverse(b.get_total_bytes_downloaded() + b.get_total_bytes_uploaded())\n    });\n\n    if bandwidth_list.len() > MAX_BANDWIDTH_ITEMS {\n        for (key, _) in &bandwidth_list[MAX_BANDWIDTH_ITEMS..] {\n            map.remove(key);\n        }\n    }\n\n    bandwidth_list\n}\n"
  },
  {
    "path": "src/main.rs",
    "content": "#![deny(clippy::enum_glob_use)]\n\nmod cli;\nmod display;\nmod network;\nmod os;\n#[cfg(test)]\nmod tests;\n\nuse std::{\n    collections::HashMap,\n    fs::File,\n    sync::{\n        atomic::{AtomicBool, AtomicUsize, Ordering},\n        Arc, Mutex, RwLock,\n    },\n    thread::{self, park_timeout},\n    time::{Duration, Instant},\n};\n\nuse clap::Parser;\nuse crossterm::{\n    event::{Event, KeyCode, KeyEvent, KeyEventKind, KeyModifiers},\n    terminal,\n};\nuse display::{elapsed_time, RawTerminalBackend, Ui};\nuse eyre::bail;\nuse network::{\n    dns::{self, IpTable},\n    LocalSocket, Sniffer, Utilization,\n};\nuse pnet::datalink::{DataLinkReceiver, NetworkInterface};\nuse ratatui::backend::{Backend, CrosstermBackend};\nuse simplelog::WriteLogger;\n\nuse crate::cli::Opt;\nuse crate::os::ProcessInfo;\n\nconst DISPLAY_DELTA: Duration = Duration::from_millis(1000);\n\nfn main() -> eyre::Result<()> {\n    let opts = Opt::parse();\n\n    // init logging\n    if let Some(ref log_path) = opts.log_to {\n        let log_file = File::options()\n            .write(true)\n            .create_new(true)\n            .open(log_path)?;\n        WriteLogger::init(\n            opts.verbosity.log_level_filter(),\n            Default::default(),\n            log_file,\n        )?;\n    }\n\n    let os_input = os::get_input(opts.interface.as_deref(), !opts.no_resolve, opts.dns_server)?;\n    if opts.raw {\n        let terminal_backend = RawTerminalBackend {};\n        start(terminal_backend, os_input, opts);\n    } else {\n        let Ok(()) = terminal::enable_raw_mode() else {\n            bail!(\n                \"Failed to get stdout: if you are trying to pipe 'bandwhich' you should use the --raw flag\"\n            )\n        };\n\n        let mut stdout = std::io::stdout();\n        // Ignore enteralternatescreen error\n        let _ = crossterm::execute!(&mut stdout, terminal::EnterAlternateScreen);\n        let terminal_backend = CrosstermBackend::new(stdout);\n        start(terminal_backend, os_input, opts);\n\n        // Ensure terminal is restored after exit (handles SIGINT case).\n        // These operations are idempotent, so safe to call even if 'q' already cleaned up.\n        let _ = terminal::disable_raw_mode();\n        let _ = crossterm::execute!(std::io::stdout(), terminal::LeaveAlternateScreen);\n    }\n    Ok(())\n}\n\npub struct OpenSockets {\n    sockets_to_procs: HashMap<LocalSocket, ProcessInfo>,\n}\n\npub struct OsInputOutput {\n    pub interfaces_with_frames: Vec<(NetworkInterface, Box<dyn DataLinkReceiver>)>,\n    pub get_open_sockets: fn() -> OpenSockets,\n    pub terminal_events: Box<dyn Iterator<Item = Event> + Send>,\n    pub dns_client: Option<dns::Client>,\n    pub write_to_stdout: Box<dyn FnMut(&str) + Send>,\n}\n\npub fn start<B>(terminal_backend: B, os_input: OsInputOutput, opts: Opt)\nwhere\n    B: Backend + Send + 'static,\n{\n    let running = Arc::new(AtomicBool::new(true));\n    let paused = Arc::new(AtomicBool::new(false));\n    let last_start_time = Arc::new(RwLock::new(Instant::now()));\n    let cumulative_time = Arc::new(RwLock::new(Duration::new(0, 0)));\n    let table_cycle_offset = Arc::new(AtomicUsize::new(0));\n\n    // handle SIGINT properly instead of as a keypress\n    // see https://github.com/imsnif/bandwhich/issues/487\n    #[cfg(not(test))]\n    {\n        let running = running.clone();\n        ctrlc::set_handler(move || {\n            running.store(false, Ordering::Release);\n        })\n        .expect(\"failed to set SIGINT handler\");\n    }\n\n    let mut active_threads = vec![];\n\n    let terminal_events = os_input.terminal_events;\n    let get_open_sockets = os_input.get_open_sockets;\n    let mut write_to_stdout = os_input.write_to_stdout;\n    let mut dns_client = os_input.dns_client;\n\n    let raw_mode = opts.raw;\n\n    let network_utilization = Arc::new(Mutex::new(Utilization::new()));\n    let ui = Arc::new(Mutex::new(Ui::new(terminal_backend, &opts)));\n\n    let display_handler = thread::Builder::new()\n        .name(\"display_handler\".to_string())\n        .spawn({\n            let running = running.clone();\n            let paused = paused.clone();\n            let table_cycle_offset = table_cycle_offset.clone();\n\n            let network_utilization = network_utilization.clone();\n            let last_start_time = last_start_time.clone();\n            let cumulative_time = cumulative_time.clone();\n            let ui = ui.clone();\n\n            move || {\n                while running.load(Ordering::Acquire) {\n                    let render_start_time = Instant::now();\n                    let utilization = network_utilization.lock().unwrap().clone_and_reset();\n                    let OpenSockets { sockets_to_procs } = get_open_sockets();\n                    let mut ip_to_host = IpTable::new();\n                    if let Some(dns_client) = dns_client.as_mut() {\n                        ip_to_host = dns_client.cache();\n                        let unresolved_ips = utilization\n                            .connections\n                            .keys()\n                            .filter(|conn| !ip_to_host.contains_key(&conn.remote_socket.ip))\n                            .map(|conn| conn.remote_socket.ip)\n                            .collect::<Vec<_>>();\n                        dns_client.resolve(unresolved_ips);\n                    }\n                    {\n                        let mut ui = ui.lock().unwrap();\n                        let paused = paused.load(Ordering::SeqCst);\n                        let table_cycle_offset = table_cycle_offset.load(Ordering::SeqCst);\n                        if !paused {\n                            ui.update_state(sockets_to_procs, utilization, ip_to_host);\n                        }\n                        let elapsed_time = elapsed_time(\n                            *last_start_time.read().unwrap(),\n                            *cumulative_time.read().unwrap(),\n                            paused,\n                        );\n\n                        if raw_mode {\n                            ui.output_text(&mut write_to_stdout);\n                        } else {\n                            ui.draw(paused, elapsed_time, table_cycle_offset);\n                        }\n                    }\n                    let render_duration = render_start_time.elapsed();\n                    if render_duration < DISPLAY_DELTA {\n                        park_timeout(DISPLAY_DELTA - render_duration);\n                    }\n                }\n                if !raw_mode {\n                    let mut ui = ui.lock().unwrap();\n                    ui.end();\n                }\n            }\n        })\n        .unwrap();\n\n    let terminal_event_handler = thread::Builder::new()\n        .name(\"terminal_events_handler\".to_string())\n        .spawn({\n            let running = running.clone();\n            let display_handler = display_handler.thread().clone();\n\n            move || {\n                let mut terminal_events = terminal_events;\n                while running.load(Ordering::Acquire) {\n                    let Some(evt) = terminal_events.next() else {\n                        continue;\n                    };\n                    let mut ui = ui.lock().unwrap();\n\n                    match evt {\n                        Event::Resize(_x, _y) if !raw_mode => {\n                            let paused = paused.load(Ordering::SeqCst);\n                            ui.draw(\n                                paused,\n                                elapsed_time(\n                                    *last_start_time.read().unwrap(),\n                                    *cumulative_time.read().unwrap(),\n                                    paused,\n                                ),\n                                table_cycle_offset.load(Ordering::SeqCst),\n                            );\n                        }\n                        Event::Key(KeyEvent {\n                            modifiers: KeyModifiers::NONE,\n                            code: KeyCode::Char('q'),\n                            kind: KeyEventKind::Press,\n                            ..\n                        }) => {\n                            running.store(false, Ordering::Release);\n                            display_handler.unpark();\n                            match terminal::disable_raw_mode() {\n                                Ok(_) => {}\n                                Err(_) => println!(\"Error could not disable raw input\"),\n                            }\n                            let mut stdout = std::io::stdout();\n                            if crossterm::execute!(&mut stdout, terminal::LeaveAlternateScreen)\n                                .is_err()\n                            {\n                                println!(\"Error could not leave alternte screen\");\n                            };\n                            break;\n                        }\n                        Event::Key(KeyEvent {\n                            modifiers: KeyModifiers::NONE,\n                            code: KeyCode::Char(' '),\n                            kind: KeyEventKind::Press,\n                            ..\n                        }) => {\n                            let restarting = paused.fetch_xor(true, Ordering::SeqCst);\n                            if restarting {\n                                *last_start_time.write().unwrap() = Instant::now();\n                            } else {\n                                let last_start_time_copy = *last_start_time.read().unwrap();\n                                let current_cumulative_time_copy = *cumulative_time.read().unwrap();\n                                let new_cumulative_time =\n                                    current_cumulative_time_copy + last_start_time_copy.elapsed();\n                                *cumulative_time.write().unwrap() = new_cumulative_time;\n                            }\n\n                            display_handler.unpark();\n                        }\n                        Event::Key(KeyEvent {\n                            modifiers: KeyModifiers::NONE,\n                            code: KeyCode::Tab,\n                            kind: KeyEventKind::Press,\n                            ..\n                        }) => {\n                            let paused = paused.load(Ordering::SeqCst);\n                            let elapsed_time = elapsed_time(\n                                *last_start_time.read().unwrap(),\n                                *cumulative_time.read().unwrap(),\n                                paused,\n                            );\n                            let table_count = ui.get_table_count();\n                            let new = table_cycle_offset.load(Ordering::SeqCst) + 1 % table_count;\n                            table_cycle_offset.store(new, Ordering::SeqCst);\n                            ui.draw(paused, elapsed_time, new);\n                        }\n                        _ => (),\n                    };\n                }\n            }\n        })\n        .unwrap();\n\n    active_threads.push(display_handler);\n    active_threads.push(terminal_event_handler);\n\n    let sniffer_threads = os_input\n        .interfaces_with_frames\n        .into_iter()\n        .map(|(iface, frames)| {\n            let name = format!(\"sniffing_handler_{}\", iface.name);\n            let running = running.clone();\n            let show_dns = opts.show_dns;\n            let network_utilization = network_utilization.clone();\n\n            thread::Builder::new()\n                .name(name)\n                .spawn(move || {\n                    let mut sniffer = Sniffer::new(iface, frames, show_dns);\n\n                    while running.load(Ordering::Acquire) {\n                        if let Some(segment) = sniffer.next() {\n                            network_utilization.lock().unwrap().ingest(segment);\n                        }\n                    }\n                })\n                .unwrap()\n        })\n        .collect::<Vec<_>>();\n    active_threads.extend(sniffer_threads);\n\n    for thread_handler in active_threads {\n        thread_handler.join().unwrap()\n    }\n}\n"
  },
  {
    "path": "src/network/connection.rs",
    "content": "use std::{\n    collections::HashMap,\n    fmt,\n    net::{IpAddr, SocketAddr},\n};\n\n#[derive(PartialEq, Hash, Eq, Clone, PartialOrd, Ord, Debug, Copy)]\npub enum Protocol {\n    Tcp,\n    Udp,\n}\n\nimpl Protocol {\n    #[allow(dead_code)]\n    pub fn from_str(string: &str) -> Option<Self> {\n        match string {\n            \"TCP\" => Some(Protocol::Tcp),\n            \"UDP\" => Some(Protocol::Udp),\n            _ => None,\n        }\n    }\n}\n\nimpl fmt::Display for Protocol {\n    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {\n        match *self {\n            Protocol::Tcp => write!(f, \"tcp\"),\n            Protocol::Udp => write!(f, \"udp\"),\n        }\n    }\n}\n\n#[derive(Clone, Ord, PartialOrd, PartialEq, Eq, Hash, Copy)]\npub struct Socket {\n    pub ip: IpAddr,\n    pub port: u16,\n}\n\nimpl fmt::Debug for Socket {\n    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\n        let Socket { ip, port } = self;\n        match ip {\n            IpAddr::V4(v4) => write!(f, \"{v4}:{port}\"),\n            IpAddr::V6(v6) => write!(f, \"[{v6}]:{port}\"),\n        }\n    }\n}\n\n#[derive(PartialEq, Hash, Eq, Clone, PartialOrd, Ord, Copy)]\npub struct LocalSocket {\n    pub ip: IpAddr,\n    pub port: u16,\n    pub protocol: Protocol,\n}\n\nimpl fmt::Debug for LocalSocket {\n    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\n        let LocalSocket { ip, port, protocol } = self;\n        match ip {\n            IpAddr::V4(v4) => write!(f, \"{protocol}://{v4}:{port}\"),\n            IpAddr::V6(v6) => write!(f, \"{protocol}://[{v6}]:{port}\"),\n        }\n    }\n}\n\n#[derive(PartialEq, Hash, Eq, Clone, PartialOrd, Ord, Copy)]\npub struct Connection {\n    pub remote_socket: Socket,\n    pub local_socket: LocalSocket,\n}\n\nimpl fmt::Debug for Connection {\n    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\n        let Connection {\n            remote_socket,\n            local_socket,\n        } = self;\n        write!(f, \"{local_socket:?} => {remote_socket:?}\")\n    }\n}\n\npub fn display_ip_or_host(ip: IpAddr, ip_to_host: &HashMap<IpAddr, String>) -> String {\n    match ip_to_host.get(&ip) {\n        Some(host) => host.clone(),\n        None => ip.to_string(),\n    }\n}\n\npub fn display_connection_string(\n    connection: &Connection,\n    ip_to_host: &HashMap<IpAddr, String>,\n    interface_name: &str,\n) -> String {\n    format!(\n        \"<{interface_name}>:{} => {}:{} ({})\",\n        connection.local_socket.port,\n        display_ip_or_host(connection.remote_socket.ip, ip_to_host),\n        connection.remote_socket.port,\n        connection.local_socket.protocol,\n    )\n}\n\nimpl Connection {\n    pub fn new(\n        remote_socket: SocketAddr,\n        local_ip: IpAddr,\n        local_port: u16,\n        protocol: Protocol,\n    ) -> Self {\n        Connection {\n            remote_socket: Socket {\n                ip: remote_socket.ip(),\n                port: remote_socket.port(),\n            },\n            local_socket: LocalSocket {\n                ip: local_ip,\n                port: local_port,\n                protocol,\n            },\n        }\n    }\n}\n"
  },
  {
    "path": "src/network/dns/client.rs",
    "content": "use std::{\n    collections::HashSet,\n    net::IpAddr,\n    sync::{Arc, Mutex},\n    thread::{Builder, JoinHandle},\n};\n\nuse tokio::{\n    runtime::Runtime,\n    sync::mpsc::{self, Sender},\n};\n\nuse crate::network::dns::{resolver::Lookup, IpTable};\n\ntype PendingAddrs = HashSet<IpAddr>;\n\nconst CHANNEL_SIZE: usize = 1_000;\n\npub struct Client {\n    cache: Arc<Mutex<IpTable>>,\n    pending: Arc<Mutex<PendingAddrs>>,\n    tx: Option<Sender<Vec<IpAddr>>>,\n    handle: Option<JoinHandle<()>>,\n}\n\nimpl Client {\n    pub fn new<R>(resolver: R, runtime: Runtime) -> eyre::Result<Self>\n    where\n        R: Lookup + Send + Sync + 'static,\n    {\n        let cache = Arc::new(Mutex::new(IpTable::new()));\n        let pending = Arc::new(Mutex::new(PendingAddrs::new()));\n        let (tx, mut rx) = mpsc::channel::<Vec<IpAddr>>(CHANNEL_SIZE);\n\n        let handle = Builder::new().name(\"resolver\".into()).spawn({\n            let cache = cache.clone();\n            let pending = pending.clone();\n            move || {\n                runtime.block_on(async {\n                    let resolver = Arc::new(resolver);\n\n                    while let Some(ips) = rx.recv().await {\n                        for ip in ips {\n                            tokio::spawn({\n                                let resolver = resolver.clone();\n                                let cache = cache.clone();\n                                let pending = pending.clone();\n\n                                async move {\n                                    if let Some(name) = resolver.lookup(ip).await {\n                                        cache.lock().unwrap().insert(ip, name);\n                                    }\n                                    pending.lock().unwrap().remove(&ip);\n                                }\n                            });\n                        }\n                    }\n                });\n            }\n        })?;\n\n        Ok(Self {\n            cache,\n            pending,\n            tx: Some(tx),\n            handle: Some(handle),\n        })\n    }\n\n    pub fn resolve(&mut self, ips: Vec<IpAddr>) {\n        // Remove ips that are already being resolved\n        let ips = ips\n            .into_iter()\n            .filter(|ip| self.pending.lock().unwrap().insert(*ip))\n            .collect::<Vec<_>>();\n\n        if !ips.is_empty() {\n            // Discard the message if the channel is full; it will be retried eventually\n            let _ = self.tx.as_mut().unwrap().try_send(ips);\n        }\n    }\n\n    pub fn cache(&mut self) -> IpTable {\n        let cache = self.cache.lock().unwrap();\n        cache.clone()\n    }\n}\n\nimpl Drop for Client {\n    fn drop(&mut self) {\n        // Do the Option dance to be able to drop the sender so that the receiver finishes and the thread can be joined\n        drop(self.tx.take().unwrap());\n        self.handle.take().unwrap().join().unwrap();\n    }\n}\n"
  },
  {
    "path": "src/network/dns/mod.rs",
    "content": "use std::{collections::HashMap, net::IpAddr};\n\nmod client;\nmod resolver;\n\npub use client::*;\npub use resolver::*;\n\npub type IpTable = HashMap<IpAddr, String>;\n"
  },
  {
    "path": "src/network/dns/resolver.rs",
    "content": "use std::net::{IpAddr, Ipv4Addr, SocketAddr, SocketAddrV4};\n\nuse async_trait::async_trait;\nuse trust_dns_resolver::{\n    config::{NameServerConfig, Protocol, ResolverConfig, ResolverOpts},\n    error::ResolveErrorKind,\n    TokioAsyncResolver,\n};\n\n#[async_trait]\npub trait Lookup {\n    async fn lookup(&self, ip: IpAddr) -> Option<String>;\n}\n\npub struct Resolver(TokioAsyncResolver);\n\nimpl Resolver {\n    pub async fn new(dns_server: Option<Ipv4Addr>) -> eyre::Result<Self> {\n        let resolver = match dns_server {\n            Some(dns_server_address) => {\n                let mut config = ResolverConfig::new();\n                let options = ResolverOpts::default();\n                let socket = SocketAddr::V4(SocketAddrV4::new(dns_server_address, 53));\n                let nameserver_config = NameServerConfig {\n                    socket_addr: socket,\n                    protocol: Protocol::Udp,\n                    tls_dns_name: None,\n                    trust_negative_responses: false,\n                    bind_addr: None,\n                };\n                config.add_name_server(nameserver_config);\n                TokioAsyncResolver::tokio(config, options)\n            }\n            None => TokioAsyncResolver::tokio_from_system_conf()?,\n        };\n        Ok(Self(resolver))\n    }\n}\n\n#[async_trait]\nimpl Lookup for Resolver {\n    async fn lookup(&self, ip: IpAddr) -> Option<String> {\n        let lookup_future = self.0.reverse_lookup(ip);\n        match lookup_future.await {\n            Ok(names) => {\n                // Take the first result and convert it to a string\n                names.into_iter().next().map(|name| name.to_string())\n            }\n            Err(e) => match e.kind() {\n                // If the IP is not associated with a hostname, store the IP\n                // so that we don't retry indefinitely\n                ResolveErrorKind::NoRecordsFound { .. } => Some(ip.to_string()),\n                _ => None,\n            },\n        }\n    }\n}\n"
  },
  {
    "path": "src/network/mod.rs",
    "content": "mod connection;\npub mod dns;\nmod sniffer;\nmod utilization;\n\npub use connection::*;\npub use sniffer::*;\npub use utilization::*;\n"
  },
  {
    "path": "src/network/sniffer.rs",
    "content": "use std::{\n    io::{self, Result},\n    net::{IpAddr, SocketAddr},\n    thread::park_timeout,\n    time::Duration,\n};\n\nuse pnet::{\n    datalink::{DataLinkReceiver, NetworkInterface},\n    ipnetwork::IpNetwork,\n    packet::{\n        ethernet::{EtherTypes, EthernetPacket},\n        ip::{IpNextHeaderProtocol, IpNextHeaderProtocols},\n        ipv4::Ipv4Packet,\n        ipv6::Ipv6Packet,\n        tcp::TcpPacket,\n        udp::UdpPacket,\n        Packet,\n    },\n};\n\nuse crate::{\n    network::{Connection, Protocol},\n    os::shared::get_datalink_channel,\n};\n\nconst PACKET_WAIT_TIMEOUT: Duration = Duration::from_millis(10);\nconst CHANNEL_RESET_DELAY: Duration = Duration::from_millis(1000);\n\n#[derive(Debug)]\npub struct Segment {\n    pub interface_name: String,\n    pub connection: Connection,\n    pub direction: Direction,\n    pub data_length: u128,\n}\n\n#[derive(PartialEq, Hash, Eq, Debug, Clone, PartialOrd)]\npub enum Direction {\n    Download,\n    Upload,\n}\n\nimpl Direction {\n    pub fn new(network_interface_ips: &[IpNetwork], source: IpAddr) -> Self {\n        if network_interface_ips\n            .iter()\n            .any(|ip_network| ip_network.ip() == source)\n        {\n            Direction::Upload\n        } else {\n            Direction::Download\n        }\n    }\n}\n\ntrait NextLevelProtocol {\n    fn get_next_level_protocol(&self) -> IpNextHeaderProtocol;\n}\n\nimpl NextLevelProtocol for Ipv6Packet<'_> {\n    fn get_next_level_protocol(&self) -> IpNextHeaderProtocol {\n        self.get_next_header()\n    }\n}\n\nmacro_rules! extract_transport_protocol {\n    (  $ip_packet: ident ) => {{\n        match $ip_packet.get_next_level_protocol() {\n            IpNextHeaderProtocols::Tcp => {\n                let message = TcpPacket::new($ip_packet.payload())?;\n                (\n                    Protocol::Tcp,\n                    message.get_source(),\n                    message.get_destination(),\n                    $ip_packet.payload().len() as u128,\n                )\n            }\n            IpNextHeaderProtocols::Udp => {\n                let datagram = UdpPacket::new($ip_packet.payload())?;\n                (\n                    Protocol::Udp,\n                    datagram.get_source(),\n                    datagram.get_destination(),\n                    $ip_packet.payload().len() as u128,\n                )\n            }\n            _ => return None,\n        }\n    }};\n}\n\npub struct Sniffer {\n    network_interface: NetworkInterface,\n    network_frames: Box<dyn DataLinkReceiver>,\n    show_dns: bool,\n}\n\nimpl Sniffer {\n    pub fn new(\n        network_interface: NetworkInterface,\n        network_frames: Box<dyn DataLinkReceiver>,\n        show_dns: bool,\n    ) -> Self {\n        Sniffer {\n            network_interface,\n            network_frames,\n            show_dns,\n        }\n    }\n    pub fn next(&mut self) -> Option<Segment> {\n        let bytes = match self.network_frames.next() {\n            Ok(bytes) => bytes,\n            Err(err) => match err.kind() {\n                std::io::ErrorKind::TimedOut => {\n                    park_timeout(PACKET_WAIT_TIMEOUT);\n                    return None;\n                }\n                _ => {\n                    park_timeout(CHANNEL_RESET_DELAY);\n                    self.reset_channel().ok();\n                    return None;\n                }\n            },\n        };\n        // See https://github.com/libpnet/libpnet/blob/master/examples/packetdump.rs\n        // VPN interfaces (such as utun0, utun1, etc) have POINT_TO_POINT bit set to 1\n        let payload_offset = if (self.network_interface.is_loopback()\n            || self.network_interface.is_point_to_point())\n            && cfg!(target_os = \"macos\")\n        {\n            // The pnet code for BPF loopback adds a zero'd out Ethernet header\n            14\n        } else {\n            0\n        };\n        let ip_packet = Ipv4Packet::new(&bytes[payload_offset..])?;\n        let version = ip_packet.get_version();\n\n        match version {\n            4 => Self::handle_v4(ip_packet, &self.network_interface, self.show_dns),\n            6 => Self::handle_v6(\n                Ipv6Packet::new(&bytes[payload_offset..])?,\n                &self.network_interface,\n            ),\n            _ => {\n                let pkg = EthernetPacket::new(bytes)?;\n                match pkg.get_ethertype() {\n                    EtherTypes::Ipv4 => Self::handle_v4(\n                        Ipv4Packet::new(pkg.payload())?,\n                        &self.network_interface,\n                        self.show_dns,\n                    ),\n                    EtherTypes::Ipv6 => {\n                        Self::handle_v6(Ipv6Packet::new(pkg.payload())?, &self.network_interface)\n                    }\n                    _ => None,\n                }\n            }\n        }\n    }\n    pub fn reset_channel(&mut self) -> Result<()> {\n        self.network_frames = get_datalink_channel(&self.network_interface)\n            .map_err(|_| io::Error::other(\"Interface not available\"))?;\n        Ok(())\n    }\n    fn handle_v6(ip_packet: Ipv6Packet, network_interface: &NetworkInterface) -> Option<Segment> {\n        let (protocol, source_port, destination_port, data_length) =\n            extract_transport_protocol!(ip_packet);\n\n        let interface_name = network_interface.name.clone();\n        let direction = Direction::new(&network_interface.ips, ip_packet.get_source().into());\n        let from = SocketAddr::new(ip_packet.get_source().into(), source_port);\n        let to = SocketAddr::new(ip_packet.get_destination().into(), destination_port);\n\n        let connection = match direction {\n            Direction::Download => Connection::new(from, to.ip(), destination_port, protocol),\n            Direction::Upload => Connection::new(to, from.ip(), source_port, protocol),\n        };\n        Some(Segment {\n            interface_name,\n            connection,\n            data_length,\n            direction,\n        })\n    }\n    fn handle_v4(\n        ip_packet: Ipv4Packet,\n        network_interface: &NetworkInterface,\n        show_dns: bool,\n    ) -> Option<Segment> {\n        let (protocol, source_port, destination_port, data_length) =\n            extract_transport_protocol!(ip_packet);\n\n        let interface_name = network_interface.name.clone();\n        let direction = Direction::new(&network_interface.ips, ip_packet.get_source().into());\n        let from = SocketAddr::new(ip_packet.get_source().into(), source_port);\n        let to = SocketAddr::new(ip_packet.get_destination().into(), destination_port);\n\n        let connection = match direction {\n            Direction::Download => Connection::new(from, to.ip(), destination_port, protocol),\n            Direction::Upload => Connection::new(to, from.ip(), source_port, protocol),\n        };\n\n        if !show_dns && connection.remote_socket.port == 53 {\n            return None;\n        }\n        Some(Segment {\n            interface_name,\n            connection,\n            data_length,\n            direction,\n        })\n    }\n}\n"
  },
  {
    "path": "src/network/utilization.rs",
    "content": "use std::collections::HashMap;\n\nuse crate::network::{Connection, Direction, Segment};\n\n#[derive(Clone)]\npub struct ConnectionInfo {\n    pub interface_name: String,\n    pub total_bytes_downloaded: u128,\n    pub total_bytes_uploaded: u128,\n}\n\n#[derive(Clone)]\npub struct Utilization {\n    pub connections: HashMap<Connection, ConnectionInfo>,\n}\n\nimpl Utilization {\n    pub fn new() -> Self {\n        let connections = HashMap::new();\n        Utilization { connections }\n    }\n    pub fn clone_and_reset(&mut self) -> Self {\n        let clone = self.clone();\n        self.connections.clear();\n        clone\n    }\n    pub fn ingest(&mut self, seg: Segment) {\n        let total_bandwidth = self\n            .connections\n            .entry(seg.connection)\n            .or_insert(ConnectionInfo {\n                interface_name: seg.interface_name,\n                total_bytes_downloaded: 0,\n                total_bytes_uploaded: 0,\n            });\n        match seg.direction {\n            Direction::Download => {\n                total_bandwidth.total_bytes_downloaded += seg.data_length;\n            }\n            Direction::Upload => {\n                total_bandwidth.total_bytes_uploaded += seg.data_length;\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "src/os/errors.rs",
    "content": "#[derive(Clone, Eq, PartialEq, Debug, thiserror::Error)]\npub enum GetInterfaceError {\n    #[error(\"Permission error: {0}\")]\n    PermissionError(String),\n    #[error(\"Other error: {0}\")]\n    OtherError(String),\n}\n"
  },
  {
    "path": "src/os/linux.rs",
    "content": "use std::collections::HashMap;\n\nuse procfs::process::FDTarget;\n\nuse crate::{\n    network::{LocalSocket, Protocol},\n    os::ProcessInfo,\n    OpenSockets,\n};\n\npub(crate) fn get_open_sockets() -> OpenSockets {\n    let mut open_sockets = HashMap::new();\n    let mut inode_to_proc = HashMap::new();\n\n    if let Ok(all_procs) = procfs::process::all_processes() {\n        for process in all_procs.filter_map(|res| res.ok()) {\n            let Ok(fds) = process.fd() else { continue };\n            let Ok(stat) = process.stat() else { continue };\n            let proc_name = stat.comm;\n            let proc_info = ProcessInfo::new(&proc_name, stat.pid as u32);\n            for fd in fds.filter_map(|res| res.ok()) {\n                if let FDTarget::Socket(inode) = fd.target {\n                    inode_to_proc.insert(inode, proc_info.clone());\n                }\n            }\n        }\n    }\n\n    macro_rules! insert_proto {\n        ($source: expr, $proto: expr) => {\n            let entries = $source.into_iter().filter_map(|res| res.ok()).flatten();\n            for entry in entries {\n                if let Some(proc_info) = inode_to_proc.get(&entry.inode) {\n                    let socket = LocalSocket {\n                        ip: entry.local_address.ip(),\n                        port: entry.local_address.port(),\n                        protocol: $proto,\n                    };\n                    open_sockets.insert(socket, proc_info.clone());\n                }\n            }\n        };\n    }\n\n    insert_proto!([procfs::net::tcp(), procfs::net::tcp6()], Protocol::Tcp);\n    insert_proto!([procfs::net::udp(), procfs::net::udp6()], Protocol::Udp);\n\n    OpenSockets {\n        sockets_to_procs: open_sockets,\n    }\n}\n"
  },
  {
    "path": "src/os/lsof.rs",
    "content": "use crate::{os::lsof_utils::get_connections, OpenSockets};\n\npub(crate) fn get_open_sockets() -> OpenSockets {\n    let sockets_to_procs = get_connections()\n        .filter_map(|raw| raw.as_local_socket().map(|s| (s, raw.proc_info)))\n        .collect();\n\n    OpenSockets { sockets_to_procs }\n}\n"
  },
  {
    "path": "src/os/lsof_utils.rs",
    "content": "use std::{ffi::OsStr, net::IpAddr, process::Command};\n\nuse log::warn;\nuse once_cell::sync::Lazy;\nuse regex::Regex;\n\nuse crate::{\n    network::{LocalSocket, Protocol},\n    os::ProcessInfo,\n};\n\n#[allow(dead_code)]\n#[derive(Debug, Clone)]\npub struct RawConnection {\n    remote_ip: String,\n    local_ip: String,\n    local_port: String,\n    remote_port: String,\n    protocol: String,\n    pub proc_info: ProcessInfo,\n}\n\nfn get_null_addr(ip_type: &str) -> &str {\n    if ip_type.contains('4') {\n        \"0.0.0.0\"\n    } else {\n        \"::0\"\n    }\n}\n\nimpl RawConnection {\n    pub fn new(raw_line: &str) -> Option<RawConnection> {\n        // Example row\n        // com.apple   664     user  198u  IPv4 0xeb179a6650592b8d      0t0    TCP 192.168.1.187:58535->1.2.3.4:443 (ESTABLISHED)\n        let columns: Vec<&str> = raw_line.split_ascii_whitespace().collect();\n        if columns.len() < 9 {\n            return None;\n        }\n        let process_name = columns[0].replace(\"\\\\x20\", \" \");\n        let pid = columns[1].parse().ok()?;\n        let proc_info = ProcessInfo::new(&process_name, pid);\n        // Unneeded\n        // let username = columns[2];\n        // let fd = columns[3];\n\n        // IPv4 or IPv6\n        let ip_type = columns[4];\n        // let device = columns[5];\n        // let size = columns[6];\n        // UDP/TCP\n        let protocol = columns[7].to_ascii_uppercase();\n        if protocol != \"TCP\" && protocol != \"UDP\" {\n            return None;\n        }\n        let connection_str = columns[8];\n        // \"(LISTEN)\" or \"(ESTABLISHED)\",  this column may or may not be present\n        // let connection_state = columns[9];\n\n        static CONNECTION_REGEX: Lazy<Regex> =\n            Lazy::new(|| Regex::new(r\"\\[?([^\\s\\]]*)\\]?:(\\d+)->\\[?([^\\s\\]]*)\\]?:(\\d+)\").unwrap());\n        static LISTEN_REGEX: Lazy<Regex> =\n            Lazy::new(|| Regex::new(r\"\\[?([^\\s\\[\\]]*)\\]?:(.*)\").unwrap());\n        // If this socket is in a \"connected\" state\n        if let Some(caps) = CONNECTION_REGEX.captures(connection_str) {\n            // Example\n            // 192.168.1.187:64230->0.1.2.3:5228\n            // *:*\n            // *:4567\n            let local_ip = String::from(caps.get(1).unwrap().as_str());\n            let local_port = String::from(caps.get(2).unwrap().as_str());\n            let remote_ip = String::from(caps.get(3).unwrap().as_str());\n            let remote_port = String::from(caps.get(4).unwrap().as_str());\n            let connection = RawConnection {\n                local_ip,\n                local_port,\n                remote_ip,\n                remote_port,\n                protocol,\n                proc_info,\n            };\n            Some(connection)\n        } else if let Some(caps) = LISTEN_REGEX.captures(connection_str) {\n            let local_ip = if caps.get(1).unwrap().as_str() == \"*\" {\n                get_null_addr(ip_type)\n            } else {\n                caps.get(1).unwrap().as_str()\n            };\n            let local_ip = String::from(local_ip);\n            let local_port = String::from(if caps.get(2).unwrap().as_str() == \"*\" {\n                \"0\"\n            } else {\n                caps.get(2).unwrap().as_str()\n            });\n            let remote_ip = String::from(get_null_addr(ip_type));\n            let remote_port = String::from(\"0\");\n            let connection = RawConnection {\n                local_ip,\n                local_port,\n                remote_ip,\n                remote_port,\n                protocol,\n                proc_info,\n            };\n            Some(connection)\n        } else {\n            None\n        }\n    }\n\n    pub fn get_protocol(&self) -> Option<Protocol> {\n        Protocol::from_str(&self.protocol)\n    }\n\n    pub fn get_local_ip(&self) -> Option<IpAddr> {\n        self.local_ip.parse().ok()\n    }\n\n    pub fn get_local_port(&self) -> Option<u16> {\n        self.local_port.parse::<u16>().ok()\n    }\n\n    pub fn as_local_socket(&self) -> Option<LocalSocket> {\n        let process = &self.proc_info.name;\n\n        let Some(ip) = self.get_local_ip() else {\n            warn!(r#\"Failed to get the local IP of a connection belonging to \"{process}\".\"#);\n            return None;\n        };\n        let Some(port) = self.get_local_port() else {\n            warn!(r#\"Failed to get the local port of a connection belonging to \"{process}\".\"#);\n            return None;\n        };\n        let Some(protocol) = self.get_protocol() else {\n            warn!(r#\"Failed to get the protocol of a connection belonging to \"{process}\".\"#);\n            return None;\n        };\n\n        Some(LocalSocket { ip, port, protocol })\n    }\n}\n\npub fn get_connections() -> RawConnections {\n    let content = run([\"-n\", \"-P\", \"-i4\", \"-i6\", \"+c\", \"0\"]);\n    RawConnections::new(content)\n}\n\nfn run<I, S>(args: I) -> String\nwhere\n    I: IntoIterator<Item = S>,\n    S: AsRef<OsStr>,\n{\n    let output = Command::new(\"lsof\")\n        .args(args)\n        .output()\n        .expect(\"failed to execute process\");\n\n    String::from_utf8_lossy(&output.stdout).into_owned()\n}\n\npub struct RawConnections {\n    content: Vec<RawConnection>,\n}\n\nimpl RawConnections {\n    pub fn new(content: String) -> RawConnections {\n        let lines: Vec<RawConnection> = content.lines().flat_map(RawConnection::new).collect();\n\n        RawConnections { content: lines }\n    }\n}\n\nimpl Iterator for RawConnections {\n    type Item = RawConnection;\n\n    fn next(&mut self) -> Option<Self::Item> {\n        self.content.pop()\n    }\n}\n\n#[cfg(test)]\nmod tests {\n    use super::*;\n\n    const IPV6_LINE_RAW_OUTPUT: &str = \"ProcessName     29266 user    9u  IPv6 0x5d53dfe5445cee01      0t0  UDP [fe80:4::aede:48ff:fe00:1122]:1111->[fe80:4::aede:48ff:fe33:4455]:2222\";\n    const LINE_RAW_OUTPUT: &str = \"ProcessName 29266 user   39u  IPv4 0x28ffb9c0021196bf      0t0  UDP 192.168.0.1:1111->198.252.206.25:2222\";\n    const FULL_RAW_OUTPUT: &str = r#\"\ncom.apple   590 etoledom  193u  IPv4 0x28ffb9c041115627      0t0  TCP 192.168.1.37:60298->31.13.83.36:443 (ESTABLISHED)\ncom.apple   590 etoledom  198u  IPv4 0x28ffb9c04110ea8f      0t0  TCP 192.168.1.37:60299->31.13.83.8:443 (ESTABLISHED)\ncom.apple   590 etoledom  203u  IPv4 0x28ffb9c04110ea8f      0t0  TCP 192.168.1.37:60299->31.13.83.8:443 (ESTABLISHED)\ncom.apple   590 etoledom  204u  IPv4 0x28ffb9c04111253f      0t0  TCP 192.168.1.37:60374->140.82.114.26:443\n\"#;\n\n    #[test]\n    fn test_iterator_multiline() {\n        let iterator = RawConnections::new(String::from(FULL_RAW_OUTPUT));\n        let connections: Vec<RawConnection> = iterator.collect();\n        assert_eq!(connections.len(), 4);\n    }\n\n    #[test]\n    fn test_raw_connection_is_created_from_raw_output_ipv4() {\n        test_raw_connection_is_created_from_raw_output(LINE_RAW_OUTPUT);\n    }\n    #[test]\n    fn test_raw_connection_is_created_from_raw_output_ipv6() {\n        test_raw_connection_is_created_from_raw_output(IPV6_LINE_RAW_OUTPUT);\n    }\n    fn test_raw_connection_is_created_from_raw_output(raw_output: &str) {\n        let connection = RawConnection::new(raw_output);\n        assert!(connection.is_some());\n    }\n\n    #[test]\n    fn test_raw_connection_is_not_created_from_wrong_raw_output() {\n        let connection = RawConnection::new(\"not a process\");\n        assert!(connection.is_none());\n    }\n\n    #[test]\n    fn test_raw_connection_parse_local_port_ipv4() {\n        test_raw_connection_parse_local_port(LINE_RAW_OUTPUT);\n    }\n    #[test]\n    fn test_raw_connection_parse_local_port_ipv6() {\n        test_raw_connection_parse_local_port(IPV6_LINE_RAW_OUTPUT);\n    }\n    fn test_raw_connection_parse_local_port(raw_output: &str) {\n        let connection = RawConnection::new(raw_output).unwrap();\n        assert_eq!(connection.get_local_port(), Some(1111));\n    }\n\n    #[test]\n    fn test_raw_connection_parse_protocol_ipv4() {\n        test_raw_connection_parse_protocol(LINE_RAW_OUTPUT);\n    }\n    #[test]\n    fn test_raw_connection_parse_protocol_ipv6() {\n        test_raw_connection_parse_protocol(IPV6_LINE_RAW_OUTPUT);\n    }\n    fn test_raw_connection_parse_protocol(raw_line: &str) {\n        let connection = RawConnection::new(raw_line).unwrap();\n        assert_eq!(connection.get_protocol(), Some(Protocol::Udp));\n    }\n\n    #[test]\n    fn test_raw_connection_parse_process_name_ipv4() {\n        test_raw_connection_parse_process_name(LINE_RAW_OUTPUT);\n    }\n    #[test]\n    fn test_raw_connection_parse_process_name_ipv6() {\n        test_raw_connection_parse_process_name(IPV6_LINE_RAW_OUTPUT);\n    }\n    fn test_raw_connection_parse_process_name(raw_line: &str) {\n        let connection = RawConnection::new(raw_line).unwrap();\n        assert_eq!(connection.proc_info.name, String::from(\"ProcessName\"));\n    }\n}\n"
  },
  {
    "path": "src/os/mod.rs",
    "content": "#[cfg(any(target_os = \"android\", target_os = \"linux\"))]\nmod linux;\n\n#[cfg(any(target_os = \"macos\", target_os = \"freebsd\"))]\nmod lsof;\n\n#[cfg(any(target_os = \"macos\", target_os = \"freebsd\"))]\nmod lsof_utils;\n\n#[cfg(target_os = \"windows\")]\nmod windows;\n\nmod errors;\npub(crate) mod shared;\n\npub use shared::*;\n"
  },
  {
    "path": "src/os/shared.rs",
    "content": "use std::{\n    io::{self, ErrorKind, Write},\n    net::Ipv4Addr,\n    time::{self, Duration},\n};\n\nuse crossterm::event::{poll, read, Event};\nuse eyre::{bail, eyre};\nuse itertools::Itertools;\nuse log::{debug, warn};\nuse pnet::datalink::{self, Channel::Ethernet, Config, DataLinkReceiver, NetworkInterface};\nuse tokio::runtime::Runtime;\n\nuse crate::{network::dns, os::errors::GetInterfaceError, OsInputOutput};\n\n#[cfg(any(target_os = \"android\", target_os = \"linux\"))]\nuse crate::os::linux::get_open_sockets;\n#[cfg(any(target_os = \"macos\", target_os = \"freebsd\"))]\nuse crate::os::lsof::get_open_sockets;\n#[cfg(target_os = \"windows\")]\nuse crate::os::windows::get_open_sockets;\n\n#[derive(Clone, Debug, Default, Hash, PartialEq, Eq)]\npub struct ProcessInfo {\n    pub name: String,\n    pub pid: u32,\n}\n\nimpl ProcessInfo {\n    pub fn new(name: &str, pid: u32) -> Self {\n        Self {\n            name: name.to_string(),\n            pid,\n        }\n    }\n}\n\n/// Poll timeout for terminal events.\n/// This allows the event loop to periodically check the `running` flag\n/// for graceful shutdown on SIGINT.\nconst POLL_TIMEOUT: Duration = Duration::from_millis(100);\n\npub struct TerminalEvents;\n\nimpl Iterator for TerminalEvents {\n    type Item = Event;\n    /// Returns the next terminal event, or `None` if no event is available\n    /// within the poll timeout.\n    ///\n    /// Note: `None` here means \"no event right now\", not \"iteration complete\".\n    /// The consumer should use `while running` instead of `for evt in ...`.\n    fn next(&mut self) -> Option<Event> {\n        match poll(POLL_TIMEOUT) {\n            Ok(true) => read().ok(),\n            Ok(false) | Err(_) => None,\n        }\n    }\n}\n\npub(crate) fn get_datalink_channel(\n    interface: &NetworkInterface,\n) -> Result<Box<dyn DataLinkReceiver>, GetInterfaceError> {\n    let config = Config {\n        read_timeout: Some(time::Duration::new(1, 0)),\n        read_buffer_size: 65536,\n        ..Default::default()\n    };\n\n    match datalink::channel(interface, config) {\n        Ok(Ethernet(_tx, rx)) => Ok(rx),\n        Ok(_) => Err(GetInterfaceError::OtherError(format!(\n            \"{}: Unsupported interface type\",\n            interface.name\n        ))),\n        Err(e) => match e.kind() {\n            ErrorKind::PermissionDenied => Err(GetInterfaceError::PermissionError(\n                interface.name.to_owned(),\n            )),\n            _ => Err(GetInterfaceError::OtherError(format!(\n                \"{}: {e}\",\n                &interface.name\n            ))),\n        },\n    }\n}\n\nfn get_interface(interface_name: &str) -> Option<NetworkInterface> {\n    datalink::interfaces()\n        .into_iter()\n        .find(|iface| iface.name == interface_name)\n}\n\nfn create_write_to_stdout() -> Box<dyn FnMut(&str) + Send> {\n    let mut stdout = io::stdout();\n    Box::new({\n        move |output| match writeln!(stdout, \"{output}\") {\n            Ok(_) => (),\n            Err(e) if e.kind() == ErrorKind::BrokenPipe => {\n                // A process that was listening to bandwhich stdout has exited\n                // We can't do much here, lets just exit as well\n                std::process::exit(0)\n            }\n            Err(e) => panic!(\"Failed to write to stdout: {e}\"),\n        }\n    })\n}\n\npub fn get_input(\n    interface_name: Option<&str>,\n    resolve: bool,\n    dns_server: Option<Ipv4Addr>,\n) -> eyre::Result<OsInputOutput> {\n    // get the user's requested interface, if any\n    // IDEA: allow requesting multiple interfaces\n    let requested_interfaces = interface_name\n        .map(|name| get_interface(name).ok_or_else(|| eyre!(\"Cannot find interface {name}\")))\n        .transpose()?\n        .map(|interface| vec![interface]);\n\n    // take the user's requested interfaces (or all interfaces), and filter for up ones\n    let available_interfaces = requested_interfaces\n        .unwrap_or_else(datalink::interfaces)\n        .into_iter()\n        .filter(|interface| {\n            // see https://github.com/libpnet/libpnet/issues/564\n            let keep = if cfg!(target_os = \"windows\") {\n                !interface.ips.is_empty()\n            } else {\n                interface.is_up() && !interface.ips.is_empty()\n            };\n            if !keep {\n                debug!(\"{} is down. Skipping it.\", interface.name);\n            }\n            keep\n        })\n        .collect_vec();\n\n    // bail if no interfaces are up\n    if available_interfaces.is_empty() {\n        bail!(\"Failed to find any network interface to listen on.\");\n    }\n\n    // try to get a frame receiver for each interface\n    let interfaces_with_frames_res = available_interfaces\n        .into_iter()\n        .map(|interface| {\n            let frames_res = get_datalink_channel(&interface);\n            (interface, frames_res)\n        })\n        .collect_vec();\n\n    // warn for all frame receivers we failed to acquire\n    interfaces_with_frames_res\n        .iter()\n        .filter_map(|(interface, frames_res)| frames_res.as_ref().err().map(|err| (interface, err)))\n        .for_each(|(interface, err)| {\n            warn!(\n                \"Failed to acquire a frame receiver for {}: {err}\",\n                interface.name\n            )\n        });\n\n    // bail if all of them fail\n    // note that `Iterator::all` returns `true` for an empty iterator, so it is important to handle\n    // that failure mode separately, which we already have\n    if interfaces_with_frames_res\n        .iter()\n        .all(|(_, frames)| frames.is_err())\n    {\n        let (permission_err_interfaces, other_errs) = interfaces_with_frames_res.iter().fold(\n            (vec![], vec![]),\n            |(mut perms, mut others), (_, res)| {\n                match res {\n                    Ok(_) => (),\n                    Err(GetInterfaceError::PermissionError(interface)) => {\n                        perms.push(interface.as_str())\n                    }\n                    Err(GetInterfaceError::OtherError(err)) => others.push(err.as_str()),\n                }\n                (perms, others)\n            },\n        );\n\n        let err_msg = match (permission_err_interfaces.is_empty(), other_errs.is_empty()) {\n            (false, false) => format!(\n                \"\\n\\n{}: {}\\nAdditional errors:\\n{}\",\n                permission_err_interfaces.join(\", \"),\n                eperm_message(),\n                other_errs.join(\"\\n\")\n            ),\n            (false, true) => format!(\n                \"\\n\\n{}: {}\",\n                permission_err_interfaces.join(\", \"),\n                eperm_message()\n            ),\n            (true, false) => format!(\"\\n\\n{}\", other_errs.join(\"\\n\")),\n            (true, true) => unreachable!(\"Found no errors in error handling code path.\"),\n        };\n        bail!(err_msg);\n    }\n\n    // filter out interfaces for which we failed to acquire a frame receiver\n    let interfaces_with_frames = interfaces_with_frames_res\n        .into_iter()\n        .filter_map(|(interface, res)| res.ok().map(|frames| (interface, frames)))\n        .collect();\n\n    let dns_client = if resolve {\n        let runtime = Runtime::new()?;\n        let resolver = runtime\n            .block_on(dns::Resolver::new(dns_server))\n            .map_err(|err| {\n                eyre!(\"Could not initialize the DNS resolver. Are you offline?\\n\\nReason: {err}\")\n            })?;\n        let dns_client = dns::Client::new(resolver, runtime)?;\n        Some(dns_client)\n    } else {\n        None\n    };\n\n    let write_to_stdout = create_write_to_stdout();\n\n    Ok(OsInputOutput {\n        interfaces_with_frames,\n        get_open_sockets,\n        terminal_events: Box::new(TerminalEvents),\n        dns_client,\n        write_to_stdout,\n    })\n}\n\n#[inline]\n#[cfg(any(target_os = \"macos\", target_os = \"freebsd\"))]\nfn eperm_message() -> &'static str {\n    \"Insufficient permissions to listen on network interface(s). Try running with sudo.\"\n}\n\n#[inline]\n#[cfg(any(target_os = \"android\", target_os = \"linux\"))]\nfn eperm_message() -> &'static str {\n    r#\"\n    Insufficient permissions to listen on network interface(s). You can work around\n    this issue like this:\n\n    * Try running `bandwhich` with `sudo`\n\n    * Build a `setcap(8)` wrapper for `bandwhich` with the following rules:\n        `cap_sys_ptrace,cap_dac_read_search,cap_net_raw,cap_net_admin+ep`\n    \"#\n}\n\n#[inline]\n#[cfg(target_os = \"windows\")]\nfn eperm_message() -> &'static str {\n    \"Insufficient permissions to listen on network interface(s). Try running with administrator rights.\"\n}\n"
  },
  {
    "path": "src/os/windows.rs",
    "content": "use std::collections::HashMap;\n\nuse netstat2::*;\nuse sysinfo::{Pid, ProcessesToUpdate, System};\n\nuse crate::{\n    network::{LocalSocket, Protocol},\n    os::ProcessInfo,\n    OpenSockets,\n};\n\npub(crate) fn get_open_sockets() -> OpenSockets {\n    let mut open_sockets = HashMap::new();\n\n    let mut sysinfo = System::new_all();\n    sysinfo.refresh_processes(ProcessesToUpdate::All, true);\n\n    let af_flags = AddressFamilyFlags::IPV4 | AddressFamilyFlags::IPV6;\n    let proto_flags = ProtocolFlags::TCP | ProtocolFlags::UDP;\n    let sockets_info = get_sockets_info(af_flags, proto_flags);\n\n    if let Ok(sockets_info) = sockets_info {\n        for si in sockets_info {\n            let proc_info = si\n                .associated_pids\n                .into_iter()\n                .find_map(|pid| sysinfo.process(Pid::from_u32(pid)))\n                .map(|p| ProcessInfo::new(&p.name().to_string_lossy(), p.pid().as_u32()))\n                .unwrap_or_default();\n\n            match si.protocol_socket_info {\n                ProtocolSocketInfo::Tcp(tcp_si) => {\n                    open_sockets.insert(\n                        LocalSocket {\n                            ip: tcp_si.local_addr,\n                            port: tcp_si.local_port,\n                            protocol: Protocol::Tcp,\n                        },\n                        proc_info,\n                    );\n                }\n                ProtocolSocketInfo::Udp(udp_si) => {\n                    open_sockets.insert(\n                        LocalSocket {\n                            ip: udp_si.local_addr,\n                            port: udp_si.local_port,\n                            protocol: Protocol::Udp,\n                        },\n                        proc_info,\n                    );\n                }\n            }\n        }\n    }\n\n    OpenSockets {\n        sockets_to_procs: open_sockets,\n    }\n}\n"
  },
  {
    "path": "src/tests/cases/mod.rs",
    "content": "pub mod raw_mode;\npub mod test_utils;\n#[cfg(feature = \"ui_test\")]\npub mod ui;\n"
  },
  {
    "path": "src/tests/cases/raw_mode.rs",
    "content": "use std::{\n    collections::HashMap,\n    net::IpAddr,\n    sync::{Arc, Mutex},\n};\n\nuse insta::assert_snapshot;\nuse once_cell::sync::Lazy;\nuse packet_builder::*;\nuse pnet::{datalink::DataLinkReceiver, packet::Packet};\nuse regex::Regex;\n\nuse crate::{\n    start,\n    tests::{\n        cases::test_utils::{\n            build_tcp_packet, opts_raw, os_input_output_dns, os_input_output_stdout,\n            test_backend_factory,\n        },\n        fakes::{create_fake_dns_client, NetworkFrames},\n    },\n    Opt,\n};\n\nfn build_ip_tcp_packet(\n    source_ip: &str,\n    destination_ip: &str,\n    source_port: u16,\n    destination_port: u16,\n    payload: &'static [u8],\n) -> Vec<u8> {\n    let mut pkt_buf = [0u8; 1500];\n    let pkt = packet_builder!(\n         pkt_buf,\n         ipv4({set_source => ipv4addr!(source_ip), set_destination => ipv4addr!(destination_ip) }) /\n         tcp({set_source => source_port, set_destination => destination_port }) /\n         payload(payload)\n    );\n    pkt.packet().to_vec()\n}\n\nfn format_raw_stdout(raw: &Mutex<Vec<u8>>) -> String {\n    static TIMESTAMP_MATCHER: Lazy<Regex> = Lazy::new(|| Regex::new(r\"<\\d+>\").unwrap());\n    let stdout = raw.lock().unwrap();\n    TIMESTAMP_MATCHER\n        .replace_all(std::str::from_utf8(&stdout).unwrap(), \"<TIMESTAMP_REMOVED>\")\n        .into()\n}\n\n#[test]\nfn one_ip_packet_of_traffic() {\n    let network_frames = vec![NetworkFrames::new(vec![Some(build_ip_tcp_packet(\n        \"10.0.0.2\",\n        \"1.1.1.1\",\n        443,\n        12345,\n        b\"I am a fake tcp packet\",\n    ))]) as Box<dyn DataLinkReceiver>];\n    let (_, _, backend) = test_backend_factory(190, 50);\n    let stdout = Arc::new(Mutex::new(Vec::new()));\n    let os_input = os_input_output_stdout(network_frames, 2, Some(stdout.clone()));\n    let opts = opts_raw();\n    start(backend, os_input, opts);\n    assert_snapshot!(format_raw_stdout(&stdout));\n}\n\n#[test]\nfn one_packet_of_traffic() {\n    let network_frames = vec![NetworkFrames::new(vec![Some(build_tcp_packet(\n        \"10.0.0.2\",\n        \"1.1.1.1\",\n        443,\n        12345,\n        b\"I am a fake tcp packet\",\n    ))]) as Box<dyn DataLinkReceiver>];\n    let (_, _, backend) = test_backend_factory(190, 50);\n    let stdout = Arc::new(Mutex::new(Vec::new()));\n    let os_input = os_input_output_stdout(network_frames, 2, Some(stdout.clone()));\n    let opts = opts_raw();\n    start(backend, os_input, opts);\n    assert_snapshot!(format_raw_stdout(&stdout));\n}\n\n#[test]\nfn bi_directional_traffic() {\n    let network_frames = vec![NetworkFrames::new(vec![\n        Some(build_tcp_packet(\n            \"10.0.0.2\",\n            \"1.1.1.1\",\n            443,\n            12345,\n            b\"I am a fake tcp upload packet\",\n        )),\n        Some(build_tcp_packet(\n            \"1.1.1.1\",\n            \"10.0.0.2\",\n            12345,\n            443,\n            b\"I am a fake tcp download packet\",\n        )),\n    ]) as Box<dyn DataLinkReceiver>];\n    let (_, _, backend) = test_backend_factory(190, 50);\n    let stdout = Arc::new(Mutex::new(Vec::new()));\n    let os_input = os_input_output_stdout(network_frames, 2, Some(stdout.clone()));\n    let opts = opts_raw();\n    start(backend, os_input, opts);\n    assert_snapshot!(format_raw_stdout(&stdout));\n}\n\n#[test]\nfn multiple_packets_of_traffic_from_different_connections() {\n    let network_frames = vec![NetworkFrames::new(vec![\n        Some(build_tcp_packet(\n            \"2.2.2.2\",\n            \"10.0.0.2\",\n            12345,\n            443,\n            b\"I have come from 2.2.2.2\",\n        )),\n        Some(build_tcp_packet(\n            \"2.2.2.2\",\n            \"10.0.0.2\",\n            54321,\n            4434,\n            b\"I come from 2.2.2.2\",\n        )),\n    ]) as Box<dyn DataLinkReceiver>];\n    let (_, _, backend) = test_backend_factory(190, 50);\n    let stdout = Arc::new(Mutex::new(Vec::new()));\n    let os_input = os_input_output_stdout(network_frames, 2, Some(stdout.clone()));\n    let opts = opts_raw();\n    start(backend, os_input, opts);\n    assert_snapshot!(format_raw_stdout(&stdout));\n}\n\n#[test]\nfn multiple_packets_of_traffic_from_single_connection() {\n    let network_frames = vec![NetworkFrames::new(vec![\n        Some(build_tcp_packet(\n            \"1.1.1.1\",\n            \"10.0.0.2\",\n            12345,\n            443,\n            b\"I have come from 1.1.1.1\",\n        )),\n        Some(build_tcp_packet(\n            \"1.1.1.1\",\n            \"10.0.0.2\",\n            12345,\n            443,\n            b\"I've come from 1.1.1.1 too!\",\n        )),\n    ]) as Box<dyn DataLinkReceiver>];\n    let (_, _, backend) = test_backend_factory(190, 50);\n    let stdout = Arc::new(Mutex::new(Vec::new()));\n    let os_input = os_input_output_stdout(network_frames, 2, Some(stdout.clone()));\n    let opts = opts_raw();\n    start(backend, os_input, opts);\n    assert_snapshot!(format_raw_stdout(&stdout));\n}\n\n#[test]\nfn one_process_with_multiple_connections() {\n    let network_frames = vec![NetworkFrames::new(vec![\n        Some(build_tcp_packet(\n            \"1.1.1.1\",\n            \"10.0.0.2\",\n            12345,\n            443,\n            b\"I have come from 1.1.1.1\",\n        )),\n        Some(build_tcp_packet(\n            \"1.1.1.1\",\n            \"10.0.0.2\",\n            12346,\n            443,\n            b\"Funny that, I'm from 1.1.1.1\",\n        )),\n    ]) as Box<dyn DataLinkReceiver>];\n    let (_, _, backend) = test_backend_factory(190, 50);\n    let stdout = Arc::new(Mutex::new(Vec::new()));\n    let os_input = os_input_output_stdout(network_frames, 2, Some(stdout.clone()));\n    let opts = opts_raw();\n    start(backend, os_input, opts);\n    assert_snapshot!(format_raw_stdout(&stdout));\n}\n\n#[test]\nfn multiple_processes_with_multiple_connections() {\n    let network_frames = vec![NetworkFrames::new(vec![\n        Some(build_tcp_packet(\n            \"1.1.1.1\",\n            \"10.0.0.2\",\n            12345,\n            443,\n            b\"I have come from 1.1.1.1\",\n        )),\n        Some(build_tcp_packet(\n            \"3.3.3.3\",\n            \"10.0.0.2\",\n            1337,\n            4435,\n            b\"Greetings traveller, I'm from 3.3.3.3\",\n        )),\n        Some(build_tcp_packet(\n            \"2.2.2.2\",\n            \"10.0.0.2\",\n            54321,\n            4434,\n            b\"You know, 2.2.2.2 is really nice!\",\n        )),\n        Some(build_tcp_packet(\n            \"4.4.4.4\",\n            \"10.0.0.2\",\n            1337,\n            4432,\n            b\"I'm partial to 4.4.4.4\",\n        )),\n    ]) as Box<dyn DataLinkReceiver>];\n    let (_, _, backend) = test_backend_factory(190, 50);\n    let stdout = Arc::new(Mutex::new(Vec::new()));\n    let os_input = os_input_output_stdout(network_frames, 2, Some(stdout.clone()));\n    let opts = opts_raw();\n    start(backend, os_input, opts);\n    assert_snapshot!(format_raw_stdout(&stdout));\n}\n\n#[test]\nfn multiple_connections_from_remote_address() {\n    let network_frames = vec![NetworkFrames::new(vec![\n        Some(build_tcp_packet(\n            \"1.1.1.1\",\n            \"10.0.0.2\",\n            12345,\n            443,\n            b\"I have come from 1.1.1.1\",\n        )),\n        Some(build_tcp_packet(\n            \"1.1.1.1\",\n            \"10.0.0.2\",\n            12346,\n            443,\n            b\"Me too, but on a different port\",\n        )),\n    ]) as Box<dyn DataLinkReceiver>];\n    let (_, _, backend) = test_backend_factory(190, 50);\n\n    let stdout = Arc::new(Mutex::new(Vec::new()));\n    let os_input = os_input_output_stdout(network_frames, 2, Some(stdout.clone()));\n    let opts = opts_raw();\n    start(backend, os_input, opts);\n    assert_snapshot!(format_raw_stdout(&stdout));\n}\n\n#[test]\nfn sustained_traffic_from_one_process() {\n    let network_frames = vec![NetworkFrames::new(vec![\n        Some(build_tcp_packet(\n            \"1.1.1.1\",\n            \"10.0.0.2\",\n            12345,\n            443,\n            b\"I have come from 1.1.1.1\",\n        )),\n        None, // sleep\n        Some(build_tcp_packet(\n            \"1.1.1.1\",\n            \"10.0.0.2\",\n            12345,\n            443,\n            b\"Same here, but one second later\",\n        )),\n    ]) as Box<dyn DataLinkReceiver>];\n    let (_, _, backend) = test_backend_factory(190, 50);\n\n    let stdout = Arc::new(Mutex::new(Vec::new()));\n    let os_input = os_input_output_stdout(network_frames, 3, Some(stdout.clone()));\n    let opts = opts_raw();\n    start(backend, os_input, opts);\n    assert_snapshot!(format_raw_stdout(&stdout));\n}\n\n#[test]\nfn sustained_traffic_from_multiple_processes() {\n    let network_frames = vec![NetworkFrames::new(vec![\n        Some(build_tcp_packet(\n            \"1.1.1.1\",\n            \"10.0.0.2\",\n            12345,\n            443,\n            b\"I have come from 1.1.1.1\",\n        )),\n        Some(build_tcp_packet(\n            \"3.3.3.3\",\n            \"10.0.0.2\",\n            1337,\n            4435,\n            b\"I come from 3.3.3.3\",\n        )),\n        None, // sleep\n        Some(build_tcp_packet(\n            \"1.1.1.1\",\n            \"10.0.0.2\",\n            12345,\n            443,\n            b\"I have come from 1.1.1.1 one second later\",\n        )),\n        Some(build_tcp_packet(\n            \"3.3.3.3\",\n            \"10.0.0.2\",\n            1337,\n            4435,\n            b\"I come 3.3.3.3 one second later\",\n        )),\n    ]) as Box<dyn DataLinkReceiver>];\n    let (_, _, backend) = test_backend_factory(190, 50);\n\n    let stdout = Arc::new(Mutex::new(Vec::new()));\n    let os_input = os_input_output_stdout(network_frames, 3, Some(stdout.clone()));\n    let opts = opts_raw();\n    start(backend, os_input, opts);\n    assert_snapshot!(format_raw_stdout(&stdout));\n}\n\n#[test]\nfn sustained_traffic_from_multiple_processes_bi_directional() {\n    let network_frames = vec![NetworkFrames::new(vec![\n        Some(build_tcp_packet(\n            \"10.0.0.2\",\n            \"3.3.3.3\",\n            4435,\n            1337,\n            b\"omw to 3.3.3.3\",\n        )),\n        Some(build_tcp_packet(\n            \"3.3.3.3\",\n            \"10.0.0.2\",\n            1337,\n            4435,\n            b\"I was just there!\",\n        )),\n        Some(build_tcp_packet(\n            \"1.1.1.1\",\n            \"10.0.0.2\",\n            12345,\n            443,\n            b\"Is it nice there? I think 1.1.1.1 is dull\",\n        )),\n        Some(build_tcp_packet(\n            \"10.0.0.2\",\n            \"1.1.1.1\",\n            443,\n            12345,\n            b\"Well, I heard 1.1.1.1 is all the rage\",\n        )),\n        None, // sleep\n        Some(build_tcp_packet(\n            \"10.0.0.2\",\n            \"3.3.3.3\",\n            4435,\n            1337,\n            b\"Wait for me!\",\n        )),\n        Some(build_tcp_packet(\n            \"3.3.3.3\",\n            \"10.0.0.2\",\n            1337,\n            4435,\n            b\"They're waiting for you...\",\n        )),\n        Some(build_tcp_packet(\n            \"1.1.1.1\",\n            \"10.0.0.2\",\n            12345,\n            443,\n            b\"1.1.1.1 forever!\",\n        )),\n        Some(build_tcp_packet(\n            \"10.0.0.2\",\n            \"1.1.1.1\",\n            443,\n            12345,\n            b\"10.0.0.2 forever!\",\n        )),\n    ]) as Box<dyn DataLinkReceiver>];\n    let (_, _, backend) = test_backend_factory(190, 50);\n    let stdout = Arc::new(Mutex::new(Vec::new()));\n    let os_input = os_input_output_stdout(network_frames, 3, Some(stdout.clone()));\n\n    let opts = opts_raw();\n    start(backend, os_input, opts);\n    assert_snapshot!(format_raw_stdout(&stdout));\n}\n\n#[test]\nfn traffic_with_host_names() {\n    let network_frames = vec![NetworkFrames::new(vec![\n        Some(build_tcp_packet(\n            \"10.0.0.2\",\n            \"3.3.3.3\",\n            4435,\n            1337,\n            b\"omw to 3.3.3.3\",\n        )),\n        Some(build_tcp_packet(\n            \"3.3.3.3\",\n            \"10.0.0.2\",\n            1337,\n            4435,\n            b\"I was just there!\",\n        )),\n        Some(build_tcp_packet(\n            \"1.1.1.1\",\n            \"10.0.0.2\",\n            12345,\n            443,\n            b\"Is it nice there? I think 1.1.1.1 is dull\",\n        )),\n        Some(build_tcp_packet(\n            \"10.0.0.2\",\n            \"1.1.1.1\",\n            443,\n            12345,\n            b\"Well, I heard 1.1.1.1 is all the rage\",\n        )),\n        None, // sleep\n        Some(build_tcp_packet(\n            \"10.0.0.2\",\n            \"3.3.3.3\",\n            4435,\n            1337,\n            b\"Wait for me!\",\n        )),\n        Some(build_tcp_packet(\n            \"3.3.3.3\",\n            \"10.0.0.2\",\n            1337,\n            4435,\n            b\"They're waiting for you...\",\n        )),\n        Some(build_tcp_packet(\n            \"1.1.1.1\",\n            \"10.0.0.2\",\n            12345,\n            443,\n            b\"1.1.1.1 forever!\",\n        )),\n        Some(build_tcp_packet(\n            \"10.0.0.2\",\n            \"1.1.1.1\",\n            443,\n            12345,\n            b\"10.0.0.2 forever!\",\n        )),\n    ]) as Box<dyn DataLinkReceiver>];\n    let (_, _, backend) = test_backend_factory(190, 50);\n    let mut ips_to_hostnames = HashMap::new();\n    ips_to_hostnames.insert(\n        IpAddr::V4(\"1.1.1.1\".parse().unwrap()),\n        String::from(\"one.one.one.one\"),\n    );\n    ips_to_hostnames.insert(\n        IpAddr::V4(\"3.3.3.3\".parse().unwrap()),\n        String::from(\"three.three.three.three\"),\n    );\n    ips_to_hostnames.insert(\n        IpAddr::V4(\"10.0.0.2\".parse().unwrap()),\n        String::from(\"i-like-cheese.com\"),\n    );\n    let dns_client = create_fake_dns_client(ips_to_hostnames);\n    let stdout = Arc::new(Mutex::new(Vec::new()));\n    let os_input = os_input_output_dns(network_frames, 3, Some(stdout.clone()), dns_client);\n    let opts = opts_raw();\n    start(backend, os_input, opts);\n    assert_snapshot!(format_raw_stdout(&stdout));\n}\n\n#[test]\nfn no_resolve_mode() {\n    let network_frames = vec![NetworkFrames::new(vec![\n        Some(build_tcp_packet(\n            \"10.0.0.2\",\n            \"3.3.3.3\",\n            4435,\n            1337,\n            b\"omw to 3.3.3.3\",\n        )),\n        Some(build_tcp_packet(\n            \"3.3.3.3\",\n            \"10.0.0.2\",\n            1337,\n            4435,\n            b\"I was just there!\",\n        )),\n        Some(build_tcp_packet(\n            \"1.1.1.1\",\n            \"10.0.0.2\",\n            12345,\n            443,\n            b\"Is it nice there? I think 1.1.1.1 is dull\",\n        )),\n        Some(build_tcp_packet(\n            \"10.0.0.2\",\n            \"1.1.1.1\",\n            443,\n            12345,\n            b\"Well, I heard 1.1.1.1 is all the rage\",\n        )),\n        None, // sleep\n        Some(build_tcp_packet(\n            \"10.0.0.2\",\n            \"3.3.3.3\",\n            4435,\n            1337,\n            b\"Wait for me!\",\n        )),\n        Some(build_tcp_packet(\n            \"3.3.3.3\",\n            \"10.0.0.2\",\n            1337,\n            4435,\n            b\"They're waiting for you...\",\n        )),\n        Some(build_tcp_packet(\n            \"1.1.1.1\",\n            \"10.0.0.2\",\n            12345,\n            443,\n            b\"1.1.1.1 forever!\",\n        )),\n        Some(build_tcp_packet(\n            \"10.0.0.2\",\n            \"1.1.1.1\",\n            443,\n            12345,\n            b\"10.0.0.2 forever!\",\n        )),\n    ]) as Box<dyn DataLinkReceiver>];\n    let (_, _, backend) = test_backend_factory(190, 50);\n    let mut ips_to_hostnames = HashMap::new();\n    ips_to_hostnames.insert(\n        IpAddr::V4(\"1.1.1.1\".parse().unwrap()),\n        String::from(\"one.one.one.one\"),\n    );\n    ips_to_hostnames.insert(\n        IpAddr::V4(\"3.3.3.3\".parse().unwrap()),\n        String::from(\"three.three.three.three\"),\n    );\n    ips_to_hostnames.insert(\n        IpAddr::V4(\"10.0.0.2\".parse().unwrap()),\n        String::from(\"i-like-cheese.com\"),\n    );\n\n    let stdout = Arc::new(Mutex::new(Vec::new()));\n    let os_input = os_input_output_dns(network_frames, 3, Some(stdout.clone()), None);\n    let opts = Opt {\n        interface: Some(String::from(\"interface_name\")),\n        raw: true,\n        no_resolve: true,\n        ..Default::default()\n    };\n    start(backend, os_input, opts);\n    assert_snapshot!(format_raw_stdout(&stdout));\n}\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__raw_mode__bi_directional_traffic.snap",
    "content": "---\nsource: src/tests/cases/raw_mode.rs\nexpression: formatted\n---\nRefreshing:\n<NO TRAFFIC>\n\nRefreshing:\nprocess: <TIMESTAMP_REMOVED> \"1\" up/down Bps: 24/25 connections: 1\nconnection: <TIMESTAMP_REMOVED> <interface_name>:443 => 1.1.1.1:12345 (tcp) up/down Bps: 24/25 process: \"1\"\nremote_address: <TIMESTAMP_REMOVED> 1.1.1.1 up/down Bps: 24/25 connections: 1\n\n\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__raw_mode__multiple_connections_from_remote_address.snap",
    "content": "---\nsource: src/tests/cases/raw_mode.rs\nexpression: formatted\n---\nRefreshing:\n<NO TRAFFIC>\n\nRefreshing:\nprocess: <TIMESTAMP_REMOVED> \"1\" up/down Bps: 0/47 connections: 2\nconnection: <TIMESTAMP_REMOVED> <interface_name>:443 => 1.1.1.1:12346 (tcp) up/down Bps: 0/25 process: \"1\"\nconnection: <TIMESTAMP_REMOVED> <interface_name>:443 => 1.1.1.1:12345 (tcp) up/down Bps: 0/22 process: \"1\"\nremote_address: <TIMESTAMP_REMOVED> 1.1.1.1 up/down Bps: 0/47 connections: 2\n\n\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__raw_mode__multiple_packets_of_traffic_from_different_connections.snap",
    "content": "---\nsource: src/tests/cases/raw_mode.rs\nexpression: formatted\n---\nRefreshing:\n<NO TRAFFIC>\n\nRefreshing:\nprocess: <TIMESTAMP_REMOVED> \"1\" up/down Bps: 0/22 connections: 1\nprocess: <TIMESTAMP_REMOVED> \"4\" up/down Bps: 0/19 connections: 1\nconnection: <TIMESTAMP_REMOVED> <interface_name>:443 => 2.2.2.2:12345 (tcp) up/down Bps: 0/22 process: \"1\"\nconnection: <TIMESTAMP_REMOVED> <interface_name>:4434 => 2.2.2.2:54321 (tcp) up/down Bps: 0/19 process: \"4\"\nremote_address: <TIMESTAMP_REMOVED> 2.2.2.2 up/down Bps: 0/41 connections: 2\n\n\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__raw_mode__multiple_packets_of_traffic_from_single_connection.snap",
    "content": "---\nsource: src/tests/cases/raw_mode.rs\nexpression: formatted\n---\nRefreshing:\n<NO TRAFFIC>\n\nRefreshing:\nprocess: <TIMESTAMP_REMOVED> \"1\" up/down Bps: 0/45 connections: 1\nconnection: <TIMESTAMP_REMOVED> <interface_name>:443 => 1.1.1.1:12345 (tcp) up/down Bps: 0/45 process: \"1\"\nremote_address: <TIMESTAMP_REMOVED> 1.1.1.1 up/down Bps: 0/45 connections: 1\n\n\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__raw_mode__multiple_processes_with_multiple_connections.snap",
    "content": "---\nsource: src/tests/cases/raw_mode.rs\nexpression: formatted\n---\nRefreshing:\n<NO TRAFFIC>\n\nRefreshing:\nprocess: <TIMESTAMP_REMOVED> \"5\" up/down Bps: 0/28 connections: 1\nprocess: <TIMESTAMP_REMOVED> \"4\" up/down Bps: 0/26 connections: 1\nprocess: <TIMESTAMP_REMOVED> \"1\" up/down Bps: 0/22 connections: 1\nprocess: <TIMESTAMP_REMOVED> \"2\" up/down Bps: 0/21 connections: 1\nconnection: <TIMESTAMP_REMOVED> <interface_name>:4435 => 3.3.3.3:1337 (tcp) up/down Bps: 0/28 process: \"5\"\nconnection: <TIMESTAMP_REMOVED> <interface_name>:4434 => 2.2.2.2:54321 (tcp) up/down Bps: 0/26 process: \"4\"\nconnection: <TIMESTAMP_REMOVED> <interface_name>:443 => 1.1.1.1:12345 (tcp) up/down Bps: 0/22 process: \"1\"\nconnection: <TIMESTAMP_REMOVED> <interface_name>:4432 => 4.4.4.4:1337 (tcp) up/down Bps: 0/21 process: \"2\"\nremote_address: <TIMESTAMP_REMOVED> 3.3.3.3 up/down Bps: 0/28 connections: 1\nremote_address: <TIMESTAMP_REMOVED> 2.2.2.2 up/down Bps: 0/26 connections: 1\nremote_address: <TIMESTAMP_REMOVED> 1.1.1.1 up/down Bps: 0/22 connections: 1\nremote_address: <TIMESTAMP_REMOVED> 4.4.4.4 up/down Bps: 0/21 connections: 1\n\n\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__raw_mode__no_resolve_mode.snap",
    "content": "---\nsource: src/tests/cases/raw_mode.rs\nexpression: formatted\n---\nRefreshing:\n<NO TRAFFIC>\n\nRefreshing:\nprocess: <TIMESTAMP_REMOVED> \"1\" up/down Bps: 28/30 connections: 1\nprocess: <TIMESTAMP_REMOVED> \"5\" up/down Bps: 17/18 connections: 1\nconnection: <TIMESTAMP_REMOVED> <interface_name>:443 => 1.1.1.1:12345 (tcp) up/down Bps: 28/30 process: \"1\"\nconnection: <TIMESTAMP_REMOVED> <interface_name>:4435 => 3.3.3.3:1337 (tcp) up/down Bps: 17/18 process: \"5\"\nremote_address: <TIMESTAMP_REMOVED> 1.1.1.1 up/down Bps: 28/30 connections: 1\nremote_address: <TIMESTAMP_REMOVED> 3.3.3.3 up/down Bps: 17/18 connections: 1\n\nRefreshing:\nprocess: <TIMESTAMP_REMOVED> \"1\" up/down Bps: 31/32 connections: 1\nprocess: <TIMESTAMP_REMOVED> \"5\" up/down Bps: 22/27 connections: 1\nconnection: <TIMESTAMP_REMOVED> <interface_name>:443 => 1.1.1.1:12345 (tcp) up/down Bps: 31/32 process: \"1\"\nconnection: <TIMESTAMP_REMOVED> <interface_name>:4435 => 3.3.3.3:1337 (tcp) up/down Bps: 22/27 process: \"5\"\nremote_address: <TIMESTAMP_REMOVED> 1.1.1.1 up/down Bps: 31/32 connections: 1\nremote_address: <TIMESTAMP_REMOVED> 3.3.3.3 up/down Bps: 22/27 connections: 1\n\n\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__raw_mode__one_ip_packet_of_traffic.snap",
    "content": "---\nsource: src/tests/cases/raw_mode.rs\nexpression: formatted\n---\nRefreshing:\n<NO TRAFFIC>\n\nRefreshing:\nprocess: <TIMESTAMP_REMOVED> \"1\" up/down Bps: 21/0 connections: 1\nconnection: <TIMESTAMP_REMOVED> <interface_name>:443 => 1.1.1.1:12345 (tcp) up/down Bps: 21/0 process: \"1\"\nremote_address: <TIMESTAMP_REMOVED> 1.1.1.1 up/down Bps: 21/0 connections: 1\n\n\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__raw_mode__one_packet_of_traffic.snap",
    "content": "---\nsource: src/tests/cases/raw_mode.rs\nexpression: formatted\n---\nRefreshing:\n<NO TRAFFIC>\n\nRefreshing:\nprocess: <TIMESTAMP_REMOVED> \"1\" up/down Bps: 21/0 connections: 1\nconnection: <TIMESTAMP_REMOVED> <interface_name>:443 => 1.1.1.1:12345 (tcp) up/down Bps: 21/0 process: \"1\"\nremote_address: <TIMESTAMP_REMOVED> 1.1.1.1 up/down Bps: 21/0 connections: 1\n\n\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__raw_mode__one_process_with_multiple_connections.snap",
    "content": "---\nsource: src/tests/cases/raw_mode.rs\nexpression: formatted\n---\nRefreshing:\n<NO TRAFFIC>\n\nRefreshing:\nprocess: <TIMESTAMP_REMOVED> \"1\" up/down Bps: 0/46 connections: 2\nconnection: <TIMESTAMP_REMOVED> <interface_name>:443 => 1.1.1.1:12346 (tcp) up/down Bps: 0/24 process: \"1\"\nconnection: <TIMESTAMP_REMOVED> <interface_name>:443 => 1.1.1.1:12345 (tcp) up/down Bps: 0/22 process: \"1\"\nremote_address: <TIMESTAMP_REMOVED> 1.1.1.1 up/down Bps: 0/46 connections: 2\n\n\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__raw_mode__sustained_traffic_from_multiple_processes.snap",
    "content": "---\nsource: src/tests/cases/raw_mode.rs\nexpression: formatted\n---\nRefreshing:\n<NO TRAFFIC>\n\nRefreshing:\nprocess: <TIMESTAMP_REMOVED> \"1\" up/down Bps: 0/22 connections: 1\nprocess: <TIMESTAMP_REMOVED> \"5\" up/down Bps: 0/19 connections: 1\nconnection: <TIMESTAMP_REMOVED> <interface_name>:443 => 1.1.1.1:12345 (tcp) up/down Bps: 0/22 process: \"1\"\nconnection: <TIMESTAMP_REMOVED> <interface_name>:4435 => 3.3.3.3:1337 (tcp) up/down Bps: 0/19 process: \"5\"\nremote_address: <TIMESTAMP_REMOVED> 1.1.1.1 up/down Bps: 0/22 connections: 1\nremote_address: <TIMESTAMP_REMOVED> 3.3.3.3 up/down Bps: 0/19 connections: 1\n\nRefreshing:\nprocess: <TIMESTAMP_REMOVED> \"1\" up/down Bps: 0/35 connections: 1\nprocess: <TIMESTAMP_REMOVED> \"5\" up/down Bps: 0/30 connections: 1\nconnection: <TIMESTAMP_REMOVED> <interface_name>:443 => 1.1.1.1:12345 (tcp) up/down Bps: 0/35 process: \"1\"\nconnection: <TIMESTAMP_REMOVED> <interface_name>:4435 => 3.3.3.3:1337 (tcp) up/down Bps: 0/30 process: \"5\"\nremote_address: <TIMESTAMP_REMOVED> 1.1.1.1 up/down Bps: 0/35 connections: 1\nremote_address: <TIMESTAMP_REMOVED> 3.3.3.3 up/down Bps: 0/30 connections: 1\n\n\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__raw_mode__sustained_traffic_from_multiple_processes_bi_directional.snap",
    "content": "---\nsource: src/tests/cases/raw_mode.rs\nexpression: formatted\n---\nRefreshing:\n<NO TRAFFIC>\n\nRefreshing:\nprocess: <TIMESTAMP_REMOVED> \"1\" up/down Bps: 28/30 connections: 1\nprocess: <TIMESTAMP_REMOVED> \"5\" up/down Bps: 17/18 connections: 1\nconnection: <TIMESTAMP_REMOVED> <interface_name>:443 => 1.1.1.1:12345 (tcp) up/down Bps: 28/30 process: \"1\"\nconnection: <TIMESTAMP_REMOVED> <interface_name>:4435 => 3.3.3.3:1337 (tcp) up/down Bps: 17/18 process: \"5\"\nremote_address: <TIMESTAMP_REMOVED> 1.1.1.1 up/down Bps: 28/30 connections: 1\nremote_address: <TIMESTAMP_REMOVED> 3.3.3.3 up/down Bps: 17/18 connections: 1\n\nRefreshing:\nprocess: <TIMESTAMP_REMOVED> \"1\" up/down Bps: 31/32 connections: 1\nprocess: <TIMESTAMP_REMOVED> \"5\" up/down Bps: 22/27 connections: 1\nconnection: <TIMESTAMP_REMOVED> <interface_name>:443 => 1.1.1.1:12345 (tcp) up/down Bps: 31/32 process: \"1\"\nconnection: <TIMESTAMP_REMOVED> <interface_name>:4435 => 3.3.3.3:1337 (tcp) up/down Bps: 22/27 process: \"5\"\nremote_address: <TIMESTAMP_REMOVED> 1.1.1.1 up/down Bps: 31/32 connections: 1\nremote_address: <TIMESTAMP_REMOVED> 3.3.3.3 up/down Bps: 22/27 connections: 1\n\n\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__raw_mode__sustained_traffic_from_one_process.snap",
    "content": "---\nsource: src/tests/cases/raw_mode.rs\nexpression: formatted\n---\nRefreshing:\n<NO TRAFFIC>\n\nRefreshing:\nprocess: <TIMESTAMP_REMOVED> \"1\" up/down Bps: 0/22 connections: 1\nconnection: <TIMESTAMP_REMOVED> <interface_name>:443 => 1.1.1.1:12345 (tcp) up/down Bps: 0/22 process: \"1\"\nremote_address: <TIMESTAMP_REMOVED> 1.1.1.1 up/down Bps: 0/22 connections: 1\n\nRefreshing:\nprocess: <TIMESTAMP_REMOVED> \"1\" up/down Bps: 0/31 connections: 1\nconnection: <TIMESTAMP_REMOVED> <interface_name>:443 => 1.1.1.1:12345 (tcp) up/down Bps: 0/31 process: \"1\"\nremote_address: <TIMESTAMP_REMOVED> 1.1.1.1 up/down Bps: 0/31 connections: 1\n\n\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__raw_mode__traffic_with_host_names.snap",
    "content": "---\nsource: src/tests/cases/raw_mode.rs\nexpression: formatted\n---\nRefreshing:\n<NO TRAFFIC>\n\nRefreshing:\nprocess: <TIMESTAMP_REMOVED> \"1\" up/down Bps: 28/30 connections: 1\nprocess: <TIMESTAMP_REMOVED> \"5\" up/down Bps: 17/18 connections: 1\nconnection: <TIMESTAMP_REMOVED> <interface_name>:443 => 1.1.1.1:12345 (tcp) up/down Bps: 28/30 process: \"1\"\nconnection: <TIMESTAMP_REMOVED> <interface_name>:4435 => 3.3.3.3:1337 (tcp) up/down Bps: 17/18 process: \"5\"\nremote_address: <TIMESTAMP_REMOVED> 1.1.1.1 up/down Bps: 28/30 connections: 1\nremote_address: <TIMESTAMP_REMOVED> 3.3.3.3 up/down Bps: 17/18 connections: 1\n\nRefreshing:\nprocess: <TIMESTAMP_REMOVED> \"1\" up/down Bps: 31/32 connections: 1\nprocess: <TIMESTAMP_REMOVED> \"5\" up/down Bps: 22/27 connections: 1\nconnection: <TIMESTAMP_REMOVED> <interface_name>:443 => one.one.one.one:12345 (tcp) up/down Bps: 31/32 process: \"1\"\nconnection: <TIMESTAMP_REMOVED> <interface_name>:4435 => three.three.three.three:1337 (tcp) up/down Bps: 22/27 process: \"5\"\nremote_address: <TIMESTAMP_REMOVED> one.one.one.one up/down Bps: 31/32 connections: 1\nremote_address: <TIMESTAMP_REMOVED> three.three.three.three up/down Bps: 22/27 connections: 1\n\n\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__basic_only_addresses.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR)\n---\nIF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B                                                                                                                                    \n┌Utilization by remote address───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐\n│Remote Address                                                                                                Connections                      Rate (Up / Down)                             │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘\n Press <SPACE> to pause. Use <TAB> to rearrange tables. (DNS queries hidden).                                                                                                                 \n\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__basic_only_connections.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR)\n---\nIF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B                                                                                                                                    \n┌Utilization by connection───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐\n│Connection                                                                                                           Process                                Rate (Up / Down)                │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘\n Press <SPACE> to pause. Use <TAB> to rearrange tables. (DNS queries hidden).                                                                                                                 \n\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__basic_only_processes.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR)\n---\nIF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B                                                                                                                                    \n┌Utilization by process name─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐\n│Process                                                               PID                            Connections                    Rate (Up / Down)                                        │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘\n Press <SPACE> to pause. Use <TAB> to rearrange tables. (DNS queries hidden).\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__basic_processes_with_dns_queries.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR)\n---\nIF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B                                                                                                                                    \n┌Utilization by process name─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐\n│Process                                                               PID                            Connections                    Rate (Up / Down)                                        │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘\n Press <SPACE> to pause. Use <TAB> to rearrange tables. (DNS queries shown).\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__basic_startup-2.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_events.lock().unwrap().as_slice()\n---\n[\n    Clear,\n    HideCursor,\n    Draw,\n    HideCursor,\n    Flush,\n    ShowCursor,\n]\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__basic_startup.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR)\n---\nIF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B                                                                                                                                    \n┌Utilization by process name──────────────────────────────────────────────────────────────────┐┌Utilization by remote address────────────────────────────────────────────────────────────────┐\n│Process                            PID             Connections     Rate (Up / Down)          ││Remote Address                              Connections       Rate (Up / Down)               │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n└─────────────────────────────────────────────────────────────────────────────────────────────┘└─────────────────────────────────────────────────────────────────────────────────────────────┘\n┌Utilization by connection───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐\n│Connection                                                                                                           Process                                Rate (Up / Down)                │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘\n Press <SPACE> to pause. Use <TAB> to rearrange tables. (DNS queries hidden).\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__bi_directional_traffic-2.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_events.lock().unwrap().as_slice()\n---\n[\n    Clear,\n    HideCursor,\n    Draw,\n    HideCursor,\n    Flush,\n    Draw,\n    HideCursor,\n    Flush,\n    ShowCursor,\n]\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__bi_directional_traffic.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR)\n---\nIF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B                                                                                                                                    \n┌Utilization by process name──────────────────────────────────────────────────────────────────┐┌Utilization by remote address────────────────────────────────────────────────────────────────┐\n│Process                            PID             Connections     Rate (Up / Down)          ││Remote Address                              Connections       Rate (Up / Down)               │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n└─────────────────────────────────────────────────────────────────────────────────────────────┘└─────────────────────────────────────────────────────────────────────────────────────────────┘\n┌Utilization by connection───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐\n│Connection                                                                                                           Process                                Rate (Up / Down)                │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘\n Press <SPACE> to pause. Use <TAB> to rearrange tables. (DNS queries hidden).                                                                                                                 \n\n--- SECTION SEPARATOR ---\n                                             24. 0B / 25.00B                                                                                                                                  \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n 1                                  1               1               24.00B / 25.00B             1.1.1.1                                     1                 24.00B / 25.00B                 \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n <interface_name>:443 => 1.1.1.1:12345 (tcp)                                                                          1                                      24.00B / 25.00B\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout-full-width-under-30-height-draw_events.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR)\n---\nIF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B                                                                                                                                    \n┌Utilization by process name──────────────────────────────────────────────────────────────────┐┌Utilization by remote address────────────────────────────────────────────────────────────────┐\n│Process                            PID             Connections     Rate (Up / Down)          ││Remote Address                              Connections       Rate (Up / Down)               │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n└─────────────────────────────────────────────────────────────────────────────────────────────┘└─────────────────────────────────────────────────────────────────────────────────────────────┘\n Press <SPACE> to pause. Use <TAB> to rearrange tables. (DNS queries hidden).                                                                                                                 \n\n--- SECTION SEPARATOR ---\n                                                     98. 0B                                                                                                                                   \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n 5                                  5               1               0.00B / 28.00B              3.3.3.3                                     1                 0.00B / 28.00B                  \n 4                                  4               1               0.00B / 26.00B              2.2.2.2                                     1                 0.00B / 26.00B                  \n 1                                  1               1               0.00B / 22.00B              1.1.1.1                                     1                 0.00B / 22.00B                  \n 2                                  2               1               0.00B / 21.00B              4.4.4.4                                     1                 0.00B / 21.00B\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout-full-width-under-30-height-events.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_events.lock().unwrap().as_slice()\n---\n[\n    Clear,\n    HideCursor,\n    Draw,\n    HideCursor,\n    Flush,\n    Draw,\n    HideCursor,\n    Flush,\n    ShowCursor,\n]\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout-under-120-width-full-height-draw_events.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR)\n---\nIF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B                                                             \n┌Utilization by process name──────────────────────────────────────────────────────────────────────────────────────────┐\n│Process                                       PID                Connections        Rate (Up / Down)                 │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘\n┌Utilization by remote address────────────────────────────────────────────────────────────────────────────────────────┐\n│Remote Address                                                       Connections          Rate (Up / Down)           │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘\n Press <SPACE> to pause. Use <TAB> to rearrange tables. (DNS queries hidden).                                          \n\n--- SECTION SEPARATOR ---\n                                                     98. 0B                                                            \n                                                                                                                       \n                                                                                                                       \n 5                                             5                  1                  0.00B / 28.00B                    \n 4                                             4                  1                  0.00B / 26.00B                    \n 1                                             1                  1                  0.00B / 22.00B                    \n 2                                             2                  1                  0.00B / 21.00B                    \n                                                                                                                       \n                                                                                                                       \n                                                                                                                       \n                                                                                                                       \n                                                                                                                       \n                                                                                                                       \n                                                                                                                       \n                                                                                                                       \n                                                                                                                       \n                                                                                                                       \n                                                                                                                       \n                                                                                                                       \n                                                                                                                       \n                                                                                                                       \n                                                                                                                       \n                                                                                                                       \n                                                                                                                       \n                                                                                                                       \n                                                                                                                       \n                                                                                                                       \n 3.3.3.3                                                              1                    0.00B / 28.00B              \n 2.2.2.2                                                              1                    0.00B / 26.00B              \n 1.1.1.1                                                              1                    0.00B / 22.00B              \n 4.4.4.4                                                              1                    0.00B / 21.00B\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout-under-120-width-full-height-events.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_events.lock().unwrap().as_slice()\n---\n[\n    Clear,\n    HideCursor,\n    Draw,\n    HideCursor,\n    Flush,\n    Draw,\n    HideCursor,\n    Flush,\n    ShowCursor,\n]\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout-under-120-width-under-30-height-draw_events.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR)\n---\nIF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B                                                             \n┌Utilization by process name──────────────────────────────────────────────────────────────────────────────────────────┐\n│Process                                       PID                Connections        Rate (Up / Down)                 │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n│                                                                                                                     │\n└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘\n Press <SPACE> to pause. Use <TAB> to rearrange tables. (DNS queries hidden).                                          \n\n--- SECTION SEPARATOR ---\n                                                     98. 0B                                                            \n                                                                                                                       \n                                                                                                                       \n 5                                             5                  1                  0.00B / 28.00B                    \n 4                                             4                  1                  0.00B / 26.00B                    \n 1                                             1                  1                  0.00B / 22.00B                    \n 2                                             2                  1                  0.00B / 21.00B\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout-under-120-width-under-30-height-events.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_events.lock().unwrap().as_slice()\n---\n[\n    Clear,\n    HideCursor,\n    Draw,\n    HideCursor,\n    Flush,\n    Draw,\n    HideCursor,\n    Flush,\n    ShowCursor,\n]\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout-under-50-width-under-50-height-draw_events.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR)\n---\nIF: interface_name | Total Rate (Up / Down): 0.00B\n┌Utilization by process name─────────────────────┐\n│Process                  Rate (Up / Down)       │\n│                                                │\n│                                                │\n│                                                │\n│                                                │\n│                                                │\n│                                                │\n│                                                │\n│                                                │\n│                                                │\n│                                                │\n│                                                │\n│                                                │\n│                                                │\n│                                                │\n│                                                │\n│                                                │\n│                                                │\n│                                                │\n│                                                │\n│                                                │\n│                                                │\n└────────────────────────────────────────────────┘\n┌Utilization by remote address───────────────────┐\n│Remote Address               Rate (Up / Down)   │\n│                                                │\n│                                                │\n│                                                │\n│                                                │\n│                                                │\n│                                                │\n│                                                │\n│                                                │\n│                                                │\n│                                                │\n│                                                │\n│                                                │\n│                                                │\n│                                                │\n│                                                │\n│                                                │\n│                                                │\n│                                                │\n│                                                │\n│                                                │\n│                                                │\n└────────────────────────────────────────────────┘\n Press <SPACE> to pause.                          \n\n--- SECTION SEPARATOR ---\n                                                  \n                                                  \n                                                  \n 5                        0.00B / 28.00B          \n 4                        0.00B / 26.00B          \n 1                        0.00B / 22.00B          \n 2                        0.00B / 21.00B          \n                                                  \n                                                  \n                                                  \n                                                  \n                                                  \n                                                  \n                                                  \n                                                  \n                                                  \n                                                  \n                                                  \n                                                  \n                                                  \n                                                  \n                                                  \n                                                  \n                                                  \n                                                  \n                                                  \n                                                  \n 3.3.3.3                      0.00B / 28.00B      \n 2.2.2.2                      0.00B / 26.00B      \n 1.1.1.1                      0.00B / 22.00B      \n 4.4.4.4                      0.00B / 21.00B\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout-under-50-width-under-50-height-events.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_events.lock().unwrap().as_slice()\n---\n[\n    Clear,\n    HideCursor,\n    Draw,\n    HideCursor,\n    Flush,\n    Draw,\n    HideCursor,\n    Flush,\n    ShowCursor,\n]\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout-under-70-width-under-30-height-draw_events.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR)\n---\nIF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B           \n┌Utilization by process name────────────────────────────────────────┐\n│Process                        Connections    Rate (Up / Down)     │\n│                                                                   │\n│                                                                   │\n│                                                                   │\n│                                                                   │\n│                                                                   │\n│                                                                   │\n│                                                                   │\n│                                                                   │\n│                                                                   │\n│                                                                   │\n│                                                                   │\n│                                                                   │\n│                                                                   │\n│                                                                   │\n│                                                                   │\n│                                                                   │\n│                                                                   │\n│                                                                   │\n│                                                                   │\n│                                                                   │\n│                                                                   │\n│                                                                   │\n│                                                                   │\n│                                                                   │\n└───────────────────────────────────────────────────────────────────┘\n Press <SPACE> to pause. Use <TAB> to rearrange tables.              \n\n--- SECTION SEPARATOR ---\n                                                     98. 0B          \n                                                                     \n                                                                     \n 5                              1              0.00B / 28.00B        \n 4                              1              0.00B / 26.00B        \n 1                              1              0.00B / 22.00B        \n 2                              1              0.00B / 21.00B\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__layout-under-70-width-under-30-height-events.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_events.lock().unwrap().as_slice()\n---\n[\n    Clear,\n    HideCursor,\n    Draw,\n    HideCursor,\n    Flush,\n    Draw,\n    HideCursor,\n    Flush,\n    ShowCursor,\n]\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__multiple_connections_from_remote_address-2.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_events.lock().unwrap().as_slice()\n---\n[\n    Clear,\n    HideCursor,\n    Draw,\n    HideCursor,\n    Flush,\n    Draw,\n    HideCursor,\n    Flush,\n    ShowCursor,\n]\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__multiple_connections_from_remote_address.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR)\n---\nIF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B                                                                                                                                    \n┌Utilization by process name──────────────────────────────────────────────────────────────────┐┌Utilization by remote address────────────────────────────────────────────────────────────────┐\n│Process                            PID             Connections     Rate (Up / Down)          ││Remote Address                              Connections       Rate (Up / Down)               │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n└─────────────────────────────────────────────────────────────────────────────────────────────┘└─────────────────────────────────────────────────────────────────────────────────────────────┘\n┌Utilization by connection───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐\n│Connection                                                                                                           Process                                Rate (Up / Down)                │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘\n Press <SPACE> to pause. Use <TAB> to rearrange tables. (DNS queries hidden).                                                                                                                 \n\n--- SECTION SEPARATOR ---\n                                                     47. 0B                                                                                                                                   \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n 1                                  1               2               0.00B / 47.00B              1.1.1.1                                     2                 0.00B / 47.00B                  \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n <interface_name>:443 => 1.1.1.1:12346 (tcp)                                                                          1                                      0.00B / 25.00B                   \n <interface_name>:443 => 1.1.1.1:12345 (tcp)                                                                          1                                      0.00B / 22.00B\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__multiple_packets_of_traffic_from_different_connections-2.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_events.lock().unwrap().as_slice()\n---\n[\n    Clear,\n    HideCursor,\n    Draw,\n    HideCursor,\n    Flush,\n    Draw,\n    HideCursor,\n    Flush,\n    ShowCursor,\n]\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__multiple_packets_of_traffic_from_different_connections.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR)\n---\nIF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B                                                                                                                                    \n┌Utilization by process name──────────────────────────────────────────────────────────────────┐┌Utilization by remote address────────────────────────────────────────────────────────────────┐\n│Process                            PID             Connections     Rate (Up / Down)          ││Remote Address                              Connections       Rate (Up / Down)               │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n└─────────────────────────────────────────────────────────────────────────────────────────────┘└─────────────────────────────────────────────────────────────────────────────────────────────┘\n┌Utilization by connection───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐\n│Connection                                                                                                           Process                                Rate (Up / Down)                │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘\n Press <SPACE> to pause. Use <TAB> to rearrange tables. (DNS queries hidden).                                                                                                                 \n\n--- SECTION SEPARATOR ---\n                                                     41. 0B                                                                                                                                   \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n 1                                  1               1               0.00B / 22.00B              2.2.2.2                                     2                 0.00B / 41.00B                  \n 4                                  4               1               0.00B / 19.00B                                                                                                            \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n <interface_name>:443 => 2.2.2.2:12345 (tcp)                                                                          1                                      0.00B / 22.00B                   \n <interface_name>:4434 => 2.2.2.2:54321 (tcp)                                                                         4                                      0.00B / 19.00B\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__multiple_packets_of_traffic_from_single_connection-2.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_events.lock().unwrap().as_slice()\n---\n[\n    Clear,\n    HideCursor,\n    Draw,\n    HideCursor,\n    Flush,\n    Draw,\n    HideCursor,\n    Flush,\n    ShowCursor,\n]\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__multiple_packets_of_traffic_from_single_connection.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR)\n---\nIF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B                                                                                                                                    \n┌Utilization by process name──────────────────────────────────────────────────────────────────┐┌Utilization by remote address────────────────────────────────────────────────────────────────┐\n│Process                            PID             Connections     Rate (Up / Down)          ││Remote Address                              Connections       Rate (Up / Down)               │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n└─────────────────────────────────────────────────────────────────────────────────────────────┘└─────────────────────────────────────────────────────────────────────────────────────────────┘\n┌Utilization by connection───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐\n│Connection                                                                                                           Process                                Rate (Up / Down)                │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘\n Press <SPACE> to pause. Use <TAB> to rearrange tables. (DNS queries hidden).                                                                                                                 \n\n--- SECTION SEPARATOR ---\n                                                     45. 0B                                                                                                                                   \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n 1                                  1               1               0.00B / 45.00B              1.1.1.1                                     1                 0.00B / 45.00B                  \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n <interface_name>:443 => 1.1.1.1:12345 (tcp)                                                                          1                                      0.00B / 45.00B\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__multiple_processes_with_multiple_connections-2.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_events.lock().unwrap().as_slice()\n---\n[\n    Clear,\n    HideCursor,\n    Draw,\n    HideCursor,\n    Flush,\n    Draw,\n    HideCursor,\n    Flush,\n    ShowCursor,\n]\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__multiple_processes_with_multiple_connections.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR)\n---\nIF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B                                                                                                                                    \n┌Utilization by process name──────────────────────────────────────────────────────────────────┐┌Utilization by remote address────────────────────────────────────────────────────────────────┐\n│Process                            PID             Connections     Rate (Up / Down)          ││Remote Address                              Connections       Rate (Up / Down)               │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n└─────────────────────────────────────────────────────────────────────────────────────────────┘└─────────────────────────────────────────────────────────────────────────────────────────────┘\n┌Utilization by connection───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐\n│Connection                                                                                                           Process                                Rate (Up / Down)                │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘\n Press <SPACE> to pause. Use <TAB> to rearrange tables. (DNS queries hidden).                                                                                                                 \n\n--- SECTION SEPARATOR ---\n                                                     98. 0B                                                                                                                                   \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n 5                                  5               1               0.00B / 28.00B              3.3.3.3                                     1                 0.00B / 28.00B                  \n 4                                  4               1               0.00B / 26.00B              2.2.2.2                                     1                 0.00B / 26.00B                  \n 1                                  1               1               0.00B / 22.00B              1.1.1.1                                     1                 0.00B / 22.00B                  \n 2                                  2               1               0.00B / 21.00B              4.4.4.4                                     1                 0.00B / 21.00B                  \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n <interface_name>:4435 => 3.3.3.3:1337 (tcp)                                                                          5                                      0.00B / 28.00B                   \n <interface_name>:4434 => 2.2.2.2:54321 (tcp)                                                                         4                                      0.00B / 26.00B                   \n <interface_name>:443 => 1.1.1.1:12345 (tcp)                                                                          1                                      0.00B / 22.00B                   \n <interface_name>:4432 => 4.4.4.4:1337 (tcp)                                                                          2                                      0.00B / 21.00B\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__no_resolve_mode-2.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_events.lock().unwrap().as_slice()\n---\n[\n    Clear,\n    HideCursor,\n    Draw,\n    HideCursor,\n    Flush,\n    Draw,\n    HideCursor,\n    Flush,\n    Draw,\n    HideCursor,\n    Flush,\n    ShowCursor,\n]\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__no_resolve_mode.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR)\n---\nIF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B                                                                                                                                    \n┌Utilization by process name──────────────────────────────────────────────────────────────────┐┌Utilization by remote address────────────────────────────────────────────────────────────────┐\n│Process                            PID             Connections     Rate (Up / Down)          ││Remote Address                              Connections       Rate (Up / Down)               │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n└─────────────────────────────────────────────────────────────────────────────────────────────┘└─────────────────────────────────────────────────────────────────────────────────────────────┘\n┌Utilization by connection───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐\n│Connection                                                                                                           Process                                Rate (Up / Down)                │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘\n Press <SPACE> to pause. Use <TAB> to rearrange tables. (DNS queries hidden).                                                                                                                 \n\n--- SECTION SEPARATOR ---\n                                             45. 0B / 49.00B                                                                                                                                  \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n 1                                  1               1               28.00B / 30.00B             1.1.1.1                                     1                 28.00B / 30.00B                 \n 5                                  5               1               17.00B / 18.00B             3.3.3.3                                     1                 17.00B / 18.00B                 \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n <interface_name>:443 => 1.1.1.1:12345 (tcp)                                                                          1                                      28.00B / 30.00B                  \n <interface_name>:4435 => 3.3.3.3:1337 (tcp)                                                                          5                                      17.00B / 18.00B                  \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n\n--- SECTION SEPARATOR ---\n                                             53       60                                                                                                                                      \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                    31        2                                                                               31        2                     \n                                                                    22       27                                                                               22       27                     \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                             31        2                      \n                                                                                                                                                             22       27\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__one_packet_of_traffic-2.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_events.lock().unwrap().as_slice()\n---\n[\n    Clear,\n    HideCursor,\n    Draw,\n    HideCursor,\n    Flush,\n    Draw,\n    HideCursor,\n    Flush,\n    ShowCursor,\n]\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__one_packet_of_traffic.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR)\n---\nIF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B                                                                                                                                    \n┌Utilization by process name──────────────────────────────────────────────────────────────────┐┌Utilization by remote address────────────────────────────────────────────────────────────────┐\n│Process                            PID             Connections     Rate (Up / Down)          ││Remote Address                              Connections       Rate (Up / Down)               │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n└─────────────────────────────────────────────────────────────────────────────────────────────┘└─────────────────────────────────────────────────────────────────────────────────────────────┘\n┌Utilization by connection───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐\n│Connection                                                                                                           Process                                Rate (Up / Down)                │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘\n Press <SPACE> to pause. Use <TAB> to rearrange tables. (DNS queries hidden).                                                                                                                 \n\n--- SECTION SEPARATOR ---\n                                             21. 0B / 0. 0B                                                                                                                                   \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n 1                                  1               1               21.00B / 0.00B              1.1.1.1                                     1                 21.00B / 0.00B                  \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n <interface_name>:443 => 1.1.1.1:12345 (tcp)                                                                          1                                      21.00B / 0.00B\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__one_process_with_multiple_connections-2.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_events.lock().unwrap().as_slice()\n---\n[\n    Clear,\n    HideCursor,\n    Draw,\n    HideCursor,\n    Flush,\n    Draw,\n    HideCursor,\n    Flush,\n    ShowCursor,\n]\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__one_process_with_multiple_connections.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR)\n---\nIF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B                                                                                                                                    \n┌Utilization by process name──────────────────────────────────────────────────────────────────┐┌Utilization by remote address────────────────────────────────────────────────────────────────┐\n│Process                            PID             Connections     Rate (Up / Down)          ││Remote Address                              Connections       Rate (Up / Down)               │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n└─────────────────────────────────────────────────────────────────────────────────────────────┘└─────────────────────────────────────────────────────────────────────────────────────────────┘\n┌Utilization by connection───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐\n│Connection                                                                                                           Process                                Rate (Up / Down)                │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘\n Press <SPACE> to pause. Use <TAB> to rearrange tables. (DNS queries hidden).                                                                                                                 \n\n--- SECTION SEPARATOR ---\n                                                     46. 0B                                                                                                                                   \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n 1                                  1               2               0.00B / 46.00B              1.1.1.1                                     2                 0.00B / 46.00B                  \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n <interface_name>:443 => 1.1.1.1:12346 (tcp)                                                                          1                                      0.00B / 24.00B                   \n <interface_name>:443 => 1.1.1.1:12345 (tcp)                                                                          1                                      0.00B / 22.00B\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__pause_by_space-2.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_events.lock().unwrap().as_slice()\n---\n[\n    Clear,\n    HideCursor,\n    Draw,\n    HideCursor,\n    Flush,\n    Draw,\n    HideCursor,\n    Flush,\n    Draw,\n    HideCursor,\n    Flush,\n    ShowCursor,\n]\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__pause_by_space.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR)\n---\nIF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B                                                                                                                                    \n┌Utilization by process name──────────────────────────────────────────────────────────────────┐┌Utilization by remote address────────────────────────────────────────────────────────────────┐\n│Process                            PID             Connections     Rate (Up / Down)          ││Remote Address                              Connections       Rate (Up / Down)               │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n└─────────────────────────────────────────────────────────────────────────────────────────────┘└─────────────────────────────────────────────────────────────────────────────────────────────┘\n┌Utilization by connection───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐\n│Connection                                                                                                           Process                                Rate (Up / Down)                │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘\n Press <SPACE> to pause. Use <TAB> to rearrange tables. (DNS queries hidden).                                                                                                                 \n\n--- SECTION SEPARATOR ---\nIF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B [PAUSED]                                                                                                                           \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                  resume. Use <TAB> to rea range tables. (DNS queries hi den).                                                                                                                \n\n--- SECTION SEPARATOR ---\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__rearranged_by_tab-2.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_events.lock().unwrap().as_slice()\n---\n[\n    Clear,\n    HideCursor,\n    Draw,\n    HideCursor,\n    Flush,\n    Draw,\n    HideCursor,\n    Flush,\n    Draw,\n    HideCursor,\n    Flush,\n    Draw,\n    HideCursor,\n    Flush,\n    Draw,\n    HideCursor,\n    Flush,\n    ShowCursor,\n]\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__rearranged_by_tab.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR)\n---\nIF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B                                                                                                                                    \n┌Utilization by process name──────────────────────────────────────────────────────────────────┐┌Utilization by remote address────────────────────────────────────────────────────────────────┐\n│Process                            PID             Connections     Rate (Up / Down)          ││Remote Address                              Connections       Rate (Up / Down)               │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n└─────────────────────────────────────────────────────────────────────────────────────────────┘└─────────────────────────────────────────────────────────────────────────────────────────────┘\n┌Utilization by connection───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐\n│Connection                                                                                                           Process                                Rate (Up / Down)                │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘\n Press <SPACE> to pause. Use <TAB> to rearrange tables. (DNS queries hidden).                                                                                                                 \n\n--- SECTION SEPARATOR ---\n                                                     22. 0B                                                                                                                                   \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n 1                                  1               1               0.00B / 22.00B              1.1.1.1                                     1                 0.00B / 22.00B                  \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n <interface_name>:443 => 1.1.1.1:12345 (tcp)                                                                          1                                      0.00B / 22.00B                   \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n\n--- SECTION SEPARATOR ---\n                                                                                                                                                                                              \n                remote addr ss                                                                                 connection────                                                                 \n Remote Address                              Connecti  s       Rate (Up / Down)                 Connection                                           Process           Rate (Up / Down)       \n  .1.1.1                                     1                 0.00B / 22.00B                   <interface_name>:443 => 1.1.1.1:12345 (tcp)          1                 0     / 22.00B         \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                proc ss name                                                                                                                                                                  \n Proc ss                                                               PID                            Connections                    Rate (Up / Down)                                         \n 1                                                                     1                              1                              0.00B / 22.00B                                           \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n\n--- SECTION SEPARATOR ---\n                                                     14                                                                                                                                       \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                       14                                                                                                      14             \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                             14                                               \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n\n--- SECTION SEPARATOR ---\n                                                      1                                                                                                                                       \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                        1                                                                                                       1             \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                              1\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__sustained_traffic_from_multiple_processes-2.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_events.lock().unwrap().as_slice()\n---\n[\n    Clear,\n    HideCursor,\n    Draw,\n    HideCursor,\n    Flush,\n    Draw,\n    HideCursor,\n    Flush,\n    Draw,\n    HideCursor,\n    Flush,\n    ShowCursor,\n]\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__sustained_traffic_from_multiple_processes.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR)\n---\nIF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B                                                                                                                                    \n┌Utilization by process name──────────────────────────────────────────────────────────────────┐┌Utilization by remote address────────────────────────────────────────────────────────────────┐\n│Process                            PID             Connections     Rate (Up / Down)          ││Remote Address                              Connections       Rate (Up / Down)               │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n└─────────────────────────────────────────────────────────────────────────────────────────────┘└─────────────────────────────────────────────────────────────────────────────────────────────┘\n┌Utilization by connection───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐\n│Connection                                                                                                           Process                                Rate (Up / Down)                │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘\n Press <SPACE> to pause. Use <TAB> to rearrange tables. (DNS queries hidden).                                                                                                                 \n\n--- SECTION SEPARATOR ---\n                                                     41. 0B                                                                                                                                   \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n 1                                  1               1               0.00B / 22.00B              1.1.1.1                                     1                 0.00B / 22.00B                  \n 5                                  5               1               0.00B / 19.00B              3.3.3.3                                     1                 0.00B / 19.00B                  \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n <interface_name>:443 => 1.1.1.1:12345 (tcp)                                                                          1                                      0.00B / 22.00B                   \n <interface_name>:4435 => 3.3.3.3:1337 (tcp)                                                                          5                                      0.00B / 19.00B                   \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n\n--- SECTION SEPARATOR ---\n                                                     65                                                                                                                                       \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                            35                                                                                        35                      \n                                                                            30                                                                                        30                      \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                     35                       \n                                                                                                                                                                     30\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__sustained_traffic_from_multiple_processes_bi_directional-2.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_events.lock().unwrap().as_slice()\n---\n[\n    Clear,\n    HideCursor,\n    Draw,\n    HideCursor,\n    Flush,\n    Draw,\n    HideCursor,\n    Flush,\n    Draw,\n    HideCursor,\n    Flush,\n    ShowCursor,\n]\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__sustained_traffic_from_multiple_processes_bi_directional.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR)\n---\nIF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B                                                                                                                                    \n┌Utilization by process name──────────────────────────────────────────────────────────────────┐┌Utilization by remote address────────────────────────────────────────────────────────────────┐\n│Process                            PID             Connections     Rate (Up / Down)          ││Remote Address                              Connections       Rate (Up / Down)               │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n└─────────────────────────────────────────────────────────────────────────────────────────────┘└─────────────────────────────────────────────────────────────────────────────────────────────┘\n┌Utilization by connection───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐\n│Connection                                                                                                           Process                                Rate (Up / Down)                │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘\n Press <SPACE> to pause. Use <TAB> to rearrange tables. (DNS queries hidden).                                                                                                                 \n\n--- SECTION SEPARATOR ---\n                                             45. 0B / 49.00B                                                                                                                                  \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n 1                                  1               1               28.00B / 30.00B             1.1.1.1                                     1                 28.00B / 30.00B                 \n 5                                  5               1               17.00B / 18.00B             3.3.3.3                                     1                 17.00B / 18.00B                 \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n <interface_name>:443 => 1.1.1.1:12345 (tcp)                                                                          1                                      28.00B / 30.00B                  \n <interface_name>:4435 => 3.3.3.3:1337 (tcp)                                                                          5                                      17.00B / 18.00B                  \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n\n--- SECTION SEPARATOR ---\n                                             53       60                                                                                                                                      \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                    31        2                                                                               31        2                     \n                                                                    22       27                                                                               22       27                     \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                             31        2                      \n                                                                                                                                                             22       27\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__sustained_traffic_from_multiple_processes_bi_directional_total-2.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_events.lock().unwrap().as_slice()\n---\n[\n    Clear,\n    HideCursor,\n    Draw,\n    HideCursor,\n    Flush,\n    Draw,\n    HideCursor,\n    Flush,\n    Draw,\n    HideCursor,\n    Flush,\n    ShowCursor,\n]\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__sustained_traffic_from_multiple_processes_bi_directional_total.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR)\n---\nIF: interface_name | Total Data (Up / Down): 0.00B / 0.00B                                                                                                                                    \n┌Utilization by process name──────────────────────────────────────────────────────────────────┐┌Utilization by remote address────────────────────────────────────────────────────────────────┐\n│Process                            PID             Connections     Data (Up / Down)          ││Remote Address                              Connections       Data (Up / Down)               │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n└─────────────────────────────────────────────────────────────────────────────────────────────┘└─────────────────────────────────────────────────────────────────────────────────────────────┘\n┌Utilization by connection───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐\n│Connection                                                                                                           Process                                Data (Up / Down)                │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘\n Press <SPACE> to pause. Use <TAB> to rearrange tables. (DNS queries hidden).                                                                                                                 \n\n--- SECTION SEPARATOR ---\n                                             45. 0B / 49.00B                                                                                                                                  \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n 1                                  1               1               28.00B / 30.00B             1.1.1.1                                     1                 28.00B / 30.00B                 \n 5                                  5               1               17.00B / 18.00B             3.3.3.3                                     1                 17.00B / 18.00B                 \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n <interface_name>:443 => 1.1.1.1:12345 (tcp)                                                                          1                                      28.00B / 30.00B                  \n <interface_name>:4435 => 3.3.3.3:1337 (tcp)                                                                          5                                      17.00B / 18.00B                  \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n\n--- SECTION SEPARATOR ---\n                                             98       109. 0B                                                                                                                                 \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                    59       62                                                                               59       62                     \n                                                                    39       45                                                                               39       45                     \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                             59       62                      \n                                                                                                                                                             39       45\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__sustained_traffic_from_multiple_processes_total-2.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_events.lock().unwrap().as_slice()\n---\n[\n    Clear,\n    HideCursor,\n    Draw,\n    HideCursor,\n    Flush,\n    Draw,\n    HideCursor,\n    Flush,\n    Draw,\n    HideCursor,\n    Flush,\n    ShowCursor,\n]\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__sustained_traffic_from_multiple_processes_total.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR)\n---\nIF: interface_name | Total Data (Up / Down): 0.00B / 0.00B                                                                                                                                    \n┌Utilization by process name──────────────────────────────────────────────────────────────────┐┌Utilization by remote address────────────────────────────────────────────────────────────────┐\n│Process                            PID             Connections     Data (Up / Down)          ││Remote Address                              Connections       Data (Up / Down)               │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n└─────────────────────────────────────────────────────────────────────────────────────────────┘└─────────────────────────────────────────────────────────────────────────────────────────────┘\n┌Utilization by connection───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐\n│Connection                                                                                                           Process                                Data (Up / Down)                │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘\n Press <SPACE> to pause. Use <TAB> to rearrange tables. (DNS queries hidden).                                                                                                                 \n\n--- SECTION SEPARATOR ---\n                                                     41. 0B                                                                                                                                   \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n 1                                  1               1               0.00B / 22.00B              1.1.1.1                                     1                 0.00B / 22.00B                  \n 5                                  5               1               0.00B / 19.00B              3.3.3.3                                     1                 0.00B / 19.00B                  \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n <interface_name>:443 => 1.1.1.1:12345 (tcp)                                                                          1                                      0.00B / 22.00B                   \n <interface_name>:4435 => 3.3.3.3:1337 (tcp)                                                                          5                                      0.00B / 19.00B                   \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n\n--- SECTION SEPARATOR ---\n                                                     106. 0B                                                                                                                                  \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                            57                                                                                        57                      \n                                                                            4                                                                                         4                       \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                     57                       \n                                                                                                                                                                     4\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__sustained_traffic_from_one_process-2.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_events.lock().unwrap().as_slice()\n---\n[\n    Clear,\n    HideCursor,\n    Draw,\n    HideCursor,\n    Flush,\n    Draw,\n    HideCursor,\n    Flush,\n    Draw,\n    HideCursor,\n    Flush,\n    ShowCursor,\n]\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__sustained_traffic_from_one_process.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR)\n---\nIF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B                                                                                                                                    \n┌Utilization by process name──────────────────────────────────────────────────────────────────┐┌Utilization by remote address────────────────────────────────────────────────────────────────┐\n│Process                            PID             Connections     Rate (Up / Down)          ││Remote Address                              Connections       Rate (Up / Down)               │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n└─────────────────────────────────────────────────────────────────────────────────────────────┘└─────────────────────────────────────────────────────────────────────────────────────────────┘\n┌Utilization by connection───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐\n│Connection                                                                                                           Process                                Rate (Up / Down)                │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘\n Press <SPACE> to pause. Use <TAB> to rearrange tables. (DNS queries hidden).                                                                                                                 \n\n--- SECTION SEPARATOR ---\n                                                     22. 0B                                                                                                                                   \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n 1                                  1               1               0.00B / 22.00B              1.1.1.1                                     1                 0.00B / 22.00B                  \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n <interface_name>:443 => 1.1.1.1:12345 (tcp)                                                                          1                                      0.00B / 22.00B                   \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n\n--- SECTION SEPARATOR ---\n                                                     31                                                                                                                                       \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                            31                                                                                        31                      \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                     31\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__sustained_traffic_from_one_process_total-2.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_events.lock().unwrap().as_slice()\n---\n[\n    Clear,\n    HideCursor,\n    Draw,\n    HideCursor,\n    Flush,\n    Draw,\n    HideCursor,\n    Flush,\n    Draw,\n    HideCursor,\n    Flush,\n    ShowCursor,\n]\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__sustained_traffic_from_one_process_total.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR)\n---\nIF: interface_name | Total Data (Up / Down): 0.00B / 0.00B                                                                                                                                    \n┌Utilization by process name──────────────────────────────────────────────────────────────────┐┌Utilization by remote address────────────────────────────────────────────────────────────────┐\n│Process                            PID             Connections     Data (Up / Down)          ││Remote Address                              Connections       Data (Up / Down)               │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n└─────────────────────────────────────────────────────────────────────────────────────────────┘└─────────────────────────────────────────────────────────────────────────────────────────────┘\n┌Utilization by connection───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐\n│Connection                                                                                                           Process                                Data (Up / Down)                │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘\n Press <SPACE> to pause. Use <TAB> to rearrange tables. (DNS queries hidden).                                                                                                                 \n\n--- SECTION SEPARATOR ---\n                                                     22. 0B                                                                                                                                   \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n 1                                  1               1               0.00B / 22.00B              1.1.1.1                                     1                 0.00B / 22.00B                  \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n <interface_name>:443 => 1.1.1.1:12345 (tcp)                                                                          1                                      0.00B / 22.00B                   \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n\n--- SECTION SEPARATOR ---\n                                                     53                                                                                                                                       \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                            53                                                                                        53                      \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                     53\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__traffic_with_host_names-2.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_events.lock().unwrap().as_slice()\n---\n[\n    Clear,\n    HideCursor,\n    Draw,\n    HideCursor,\n    Flush,\n    Draw,\n    HideCursor,\n    Flush,\n    Draw,\n    HideCursor,\n    Flush,\n    ShowCursor,\n]\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__traffic_with_host_names.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR)\n---\nIF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B                                                                                                                                    \n┌Utilization by process name──────────────────────────────────────────────────────────────────┐┌Utilization by remote address────────────────────────────────────────────────────────────────┐\n│Process                            PID             Connections     Rate (Up / Down)          ││Remote Address                              Connections       Rate (Up / Down)               │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n└─────────────────────────────────────────────────────────────────────────────────────────────┘└─────────────────────────────────────────────────────────────────────────────────────────────┘\n┌Utilization by connection───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐\n│Connection                                                                                                           Process                                Rate (Up / Down)                │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘\n Press <SPACE> to pause. Use <TAB> to rearrange tables. (DNS queries hidden).                                                                                                                 \n\n--- SECTION SEPARATOR ---\n                                             45. 0B / 49.00B                                                                                                                                  \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n 1                                  1               1               28.00B / 30.00B             1.1.1.1                                     1                 28.00B / 30.00B                 \n 5                                  5               1               17.00B / 18.00B             3.3.3.3                                     1                 17.00B / 18.00B                 \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n <interface_name>:443 => 1.1.1.1:12345 (tcp)                                                                          1                                      28.00B / 30.00B                  \n <interface_name>:4435 => 3.3.3.3:1337 (tcp)                                                                          5                                      17.00B / 18.00B                  \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n\n--- SECTION SEPARATOR ---\n                                             53       60                                                                                                                                      \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                    31        2                 one one.one.one                                               31        2                     \n                                                                    22       27                 three three.three.three                                       22       27                     \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                         one one.one.one:12345 (tcp)                                                                                                         31        2                      \n                          three three.three.three:1337 (tcp)                                                                                                 22       27\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__traffic_with_winch_event-2.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_events.lock().unwrap().as_slice()\n---\n[\n    Clear,\n    HideCursor,\n    Draw,\n    HideCursor,\n    Flush,\n    Draw,\n    HideCursor,\n    Flush,\n    Draw,\n    HideCursor,\n    Flush,\n    ShowCursor,\n]\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__traffic_with_winch_event.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR)\n---\nIF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B                                                                                                                                    \n┌Utilization by process name──────────────────────────────────────────────────────────────────┐┌Utilization by remote address────────────────────────────────────────────────────────────────┐\n│Process                            PID             Connections     Rate (Up / Down)          ││Remote Address                              Connections       Rate (Up / Down)               │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n└─────────────────────────────────────────────────────────────────────────────────────────────┘└─────────────────────────────────────────────────────────────────────────────────────────────┘\n┌Utilization by connection───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐\n│Connection                                                                                                           Process                                Rate (Up / Down)                │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘\n Press <SPACE> to pause. Use <TAB> to rearrange tables. (DNS queries hidden).                                                                                                                 \n\n--- SECTION SEPARATOR ---\n                                             21. 0B / 0. 0B                                                                                                                                   \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n 1                                  1               1               21.00B / 0.00B              1.1.1.1                                     1                 21.00B / 0.00B                  \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n <interface_name>:443 => 1.1.1.1:12345 (tcp)                                                                          1                                      21.00B / 0.00B                   \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n\n--- SECTION SEPARATOR ---\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__truncate_long_hostnames-2.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_events.lock().unwrap().as_slice()\n---\n[\n    Clear,\n    HideCursor,\n    Draw,\n    HideCursor,\n    Flush,\n    Draw,\n    HideCursor,\n    Flush,\n    Draw,\n    HideCursor,\n    Flush,\n    ShowCursor,\n]\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__truncate_long_hostnames.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR)\n---\nIF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B                                                                                                                                    \n┌Utilization by process name──────────────────────────────────────────────────────────────────┐┌Utilization by remote address────────────────────────────────────────────────────────────────┐\n│Process                            PID             Connections     Rate (Up / Down)          ││Remote Address                              Connections       Rate (Up / Down)               │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n└─────────────────────────────────────────────────────────────────────────────────────────────┘└─────────────────────────────────────────────────────────────────────────────────────────────┘\n┌Utilization by connection───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐\n│Connection                                                                                                           Process                                Rate (Up / Down)                │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘\n Press <SPACE> to pause. Use <TAB> to rearrange tables. (DNS queries hidden).                                                                                                                 \n\n--- SECTION SEPARATOR ---\n                                             45. 0B / 49.00B                                                                                                                                  \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n 1                                  1               1               28.00B / 30.00B             1.1.1.1                                     1                 28.00B / 30.00B                 \n 5                                  5               1               17.00B / 18.00B             3.3.3.3                                     1                 17.00B / 18.00B                 \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n <interface_name>:443 => 1.1.1.1:12345 (tcp)                                                                          1                                      28.00B / 30.00B                  \n <interface_name>:4435 => 3.3.3.3:1337 (tcp)                                                                          5                                      17.00B / 18.00B                  \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n\n--- SECTION SEPARATOR ---\n                                             53       60                                                                                                                                      \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                    31        2                 i am.not.too.long                                             31        2                     \n                                                                    22       27                 i am.an.obnoxiosuly...do.this.really.i.ask                    22       27                     \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                         i am.not.too.long:12345 (tcp)                                                                                                       31        2                      \n                          i am.an.obnoxiosuly.long.hostname.why.would.anyone.do.this.really.i.ask:1337 (tcp)                                                 22       27\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__two_packets_only_addresses.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR)\n---\nIF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B                                                                                                                                    \n┌Utilization by remote address───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐\n│Remote Address                                                                                                Connections                      Rate (Up / Down)                             │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘\n Press <SPACE> to pause. Use <TAB> to rearrange tables. (DNS queries hidden).                                                                                                                 \n\n--- SECTION SEPARATOR ---\n                                             24. 0B / 25.00B                                                                                                                                  \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n 1.1.1.1                                                                                                       1                                24.00B / 25.00B                               \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__two_packets_only_connections.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR)\n---\nIF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B                                                                                                                                    \n┌Utilization by connection───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐\n│Connection                                                                                                           Process                                Rate (Up / Down)                │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘\n Press <SPACE> to pause. Use <TAB> to rearrange tables. (DNS queries hidden).                                                                                                                 \n\n--- SECTION SEPARATOR ---\n                                             24. 0B / 25.00B                                                                                                                                  \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n <interface_name>:443 => 1.1.1.1:12345 (tcp)                                                                          1                                      24.00B / 25.00B                  \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__two_packets_only_processes.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR)\n---\nIF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B                                                                                                                                    \n┌Utilization by process name─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐\n│Process                                                               PID                            Connections                    Rate (Up / Down)                                        │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n│                                                                                                                                                                                            │\n└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘\n Press <SPACE> to pause. Use <TAB> to rearrange tables. (DNS queries hidden).                                                                                                                 \n\n--- SECTION SEPARATOR ---\n                                             24. 0B / 25.00B                                                                                                                                  \n                                                                                                                                                                                              \n                                                                                                                                                                                              \n 1                                                                     1                              1                              24.00B / 25.00B\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__two_windows_split_horizontally.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR)\n---\nIF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B  \n┌Utilization by remote address─────────────────────────────┐\n│Remote Address                     Rate (Up / Down)       │\n│                                                          │\n│                                                          │\n│                                                          │\n│                                                          │\n│                                                          │\n│                                                          │\n│                                                          │\n│                                                          │\n│                                                          │\n│                                                          │\n│                                                          │\n│                                                          │\n│                                                          │\n│                                                          │\n│                                                          │\n│                                                          │\n│                                                          │\n│                                                          │\n│                                                          │\n│                                                          │\n│                                                          │\n└──────────────────────────────────────────────────────────┘\n┌Utilization by connection─────────────────────────────────┐\n│Connection                              Rate (Up / Down)  │\n│                                                          │\n│                                                          │\n│                                                          │\n│                                                          │\n│                                                          │\n│                                                          │\n│                                                          │\n│                                                          │\n│                                                          │\n│                                                          │\n│                                                          │\n│                                                          │\n│                                                          │\n│                                                          │\n│                                                          │\n│                                                          │\n│                                                          │\n│                                                          │\n│                                                          │\n│                                                          │\n│                                                          │\n└──────────────────────────────────────────────────────────┘\n Press <SPACE> to pause. Use <TAB> to rearrange tables.     \n\n--- SECTION SEPARATOR ---\n                                                            \n                                                            \n                                                            \n                                                            \n                                                            \n                                                            \n                                                            \n                                                            \n                                                            \n                                                            \n                                                            \n                                                            \n                                                            \n                                                            \n                                                            \n                                                            \n                                                            \n                                                            \n                                                            \n                                                            \n                                                            \n                                                            \n                                                            \n                                                            \n                                                            \n                                                            \n                                                            \n                                                            \n                                                            \n                                                            \n                                                            \n                                                            \n                                                            \n                                                            \n                                                            \n                                                            \n                                                            \n                                                            \n                                                            \n                                                            \n                                                            \n                                                            \n                                                            \n                                                            \n                                                            \n                                                            \n                                                            \n                                                            \n                                                            \n                                                            \n\n"
  },
  {
    "path": "src/tests/cases/snapshots/bandwhich__tests__cases__ui__two_windows_split_vertically.snap",
    "content": "---\nsource: src/tests/cases/ui.rs\nexpression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR)\n---\nIF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B                                                                                                                                    \n┌Utilization by remote address────────────────────────────────────────────────────────────────┐┌Utilization by connection────────────────────────────────────────────────────────────────────┐\n│Remote Address                              Connections       Rate (Up / Down)               ││Connection                                           Process           Rate (Up / Down)      │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n│                                                                                             ││                                                                                             │\n└─────────────────────────────────────────────────────────────────────────────────────────────┘└─────────────────────────────────────────────────────────────────────────────────────────────┘\n Press <SPACE> to pause. Use <TAB> to rearrange tables. (DNS queries hidden).                                                                                                                 \n\n"
  },
  {
    "path": "src/tests/cases/test_utils.rs",
    "content": "#![cfg_attr(not(feature = \"ui_test\"), allow(dead_code))]\n\nuse std::{\n    collections::HashMap,\n    io::Write,\n    iter,\n    sync::{Arc, Mutex},\n};\n\nuse crossterm::event::{Event, KeyCode, KeyEvent, KeyModifiers};\nuse packet_builder::*;\nuse pnet::{datalink::DataLinkReceiver, packet::Packet};\nuse pnet_base::MacAddr;\nuse rstest::fixture;\n\nuse crate::{\n    network::dns::Client,\n    tests::fakes::{\n        create_fake_dns_client, get_interfaces_with_frames, get_open_sockets, NetworkFrames,\n        TerminalEvent, TerminalEvents, TestBackend,\n    },\n    Opt, OsInputOutput,\n};\n\npub fn sleep_and_quit_events(sleep_num: usize) -> Box<TerminalEvents> {\n    let events = iter::repeat_n(None, sleep_num)\n        .chain([Some(Event::Key(KeyEvent::new(\n            KeyCode::Char('q'),\n            KeyModifiers::NONE,\n        )))])\n        .collect();\n    Box::new(TerminalEvents::new(events))\n}\n\npub fn sleep_resize_and_quit_events(sleep_num: usize) -> Box<TerminalEvents> {\n    let events = iter::repeat_n(None, sleep_num)\n        .chain([\n            Some(Event::Resize(100, 100)),\n            Some(Event::Key(KeyEvent::new(\n                KeyCode::Char('q'),\n                KeyModifiers::NONE,\n            ))),\n        ])\n        .collect();\n    Box::new(TerminalEvents::new(events))\n}\n\npub fn build_tcp_packet(\n    source_ip: &str,\n    destination_ip: &str,\n    source_port: u16,\n    destination_port: u16,\n    payload: &'static [u8],\n) -> Vec<u8> {\n    let mut pkt_buf = [0u8; 1500];\n    let pkt = packet_builder!(\n         pkt_buf,\n         ether({set_destination => MacAddr(0,0,0,0,0,0), set_source => MacAddr(0,0,0,0,0,0)}) /\n         ipv4({set_source => ipv4addr!(source_ip), set_destination => ipv4addr!(destination_ip) }) /\n         tcp({set_source => source_port, set_destination => destination_port }) /\n         payload(payload)\n    );\n    pkt.packet().to_vec()\n}\n\n#[fixture]\npub fn sample_frames_short() -> Vec<Box<dyn DataLinkReceiver>> {\n    vec![NetworkFrames::new(vec![\n        Some(build_tcp_packet(\n            \"10.0.0.2\",\n            \"1.1.1.1\",\n            443,\n            12345,\n            b\"I am a fake tcp upload packet\",\n        )),\n        Some(build_tcp_packet(\n            \"1.1.1.1\",\n            \"10.0.0.2\",\n            12345,\n            443,\n            b\"I am a fake tcp download packet\",\n        )),\n        Some(build_tcp_packet(\n            \"10.0.0.2\",\n            \"1.1.1.1\",\n            54321,\n            53,\n            b\"I am a fake DNS query packet\",\n        )),\n    ]) as Box<dyn DataLinkReceiver>]\n}\n\n#[fixture]\npub fn sample_frames_sustained_one_process() -> Vec<Box<dyn DataLinkReceiver>> {\n    vec![NetworkFrames::new(vec![\n        Some(build_tcp_packet(\n            \"1.1.1.1\",\n            \"10.0.0.2\",\n            12345,\n            443,\n            b\"I have come from 1.1.1.1\",\n        )),\n        None, // sleep\n        Some(build_tcp_packet(\n            \"1.1.1.1\",\n            \"10.0.0.2\",\n            12345,\n            443,\n            b\"Same here, but one second later\",\n        )),\n    ]) as Box<dyn DataLinkReceiver>]\n}\n\n#[fixture]\npub fn sample_frames_sustained_multiple_processes() -> Vec<Box<dyn DataLinkReceiver>> {\n    vec![NetworkFrames::new(vec![\n        Some(build_tcp_packet(\n            \"1.1.1.1\",\n            \"10.0.0.2\",\n            12345,\n            443,\n            b\"I have come from 1.1.1.1\",\n        )),\n        Some(build_tcp_packet(\n            \"3.3.3.3\",\n            \"10.0.0.2\",\n            1337,\n            4435,\n            b\"I come from 3.3.3.3\",\n        )),\n        None, // sleep\n        Some(build_tcp_packet(\n            \"1.1.1.1\",\n            \"10.0.0.2\",\n            12345,\n            443,\n            b\"I have come from 1.1.1.1 one second later\",\n        )),\n        Some(build_tcp_packet(\n            \"3.3.3.3\",\n            \"10.0.0.2\",\n            1337,\n            4435,\n            b\"I come 3.3.3.3 one second later\",\n        )),\n    ]) as Box<dyn DataLinkReceiver>]\n}\n\n#[fixture]\npub fn sample_frames_sustained_long() -> Vec<Box<dyn DataLinkReceiver>> {\n    vec![NetworkFrames::new(vec![\n        Some(build_tcp_packet(\n            \"10.0.0.2\",\n            \"3.3.3.3\",\n            4435,\n            1337,\n            b\"omw to 3.3.3.3\",\n        )),\n        Some(build_tcp_packet(\n            \"3.3.3.3\",\n            \"10.0.0.2\",\n            1337,\n            4435,\n            b\"I was just there!\",\n        )),\n        Some(build_tcp_packet(\n            \"1.1.1.1\",\n            \"10.0.0.2\",\n            12345,\n            443,\n            b\"Is it nice there? I think 1.1.1.1 is dull\",\n        )),\n        Some(build_tcp_packet(\n            \"10.0.0.2\",\n            \"1.1.1.1\",\n            443,\n            12345,\n            b\"Well, I heard 1.1.1.1 is all the rage\",\n        )),\n        None, // sleep\n        Some(build_tcp_packet(\n            \"10.0.0.2\",\n            \"3.3.3.3\",\n            4435,\n            1337,\n            b\"Wait for me!\",\n        )),\n        Some(build_tcp_packet(\n            \"3.3.3.3\",\n            \"10.0.0.2\",\n            1337,\n            4435,\n            b\"They're waiting for you...\",\n        )),\n        Some(build_tcp_packet(\n            \"1.1.1.1\",\n            \"10.0.0.2\",\n            12345,\n            443,\n            b\"1.1.1.1 forever!\",\n        )),\n        Some(build_tcp_packet(\n            \"10.0.0.2\",\n            \"1.1.1.1\",\n            443,\n            12345,\n            b\"10.0.0.2 forever!\",\n        )),\n    ]) as Box<dyn DataLinkReceiver>]\n}\n\npub fn os_input_output(\n    network_frames: Vec<Box<dyn DataLinkReceiver>>,\n    sleep_num: usize,\n) -> OsInputOutput {\n    os_input_output_factory(\n        network_frames,\n        None,\n        create_fake_dns_client(HashMap::new()),\n        sleep_and_quit_events(sleep_num),\n    )\n}\npub fn os_input_output_stdout(\n    network_frames: Vec<Box<dyn DataLinkReceiver>>,\n    sleep_num: usize,\n    stdout: Option<Arc<Mutex<Vec<u8>>>>,\n) -> OsInputOutput {\n    os_input_output_factory(\n        network_frames,\n        stdout,\n        create_fake_dns_client(HashMap::new()),\n        sleep_and_quit_events(sleep_num),\n    )\n}\n\npub fn os_input_output_dns(\n    network_frames: Vec<Box<dyn DataLinkReceiver>>,\n    sleep_num: usize,\n    stdout: Option<Arc<Mutex<Vec<u8>>>>,\n    dns_client: Option<Client>,\n) -> OsInputOutput {\n    os_input_output_factory(\n        network_frames,\n        stdout,\n        dns_client,\n        sleep_and_quit_events(sleep_num),\n    )\n}\n\npub fn os_input_output_factory(\n    network_frames: impl IntoIterator<Item = Box<dyn DataLinkReceiver>>,\n    stdout: Option<Arc<Mutex<Vec<u8>>>>,\n    dns_client: Option<Client>,\n    keyboard_events: Box<dyn Iterator<Item = Event> + Send>,\n) -> OsInputOutput {\n    let interfaces_with_frames = get_interfaces_with_frames(network_frames);\n\n    let write_to_stdout: Box<dyn FnMut(&str) + Send> = match stdout {\n        Some(stdout) => Box::new({\n            move |output| {\n                let mut stdout = stdout.lock().unwrap();\n                writeln!(&mut stdout, \"{output}\").unwrap();\n            }\n        }),\n        None => Box::new(|_output| {}),\n    };\n\n    OsInputOutput {\n        interfaces_with_frames,\n        get_open_sockets,\n        terminal_events: keyboard_events,\n        dns_client,\n        write_to_stdout,\n    }\n}\n\npub fn opts_raw() -> Opt {\n    Opt {\n        interface: Some(String::from(\"interface_name\")),\n        raw: true,\n        ..Default::default()\n    }\n}\npub fn opts_ui() -> Opt {\n    Opt {\n        interface: Some(String::from(\"interface_name\")),\n        ..Default::default()\n    }\n}\n\ntype BackendWithStreams = (\n    Arc<Mutex<Vec<TerminalEvent>>>,\n    Arc<Mutex<Vec<String>>>,\n    TestBackend,\n);\npub fn test_backend_factory(w: u16, h: u16) -> BackendWithStreams {\n    let terminal_events: Arc<Mutex<Vec<TerminalEvent>>> = Arc::new(Mutex::new(Vec::new()));\n    let terminal_draw_events: Arc<Mutex<Vec<String>>> = Arc::new(Mutex::new(Vec::new()));\n\n    let backend = TestBackend::new(\n        terminal_events.clone(),\n        terminal_draw_events.clone(),\n        Arc::new(Mutex::new(w)),\n        Arc::new(Mutex::new(h)),\n    );\n    (terminal_events, terminal_draw_events, backend)\n}\n"
  },
  {
    "path": "src/tests/cases/ui.rs",
    "content": "use std::{collections::HashMap, net::IpAddr};\n\nuse crossterm::event::{Event, KeyCode, KeyEvent, KeyModifiers};\nuse insta::{assert_debug_snapshot, assert_snapshot};\nuse itertools::Itertools;\nuse pnet::datalink::DataLinkReceiver;\nuse rstest::rstest;\n\nuse crate::{\n    cli::RenderOpts,\n    start,\n    tests::{\n        cases::test_utils::{\n            build_tcp_packet, opts_ui, os_input_output, os_input_output_factory,\n            sample_frames_short, sample_frames_sustained_long,\n            sample_frames_sustained_multiple_processes, sample_frames_sustained_one_process,\n            sleep_and_quit_events, sleep_resize_and_quit_events, test_backend_factory,\n        },\n        fakes::{\n            create_fake_dns_client, get_interfaces_with_frames, get_open_sockets, NetworkFrames,\n            TerminalEvents,\n        },\n    },\n    Opt, OsInputOutput,\n};\n\nconst SNAPSHOT_SECTION_SEPARATOR: &str = \"\\n--- SECTION SEPARATOR ---\\n\";\n\n#[test]\nfn basic_startup() {\n    let network_frames = vec![NetworkFrames::new(vec![\n        None, // sleep\n    ]) as Box<dyn DataLinkReceiver>];\n\n    let (terminal_events, terminal_draw_events, backend) = test_backend_factory(190, 50);\n    let os_input = os_input_output(network_frames, 1);\n    let opts = opts_ui();\n    start(backend, os_input, opts);\n\n    assert_snapshot!(terminal_draw_events\n        .lock()\n        .unwrap()\n        .join(SNAPSHOT_SECTION_SEPARATOR));\n    assert_debug_snapshot!(terminal_events.lock().unwrap().as_slice());\n}\n\n#[test]\nfn pause_by_space() {\n    let network_frames = vec![NetworkFrames::new(vec![\n        Some(build_tcp_packet(\n            \"1.1.1.1\",\n            \"10.0.0.2\",\n            12345,\n            443,\n            b\"I have come from 1.1.1.1\",\n        )),\n        None, // sleep\n        None, // sleep\n        None, // sleep\n        Some(build_tcp_packet(\n            \"1.1.1.1\",\n            \"10.0.0.2\",\n            12345,\n            443,\n            b\"Same here, but one second later\",\n        )),\n    ]) as Box<dyn DataLinkReceiver>];\n\n    let events = [\n        None,\n        Some(KeyEvent::new(KeyCode::Char(' '), KeyModifiers::NONE)),\n        None,\n        None,\n        Some(KeyEvent::new(KeyCode::Char(' '), KeyModifiers::NONE)),\n        Some(KeyEvent::new(KeyCode::Char('c'), KeyModifiers::CONTROL)),\n    ]\n    .into_iter()\n    .map(|ke| ke.map(Event::Key))\n    .collect_vec();\n\n    let events = Box::new(TerminalEvents::new(events));\n    let os_input = os_input_output_factory(network_frames, None, None, events);\n    let (terminal_events, terminal_draw_events, backend) = test_backend_factory(190, 50);\n    let opts = opts_ui();\n    start(backend, os_input, opts);\n\n    assert_snapshot!(terminal_draw_events\n        .lock()\n        .unwrap()\n        .join(SNAPSHOT_SECTION_SEPARATOR));\n    assert_debug_snapshot!(terminal_events.lock().unwrap().as_slice());\n}\n\n#[test]\nfn rearranged_by_tab() {\n    let network_frames = vec![NetworkFrames::new(vec![\n        Some(build_tcp_packet(\n            \"1.1.1.1\",\n            \"10.0.0.2\",\n            12345,\n            443,\n            b\"I have come from 1.1.1.1\",\n        )),\n        None, // sleep\n        None, // sleep\n        None, // sleep\n        Some(build_tcp_packet(\n            \"1.1.1.1\",\n            \"10.0.0.2\",\n            12345,\n            443,\n            b\"Same here, but one second later\",\n        )),\n    ]) as Box<dyn DataLinkReceiver>];\n\n    let events = [\n        None,\n        None,\n        Some(KeyEvent::new(KeyCode::Tab, KeyModifiers::NONE)),\n        None,\n        None,\n        Some(KeyEvent::new(KeyCode::Char('c'), KeyModifiers::CONTROL)),\n    ]\n    .into_iter()\n    .map(|ke| ke.map(Event::Key))\n    .collect_vec();\n\n    let events = Box::new(TerminalEvents::new(events));\n    let os_input = os_input_output_factory(network_frames, None, None, events);\n    let (terminal_events, terminal_draw_events, backend) = test_backend_factory(190, 50);\n    let opts = opts_ui();\n    start(backend, os_input, opts);\n\n    assert_snapshot!(terminal_draw_events\n        .lock()\n        .unwrap()\n        .join(SNAPSHOT_SECTION_SEPARATOR));\n    assert_debug_snapshot!(terminal_events.lock().unwrap().as_slice());\n}\n\n#[test]\nfn basic_only_processes() {\n    let network_frames = vec![NetworkFrames::new(vec![\n        None, // sleep\n    ]) as Box<dyn DataLinkReceiver>];\n\n    let (_, terminal_draw_events, backend) = test_backend_factory(190, 50);\n    let os_input = os_input_output(network_frames, 1);\n    let opts = Opt {\n        render_opts: RenderOpts {\n            processes: true,\n            ..Default::default()\n        },\n        ..opts_ui()\n    };\n    start(backend, os_input, opts);\n\n    assert_snapshot!(terminal_draw_events\n        .lock()\n        .unwrap()\n        .join(SNAPSHOT_SECTION_SEPARATOR));\n}\n\n#[test]\nfn basic_processes_with_dns_queries() {\n    let network_frames = vec![NetworkFrames::new(vec![\n        None, // sleep\n    ]) as Box<dyn DataLinkReceiver>];\n\n    let (_, terminal_draw_events, backend) = test_backend_factory(190, 50);\n    let os_input = os_input_output(network_frames, 1);\n    let opts = Opt {\n        show_dns: true,\n        render_opts: RenderOpts {\n            processes: true,\n            ..Default::default()\n        },\n        ..opts_ui()\n    };\n    start(backend, os_input, opts);\n\n    assert_snapshot!(terminal_draw_events\n        .lock()\n        .unwrap()\n        .join(SNAPSHOT_SECTION_SEPARATOR));\n}\n\n#[test]\nfn basic_only_connections() {\n    let network_frames = vec![NetworkFrames::new(vec![\n        None, // sleep\n    ]) as Box<dyn DataLinkReceiver>];\n\n    let (_, terminal_draw_events, backend) = test_backend_factory(190, 50);\n    let os_input = os_input_output(network_frames, 1);\n    let opts = Opt {\n        render_opts: RenderOpts {\n            connections: true,\n            ..Default::default()\n        },\n        ..opts_ui()\n    };\n    start(backend, os_input, opts);\n\n    assert_snapshot!(terminal_draw_events\n        .lock()\n        .unwrap()\n        .join(SNAPSHOT_SECTION_SEPARATOR));\n}\n\n#[test]\nfn basic_only_addresses() {\n    let network_frames = vec![NetworkFrames::new(vec![\n        None, // sleep\n    ]) as Box<dyn DataLinkReceiver>];\n\n    let (_, terminal_draw_events, backend) = test_backend_factory(190, 50);\n    let os_input = os_input_output(network_frames, 1);\n    let opts = Opt {\n        render_opts: RenderOpts {\n            addresses: true,\n            ..Default::default()\n        },\n        ..opts_ui()\n    };\n    start(backend, os_input, opts);\n\n    assert_snapshot!(terminal_draw_events\n        .lock()\n        .unwrap()\n        .join(SNAPSHOT_SECTION_SEPARATOR));\n}\n\n#[rstest(sample_frames_short as frames)]\nfn two_packets_only_processes(frames: Vec<Box<dyn DataLinkReceiver>>) {\n    let (_, terminal_draw_events, backend) = test_backend_factory(190, 50);\n    let os_input = os_input_output(frames, 2);\n    let opts = Opt {\n        render_opts: RenderOpts {\n            processes: true,\n            ..Default::default()\n        },\n        ..opts_ui()\n    };\n    start(backend, os_input, opts);\n\n    assert_snapshot!(terminal_draw_events\n        .lock()\n        .unwrap()\n        .join(SNAPSHOT_SECTION_SEPARATOR));\n}\n\n#[rstest(sample_frames_short as frames)]\nfn two_packets_only_connections(frames: Vec<Box<dyn DataLinkReceiver>>) {\n    let (_, terminal_draw_events, backend) = test_backend_factory(190, 50);\n    let os_input = os_input_output(frames, 2);\n    let opts = Opt {\n        render_opts: RenderOpts {\n            connections: true,\n            ..Default::default()\n        },\n        ..opts_ui()\n    };\n    start(backend, os_input, opts);\n\n    assert_snapshot!(terminal_draw_events\n        .lock()\n        .unwrap()\n        .join(SNAPSHOT_SECTION_SEPARATOR));\n}\n\n#[rstest(sample_frames_short as frames)]\nfn two_packets_only_addresses(frames: Vec<Box<dyn DataLinkReceiver>>) {\n    let (_, terminal_draw_events, backend) = test_backend_factory(190, 50);\n    let os_input = os_input_output(frames, 2);\n    let opts = Opt {\n        render_opts: RenderOpts {\n            addresses: true,\n            ..Default::default()\n        },\n        ..opts_ui()\n    };\n    start(backend, os_input, opts);\n\n    assert_snapshot!(terminal_draw_events\n        .lock()\n        .unwrap()\n        .join(SNAPSHOT_SECTION_SEPARATOR));\n}\n\n#[test]\nfn two_windows_split_horizontally() {\n    let network_frames = vec![NetworkFrames::new(vec![\n        None, // sleep\n    ]) as Box<dyn DataLinkReceiver>];\n\n    let (_, terminal_draw_events, backend) = test_backend_factory(60, 50);\n    let os_input = os_input_output(network_frames, 2);\n    let opts = Opt {\n        render_opts: RenderOpts {\n            addresses: true,\n            connections: true,\n            ..Default::default()\n        },\n        ..opts_ui()\n    };\n    start(backend, os_input, opts);\n\n    assert_snapshot!(terminal_draw_events\n        .lock()\n        .unwrap()\n        .join(SNAPSHOT_SECTION_SEPARATOR));\n}\n\n#[test]\nfn two_windows_split_vertically() {\n    let network_frames = vec![NetworkFrames::new(vec![\n        None, // sleep\n    ]) as Box<dyn DataLinkReceiver>];\n\n    let (_, terminal_draw_events, backend) = test_backend_factory(190, 50);\n    let os_input = os_input_output(network_frames, 1);\n    let opts = Opt {\n        render_opts: RenderOpts {\n            addresses: true,\n            connections: true,\n            ..Default::default()\n        },\n        ..opts_ui()\n    };\n    start(backend, os_input, opts);\n\n    assert_snapshot!(terminal_draw_events\n        .lock()\n        .unwrap()\n        .join(SNAPSHOT_SECTION_SEPARATOR));\n}\n\n#[test]\nfn one_packet_of_traffic() {\n    let network_frames = vec![NetworkFrames::new(vec![Some(build_tcp_packet(\n        \"10.0.0.2\",\n        \"1.1.1.1\",\n        443,\n        12345,\n        b\"I am a fake tcp packet\",\n    ))]) as Box<dyn DataLinkReceiver>];\n    let (terminal_events, terminal_draw_events, backend) = test_backend_factory(190, 50);\n    let os_input = os_input_output(network_frames, 2);\n    let opts = opts_ui();\n    start(backend, os_input, opts);\n\n    assert_snapshot!(terminal_draw_events\n        .lock()\n        .unwrap()\n        .join(SNAPSHOT_SECTION_SEPARATOR));\n    assert_debug_snapshot!(terminal_events.lock().unwrap().as_slice());\n}\n\n#[rstest(sample_frames_short as frames)]\nfn bi_directional_traffic(frames: Vec<Box<dyn DataLinkReceiver>>) {\n    let (terminal_events, terminal_draw_events, backend) = test_backend_factory(190, 50);\n    let os_input = os_input_output(frames, 2);\n    let opts = opts_ui();\n    start(backend, os_input, opts);\n\n    assert_snapshot!(terminal_draw_events\n        .lock()\n        .unwrap()\n        .join(SNAPSHOT_SECTION_SEPARATOR));\n    assert_debug_snapshot!(terminal_events.lock().unwrap().as_slice());\n}\n\n#[test]\nfn multiple_packets_of_traffic_from_different_connections() {\n    let network_frames = vec![NetworkFrames::new(vec![\n        Some(build_tcp_packet(\n            \"2.2.2.2\",\n            \"10.0.0.2\",\n            12345,\n            443,\n            b\"I have come from 2.2.2.2\",\n        )),\n        Some(build_tcp_packet(\n            \"2.2.2.2\",\n            \"10.0.0.2\",\n            54321,\n            4434,\n            b\"I come from 2.2.2.2\",\n        )),\n    ]) as Box<dyn DataLinkReceiver>];\n\n    let (terminal_events, terminal_draw_events, backend) = test_backend_factory(190, 50);\n    let os_input = os_input_output(network_frames, 2);\n    let opts = opts_ui();\n    start(backend, os_input, opts);\n\n    assert_snapshot!(terminal_draw_events\n        .lock()\n        .unwrap()\n        .join(SNAPSHOT_SECTION_SEPARATOR));\n    assert_debug_snapshot!(terminal_events.lock().unwrap().as_slice());\n}\n\n#[test]\nfn multiple_packets_of_traffic_from_single_connection() {\n    let network_frames = vec![NetworkFrames::new(vec![\n        Some(build_tcp_packet(\n            \"1.1.1.1\",\n            \"10.0.0.2\",\n            12345,\n            443,\n            b\"I have come from 1.1.1.1\",\n        )),\n        Some(build_tcp_packet(\n            \"1.1.1.1\",\n            \"10.0.0.2\",\n            12345,\n            443,\n            b\"I've come from 1.1.1.1 too!\",\n        )),\n    ]) as Box<dyn DataLinkReceiver>];\n\n    let (terminal_events, terminal_draw_events, backend) = test_backend_factory(190, 50);\n    let os_input = os_input_output(network_frames, 2);\n    let opts = opts_ui();\n    start(backend, os_input, opts);\n\n    assert_snapshot!(terminal_draw_events\n        .lock()\n        .unwrap()\n        .join(SNAPSHOT_SECTION_SEPARATOR));\n    assert_debug_snapshot!(terminal_events.lock().unwrap().as_slice());\n}\n\n#[test]\nfn one_process_with_multiple_connections() {\n    let network_frames = vec![NetworkFrames::new(vec![\n        Some(build_tcp_packet(\n            \"1.1.1.1\",\n            \"10.0.0.2\",\n            12345,\n            443,\n            b\"I have come from 1.1.1.1\",\n        )),\n        Some(build_tcp_packet(\n            \"1.1.1.1\",\n            \"10.0.0.2\",\n            12346,\n            443,\n            b\"Funny that, I'm from 1.1.1.1\",\n        )),\n    ]) as Box<dyn DataLinkReceiver>];\n\n    let (terminal_events, terminal_draw_events, backend) = test_backend_factory(190, 50);\n    let os_input = os_input_output(network_frames, 2);\n    let opts = opts_ui();\n    start(backend, os_input, opts);\n\n    assert_snapshot!(terminal_draw_events\n        .lock()\n        .unwrap()\n        .join(SNAPSHOT_SECTION_SEPARATOR));\n    assert_debug_snapshot!(terminal_events.lock().unwrap().as_slice());\n}\n\n#[test]\nfn multiple_processes_with_multiple_connections() {\n    let network_frames = vec![NetworkFrames::new(vec![\n        Some(build_tcp_packet(\n            \"1.1.1.1\",\n            \"10.0.0.2\",\n            12345,\n            443,\n            b\"I have come from 1.1.1.1\",\n        )),\n        Some(build_tcp_packet(\n            \"3.3.3.3\",\n            \"10.0.0.2\",\n            1337,\n            4435,\n            b\"Greetings traveller, I'm from 3.3.3.3\",\n        )),\n        Some(build_tcp_packet(\n            \"2.2.2.2\",\n            \"10.0.0.2\",\n            54321,\n            4434,\n            b\"You know, 2.2.2.2 is really nice!\",\n        )),\n        Some(build_tcp_packet(\n            \"4.4.4.4\",\n            \"10.0.0.2\",\n            1337,\n            4432,\n            b\"I'm partial to 4.4.4.4\",\n        )),\n    ]) as Box<dyn DataLinkReceiver>];\n\n    let (terminal_events, terminal_draw_events, backend) = test_backend_factory(190, 50);\n    let os_input = os_input_output(network_frames, 2);\n    let opts = opts_ui();\n    start(backend, os_input, opts);\n\n    assert_snapshot!(terminal_draw_events\n        .lock()\n        .unwrap()\n        .join(SNAPSHOT_SECTION_SEPARATOR));\n    assert_debug_snapshot!(terminal_events.lock().unwrap().as_slice());\n}\n\n#[test]\nfn multiple_connections_from_remote_address() {\n    let network_frames = vec![NetworkFrames::new(vec![\n        Some(build_tcp_packet(\n            \"1.1.1.1\",\n            \"10.0.0.2\",\n            12345,\n            443,\n            b\"I have come from 1.1.1.1\",\n        )),\n        Some(build_tcp_packet(\n            \"1.1.1.1\",\n            \"10.0.0.2\",\n            12346,\n            443,\n            b\"Me too, but on a different port\",\n        )),\n    ]) as Box<dyn DataLinkReceiver>];\n\n    let (terminal_events, terminal_draw_events, backend) = test_backend_factory(190, 50);\n    let os_input = os_input_output(network_frames, 2);\n    let opts = opts_ui();\n    start(backend, os_input, opts);\n\n    assert_snapshot!(terminal_draw_events\n        .lock()\n        .unwrap()\n        .join(SNAPSHOT_SECTION_SEPARATOR));\n    assert_debug_snapshot!(terminal_events.lock().unwrap().as_slice());\n}\n\n#[rstest(sample_frames_sustained_one_process as frames)]\nfn sustained_traffic_from_one_process(frames: Vec<Box<dyn DataLinkReceiver>>) {\n    let (terminal_events, terminal_draw_events, backend) = test_backend_factory(190, 50);\n\n    let os_input = os_input_output(frames, 3);\n    let opts = opts_ui();\n    start(backend, os_input, opts);\n\n    assert_snapshot!(terminal_draw_events\n        .lock()\n        .unwrap()\n        .join(SNAPSHOT_SECTION_SEPARATOR));\n    assert_debug_snapshot!(terminal_events.lock().unwrap().as_slice());\n}\n\n#[rstest(sample_frames_sustained_one_process as frames)]\nfn sustained_traffic_from_one_process_total(frames: Vec<Box<dyn DataLinkReceiver>>) {\n    let (terminal_events, terminal_draw_events, backend) = test_backend_factory(190, 50);\n\n    let os_input = os_input_output(frames, 3);\n    let mut opts = opts_ui();\n    opts.render_opts.total_utilization = true;\n    start(backend, os_input, opts);\n\n    assert_snapshot!(terminal_draw_events\n        .lock()\n        .unwrap()\n        .join(SNAPSHOT_SECTION_SEPARATOR));\n    assert_debug_snapshot!(terminal_events.lock().unwrap().as_slice());\n}\n\n#[rstest(sample_frames_sustained_multiple_processes as frames)]\nfn sustained_traffic_from_multiple_processes(frames: Vec<Box<dyn DataLinkReceiver>>) {\n    let (terminal_events, terminal_draw_events, backend) = test_backend_factory(190, 50);\n\n    let os_input = os_input_output(frames, 3);\n    let opts = opts_ui();\n    start(backend, os_input, opts);\n\n    assert_snapshot!(terminal_draw_events\n        .lock()\n        .unwrap()\n        .join(SNAPSHOT_SECTION_SEPARATOR));\n    assert_debug_snapshot!(terminal_events.lock().unwrap().as_slice());\n}\n\n#[rstest(sample_frames_sustained_multiple_processes as frames)]\nfn sustained_traffic_from_multiple_processes_total(frames: Vec<Box<dyn DataLinkReceiver>>) {\n    let (terminal_events, terminal_draw_events, backend) = test_backend_factory(190, 50);\n\n    let os_input = os_input_output(frames, 3);\n    let mut opts = opts_ui();\n    opts.render_opts.total_utilization = true;\n    start(backend, os_input, opts);\n\n    assert_snapshot!(terminal_draw_events\n        .lock()\n        .unwrap()\n        .join(SNAPSHOT_SECTION_SEPARATOR));\n    assert_debug_snapshot!(terminal_events.lock().unwrap().as_slice());\n}\n\n#[rstest(sample_frames_sustained_long as frames)]\nfn sustained_traffic_from_multiple_processes_bi_directional(\n    frames: Vec<Box<dyn DataLinkReceiver>>,\n) {\n    let (terminal_events, terminal_draw_events, backend) = test_backend_factory(190, 50);\n\n    let os_input = os_input_output(frames, 3);\n    let opts = opts_ui();\n    start(backend, os_input, opts);\n\n    assert_snapshot!(terminal_draw_events\n        .lock()\n        .unwrap()\n        .join(SNAPSHOT_SECTION_SEPARATOR));\n    assert_debug_snapshot!(terminal_events.lock().unwrap().as_slice());\n}\n\n#[rstest(sample_frames_sustained_long as frames)]\nfn sustained_traffic_from_multiple_processes_bi_directional_total(\n    frames: Vec<Box<dyn DataLinkReceiver>>,\n) {\n    let (terminal_events, terminal_draw_events, backend) = test_backend_factory(190, 50);\n\n    let os_input = os_input_output(frames, 3);\n    let mut opts = opts_ui();\n    opts.render_opts.total_utilization = true;\n    start(backend, os_input, opts);\n\n    assert_snapshot!(terminal_draw_events\n        .lock()\n        .unwrap()\n        .join(SNAPSHOT_SECTION_SEPARATOR));\n    assert_debug_snapshot!(terminal_events.lock().unwrap().as_slice());\n}\n\n#[rstest(sample_frames_sustained_long as network_frames)]\nfn traffic_with_host_names(network_frames: Vec<Box<dyn DataLinkReceiver>>) {\n    let (terminal_events, terminal_draw_events, backend) = test_backend_factory(190, 50);\n\n    let interfaces_with_frames = get_interfaces_with_frames(network_frames);\n\n    let mut ips_to_hostnames = HashMap::new();\n    ips_to_hostnames.insert(\n        IpAddr::V4(\"1.1.1.1\".parse().unwrap()),\n        String::from(\"one.one.one.one\"),\n    );\n    ips_to_hostnames.insert(\n        IpAddr::V4(\"3.3.3.3\".parse().unwrap()),\n        String::from(\"three.three.three.three\"),\n    );\n    ips_to_hostnames.insert(\n        IpAddr::V4(\"10.0.0.2\".parse().unwrap()),\n        String::from(\"i-like-cheese.com\"),\n    );\n    let dns_client = create_fake_dns_client(ips_to_hostnames);\n    let write_to_stdout = Box::new(|_output: &_| {});\n\n    let os_input = OsInputOutput {\n        interfaces_with_frames,\n        get_open_sockets,\n        terminal_events: sleep_and_quit_events(3),\n        dns_client,\n        write_to_stdout,\n    };\n    let opts = opts_ui();\n    start(backend, os_input, opts);\n\n    assert_snapshot!(terminal_draw_events\n        .lock()\n        .unwrap()\n        .join(SNAPSHOT_SECTION_SEPARATOR));\n    assert_debug_snapshot!(terminal_events.lock().unwrap().as_slice());\n}\n\n#[rstest(sample_frames_sustained_long as network_frames)]\nfn truncate_long_hostnames(network_frames: Vec<Box<dyn DataLinkReceiver>>) {\n    let (terminal_events, terminal_draw_events, backend) = test_backend_factory(190, 50);\n\n    let interfaces_with_frames = get_interfaces_with_frames(network_frames);\n\n    let mut ips_to_hostnames = HashMap::new();\n    ips_to_hostnames.insert(\n        IpAddr::V4(\"1.1.1.1\".parse().unwrap()),\n        String::from(\"i.am.not.too.long\"),\n    );\n    ips_to_hostnames.insert(\n        IpAddr::V4(\"3.3.3.3\".parse().unwrap()),\n        String::from(\"i.am.an.obnoxiosuly.long.hostname.why.would.anyone.do.this.really.i.ask\"),\n    );\n    ips_to_hostnames.insert(\n        IpAddr::V4(\"10.0.0.2\".parse().unwrap()),\n        String::from(\"i-like-cheese.com\"),\n    );\n    let dns_client = create_fake_dns_client(ips_to_hostnames);\n    let write_to_stdout = Box::new(|_output: &_| {});\n\n    let os_input = OsInputOutput {\n        interfaces_with_frames,\n        get_open_sockets,\n        terminal_events: sleep_and_quit_events(3),\n        dns_client,\n        write_to_stdout,\n    };\n    let opts = opts_ui();\n    start(backend, os_input, opts);\n\n    assert_snapshot!(terminal_draw_events\n        .lock()\n        .unwrap()\n        .join(SNAPSHOT_SECTION_SEPARATOR));\n    assert_debug_snapshot!(terminal_events.lock().unwrap().as_slice());\n}\n\n#[rstest(sample_frames_sustained_long as network_frames)]\nfn no_resolve_mode(network_frames: Vec<Box<dyn DataLinkReceiver>>) {\n    let (terminal_events, terminal_draw_events, backend) = test_backend_factory(190, 50);\n\n    let interfaces_with_frames = get_interfaces_with_frames(network_frames);\n\n    let mut ips_to_hostnames = HashMap::new();\n    ips_to_hostnames.insert(\n        IpAddr::V4(\"1.1.1.1\".parse().unwrap()),\n        String::from(\"one.one.one.one\"),\n    );\n    ips_to_hostnames.insert(\n        IpAddr::V4(\"3.3.3.3\".parse().unwrap()),\n        String::from(\"three.three.three.three\"),\n    );\n    ips_to_hostnames.insert(\n        IpAddr::V4(\"10.0.0.2\".parse().unwrap()),\n        String::from(\"i-like-cheese.com\"),\n    );\n    let dns_client = None;\n    let write_to_stdout = Box::new(|_output: &_| {});\n\n    let os_input = OsInputOutput {\n        interfaces_with_frames,\n        get_open_sockets,\n        terminal_events: sleep_and_quit_events(3),\n        dns_client,\n        write_to_stdout,\n    };\n    let opts = opts_ui();\n    start(backend, os_input, opts);\n\n    assert_snapshot!(terminal_draw_events\n        .lock()\n        .unwrap()\n        .join(SNAPSHOT_SECTION_SEPARATOR));\n    assert_debug_snapshot!(terminal_events.lock().unwrap().as_slice());\n}\n\n#[test]\nfn traffic_with_winch_event() {\n    let network_frames = vec![NetworkFrames::new(vec![Some(build_tcp_packet(\n        \"10.0.0.2\",\n        \"1.1.1.1\",\n        443,\n        12345,\n        b\"I am a fake tcp packet\",\n    ))]) as Box<dyn DataLinkReceiver>];\n    let interfaces_with_frames = get_interfaces_with_frames(network_frames);\n\n    let (terminal_events, terminal_draw_events, backend) = test_backend_factory(190, 50);\n\n    let dns_client = create_fake_dns_client(HashMap::new());\n    let write_to_stdout = Box::new(|_output: &_| {});\n\n    let os_input = OsInputOutput {\n        interfaces_with_frames,\n        get_open_sockets,\n        terminal_events: sleep_resize_and_quit_events(2),\n        dns_client,\n        write_to_stdout,\n    };\n    let opts = opts_ui();\n    start(backend, os_input, opts);\n\n    assert_snapshot!(terminal_draw_events\n        .lock()\n        .unwrap()\n        .join(SNAPSHOT_SECTION_SEPARATOR));\n    assert_debug_snapshot!(terminal_events.lock().unwrap().as_slice());\n}\n\n#[rstest]\n#[case(\"full-width-under-30-height\", 190, 29)]\n#[case(\"under-120-width-full-height\", 119, 50)]\n#[case(\"under-120-width-under-30-height\", 119, 29)]\n#[case(\"under-50-width-under-50-height\", 50, 50)]\n#[case(\"under-70-width-under-30-height\", 69, 29)]\nfn layout(#[case] name: &str, #[case] width: u16, #[case] height: u16) {\n    let network_frames = vec![NetworkFrames::new(vec![\n        Some(build_tcp_packet(\n            \"1.1.1.1\",\n            \"10.0.0.2\",\n            12345,\n            443,\n            b\"I have come from 1.1.1.1\",\n        )),\n        Some(build_tcp_packet(\n            \"3.3.3.3\",\n            \"10.0.0.2\",\n            1337,\n            4435,\n            b\"Greetings traveller, I'm from 3.3.3.3\",\n        )),\n        Some(build_tcp_packet(\n            \"2.2.2.2\",\n            \"10.0.0.2\",\n            54321,\n            4434,\n            b\"You know, 2.2.2.2 is really nice!\",\n        )),\n        Some(build_tcp_packet(\n            \"4.4.4.4\",\n            \"10.0.0.2\",\n            1337,\n            4432,\n            b\"I'm partial to 4.4.4.4\",\n        )),\n    ]) as Box<dyn DataLinkReceiver>];\n\n    let (terminal_events, terminal_draw_events, backend) = test_backend_factory(width, height);\n\n    let os_input = os_input_output(network_frames, 2);\n    let opts = opts_ui();\n    start(backend, os_input, opts);\n\n    assert_snapshot!(\n        format!(\"layout-{name}-draw_events\"),\n        terminal_draw_events\n            .lock()\n            .unwrap()\n            .join(SNAPSHOT_SECTION_SEPARATOR)\n    );\n    assert_debug_snapshot!(\n        format!(\"layout-{name}-events\"),\n        terminal_events.lock().unwrap().as_slice()\n    );\n}\n"
  },
  {
    "path": "src/tests/fakes/fake_input.rs",
    "content": "use std::{\n    collections::HashMap,\n    net::{IpAddr, Ipv4Addr, SocketAddr},\n    thread, time,\n};\n\nuse async_trait::async_trait;\nuse crossterm::event::Event;\nuse itertools::Itertools;\nuse pnet::{\n    datalink::{DataLinkReceiver, NetworkInterface},\n    ipnetwork::IpNetwork,\n};\nuse tokio::runtime::Runtime;\n\nuse crate::{\n    network::{\n        dns::{self, Lookup},\n        Connection, Protocol,\n    },\n    os::ProcessInfo,\n    OpenSockets,\n};\n\npub struct TerminalEvents {\n    pub events: Vec<Option<Event>>,\n}\n\nimpl TerminalEvents {\n    pub fn new(mut events: Vec<Option<Event>>) -> Self {\n        events.reverse(); // this is so that we do not have to shift the array\n        TerminalEvents { events }\n    }\n}\nimpl Iterator for TerminalEvents {\n    type Item = Event;\n    fn next(&mut self) -> Option<Event> {\n        match self.events.pop() {\n            Some(ev) => match ev {\n                Some(ev) => Some(ev),\n                None => {\n                    thread::sleep(time::Duration::from_millis(900));\n                    self.next()\n                }\n            },\n            None => None,\n        }\n    }\n}\n\npub struct NetworkFrames {\n    pub packets: Vec<Option<Vec<u8>>>,\n    pub current_index: usize,\n}\n\nimpl NetworkFrames {\n    pub fn new(packets: Vec<Option<Vec<u8>>>) -> Box<Self> {\n        Box::new(NetworkFrames {\n            packets,\n            current_index: 0,\n        })\n    }\n    fn next_packet(&mut self) -> Option<&[u8]> {\n        let next_index = self.current_index;\n        self.current_index += 1;\n        self.packets.get(next_index).and_then(|p| p.as_deref())\n    }\n}\nimpl DataLinkReceiver for NetworkFrames {\n    fn next(&mut self) -> Result<&[u8], std::io::Error> {\n        if self.current_index == 0 {\n            // make it less likely to have a race condition with the display loop\n            // this is so the tests pass consistently\n            thread::sleep(time::Duration::from_millis(500));\n        }\n        if self.current_index < self.packets.len() {\n            let action = self.next_packet();\n            match action {\n                Some(packet) => Ok(packet),\n                None => {\n                    thread::sleep(time::Duration::from_secs(1));\n                    Ok(&[])\n                }\n            }\n        } else {\n            thread::sleep(time::Duration::from_secs(1));\n            Ok(&[])\n        }\n    }\n}\n\npub fn get_open_sockets() -> OpenSockets {\n    let mut open_sockets = HashMap::new();\n    let local_ip = IpAddr::V4(Ipv4Addr::new(10, 0, 0, 2));\n    open_sockets.insert(\n        Connection::new(\n            SocketAddr::new(IpAddr::V4(Ipv4Addr::new(1, 1, 1, 1)), 12345),\n            local_ip,\n            443,\n            Protocol::Tcp,\n        ),\n        ProcessInfo::new(\"1\", 1),\n    );\n    open_sockets.insert(\n        Connection::new(\n            SocketAddr::new(IpAddr::V4(Ipv4Addr::new(2, 2, 2, 2)), 54321),\n            local_ip,\n            4434,\n            Protocol::Tcp,\n        ),\n        ProcessInfo::new(\"4\", 4),\n    );\n    open_sockets.insert(\n        Connection::new(\n            SocketAddr::new(IpAddr::V4(Ipv4Addr::new(3, 3, 3, 3)), 1337),\n            local_ip,\n            4435,\n            Protocol::Tcp,\n        ),\n        ProcessInfo::new(\"5\", 5),\n    );\n    open_sockets.insert(\n        Connection::new(\n            SocketAddr::new(IpAddr::V4(Ipv4Addr::new(4, 4, 4, 4)), 1337),\n            local_ip,\n            4432,\n            Protocol::Tcp,\n        ),\n        ProcessInfo::new(\"2\", 2),\n    );\n    open_sockets.insert(\n        Connection::new(\n            SocketAddr::new(IpAddr::V4(Ipv4Addr::new(1, 1, 1, 1)), 12346),\n            local_ip,\n            443,\n            Protocol::Tcp,\n        ),\n        ProcessInfo::new(\"1\", 1),\n    );\n    let mut local_socket_to_procs = HashMap::new();\n    let mut connections = std::vec::Vec::new();\n    for (connection, proc_info) in open_sockets {\n        local_socket_to_procs.insert(connection.local_socket, proc_info);\n        connections.push(connection);\n    }\n\n    OpenSockets {\n        sockets_to_procs: local_socket_to_procs,\n    }\n}\n\npub fn get_interfaces() -> Vec<NetworkInterface> {\n    vec![NetworkInterface {\n        name: String::from(\"interface_name\"),\n        description: String::from(\"Fake interface\"),\n        index: 42,\n        mac: None,\n        ips: vec![IpNetwork::V4(\"10.0.0.2\".parse().unwrap())],\n        // It's important that the IFF_LOOPBACK bit is set to 0.\n        // Otherwise sniffer will attempt to start parse packets\n        // at offset 14\n        flags: 0,\n    }]\n}\n\npub fn get_interfaces_with_frames(\n    frames: impl IntoIterator<Item = Box<dyn DataLinkReceiver>>,\n) -> Vec<(NetworkInterface, Box<dyn DataLinkReceiver>)> {\n    get_interfaces().into_iter().zip_eq(frames).collect()\n}\n\npub fn create_fake_dns_client(ips_to_hosts: HashMap<IpAddr, String>) -> Option<dns::Client> {\n    let runtime = Runtime::new().unwrap();\n    let dns_client = dns::Client::new(FakeResolver(ips_to_hosts), runtime).unwrap();\n    Some(dns_client)\n}\n\nstruct FakeResolver(HashMap<IpAddr, String>);\n\n#[async_trait]\nimpl Lookup for FakeResolver {\n    async fn lookup(&self, ip: IpAddr) -> Option<String> {\n        self.0.get(&ip).cloned()\n    }\n}\n"
  },
  {
    "path": "src/tests/fakes/fake_output.rs",
    "content": "use std::{\n    collections::HashMap,\n    io,\n    sync::{Arc, Mutex},\n};\n\nuse ratatui::{\n    backend::{Backend, WindowSize},\n    buffer::Cell,\n    layout::{Position, Size},\n};\n\n#[derive(Hash, Debug, PartialEq)]\npub enum TerminalEvent {\n    Clear,\n    HideCursor,\n    ShowCursor,\n    GetCursor,\n    Flush,\n    Draw,\n}\n\npub struct TestBackend {\n    pub events: Arc<Mutex<Vec<TerminalEvent>>>,\n    pub draw_events: Arc<Mutex<Vec<String>>>,\n    terminal_width: Arc<Mutex<u16>>,\n    terminal_height: Arc<Mutex<u16>>,\n}\n\nimpl TestBackend {\n    pub fn new(\n        log: Arc<Mutex<Vec<TerminalEvent>>>,\n        draw_log: Arc<Mutex<Vec<String>>>,\n        terminal_width: Arc<Mutex<u16>>,\n        terminal_height: Arc<Mutex<u16>>,\n    ) -> TestBackend {\n        TestBackend {\n            events: log,\n            draw_events: draw_log,\n            terminal_width,\n            terminal_height,\n        }\n    }\n}\n\n#[derive(Hash, Eq, PartialEq)]\nstruct Point {\n    x: u16,\n    y: u16,\n}\n\nimpl Backend for TestBackend {\n    fn clear(&mut self) -> io::Result<()> {\n        self.events.lock().unwrap().push(TerminalEvent::Clear);\n        Ok(())\n    }\n\n    fn hide_cursor(&mut self) -> io::Result<()> {\n        self.events.lock().unwrap().push(TerminalEvent::HideCursor);\n        Ok(())\n    }\n\n    fn show_cursor(&mut self) -> io::Result<()> {\n        self.events.lock().unwrap().push(TerminalEvent::ShowCursor);\n        Ok(())\n    }\n\n    fn get_cursor_position(&mut self) -> io::Result<Position> {\n        self.events.lock().unwrap().push(TerminalEvent::GetCursor);\n        Ok(Position::new(0, 0))\n    }\n\n    fn set_cursor_position<P: Into<Position>>(&mut self, _position: P) -> io::Result<()> {\n        Ok(())\n    }\n\n    fn draw<'a, I>(&mut self, content: I) -> io::Result<()>\n    where\n        I: Iterator<Item = (u16, u16, &'a Cell)>,\n    {\n        // use std::fmt::Write;\n        self.events.lock().unwrap().push(TerminalEvent::Draw);\n        let mut string = String::with_capacity(content.size_hint().0 * 3);\n        let mut coordinates = HashMap::new();\n        for (x, y, cell) in content {\n            coordinates.insert(Point { x, y }, cell);\n        }\n        let terminal_height = self.terminal_height.lock().unwrap();\n        let terminal_width = self.terminal_width.lock().unwrap();\n        for y in 0..*terminal_height {\n            for x in 0..*terminal_width {\n                match coordinates.get(&Point { x, y }) {\n                    Some(cell) => {\n                        // this will contain no style information at all\n                        // should be good enough for testing\n                        string.push_str(cell.symbol());\n                    }\n                    None => {\n                        string.push(' ');\n                    }\n                }\n            }\n            string.push('\\n');\n        }\n        self.draw_events.lock().unwrap().push(string);\n        Ok(())\n    }\n\n    fn size(&self) -> io::Result<Size> {\n        let terminal_height = self.terminal_height.lock().unwrap();\n        let terminal_width = self.terminal_width.lock().unwrap();\n\n        Ok(Size::new(*terminal_width, *terminal_height))\n    }\n\n    fn window_size(&mut self) -> io::Result<WindowSize> {\n        let width = *self.terminal_width.lock().unwrap();\n        let height = *self.terminal_height.lock().unwrap();\n\n        Ok(WindowSize {\n            columns_rows: Size { width, height },\n            pixels: Size::default(),\n        })\n    }\n\n    fn flush(&mut self) -> io::Result<()> {\n        self.events.lock().unwrap().push(TerminalEvent::Flush);\n        Ok(())\n    }\n}\n"
  },
  {
    "path": "src/tests/fakes/mod.rs",
    "content": "mod fake_input;\nmod fake_output;\n\npub use fake_input::*;\npub use fake_output::*;\n"
  },
  {
    "path": "src/tests/mod.rs",
    "content": "pub mod cases;\npub mod fakes;\n"
  }
]