Skip to content

Instantly share code, notes, and snippets.

@zeroFruit
Last active October 31, 2020 12:22
Show Gist options
  • Save zeroFruit/00335ac80791a246283a9294c5d189db to your computer and use it in GitHub Desktop.
Save zeroFruit/00335ac80791a246283a9294c5d189db to your computer and use it in GitHub Desktop.
Modeling the Internet from the scratch: Link-layer, LAN, Switch - Code snippet: Host, Interface
package link
type Transmitter interface {
Transmit(frame []byte) error
}
type Interface interface {
Transmitter
EndPoint
Address() types.HwAddr
}
// NetHandler receives serialized frame payload. With this, doing some high-level protocol
type NetHandler interface {
Handle(pl []byte)
}
type Host struct {
Interface Interface
netHandler NetHandler
frmEnc *FrameEncoder
frmDec *FrameDecoder
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment