Documentation ¶
Overview ¶
Package bwallocation implements the control plane parts of the bandwidth allocation system for star-topologies.
At the core is the Manager. It manages bandwidth reservation subscriptions that can be used to send traffic with reserved bandwidth. Client applications that want to use bandwidth reservations to send traffic initialize the Manager and subscribe for a subscription with a set of parameters. The manager takes care of establishing and renewing the reservation for all of its entire lifetime.
Subscriptions simply return the latest reservation token that the client application should use for its communication. After the client is done using the reservation, it should close the subscription to abort unnecessary renewal. This is especially important for subscriptions with unbounded expiration time.
To use the reservation for sending traffic, simply use the Conn wrapper and pass the subscription to it.
Example ¶
package main import ( "context" "net" "time" "github.com/anapaya/bwallocation" "github.com/scionproto/scion/go/lib/snet" "github.com/scionproto/scion/go/lib/spath" "github.com/scionproto/scion/go/pkg/grpc" ) func main() { var ( // conn is the underlying connection that is used to send traffic. conn *snet.Conn // deamonAddr is the TCP address where the SCION daemon is exposed. daemonAddr net.Addr // bandwidth is the bandwidth that should be reserved. bandwidth bwallocation.Bandwidth // expiration is the time until the Manager shall renew the reservation. expiration time.Time // remote is the address of the remote application. remote *snet.UDPAddr // local is the address of this application. local *snet.UDPAddr // path is the raw path that is used for creating the reservation. path *spath.Path ) // Initialize the manager with the local SCION daemon as the service. The // SCION daemon proxies the requests to the correct control service // instance. manager := bwallocation.Manager{ Service: daemonAddr, Dialer: grpc.SimpleDialer{}, } // Create a subscription to get the reservation token. sub, err := manager.Subscribe(context.Background(), bwallocation.SubscriptionInfo{ Bandwidth: bandwidth, Destination: remote, Source: local, Expiration: expiration, Path: path, }) if err != nil { // Handle error. } // Close the subscription as soon as it is no longer needed. defer sub.Close() // Wrap the conn such that it uses the reservation token. rsvConn := &bwallocation.Conn{ Conn: conn, Subscription: sub, } rsvConn.Write([]byte("hello with reserved bandwidth")) }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bandwidth ¶
type Bandwidth uint64
Bandwidth is the bandwidth in bps
func (Bandwidth) MarshalText ¶
func (*Bandwidth) UnmarshalText ¶
type Conn ¶
type Conn struct { *snet.Conn Subscription *Subscription }
Conn is a wrapper for a snet.Conn that injects the reservation token fetched from the configured subscription.
type Link ¶
Link represents a link from a leaf AS to the provider.
func (Link) MarshalText ¶
func (*Link) UnmarshalText ¶
type Manager ¶
type Manager struct { // Service is the address that exposes the bandwidth allocation service. // Usually, this should be the SCION daemon address. Service net.Addr // Dialer is the gRPC dialer that is used to connect to the service. Dialer grpc.Dialer // Logger is used for logging. If nil, nothing is logged. Logger log.Logger // FetchInterval indicates the minimum interval between successive // reservation renewal. If zero, the default interval is used. FetchInterval time.Duration // FetchLeadTime indicates the minimum remaining token validity before the // reservation is renewed. If zero, default lead time is used. FetchLeadTime time.Duration // MaxExpiry indicates the maximum reservation validity period that is // requested. If zero, the default max expiry is used. MaxExpiry time.Duration }
Manager manages bandwidth reservation subscriptions that can be used to to send traffic with reserved bandwidth.
func (*Manager) Subscribe ¶
func (m *Manager) Subscribe(ctx context.Context, info SubscriptionInfo) (*Subscription, error)
Subscribe subscribes for a bandwidth reservation. The subscription automatically renews the reservation token and must be closed after it is no longer required.
type Subscription ¶
type Subscription struct {
// contains filtered or unexported fields
}
Subscription is a bandwidth reservation subscription that is periodically updated with a token.
func (*Subscription) Close ¶
func (s *Subscription) Close()
Close closes the subscription. It must be called after the subscription is no longer required.
func (*Subscription) Token ¶
func (s *Subscription) Token() (Token, error)
Token returns the currently active token. The contents must not be modified.
type SubscriptionInfo ¶
type SubscriptionInfo struct { // Source is the local address of the connection bandwidth should be // reserved on. Source *snet.UDPAddr // Destination is the remote address of the connection bandwidth should be // reserved on. Destination *snet.UDPAddr // Path is the original SCION path on which a bandwidth reservation should // be established. Path *spath.Path // Bandwidth is the bandwidth the reservation should have. It must be a // multiple of 1mbps, i.e., divisible by 1e6. Bandwidth Bandwidth // Expiration is the desired expiration time. For the zero value, the // Manager continuously renews the reservation. In case the bandwidth // allocation service is not willing to handout a reservation until expiry. // The manager continuously renews reservations until the expiration time is // reached. Expiration time.Time }
SubscriptionInfo is the information for a bandwidth reservation subscription.
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
bwreserver/client/view
Package view contains the frontend for the client application.
|
Package view contains the frontend for the client application. |
bwreserver/telemetry
Package telemetry adds a simple timeseries implementation for flexible computation of rates based on an append-only log of cumulative values.
|
Package telemetry adds a simple timeseries implementation for flexible computation of rates based on an append-only log of cumulative values. |
proto
|
|
bw_allocation/v1/mock_bw_allocation
Package mock_v1 is a generated GoMock package.
|
Package mock_v1 is a generated GoMock package. |
Package reservation defines the dataplane representation of the bandwidth reservation token in the bandwidth allocation system for star topologies.
|
Package reservation defines the dataplane representation of the bandwidth reservation token in the bandwidth allocation system for star topologies. |