{"id":13646422,"url":"https://github.com/jessfraz/cni-benchmarks","last_synced_at":"2025-03-26T03:31:59.984Z","repository":{"id":141979967,"uuid":"130083138","full_name":"jessfraz/cni-benchmarks","owner":"jessfraz","description":"A simple program to benchmark various container networking (CNI) plugins.","archived":false,"fork":false,"pushed_at":"2018-12-29T17:14:53.000Z","size":90791,"stargazers_count":84,"open_issues_count":0,"forks_count":3,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-21T04:51:13.697Z","etag":null,"topics":["cni","container-networking","containers","docker","kubernetes"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":false,"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/jessfraz.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}},"created_at":"2018-04-18T15:25:34.000Z","updated_at":"2024-11-07T12:44:08.000Z","dependencies_parsed_at":"2024-01-14T10:13:52.741Z","dependency_job_id":null,"html_url":"https://github.com/jessfraz/cni-benchmarks","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/jessfraz%2Fcni-benchmarks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jessfraz%2Fcni-benchmarks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jessfraz%2Fcni-benchmarks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jessfraz%2Fcni-benchmarks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jessfraz","download_url":"https://codeload.github.com/jessfraz/cni-benchmarks/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245585136,"owners_count":20639667,"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":["cni","container-networking","containers","docker","kubernetes"],"created_at":"2024-08-02T01:02:55.180Z","updated_at":"2025-03-26T03:31:54.966Z","avatar_url":"https://github.com/jessfraz.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# cni-benchmarks\n\n[![Travis CI](https://travis-ci.org/jessfraz/cni-benchmarks.svg?branch=master)](https://travis-ci.org/jessfraz/cni-benchmarks)\n\n**Table of Contents**\n\n\u003c!-- toc --\u003e\n\n- [What this does...](#what-this-does)\n- [Running](#running)\n  * [Setup](#setup)\n  * [Running the benchmarks](#running-the-benchmarks)\n  * [Running the main program](#running-the-main-program)\n- [Using the Makefile to update the CNI binaries, etc](#using-the-makefile-to-update-the-cni-binaries-etc)\n\n\u003c!-- tocstop --\u003e\n\n## What this does...\n\nThe `main.go` resulting binary loads all the cni plugin configurations from\n[`net.d`](net.d) performs the following on each:\n\n1. Unshares a new network namespace with a `sleep` process.\n2. Sets up networking for the process via the specific plugin passed.\n3. Enters the network namespace and calls get to `https://httpbin.org/ip` \n    just to make sure network works.\n4.  Returns to the original namespace. Kills the process and cleans up the\n    network.\n\n**This is not benchmarking network speed, it is benchmarking the creation,\nsetup and deletion of networks in the network namespace.**\n\n## Running\n\nRunning the benchmarks is just done with go.\nYou will need to use `sudo` since it requires creating network namespaces.\n\n### Setup\n\nBefore testing the `cilium`, `calico`, `flannel`, and `weave` plugins you will want to run the\nfollowing command which will start `etcd`, `calico`, `cilium`, and `weave` containers:\n\n```\n$ make run-containers\n```\n\n**NOTE:** Both `cilium` and `flannel` use `vxlan` devices so you cannot run both at\nthe same time. You will need to test those separately. The `Makefile` will\nautomatically do this for you if you are using `make benchmark`.\n\n### Running the benchmarks\n\n```console\n$ make benchmark\ngoos: linux\ngoarch: amd64\npkg: github.com/jessfraz/cni-benchmarks\nBenchmarkAzure/setup_network_in_netns-8                  5         293583711 ns/op\nBenchmarkAzure/delete_network_from_netns-8              10         167036372 ns/op\nBenchmarkBridge/setup_network_in_netns-8                 5         231135669 ns/op\nBenchmarkBridge/delete_network_from_netns-8             10         169736314 ns/op\nBenchmarkCalico/setup_network_in_netns-8                10         163298127 ns/op\nBenchmarkCalico/delete_network_from_netns-8             10         151587425 ns/op\nBenchmarkCilium/setup_network_in_netns-8                 2         670156235 ns/op\nBenchmarkCilium/delete_network_from_netns-8             10         146059922 ns/op\nBenchmarkFlannelIPvlan/setup_network_in_netns-8         20          58527628 ns/op\nBenchmarkFlannelIPvlan/delete_network_from_netns-8      20          55026466 ns/op\nBenchmarkFlannelBridge/setup_network_in_netns-8         30          69051333 ns/op\nBenchmarkFlannelBridge/delete_network_from_netns-8      20          78479942 ns/op\nBenchmarkIPvlan/setup_network_in_netns-8                30          36967398 ns/op\nBenchmarkIPvlan/delete_network_from_netns-8             30          50841063 ns/op\nBenchmarkMacvlan/setup_network_in_netns-8               20          68855256 ns/op\nBenchmarkMacvlan/delete_network_from_netns-8            30          50002883 ns/op\nBenchmarkPTP/setup_network_in_netns-8                   20          69022267 ns/op\nBenchmarkPTP/delete_network_from_netns-8                20          69180087 ns/op\nBenchmarkWeave/setup_network_in_netns-8                  5         251617140 ns/op\nBenchmarkWeave/delete_network_from_netns-8              10         133323976 ns/op\nPASS\nok      github.com/jessfraz/cni-benchmarks      229.918s\n\n\n# You can change the benchmark time with the BENCHTIME variable.\n$ make benchmark BENCHTIME=2s\ngoos: linux\ngoarch: amd64\npkg: github.com/jessfraz/cni-benchmarks\nBenchmarkBridge/setup_network_in_netns-8                20         197434399 ns/op\nBenchmarkBridge/delete_network_from_netns-8             20         149696059 ns/op\nBenchmarkCalico/setup_network_in_netns-8                20         151476354 ns/op\nBenchmarkCalico/delete_network_from_netns-8             20         150307158 ns/op\nBenchmarkCilium/setup_network_in_netns-8                 5         653119071 ns/op\nBenchmarkCilium/delete_network_from_netns-8             20         144616301 ns/op\nBenchmarkFlannelIPvlan/setup_network_in_netns-8         50          53004252 ns/op\nBenchmarkFlannelIPvlan/delete_network_from_netns-8      50          50625823 ns/op\nBenchmarkFlannelBridge/setup_network_in_netns-8         50          64475335 ns/op\nBenchmarkFlannelBridge/delete_network_from_netns-8      50          78113078 ns/op\nBenchmarkIPvlan/setup_network_in_netns-8               100          41185221 ns/op\nBenchmarkIPvlan/delete_network_from_netns-8             50          48729643 ns/op\nBenchmarkMacvlan/setup_network_in_netns-8               30          67917123 ns/op\nBenchmarkMacvlan/delete_network_from_netns-8            50          51722428 ns/op\nBenchmarkPTP/setup_network_in_netns-8                   50          73868438 ns/op\nBenchmarkPTP/delete_network_from_netns-8                30          67201857 ns/op\nBenchmarkWeave/setup_network_in_netns-8                 20         266690572 ns/op\nBenchmarkWeave/delete_network_from_netns-8              20         127898436 ns/op\nPASS\nok      github.com/jessfraz/cni-benchmarks      376.501s\n```\n\n### Running the main program\n\nThe `main.go` program just runs all the plugins.\n\n```console\n$ make\n\n# You have to sudo the resulting binary since it creates new network\n# namespaces.\n$ sudo ./cni-benchmarks\nINFO[0000] Found plugin configurations for bridge, calico, cilium, ipvlan, macvlan, ptp, weave \nINFO[0000] Parent process ($this) has PID 1837          \nINFO[0000] creating new netns process                    plugin=bridge\nINFO[0000] netns process has PID 1842                    plugin=bridge\nINFO[0000] IP of the default interface (eth0) in the netns is 10.10.0.111  plugin=bridge\nINFO[0000] getting netns file descriptor from the pid 1842  plugin=bridge\nINFO[0000] [performing setns into netns from pid 1842    plugin=bridge\nINFO[0000] found netns ip links: device-\u003elo, ipip-\u003etunl0, ip6gre-\u003egre0, ip6gretap-\u003egretap0, erspan-\u003eerspan0, vti-\u003eip_vti0, vti6-\u003eip6_vti0, sit-\u003esit0, ip6tnl-\u003eip6tnl0, ip6gre-\u003eip6gre0, veth-\u003eeth0  plugin=bridge\nINFO[0000] httpbin returned: {\"origin\":\"69.203.154.19\"}  plugin=bridge\nINFO[0001] creating new netns process                    plugin=calico\nINFO[0002] netns process has PID 1962                    plugin=calico\nCalico CNI IPAM request count IPv4=1 IPv6=0\nCalico CNI IPAM handle=calico-benchmark.1962\nCalico CNI IPAM assigned addresses IPv4=[192.168.245.204] IPv6=[]\nCalico CNI using IPs: [192.168.245.204/32]\nINFO[0002] IP of the default interface (eth0) in the netns is 192.168.245.204  plugin=calico\nINFO[0002] getting netns file descriptor from the pid 1962  plugin=calico\nINFO[0002] [performing setns into netns from pid 1962    plugin=calico\nINFO[0002] found netns ip links: device-\u003elo, ipip-\u003etunl0, ip6gre-\u003egre0, ip6gretap-\u003egretap0, erspan-\u003eerspan0, vti-\u003eip_vti0, vti6-\u003eip6_vti0, sit-\u003esit0, ip6tnl-\u003eip6tnl0, ip6gre-\u003eip6gre0, veth-\u003eeth0  plugin=calico\nINFO[0002] httpbin returned: {\"origin\":\"69.203.154.19\"}  plugin=calico\nINFO[0012] creating new netns process                    plugin=cilium\nINFO[0014] netns process has PID 2109                    plugin=cilium\nlevel=debug msg=\"Processing CNI ADD request\" args=\"\u0026{2109 /proc/2109/ns/net eth0  /home/jessie/.go/src/github.com/jessfraz/cni-benchmarks/bin:/opt/cni/bin [123 34 99 110 105 86 101 114 115 105 111 110 34 58 34 34 44 34 109 116 117 34 58 49 52 53 48 44 34 110 97 109 101 34 58 34 99 105 108 105 117 109 34 44 34 116 121 112 101 34 58 34 99 105 108 105 117 109 45 99 110 105 34 125]}\"\nlevel=debug msg=\"Created veth pair\" vethPair=\"[tmp2109 lxc2109]\"\nlevel=debug msg=\"Configuring link\" interface=eth0 ipAddr=10.25.220.6 netLink=\"\u0026{LinkAttrs:{Index:1422 MTU:1450 TxQLen:0 Name:eth0 HardwareAddr:46:e5:08:3c:25:56 Flags:broadcast|multicast RawFlags:4098 ParentIndex:1423 MasterIndex:0 Namespace:\u003cnil\u003e Alias: Statistics:0xc42159c0e8 Promisc:0 Xdp:0xc4215762e0 EncapType:ether Protinfo:\u003cnil\u003e OperState:down} PeerName:}\"\nlevel=debug msg=\"Adding route\" route=\"{Prefix:{IP:10.25.28.238 Mask:ffffffff} Nexthop:\u003cnil\u003e}\"\nlevel=debug msg=\"Adding route\" route=\"{Prefix:{IP:0.0.0.0 Mask:00000000} Nexthop:10.25.28.238}\"\nlevel=debug msg=\"Configuring link\" interface=eth0 ipAddr=\"f00d::a19:0:0:815b\" netLink=\"\u0026{LinkAttrs:{Index:1422 MTU:1450 TxQLen:0 Name:eth0 HardwareAddr:46:e5:08:3c:25:56 Flags:broadcast|multicast RawFlags:4098 ParentIndex:1423 MasterIndex:0 Namespace:\u003cnil\u003e Alias: Statistics:0xc42159c0e8 Promisc:0 Xdp:0xc4215762e0 EncapType:ether Protinfo:\u003cnil\u003e OperState:down} PeerName:}\"\nlevel=debug msg=\"Adding route\" route=\"{Prefix:{IP:f00d::a19:0:0:8ad6 Mask:ffffffffffffffffffffffffffffffff} Nexthop:\u003cnil\u003e}\"\nlevel=debug msg=\"Adding route\" route=\"{Prefix:{IP::: Mask:00000000000000000000000000000000} Nexthop:f00d::a19:0:0:8ad6}\"\nINFO[0014] IP of the default interface (eth0) in the netns is 10.25.220.6  plugin=cilium\nINFO[0014] getting netns file descriptor from the pid 2109  plugin=cilium\nINFO[0014] [performing setns into netns from pid 2109    plugin=cilium\nINFO[0014] found netns ip links: device-\u003elo, ipip-\u003etunl0, ip6gre-\u003egre0, ip6gretap-\u003egretap0, erspan-\u003eerspan0, vti-\u003eip_vti0, vti6-\u003eip6_vti0, sit-\u003esit0, ip6tnl-\u003eip6tnl0, ip6gre-\u003eip6gre0, veth-\u003eeth0  plugin=cilium\nINFO[0014] httpbin returned: {\"origin\":\"69.203.154.19\"}  plugin=cilium\nlevel=debug msg=\"Processing CNI DEL request\" args=\"\u0026{2109 /proc/2109/ns/net eth0  /home/jessie/.go/src/github.com/jessfraz/cni-benchmarks/bin:/opt/cni/bin [123 34 99 110 105 86 101 114 115 105 111 110 34 58 34 34 44 34 109 116 117 34 58 49 52 53 48 44 34 110 97 109 101 34 58 34 99 105 108 105 117 109 34 44 34 116 121 112 101 34 58 34 99 105 108 105 117 109 45 99 110 105 34 125]}\"\nINFO[0003] creating new netns process                    plugin=flannel-bridge\nINFO[0004] netns process has PID 3535                    plugin=flannel-bridge\nINFO[0004] IP of the default interface (eth0) in the netns is 10.6.50.26  plugin=flannel-bridge\nINFO[0004] getting netns file descriptor from the pid 3535  plugin=flannel-bridge\nINFO[0004] [performing setns into netns from pid 3535    plugin=flannel-bridge\nINFO[0004] found netns ip links: device-\u003elo, ipip-\u003etunl0, ip6gre-\u003egre0, ip6gretap-\u003egretap0, erspan-\u003eerspan0, vti-\u003eip_vti0, vti6-\u003eip6_vti0, sit-\u003esit0, ip6tnl-\u003eip6tnl0, ip6gre-\u003eip6gre0, veth-\u003eeth0  plugin=flannel-bridge\nINFO[0004] httpbin returned: {\"origin\":\"69.203.154.19\"}  plugin=flannel-bridge\nINFO[0004] creating new netns process                    plugin=flannel-ipvlan\nINFO[0005] netns process has PID 3644                    plugin=flannel-ipvlan\nINFO[0005] IP of the default interface (eth0) in the netns is 10.6.50.95  plugin=flannel-ipvlan\nINFO[0005] getting netns file descriptor from the pid 3644  plugin=flannel-ipvlan\nINFO[0005] [performing setns into netns from pid 3644    plugin=flannel-ipvlan\nINFO[0005] found netns ip links: device-\u003elo, ipip-\u003etunl0, ip6gre-\u003egre0, ip6gretap-\u003egretap0, erspan-\u003eerspan0, vti-\u003eip_vti0, vti6-\u003eip6_vti0, sit-\u003esit0, ip6tnl-\u003eip6tnl0, ip6gre-\u003eip6gre0, ipvlan-\u003eeth0  plugin=flannel-ipvlan\nINFO[0005] httpbin returned: {\"origin\":\"69.203.154.19\"}  plugin=flannel-ipvlan\nINFO[0014] creating new netns process                    plugin=ipvlan\nINFO[0015] netns process has PID 2235                    plugin=ipvlan\nINFO[0015] IP of the default interface (eth0) in the netns is 10.1.2.163  plugin=ipvlan\nINFO[0015] getting netns file descriptor from the pid 2235  plugin=ipvlan\nINFO[0015] [performing setns into netns from pid 2235    plugin=ipvlan\nINFO[0015] found netns ip links: device-\u003elo, ipip-\u003etunl0, ip6gre-\u003egre0, ip6gretap-\u003egretap0, erspan-\u003eerspan0, vti-\u003eip_vti0, vti6-\u003eip6_vti0, sit-\u003esit0, ip6tnl-\u003eip6tnl0, ip6gre-\u003eip6gre0, ipvlan-\u003eeth0  plugin=ipvlan\nINFO[0015] httpbin returned: {\"origin\":\"69.203.154.19\"}  plugin=ipvlan\nINFO[0015] creating new netns process                    plugin=macvlan\nINFO[0016] netns process has PID 2287                    plugin=macvlan\nINFO[0016] IP of the default interface (eth0) in the netns is 20.0.0.101  plugin=macvlan\nINFO[0016] getting netns file descriptor from the pid 2287  plugin=macvlan\nINFO[0016] [performing setns into netns from pid 2287    plugin=macvlan\nINFO[0016] found netns ip links: device-\u003elo, ipip-\u003etunl0, ip6gre-\u003egre0, ip6gretap-\u003egretap0, erspan-\u003eerspan0, vti-\u003eip_vti0, vti6-\u003eip6_vti0, sit-\u003esit0, ip6tnl-\u003eip6tnl0, ip6gre-\u003eip6gre0, macvlan-\u003eeth0  plugin=macvlan\nINFO[0016] httpbin returned: {\"origin\":\"69.203.154.19\"}  plugin=macvlan\nINFO[0016] creating new netns process                    plugin=ptp\nINFO[0017] netns process has PID 2337                    plugin=ptp\nINFO[0017] IP of the default interface (eth0) in the netns is 10.1.1.89  plugin=ptp\nINFO[0017] getting netns file descriptor from the pid 2337  plugin=ptp\nINFO[0017] [performing setns into netns from pid 2337    plugin=ptp\nINFO[0017] found netns ip links: device-\u003elo, ipip-\u003etunl0, ip6gre-\u003egre0, ip6gretap-\u003egretap0, erspan-\u003eerspan0, vti-\u003eip_vti0, vti6-\u003eip6_vti0, sit-\u003esit0, ip6tnl-\u003eip6tnl0, ip6gre-\u003eip6gre0, veth-\u003eeth0  plugin=ptp\nINFO[0017] httpbin returned: {\"origin\":\"69.203.154.19\"}  plugin=ptp\nINFO[0017] creating new netns process                    plugin=weave\nINFO[0018] netns process has PID 2423                    plugin=weave\nINFO[0019] IP of the default interface (eth0) in the netns is 10.32.0.1  plugin=weave\nINFO[0019] getting netns file descriptor from the pid 2423  plugin=weave\nINFO[0019] [performing setns into netns from pid 2423    plugin=weave\nINFO[0019] found netns ip links: device-\u003elo, ipip-\u003etunl0, ip6gre-\u003egre0, ip6gretap-\u003egretap0, erspan-\u003eerspan0, vti-\u003eip_vti0, vti6-\u003eip6_vti0, sit-\u003esit0, ip6tnl-\u003eip6tnl0, ip6gre-\u003eip6gre0, veth-\u003eeth0  plugin=weave\nINFO[0019] httpbin returned: {\"origin\":\"69.203.154.19\"}  plugin=weave\n```\n\n## Using the Makefile to update the CNI binaries, etc\n\n```console\n$ make help\nall                            Runs a clean, build, fmt, lint, test, staticcheck, vet and install\nbenchmark                      Run all the benchmarks. Set BENCHTIME to change the benchtime.\nbuild                          Builds a dynamic executable or package\nbump-version                   Bump the version in the version file. Set BUMP to [ patch | major | minor ]\nclean                          Cleanup any build binaries or packages\ncover                          Runs go test with coverage\ncross                          Builds the cross-compiled binaries, creating a clean directory structure (eg. GOOS/GOARCH/binary)\nfmt                            Verifies all files have men `gofmt`ed\ninstall                        Installs the executable or package\nlint                           Verifies `golint` passes\nrelease                        Builds the cross-compiled binaries, naming them in such a way for release (eg. binary-GOOS-GOARCH)\nrun-calico                     Run calico in a container for testing calico against.\nrun-cilium                     Run cilium in a container for testing cilium against.\nrun-containers                 Runs the etcd, calico, cilium, flannel, and weave containers.\nrun-etcd                       Run etcd in a container for testing calico and cilium against.\nrun-flannel                    Run flannel in a container for testing flannel against.\nrun-weave                      Run weave in a container for testing weave against.\nstatic                         Builds a static executable\nstaticcheck                    Verifies `staticcheck` passes\nstop-containers                Stops all the running containers.\ntag                            Create a new git tag to prepare to build a release\ntest                           Runs the go tests\nupdate-binaries                Run the dev dockerfile which builds all the cni binaries for testing.\nvet                            Verifies `go vet` passes\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjessfraz%2Fcni-benchmarks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjessfraz%2Fcni-benchmarks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjessfraz%2Fcni-benchmarks/lists"}