{"id":17910813,"url":"https://github.com/dgzlopes/tcp-latency","last_synced_at":"2025-06-21T21:36:16.567Z","repository":{"id":44332955,"uuid":"197553911","full_name":"dgzlopes/tcp-latency","owner":"dgzlopes","description":"Module and command-line tool to measure latency using TCP.","archived":false,"fork":false,"pushed_at":"2022-07-11T13:12:50.000Z","size":28,"stargazers_count":58,"open_issues_count":9,"forks_count":15,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-09-18T00:42:01.671Z","etag":null,"topics":["aws-lambda","devops","lambda","latency","latency-test","networking","ping","python","serverless","tcp"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/tcp-latency/","language":"Python","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/dgzlopes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-18T09:16:31.000Z","updated_at":"2024-06-24T10:35:17.000Z","dependencies_parsed_at":"2022-09-08T07:10:45.256Z","dependency_job_id":null,"html_url":"https://github.com/dgzlopes/tcp-latency","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgzlopes%2Ftcp-latency","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgzlopes%2Ftcp-latency/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgzlopes%2Ftcp-latency/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgzlopes%2Ftcp-latency/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dgzlopes","download_url":"https://codeload.github.com/dgzlopes/tcp-latency/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221919604,"owners_count":16901811,"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":["aws-lambda","devops","lambda","latency","latency-test","networking","ping","python","serverless","tcp"],"created_at":"2024-10-28T19:34:43.892Z","updated_at":"2024-10-28T19:34:44.787Z","avatar_url":"https://github.com/dgzlopes.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tcp-latency\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/tcp-latency.svg)](https://pypi.org/project/tcp-latency/)\n[![PyPI](https://img.shields.io/pypi/v/tcp-latency.svg)](https://pypi.org/project/tcp-latency/)\n[![PyPI - License](https://img.shields.io/pypi/l/tcp-latency.svg)](https://github.com/dgzlopes/tcp-latency/blob/master/LICENSE.md)\n[![Build Status](https://travis-ci.org/dgzlopes/tcp-latency.svg?branch=master)](https://travis-ci.org/dgzlopes/tcp-latency)\n[![PyPI - Downloads](https://img.shields.io/pypi/dm/tcp-latency)](https://pypistats.org/packages/tcp-latency)\n## About\n`tcp-latency` provides an easy way to measure latency using TCP.\n\nInspired by other [similar tools](#similar-tools), `tcp-latency` comes from the need of running network diagnosis/troubleshooting tasks with Python on serverless infrastructure (as many providers don't include ping/ICMP support) but should work too in any other environment with Python\u003e=36.\n## Features\n- Runs as a command-line tool or inside your code as a module.\n- Custom parameters for a port, runs, timeout and wait time between runs.\n- IPv4 (e.g 52.26.14.11) and domain (e.g google.com) host support.\n- Human readable output when running as a command-line tool.\n- No external dependencies.\n- Small and extensible.\n## Usage\n`tcp-latency` can be used both as a module and as a standalone script.\n\n### Module\n```\n\u003e\u003e\u003e from tcp_latency import measure_latency\n\u003e\u003e\u003e measure_latency(host='google.com')\n[34.57]\n\u003e\u003e\u003e measure_latency(host='52.26.14.11', port=80, runs=10, timeout=2.5)\n[433.82, 409.21, 409.25, 307.09, 306.64, 409.45, 306.58, 306.93, 409.25, 409.26]\n```\nNote: If omitted, `measure_latency()` arguments use the same defaults that command-line mode.\n### Command-line\n```\n$ tcplatency -h\nusage: tcp-latency [-h] [-p [p]] [-t [t]] [-r [r]] [-w [w]] h\n\nMeasure latency using TCP.\n\npositional arguments:\n  host\n\noptional arguments:\n  -h, --help            show this help message and exit\n  -p [p], --port [p]    (default: 443)\n  -t [t], --timeout [t]\n                        (seconds, float, default: 5)\n  -r [r], --runs [r]    number of latency points (int, default: 5)\n  -w [w], --wait [w]    between each run (seconds, float, default: 1)\n```\n```\n$ tcp-latency google.com\ntcp-latency google.com\ngoogle.com: tcp seq=0 port=443 timeout=5 time=15.16 ms\ngoogle.com: tcp seq=1 port=443 timeout=5 time=15.63 ms\ngoogle.com: tcp seq=2 port=443 timeout=5 time=14.86 ms\ngoogle.com: tcp seq=3 port=443 timeout=5 time=14.76 ms\ngoogle.com: tcp seq=4 port=443 timeout=5 time=14.59 ms\n--- google.com tcp-latency statistics ---\n5 packets transmitted\nrtt min/avg/max = 14.76/15.1025/15.63 ms\n\n$ tcp-latency 52.26.14.11 --port 80 --runs 3 --wait 0.5\ntcp-latency 52.26.14.11\n52.26.14.11: tcp seq=0 port=80 timeout=5 time=230.2 ms\n52.26.14.11: tcp seq=1 port=80 timeout=5 time=228.96 ms\n52.26.14.11: tcp seq=2 port=80 timeout=5 time=224.51 ms\n--- 52.26.14.11 tcp-latency statistics ---\n3 packets transmitted\nrtt min/avg/max = 228.96/229.57999999999998/230.2 ms\n\n$ tcp-latency google.com -r 1\ntcp-latency google.com\ngoogle.com: tcp seq=0 port=443 timeout=5 time=34.36 ms\n--- google.com tcp-latency statistics ---\n1 packets transmitted\n```\n\n## Installation\nVia pip:\n```\npip install tcp-latency\n```\n## How to contribute\n1. Check for open issues or open a fresh issue to start a discussion around a feature idea or a bug.\n2. Fork [the repository](https://github.com/dgzlopes/tcp-latency) on GitHub to start making your changes to the master branch (or branch off of it).\n3. Write a test which shows that the bug was fixed or that the feature works as expected.\n4. Send a [pull request](https://help.github.com/en/articles/creating-a-pull-request-from-a-fork) and bug [me](https://github.com/dgzlopes) until it gets merged and published.\n\nSome things that would be great to have:\n- Add transmitted vs received statistics (e.g packet loss)\n- Add bytes information (ping-like)\n- Add support for machine-readable output (JSON,XML,YAML).\n- Add automated releases with TravisCI.\n- Improve test suite.\n- Improve `How to contribute` information (pyenv, tox, pre-commit...)\n\n## Similar tools\n- [yantisj/tcpping](https://github.com/yantisj/tcpping)\n- [ipv6freely/tcpping](https://github.com/ipv6freely/tcpping)\n- [yahoo/serviceping](https://github.com/yahoo/serviceping)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdgzlopes%2Ftcp-latency","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdgzlopes%2Ftcp-latency","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdgzlopes%2Ftcp-latency/lists"}