{"id":16164639,"url":"https://github.com/johnsonjh/gfcptun","last_synced_at":"2025-03-18T23:30:31.159Z","repository":{"id":40487724,"uuid":"342761739","full_name":"johnsonjh/gfcptun","owner":"johnsonjh","description":"gfcptun: A fast and low-latency tunnel using GFCP over UDP","archived":false,"fork":false,"pushed_at":"2024-04-19T16:21:15.000Z","size":3647,"stargazers_count":10,"open_issues_count":1,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-04-20T13:48:53.913Z","etag":null,"topics":["bdp","gfcp","gfsmux","holb","kcp","kcptun","low-latency","tun","tunnel","udp"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/johnsonjh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2021-02-27T03:31:11.000Z","updated_at":"2024-04-23T12:55:16.838Z","dependencies_parsed_at":"2023-02-12T19:31:22.478Z","dependency_job_id":"6808ef69-4cb5-4911-b63c-c17fae4cb035","html_url":"https://github.com/johnsonjh/gfcptun","commit_stats":null,"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnsonjh%2Fgfcptun","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnsonjh%2Fgfcptun/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnsonjh%2Fgfcptun/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnsonjh%2Fgfcptun/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/johnsonjh","download_url":"https://codeload.github.com/johnsonjh/gfcptun/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243955432,"owners_count":20374369,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bdp","gfcp","gfsmux","holb","kcp","kcptun","low-latency","tun","tunnel","udp"],"created_at":"2024-10-10T02:47:19.448Z","updated_at":"2025-03-18T23:30:30.806Z","avatar_url":"https://github.com/johnsonjh.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gfcptun\n\n[![GRC](https://goreportcard.com/badge/github.com/johnsonjh/gfcptun)](https://goreportcard.com/badge/github.com/johnsonjh/gfcptun)\n[![Maintainability](https://api.codeclimate.com/v1/badges/3d0e75c080ab05a06a87/maintainability)](https://codeclimate.com/github/johnsonjh/gfcptun/maintainability)\n\ngfcptun: A fast and low-latency connection tunnel using GFCP over UDP.\n\n---\n\n## Basic gfcptun/GFCP recommendations\n\n- Make available 65535 or more file descriptors per gfcptun process.\n\n- MTU of 9000-9702 is recommended for high-speed local links.\n\n- Suggested minimum `sysctl` tuning parameters for Linux UDP handling:\n\n  - (See\n    \u003chttps://www.sciencedirect.com/topics/computer-science/bandwidth-delay-product\u003e\n    for additional BDP background information.)\n\n```shell\nnet.core.rmem_max=26214400       # Tune for BDP (bandwidth delay product)\nnet.core.rmem_default=26214400\nnet.core.wmem_max=26214400\nnet.core.wmem_default=26214400\nnet.core.netdev_max_backlog=2048 # (Adjust proportional to receive window)\n```\n\n- Increase buffering for high-speed local links to 16MiB or more, example:\n\n```text\n-sockbuf 16777217\n```\n\n---\n\n## Process invocation examples\n\n```shell\nclient -r \"IN:4321\" -l \":8765\" -mode fast3 -nocomp -autoexpire 900 -sockbuf 33554434 -dscp 46\nserver -t \"OUT:8765\" -l \":4321\" -mode fast3 -nocomp -sockbuf 33554434 -dscp 46\n```\n\n- Application → Out (8765/TCP) → Internet → In (4321/UDP) → Server (8765/TCP)\n\n  - Other useful parameters: `-mode fast3 -ds 10 -ps 3`, etc.\n\n---\n\n## Tuning for increased total throughput\n\n- To tune, increase `-rcvwnd` on client, and `-sndwnd` on server, in unison.\n\n  - The minimum window size will dictate the maximum link throughput:\n    `( 'Wnd' * ( 'MTU' / 'RTT' ) )`\n\n  - MTU should be set by -mtu parameter and never exceed the MTU of the physical\n    interface. For DC/high-speed local links w/jumbo framing, using an MTU of\n    9000-9702 is highly recommended.\n\n---\n\n## Tuning for reduced overall latency\n\n- Adjust the retransmission algorithm aggressiveness:\n\n  - _`fast3` *→* `fast2` *→* `fast` *→* `normal` *→* `default`_\n\n---\n\n## Avoiding **N** _→_ **1** multiplexing [head-of-line blocking](https://www.sciencedirect.com/topics/computer-science/head-of-line-blocking) behavior\n\n- Raise `-smuxbuf` to 16MiB (or more), however, the actual value to use depends\n  on link congestion as well as available contiguous system memory.\n\n- SMUXv2 can be used to limit per-stream memory usage. Enable with `-smuxver 2`,\n  and then tune with `-streambuf` _(size in bytes)_.\n\n  - Example: `-smuxver 2 -streambuf 8388608` for an 8MiB buffer (per stream).\n\n- Start tuning by limiting the stream buffer on the **receiving** side of the\n  link.\n\n  - Back-pressure should trigger existing congestion control mechanisms,\n    providing practical rate limiting to prevent the exhaustion of upstream\n    capacity and also avoiding downlink starvation (bufferbloat scenario).\n\n- SMUXv2 configuration is _not negotiated_, so must be set manually on **both**\n  sides of the GFCP link.\n\n---\n\n## Memory consumption control\n\n- `GOGC` runtime environment variable tuning recommendation:\n\n  - **10**-**20** for low-memory systems and embedded devices\n\n  - **120**-**150** (or higher) for dedicated servers\n\n- Notes regarding (GF)SMUX(v1/v2) tuning:\n\n  - Primary memory allocation is done from a buffer pool (_xmit.Buf_), in the\n    GFCP layer. When allocating, a _fixed-size_ buffer, determined by the\n    MtuLimit, will be returned. From there, the _rx queue_, _tx queue_, and,\n    _fec queue_ will be allocated, and will return the allocation to the buffer\n    pool after use.\n\n- The buffer pool mechanism maintains a _high watermark_ for _in-flight_ objects\n  from the pool to survive periodic runtime garbage collection.\n\n- Memory will be returned to the system by the Go runtime when idle. Variables\n  that can be used for tuning this are `-sndwnd`,`-rcvwnd`,`-ds`, and `-ps`.\n\n  - These parameters affect the _high watermark_ - the larger the value, the\n    higher the total memory consumption can be at any given moment.\n\n- The `-smuxbuf` setting and `GOMAXPROCS` variable can be used to tune the\n  balance between the _concurrency limit_ and overall _resource usage_.\n\n  - Increasing `-smuxbuf` will increase the practical concurrency limit,\n    however, the `-smuxbuf` value is **not** linerally proprotional to the\n    concurrency handling maximum because Go runtime's garbage collection is, for\n    practical purposes, non-deterministic.\n\n  - Only empirical testing can provide the feedback required for real-world link\n    tuning and optimization.\n\n---\n\n## Link compression\n\n- Optional compression (using _Snappy_) is supported.\n\n- Compression saves bandwidth on _redundant, low-entropy_ data, but **will**\n  **increase** overhead (and CPU usage) in **all** other cases.\n\n  - Compression is **enabled by default**: use `-nocomp` to disable.\n\n    - Both ends of the link **must** use the same compression setting.\n\n---\n\n## GFCP SNSI monitoring\n\n- Upon receiving a `USR1` signal, detailed link information will be displayed.\n\n---\n\n## Low-level GFCP tuning\n\n- Example: `-mode manual -nodelay 1 -interval 20 -resend 2 -nc 1`\n\n---\n\n## Availability\n\n- [GitHub](https://github.com/johnsonjh/gfcptun)\n- [GitLab](https://gitlab.com/johnsonjh/gfcptun)\n- [SourceHut](https://sr.ht/~trn/gfcptun)\n- [NotABug](https://notabug.org/trn/gfcptun)\n\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnsonjh%2Fgfcptun","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohnsonjh%2Fgfcptun","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnsonjh%2Fgfcptun/lists"}