Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/0x9ef/ethernet
Implementation of Ethernet 802.3, VLAN, 802.1P, 802.11 (Wireless Ethernet) frame serialization/deserialization library written in Go
https://github.com/0x9ef/ethernet
encoding ethernet frame golang network serialization wireless
Last synced: about 2 months ago
JSON representation
Implementation of Ethernet 802.3, VLAN, 802.1P, 802.11 (Wireless Ethernet) frame serialization/deserialization library written in Go
- Host: GitHub
- URL: https://github.com/0x9ef/ethernet
- Owner: 0x9ef
- License: mit
- Created: 2022-02-05T11:15:51.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2024-03-14T22:28:47.000Z (10 months ago)
- Last Synced: 2024-06-20T09:19:23.636Z (7 months ago)
- Topics: encoding, ethernet, frame, golang, network, serialization, wireless
- Language: Go
- Homepage:
- Size: 57.6 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Ethernet Frame Serializarion/Deserazization library written in Go
The library implements frame serialization/deserialization in pure Go. The list of the supported Ethernet standards:
* [802.3](https://en.wikipedia.org/wiki/Ethernet)
* [802.1Q](https://en.wikipedia.org/wiki/IEEE_802.1Q)
* [802.1P](https://en.wikipedia.org/wiki/IEEE_P802.1p)
* [802.11/Wireless](https://en.wikipedia.org/wiki/IEEE_802.11)## Usage Examples
See the `*_test.go` files.## How to Encode?
```go
dstAddr := ethernet.NewHardwareAddr(0x8C, 0x8E, 0xC4, 0xFF, 0x9E, 0xA2)
srcAddr := ethernet.NewHardwareAddr(0x8C, 0x8E, 0xC4, 0xAA, 0x4E, 0xF1)
f := ethernet.NewFrame(srcAddr, dst, []byte("Hello :)"))
f.SetTag8021q(ðernet.Tag8021q{Tpid: 0x8100, Tci: ethernet.Encode8021qTci(3, 0, 1024)})
b := f.Marshal()
```
## How to Decode?
```go
b := f.Marshal()var f Frame
err := ethernet.Unmarshal(b, &f)
if err != nil {
panic(err)
}pcp, dei, vlan := ethernet.Decode8021qTci(f.Tag8021q().Tci)
fmt.Println("PCP:", pcp)
fmt.Println("DEI:", dei)
fmt.Println("VLAN ID:", vlan)
fmt.Println("EtherType:", f.EtherType())
fmt.Println("Checksum (FCS):", f.FCS())
```## License
[MIT](./LICENSE)