Skip to content

Instantly share code, notes, and snippets.

@zeroFruit
Created October 31, 2020 12:24
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/e11dbb5eb956a825049093d416969950 to your computer and use it in GitHub Desktop.
Save zeroFruit/e11dbb5eb956a825049093d416969950 to your computer and use it in GitHub Desktop.
Modeling the Internet from the scratch: Link-layer, LAN, Switch - Code snippet: Switch
type ForwardEntry struct {
// Incoming is port id attached to switch
Incoming Id
// Addr is destination node address
Addr types.HwAddr
// Time is timestamp when this entry is created
Time time.Time
}
type FrameForwardTable struct {
entries []ForwardEntry
}
type Switch struct {
PortList map[Id]Port
Table *FrameForwardTable
frmDec *FrameDecoder
frmEnc *FrameEncoder
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment