Skip to content

Instantly share code, notes, and snippets.

@zeroFruit

zeroFruit/host.go

Created Oct 31, 2020
Embed
What would you like to do?
Modeling the Internet from the scratch: Link-layer, LAN, Switch - Code snippet: Network Topology
package link
type Link struct {
cost uint
ep1 EndPoint
ep2 EndPoint
}
func (l *Link) AttachEndpoint(ep EndPoint) error {
...
}
// Opposite returns other endpoint of given id. If other endpoint does not exist,
// then return error
func (l *Link) Opposite(id Id) (EndPoint, error) {
...
}
// EndPoint represents point of link. Link is the channel to pass data to end-point
// either side to the opposite
type EndPoint interface {
Id() Id
GetLink() *Link
AttachLink(link *Link) error
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.