{"id":13581966,"url":"https://github.com/newtools/zsocket","last_synced_at":"2025-04-06T10:33:07.263Z","repository":{"id":57484367,"uuid":"59538658","full_name":"newtools/zsocket","owner":"newtools","description":"Zero-copy sockets for Linux in Golang","archived":false,"fork":false,"pushed_at":"2020-07-07T14:07:10.000Z","size":93,"stargazers_count":826,"open_issues_count":8,"forks_count":73,"subscribers_count":30,"default_branch":"master","last_synced_at":"2024-08-13T20:17:09.874Z","etag":null,"topics":["ethernet","golang","linux","network-programming","software-defined-network","tcp","zsocket"],"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/newtools.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":"2016-05-24T03:49:53.000Z","updated_at":"2024-07-09T09:49:30.000Z","dependencies_parsed_at":"2022-08-26T14:23:13.251Z","dependency_job_id":null,"html_url":"https://github.com/newtools/zsocket","commit_stats":null,"previous_names":["nathanjsweet/zsocket"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/newtools%2Fzsocket","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/newtools%2Fzsocket/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/newtools%2Fzsocket/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/newtools%2Fzsocket/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/newtools","download_url":"https://codeload.github.com/newtools/zsocket/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247470558,"owners_count":20944146,"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":["ethernet","golang","linux","network-programming","software-defined-network","tcp","zsocket"],"created_at":"2024-08-01T15:02:21.396Z","updated_at":"2025-04-06T10:33:06.155Z","avatar_url":"https://github.com/newtools.png","language":"Go","readme":"# ZSocket\n\nZSocket is a library that wraps the linux zero-copy socket syscall to create a ring buffer in a memory mapped file.\nIt also contains some utility functions and types to help with a handful of layer 2, 3, and 4 types.\nIt is a lot like libcap, except it has easy to understand facilities for writing (injecting packets) to an interface.\n\nZSocket doesn't contain or wrap any C/C++, and it is lock free and thread safe.\n\nThe following program prints out all know layer types to ZSocket on a given interface:\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n\n    \"github.com/newtools/zsocket\"\n    \"github.com/newtools/zsocket/nettypes\"\n)\n\nfunc main() {\n\t// args: interfaceIndex, options, maxFrameSize, and maxTotalFrames\n\n\t// inerfaceIndex: the index of the net device you want to open a raw socket to\n\t// options: RX and TX, or just one or the other?\n\t// maxFrameSize: must be a power of 2, bigger than zsocket.MinimumFrameSize,\n\t// \tand smaller than maximum frame size\n\t// maxTotalFrames: must be at least 16, and be a multiple of 8.\n\tzs, err := zsocket.NewZSocket(14, zsocket.EnableRX, 2048, 64, nettypes.All)\n\t// the above will result in a ring buffer of 64 frames at\n\t// \t(2048 - zsocket.PacketOffset()) *writeable* bytes each\n\t// \tfor a total of 2048*64 bytes of *unswappable* system memory consumed.\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tzs.Listen(func(f *nettypes.Frame, frameLen, capturedLen uint16) {\n\t\tfmt.Printf(f.String(capturedLen, 0))\n\t})\n}\n```\n\n1. See the examples folder for more simple programs that do various things with ZSocket.\n\n2. Learn how to set up a docker container with a custom veth-pair in the utils folder (useful for setting up\ncomplex virtual networking scenarios)\n\n3. Play around with FakeInterface to (and its examples folder) to play around with networking protocols.\n","funding_links":[],"categories":["Go"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnewtools%2Fzsocket","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnewtools%2Fzsocket","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnewtools%2Fzsocket/lists"}