Skip to content

Instantly share code, notes, and snippets.

@zeroFruit
Created October 31, 2020 12:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeroFruit/6c3f0fc074bc90283699b6dc56908749 to your computer and use it in GitHub Desktop.
Save zeroFruit/6c3f0fc074bc90283699b6dc56908749 to your computer and use it in GitHub Desktop.
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