All Projects → jwhited → Corebgp

jwhited / Corebgp

Licence: apache-2.0
CoreBGP is a BGP library written in Go that implements the BGP FSM with an event-driven, pluggable model.

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Corebgp

hybridnet
A CNI plugin, provides networking environment where overlay and underlay containers can run on the same node and have cluster-wide bidirectional network connectivity.
Stars: ✭ 188 (+51.61%)
Mutual labels:  bgp, sdn
Kathara
A lightweight container-based network emulation system.
Stars: ✭ 139 (+12.1%)
Mutual labels:  bgp, sdn
pathman-sr
Pathman SR is an open-source app to compute paths and deploy routes in Segment Routing-enabled network.
Stars: ✭ 79 (-36.29%)
Mutual labels:  bgp, sdn
Yabgp
Yet Another BGP Python Implementation
Stars: ✭ 177 (+42.74%)
Mutual labels:  bgp, sdn
Ryu-SDN-IP
SDN-IP project implemented by Ryu SDN framework.
Stars: ✭ 33 (-73.39%)
Mutual labels:  bgp, sdn
pilot
Simple web-based SDN controller for family and friends
Stars: ✭ 33 (-73.39%)
Mutual labels:  bgp, sdn
Xdp
Package xdp allows one to use XDP sockets from the Go programming language.
Stars: ✭ 36 (-70.97%)
Mutual labels:  network-programming, sdn
Pynms
A vendor-agnostic NMS for carrier-grade network simulation and automation
Stars: ✭ 73 (-41.13%)
Mutual labels:  network-programming
Good Articles By Sort
本仓库用来存放我看过的认为比较好的文章---根据分类排序
Stars: ✭ 93 (-25%)
Mutual labels:  sdn
Beehive Netctrl
Distributed SDN controller built on top of beehive.
Stars: ✭ 56 (-54.84%)
Mutual labels:  sdn
Delta
PROJECT DELTA: SDN SECURITY EVALUATION FRAMEWORK
Stars: ✭ 55 (-55.65%)
Mutual labels:  sdn
China Operator Ip
中国运营商IPv4/IPv6地址库-每日更新
Stars: ✭ 1,255 (+912.1%)
Mutual labels:  bgp
Divert
WinDivert: Windows Packet Divert
Stars: ✭ 1,318 (+962.9%)
Mutual labels:  network-programming
Blackhat Python3
Source code for the book "Black Hat Python" by Justin Seitz. The code has been fully converted to Python 3, reformatted to comply with PEP8 standards and refactored to eliminate dependency issues involving the implementation of deprecated libraries.
Stars: ✭ 1,125 (+807.26%)
Mutual labels:  network-programming
Fusis
Fusis Balancer is a dynamic and distributed TCP/UDP Load Balancer
Stars: ✭ 119 (-4.03%)
Mutual labels:  bgp
Gev
🚀Gev is a lightweight, fast non-blocking TCP network library based on Reactor mode. Support custom protocols to quickly and easily build high-performance servers.
Stars: ✭ 1,082 (+772.58%)
Mutual labels:  network-programming
Dtcraft
A High-performance Cluster Computing Engine
Stars: ✭ 122 (-1.61%)
Mutual labels:  network-programming
Terraform Provider Zerotier
Create, modify and destroy ZeroTier networks and members through Terraform.
Stars: ✭ 113 (-8.87%)
Mutual labels:  sdn
Tabi
BGP Hijack Detection
Stars: ✭ 90 (-27.42%)
Mutual labels:  bgp
Proxifier For Linux
Simple C code with iptables make this tool proxifier which tunnels whole system traffic through the proxy server, without configuring individual application
Stars: ✭ 89 (-28.23%)
Mutual labels:  network-programming

CoreBGP

GoDev

CoreBGP is a BGP library written in Go that implements the BGP FSM with an event-driven, pluggable model. It exposes an API that empowers the user to:

  • send and validate OPEN message capabilities
  • handle "important" state transitions
  • handle incoming UPDATE messages
  • send outgoing UPDATE messages

CoreBGP does not decode UPDATE messages (besides header validation), manage a routing table, or send its own UPDATE messages. These responsibilities are all passed down to the user. Therefore, the intended user is someone who wants that responsibility.

See this blog post for the background and reasoning behind the development of CoreBGP.

Plugin

The primary building block of CoreBGP is a Plugin, defined by the following interface:

// Plugin is a BGP peer plugin.
type Plugin interface {
	// GetCapabilities is fired when a peer's FSM is in the Connect state prior
	// to sending an Open message. The returned capabilities are included in the
	// Open message sent to the peer.
	GetCapabilities(peer PeerConfig) []Capability

	// OnOpenMessage is fired when an Open message is received from a peer
	// during the OpenSent state. Returning a non-nil Notification will cause it
	// to be sent to the peer and the FSM will transition to the Idle state.
	//
	// Per RFC5492 a BGP speaker should only send a Notification if a required
	// capability is missing; unknown or unsupported capabilities should be
	// ignored.
	OnOpenMessage(peer PeerConfig, routerID net.IP, capabilities []Capability) *Notification

	// OnEstablished is fired when a peer's FSM transitions to the Established
	// state. The returned UpdateMessageHandler will be fired when an Update
	// message is received from the peer.
	//
	// The provided writer can be used to send Update messages to the peer for
	// the lifetime of the FSM's current, established state. It should be
	// discarded once OnClose() fires.
	OnEstablished(peer PeerConfig, writer UpdateMessageWriter) UpdateMessageHandler

	// OnClose is fired when a peer's FSM transitions out of the Established
	// state.
	OnClose(peer PeerConfig)
}

Here's an example Plugin that logs when a peer enters/leaves an established state and when an UPDATE message is received:

type plugin struct{}

func (p *plugin) GetCapabilities(c corebgp.PeerConfig) []corebgp.Capability {
	caps := make([]corebgp.Capability, 0)
	return caps
}

func (p *plugin) OnOpenMessage(peer corebgp.PeerConfig, routerID net.IP, capabilities []corebgp.Capability) *corebgp.Notification {
	return nil
}

func (p *plugin) OnEstablished(peer corebgp.PeerConfig, writer corebgp.UpdateMessageWriter) corebgp.UpdateMessageHandler {
	log.Println("peer established")
	// send End-of-Rib
	writer.WriteUpdate([]byte{0, 0, 0, 0})
	return p.handleUpdate
}

func (p *plugin) OnClose(peer corebgp.PeerConfig) {
	log.Println("peer closed")
}

func (p *plugin) handleUpdate(peer corebgp.PeerConfig, u []byte) *corebgp.Notification {
	log.Printf("got update message of len: %d", len(u))
	return nil
}

Plugins are attached to peers when they are added to the Server, which manages their lifetime:

routerID := net.ParseIP("192.0.2.1")
srv, err := corebgp.NewServer(routerID)
if err != nil {
    log.Fatalf("error constructing server: %v", err)
}
p := &plugin{}
err = srv.AddPeer(corebgp.PeerConfig{
    LocalAddress:  routerID,
    RemoteAddress: net.ParseIP("198.51.100.10"),
    LocalAS:       65001,
    RemoteAS:      65010,
}, p)
if err != nil {
    log.Fatalf("error adding peer: %v", err)
}

For more examples check out the examples directory and pkg.go.dev for the complete API.

Versioning

CoreBGP follows semver as closely as it can. Seeing as we are still major version zero (0.y.z), the public API should not be considered stable. You are encouraged to pin CoreBGP's version with your dependency management solution of choice.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].