Implementation of Ethernet 2, 802.1Q, 802.1P, 802.11 (Wireless Ethernet) frame serialization/deserialization

Ethernet

Implementation of Ethernet 2, 802.1Q, 802.1P, 802.11 (Wireless Ethernet) frame serialization/deserialization

Example of marshaling and unmarshaling Ethernet 2 frames

func main() {
	dstAddr := ethernet.NewHardwareAddr(0x8C, 0x8E, 0xC4, 0xFF, 0x9E, 0xA2)
	srcAddr := ethernet.NewHardwareAddr(0x8C, 0x8E, 0xC4, 0xAA, 0x4E, 0xF1)
	f := ethernet.NewFrame(dstAddr, srcAddr, []byte("Hello :)"))
	f.SetTag8021q(&ethernet.Tag8021q{Tpid: 0x8100, Tci: ethernet.Encode8021qTci(3, 0, 1024)})
	b := f.Marshal()
	uf, err := ethernet.Unmarshal(b)
	if err != nil {
		panic(err)
	}

	fmt.Println("Source address:", uf.Source())
	fmt.Println("Destination address:", uf.Destination())
	fmt.Println("Payload:", string(uf.Payload()))

	pcp, dei, vlan := ethernet.Decode8021qTci(uf.Tag8021q().Tci)
	fmt.Println("PCP:", pcp)
	fmt.Println("DEI:", dei)
	fmt.Println("VLAN ID:", vlan)
	fmt.Println("EtherType:", uf.EtherType())
	fmt.Println("Checksum (FCS):", uf.FCS())
}

License

MIT

Similar Resources

An Etsy StatsD (https://github.com/etsy/statsd) implementation in Go

STATSD-GO Port of Etsy's statsd, written in Go. This was forked from https://github.com/amir/gographite to provide Ganglia submission support. USAGE U

Mar 5, 2021

Implementation of the FTPS protocol for Golang.

FTPS Implementation for Go Information This implementation does not implement the full FTP/FTPS specification. Only a small subset. I have not done a

Mar 14, 2022

🚥 Yet another pinger: A high-performance ICMP ping implementation build on top of BPF technology.

yap Yet-Another-Pinger: A high-performance ICMP ping implementation build on top of BPF technology. yap uses the gopacket library to receive and handl

Nov 9, 2022

Pure Go implementation of the WebRTC API

Pure Go implementation of the WebRTC API

Pure Go implementation of the WebRTC API

Jan 8, 2023

Fast RFC 5389 STUN implementation in go

STUN Package stun implements Session Traversal Utilities for NAT (STUN) [RFC5389] protocol and client with no external dependencies and zero allocatio

Jan 1, 2023

Go implementation of the traceroute tool

tracesite tracesite is a simple Go implementation of the traceroute tool Check out the blog post on explanation Install : Download binary from release

Dec 9, 2022

The Go language implementation of gRPC. HTTP/2 based RPC

gRPC-Go The Go implementation of gRPC: A high performance, open source, general RPC framework that puts mobile and HTTP/2 first. For more information

Jan 6, 2023

Golang implementation of Sliding Window Algorithm for distributed rate limiting.

Golang implementation of Sliding Window Algorithm for distributed rate limiting.

slidingwindow Golang implementation of Sliding Window Algorithm for distributed rate limiting. Installation $ go get -u github.com/RussellLuo/slidingw

Dec 27, 2022

IPFS implementation in Go

IPFS implementation in Go

go-ipfs What is IPFS? IPFS is a global, versioned, peer-to-peer filesystem. It combines good ideas from previous systems such as Git, BitTorrent, Kade

Jan 9, 2023
The Swiss Army knife for 802.11, BLE and Ethernet networks reconnaissance and MITM attacks.
The Swiss Army knife for 802.11, BLE and Ethernet networks reconnaissance and MITM attacks.

bettercap is a powerful, easily extensible and portable framework written in Go which aims to offer to security researchers, red teamers and reverse e

Jan 3, 2023
A Go package for sending and receiving ethernet frames. Currently supporting Linux, Freebsd, and OS X.

ether ether is a go package for sending and receiving ethernet frames. Currently supported platform: BPF based OS X FreeBSD AF_PACKET based Linux Docu

Sep 27, 2022
fbstatus graphically shows the gokrazy system status on the Linux frame buffer, which is typically available via HDMI when running on a Raspberry Pi or a PC.
fbstatus graphically shows the gokrazy system status on the Linux frame buffer, which is typically available via HDMI when running on a Raspberry Pi or a PC.

gokrazy framebuffer status (fbstatus) fbstatus graphically shows the gokrazy system status on the Linux frame buffer, which is typically available via

Aug 4, 2022
A go implementation of the STUN client (RFC 3489 and RFC 5389)

go-stun go-stun is a STUN (RFC 3489, 5389) client implementation in golang (a.k.a. UDP hole punching). RFC 3489: STUN - Simple Traversal of User Datag

Jan 5, 2023
A QUIC implementation in pure go
A QUIC implementation in pure go

A QUIC implementation in pure Go quic-go is an implementation of the QUIC protocol in Go. It implements the IETF QUIC draft-29 and draft-32. Version c

Jan 9, 2023
Fast RFC 5389 STUN implementation in go

STUN Package stun implements Session Traversal Utilities for NAT (STUN) [RFC5389] protocol and client with no external dependencies and zero allocatio

Nov 28, 2022
Pure Go implementation of the WebRTC API
Pure Go implementation of the WebRTC API

Pion WebRTC A pure Go implementation of the WebRTC API New Release Pion WebRTC v3.0.0 has been released! See the release notes to learn about new feat

Jan 1, 2023
A LWM2M Client and Server implementation (For Go/Golang)

Betwixt - A LWM2M Client and Server in Go Betwixt is a Lightweight M2M implementation written in Go OMA Lightweight M2M is a protocol from the Open Mo

Dec 23, 2022
A Socket.IO backend implementation written in Go

go-socket.io The socketio package is a simple abstraction layer for different web browser- supported transport mechanisms. It is fully compatible with

Sep 25, 2022
A Windows named pipe implementation written in pure Go.

npipe Package npipe provides a pure Go wrapper around Windows named pipes. Windows named pipe documentation: http://msdn.microsoft.com/en-us/library/w

Jan 1, 2023