Created
October 31, 2020 12:19
-
-
Save zeroFruit/7ef06d758c9a7ade529bde047dfb02ec to your computer and use it in GitHub Desktop.
Modeling the Internet from the scratch: Link-layer, LAN, Switch - Code snippet: Network Topology
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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