{"id":15776619,"url":"https://github.com/jbemmel/srl-auto-router-id","last_synced_at":"2026-03-18T03:58:23.490Z","repository":{"id":78268973,"uuid":"393236140","full_name":"jbemmel/srl-auto-router-id","owner":"jbemmel","description":"Agent to auto-assign router IDs using a distributed spanning tree protocol over LLDP","archived":false,"fork":false,"pushed_at":"2021-08-07T23:47:23.000Z","size":12,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-21T04:47:17.411Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jbemmel.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":"2021-08-06T03:26:54.000Z","updated_at":"2022-11-07T14:26:08.000Z","dependencies_parsed_at":"2023-03-12T03:58:27.865Z","dependency_job_id":null,"html_url":"https://github.com/jbemmel/srl-auto-router-id","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jbemmel/srl-auto-router-id","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbemmel%2Fsrl-auto-router-id","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbemmel%2Fsrl-auto-router-id/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbemmel%2Fsrl-auto-router-id/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbemmel%2Fsrl-auto-router-id/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jbemmel","download_url":"https://codeload.github.com/jbemmel/srl-auto-router-id/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbemmel%2Fsrl-auto-router-id/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30646441,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-18T02:48:56.676Z","status":"ssl_error","status_checked_at":"2026-03-18T02:48:55.747Z","response_time":104,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2024-10-04T17:22:50.447Z","updated_at":"2026-03-18T03:58:23.475Z","avatar_url":"https://github.com/jbemmel.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# srl-auto-router-id\nAgent to auto-assign router IDs using a distributed spanning tree algorithm over LLDP\n\n[Back in 1983](https://wayback.archive-it.org/all/20161012010517/http://courses.csail.mit.edu/6.852/05/papers/p66-gallager.pdf) Gallager et al. from MIT wrote a paper about a distributed algorithm for determining a Minimum Spanning Tree in a network. This agent represents a modern Python based implementation, using LLDP (changing hostnames) to communicate messages between nodes.\n\nEach node starts in SLEEPING, transitioning to FOUND when the agent starts. It then proceeds to FIND by initiating MST discovery.\n\nThere are 7 types of messages:\n1. Connect(Level, starts at 0)\n2. Initiate(Level,Fragment Identity,State(FIND or FOUND)) - can sometimes be multicast to multiple neighbors\n3. Test(Level,Fragment Identity)\n4. Report(best edge weight)\n5. Accept\n6. Reject\n7. Change-root\n\nGiven the nature of LLDP, there may be a need for a confirmation protocol to avoid changing the hostname too quickly. Also, LLDP events may get duplicated, so filtering needs to be in place\n\n## Pending messages at end-of-queue\nThe algorithm has 3 situations in which messages \"are placed at the end of the queue\":\n1. Receive Connect with L\u003e=LN, on a port in BASIC state\n2. Receive Test with L\u003eLN\n3. Receive Report on in-branch port while in FIND state\n\nThese conditions can get cleared upon receipt of Initiate or Report, and basically form substates of FIND (FIND with pending Connect on port X, etc.)\n\n## Edge weights\nIn this implementation, e1-1 has the lowest weight, then e1-2, etc. System MAC address serves as a tie breaker; the lower MAC ID wins.\n\n## Allocating router IDs\nOnce the MST is determined, there is a root node (node connected to root edge with lowest port and/or system MAC). This root node gets ID 0 ( out of a configured range, say 1.1.0.0/22 then root=1.1.0.0/32 ). Subsequent levels get IDs according to the root port they are connected to: e1-1 = 1, e1-2 = 2, etc.\nNote that in a spine-leaf CLOS this could lead to a situation where 2 \"Spines\" have IDs from different levels (spine1=level 0=root, spine2=level 2) - there could be a configuration parameter to collapse disjoint layers for the purpose of ID assignment. Similarly, it is possible for a leaf node to become root ( e.g. leaf1 connected to spine1-4 on e1-1..e1-4 )\n\nEach level advertises the number of nodes at the next level, such that IDs can be assigned sequentially. Between levels, router IDs must vary by more than the last bit; so if the root gets 1.1.1.0, 1.1.1.1 is skipped and 1.1.1.2 is allocated next. Alternatively, the root can be 1.1.0.1, then 1.1.1.1..x, next level 1.1.2.1..y, and so on.\n\nNote that a traditional spine-leaf topology may appear as a 3-level tree, with a spine at the root and other spines at root+2 (assuming a spine node wins the election).\nThe algorithm may need to be adjusted such that spines come out on top\n\n## Allocating AS numbers\nLike the router IDs, unique AS numbers must be allocated to leaves (last level in the tree), while further up the tree each level gets its own AS. As a slight variation, a spine layer (which appears as root node + 1 or more level 2 nodes) should be allocated the same AS.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjbemmel%2Fsrl-auto-router-id","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjbemmel%2Fsrl-auto-router-id","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjbemmel%2Fsrl-auto-router-id/lists"}