Skip to content

Instantly share code, notes, and snippets.

@zeroFruit

zeroFruit/network.go

Created Oct 31, 2020
Embed
What would you like to do?
Modeling the Internet from the scratch: Link-layer, LAN, Switch - Code snippet: Build network-3
func Build() (host1 *link.Host, host2 *link.Host, host3 *link.Host,
swch1 *link.Switch, swch2 *link.Switch) {
// setup node
// setup interface
...
// setup link
link1 := link.NewLink(1)
attachLink(intf1, link1)
attachLink(sp11, link1)
link2 := link.NewLink(1)
attachLink(intf2, link2)
attachLink(sp12, link2)
link3 := link.NewLink(1)
attachLink(sp13, link3)
attachLink(sp21, link3)
link4 := link.NewLink(1)
attachLink(sp22, link4)
attachLink(intf3, link4)
return
}
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.