{"id":32143240,"url":"https://github.com/453jerry/netdiagnosis","last_synced_at":"2025-10-21T07:55:25.768Z","repository":{"id":146451768,"uuid":"618105859","full_name":"453jerry/NetDiagnosis","owner":"453jerry","description":"Provide swift developers with a bunch of network diagnostic tools that support both IPv4 and IPv6","archived":false,"fork":false,"pushed_at":"2025-01-15T17:08:38.000Z","size":56,"stargazers_count":28,"open_issues_count":0,"forks_count":11,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-16T17:14:54.414Z","etag":null,"topics":["diagnosis","diagnostic","net","netdiagnosis","network","ping","swift","traceroute"],"latest_commit_sha":null,"homepage":"","language":"Swift","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/453jerry.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":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-23T19:06:37.000Z","updated_at":"2025-08-19T16:56:39.000Z","dependencies_parsed_at":null,"dependency_job_id":"95aba787-5842-4cd2-ad52-99aa084c10da","html_url":"https://github.com/453jerry/NetDiagnosis","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/453jerry/NetDiagnosis","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/453jerry%2FNetDiagnosis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/453jerry%2FNetDiagnosis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/453jerry%2FNetDiagnosis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/453jerry%2FNetDiagnosis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/453jerry","download_url":"https://codeload.github.com/453jerry/NetDiagnosis/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/453jerry%2FNetDiagnosis/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280225807,"owners_count":26293888,"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","status":"online","status_checked_at":"2025-10-21T02:00:06.614Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["diagnosis","diagnostic","net","netdiagnosis","network","ping","swift","traceroute"],"created_at":"2025-10-21T07:55:22.372Z","updated_at":"2025-10-21T07:55:25.761Z","avatar_url":"https://github.com/453jerry.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NetDiagnosis\n\n[![swift_ver](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2F453jerry%2FNetDiagnosis%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/453jerry/NetDiagnosis)\n[![platform](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2F453jerry%2FNetDiagnosis%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/453jerry/NetDiagnosis)\n\nThe goal of this project is to provide swift developers with a bunch of network diagnostic tools that support both IPv4 and IPv6. Currently  Ping, Traceroute, domain name resolve has been implementd.\n\n## How to use\n\n### Resolve domain name\n\n```swift\n// lookup ipv4 addrress\nlet ipv4Result = try! IPAddr.resolve(domainName: \"bing.com\", addressFamily: .ipv4)\nfor ip in ipv4Result {\n    print(ip)\n}\n// Output:\n// 13.107.21.200\n// 204.79.197.200\n// 204.79.197.200\n\n// lookup ipv6 addrress\nlet ipv6Result = try! IPAddr.resolve(domainName: \"bing.com\", addressFamily: .ipv6)\nfor ip in ipv6Result {\n    print(ip)\n}\n// Output:\n// 2620:1ec:c11::200\n```\n\n### Ping\n\n```swift\nlet remoteAddr = IPAddr.create(\"13.107.21.200\", addressFamily: .ipv4)\n// Also support IPv6 address\n// let remoteAddr = IPAddr.create(\"2620:1ec:c11::200\", addressFamily: .ipv6) \nlet pinger = try! Pinger.init(remoteAddr: remoteAddr) \n\npinger.ping { result in\n    print(result)\n}\n// Output:\n// pong(from: 13.107.21.200, hopLimit: 113, sequence: 0, identifier: 58577, time: 0.08944892883300781)\n\npinger.ping(hopLimit: 3) { result in\n    print(result)\n}\n// Output:\n// hopLimitExceeded(from: 100.96.15.65, hopLimit: 253, sequence: 1, identifier: 58577, time: 0.030148029327392578)\n\npinger.ping(hopLimit: 3, timeOut: 0.001) { result in\n    print(result)\n}\n// Output:\n// timeout(sequence: 2, identifier: 58577)\n```\n\n### Trace route\n\n```swift\nlet remoteAddr = IPAddr.create(\"13.107.21.200\", addressFamily: .ipv4)\n// Also support IPv6 address\n// let remoteAddr = IPAddr.create(\"2620:1ec:c11::200\", addressFamily: .ipv6) \nlet pinger = try! Pinger.init(remoteAddr: remoteAddr) \n\npinger.trace { result, status in\n    for (hop,responses) in result {\n        print(\"hop:\\(hop)\")\n        for response in responses {\n            print(response)\n        }\n    }\n    print(\"Complete Status:\\(status)\")\n}\n// Output:\n//    hop:1\n//    hopLimitExceeded(from: 172.20.10.1, hopLimit: 64, sequence: 3, identifier: 63182, time: 0.0032230615615844727)\n//    hopLimitExceeded(from: 172.20.10.1, hopLimit: 64, sequence: 4, identifier: 63182, time: 0.0031599998474121094)\n//    hopLimitExceeded(from: 172.20.10.1, hopLimit: 64, sequence: 5, identifier: 63182, time: 0.002807021141052246)\n//    hop:2\n//    timeout(sequence: 6, identifier: 63182)\n//    timeout(sequence: 7, identifier: 63182)\n//    timeout(sequence: 8, identifier: 63182)\n//\n//    ......\n//\n//    hop:13\n//    hopLimitExceeded(from: 104.44.236.180, hopLimit: 243, sequence: 39, identifier: 63182, time: 0.04397702217102051)\n//    hopLimitExceeded(from: 104.44.236.180, hopLimit: 243, sequence: 40, identifier: 63182, time: 0.059321045875549316)\n//    hopLimitExceeded(from: 104.44.236.180, hopLimit: 243, sequence: 41, identifier: 63182, time: 0.04588794708251953)\n//    hop:14\n//    timeout(sequence: 42, identifier: 63182)\n//    timeout(sequence: 43, identifier: 63182)\n//    timeout(sequence: 44, identifier: 63182)\n//    hop:15\n//    timeout(sequence: 45, identifier: 63182)\n//    timeout(sequence: 46, identifier: 63182)\n//    timeout(sequence: 47, identifier: 63182)\n//    hop:16\n//    pong(from: 13.107.21.200, hopLimit: 113, sequence: 48, identifier: 63182, time: 0.0753859281539917)\n//    pong(from: 13.107.21.200, hopLimit: 113, sequence: 49, identifier: 63182, time: 0.06895899772644043)\n//    pong(from: 13.107.21.200, hopLimit: 113, sequence: 50, identifier: 63182, time: 0.06241798400878906)\n//\n//    Complete Status:traced\n\npinger.trace(initHop: 10, maxHop: 14, packetCount: 1) { response, hop, packetIndex, stopTrace in\n    print(\"Hop:\\(hop) packetIdx:\\(packetIndex), response:\\(response)\")\n    // If you want stop trace\n    // stopTrace(true)\n} onTraceComplete: { _, status in\n    print(\"Complete Status:\\(status)\")\n}\n// Output:\n// Hop:10 packetIdx:0, response:hopLimitExceeded(from: 202.97.19.94, hopLimit: 246, sequence: 3, identifier: 62186, time: 0.04130589962005615)\n// Hop:11 packetIdx:0, response:hopLimitExceeded(from: 203.215.236.98, hopLimit: 244, sequence: 4, identifier: 62186, time: 0.04481005668640137)\n// Hop:12 packetIdx:0, response:hopLimitExceeded(from: 104.44.235.186, hopLimit: 244, sequence: 5, identifier: 62186, time: 0.04833698272705078)\n// Hop:13 packetIdx:0, response:hopLimitExceeded(from: 104.44.236.180, hopLimit: 243, sequence: 6, identifier: 62186, time: 0.041616082191467285)\n// Hop:14 packetIdx:0, response:timeout(sequence: 7, identifier: 62186)\n// Complete Status:maxHopExceeded\n```\n\n## RxSwfit Support\n\n### Ping\n\n```swift\npinger.rx.ping().subscribe { r in\n    print(r)\n}\n.disposed(by: disposeBag)\n// Output:\n// success(NetDiagnosis.Pinger.PingResult.pong(NetDiagnosis.Pinger.Response(len: 64, from: 110.242.68.66, hopLimit: 51, sequence: 0, identifier: 47189, rtt: 0.03671896457672119)))\n```\n\n\n### Trace route\n\n```swift\npinger.rx.trace().subscribe { r in\n    print(r)\n}\n.disposed(by: disposeBag)\n\n// Output:\n// next(TracePacketResult(pingResult: NetDiagnosis.Pinger.PingResult.timeout(sequence: 0, identifier: 38724), hop: 1, packetIndex: 0))\n// next(TracePacketResult(pingResult: NetDiagnosis.Pinger.PingResult.timeout(sequence: 1, identifier: 38724), hop: 1, packetIndex: 1))\n// next(TracePacketResult(pingResult: NetDiagnosis.Pinger.PingResult.timeout(sequence: 2, identifier: 38724), hop: 1, packetIndex: 2))\n\n//...\n\n//next(TracePacketResult(pingResult: NetDiagnosis.Pinger.PingResult.pong(NetDiagnosis.Pinger.Response(len: 64, from: 110.242.68.66, hopLimit: 51, sequence: 48, identifier: 38724, rtt: 0.03915095329284668)), hop: 17, packetIndex: 0))\n// next(TracePacketResult(pingResult: NetDiagnosis.Pinger.PingResult.pong(NetDiagnosis.Pinger.Response(len: 64, from: 110.242.68.66, hopLimit: 51, sequence: 49, identifier: 38724, rtt: 0.03501296043395996)), hop: 17, packetIndex: 1))\n// next(TracePacketResult(pingResult: NetDiagnosis.Pinger.PingResult.pong(NetDiagnosis.Pinger.Response(len: 64, from: 110.242.68.66, hopLimit: 51, sequence: 50, identifier: 38724, rtt: 0.03649783134460449)), hop: 17, packetIndex: 2))\n// completed\n\n\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F453jerry%2Fnetdiagnosis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F453jerry%2Fnetdiagnosis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F453jerry%2Fnetdiagnosis/lists"}