seqs
1.0.0
seqs
就是通常所說的用戶空間 IP 實作。它處理:
stacks/tcpconn.go
httpx
包 // stack works by having access to Ethernet packet sending
// and processing. NIC is our physical link to the internet.
var NIC NetworkInterfaceCard = getNIC ()
stack := stacks . NewPortStack (stacks. PortStackConfig {
MAC : MAC ,
MaxOpenPortsTCP : 1 ,
MaxOpenPortsUDP : 1 ,
MTU : 2048 ,
})
// stack.RecvEth should be called on receiving an ethernet packet. It should NOT block.
NIC . SetRecvEthHandle ( stack . RecvEth )
// Static IP setting.
ip := netip . AddrFrom4 ([ 4 ] byte { 192 , 168 , 1 , 45 })
stack . SetAddr ( ip )
// Or can request an address via DHCP.
dhcpClient := stacks . NewDHCPClient ( stack , dhcp . DefaultClientPort )
err = dhcpClient . BeginRequest (stacks. DHCPRequestConfig {
RequestedAddr : netip . AddrFrom4 ([ 4 ] byte { 192 , 168 , 1 , 69 }),
Xid : 0x12345678 ,
Hostname : "tinygo-pico" ,
})
if err != nil {
panic ( err )
}
fmt . Println ( "Start DHCP..." )
for ! dhcpClient . Done () {
doNICPoll ( NIC )
time . Sleep ( time . Second / 10 )
}
offeredIP := dhcpClient . Offer ()
fmt . Println ( "got offer:" , offeredIP )
stack . SetAddr ( offeredIP )
如何使用seqs
go mod download github.com/soypat/seqs@latest
在seqs
之前有:
ether-swtch
- 大約 2021 年 6 月,在嵌入式系統上工作的 Go 中(勉強)工作的 TCP/IP 堆疊的第一個已知實例。眾所周知的糟糕的設計、程式碼、效能、可讀性。dgrams
- 為 Pico W 的 wifi 晶片準備的庫。已經顯示出與seqs
的相似之處。約 2023 年 5 月。