Documentation ¶
Overview ¶
Package packetgen [allows sending customized tcp/udp traffic. Inspired by https://github.com/bilalcaliskan/syn-flood]
Index ¶
- Constants
- func BuildLinkLayer(c LayerConfig) (gopacket.LinkLayer, error)
- func BuildNetworkLayer(c LayerConfig) (gopacket.NetworkLayer, error)
- func BuildPayload(c LayerConfig) (gopacket.Layer, error)
- func BuildTransportLayer(c LayerConfig, network gopacket.NetworkLayer) (gopacket.TransportLayer, error)
- func OpenRawConnection(c ConnectionConfig) (*ipv6.PacketConn, error)
- func Serialize(payloadBuf gopacket.SerializeBuffer, layer gopacket.Layer) error
- func SerializeLayers(payloadBuf gopacket.SerializeBuffer, layers ...gopacket.Layer) error
- type ConnectionConfig
- type DNSPacketConfig
- type EthernetPacketConfig
- type ICMPV4PacketConfig
- type IPPacketConfig
- type LayerConfig
- type Packet
- type PacketConfig
- type TCPFlagsConfig
- type TCPPacketConfig
- type UDPPacketConfig
Constants ¶
View Source
const ( TCPHeaderSize = 25 // 20 for header + at least 5 for options UDPHeaderSize = 8 IPHeaderSize = 20 )
Common protocol header sizes to help with metrics
Variables ¶
This section is empty.
Functions ¶
func BuildLinkLayer ¶
func BuildLinkLayer(c LayerConfig) (gopacket.LinkLayer, error)
func BuildNetworkLayer ¶
func BuildNetworkLayer(c LayerConfig) (gopacket.NetworkLayer, error)
func BuildPayload ¶
func BuildPayload(c LayerConfig) (gopacket.Layer, error)
func BuildTransportLayer ¶
func BuildTransportLayer(c LayerConfig, network gopacket.NetworkLayer) (gopacket.TransportLayer, error)
func OpenRawConnection ¶
func OpenRawConnection(c ConnectionConfig) (*ipv6.PacketConn, error)
OpenRawConnection opens a raw ip network connection based on the provided config use ipv6 as it also supports ipv4
func SerializeLayers ¶
func SerializeLayers(payloadBuf gopacket.SerializeBuffer, layers ...gopacket.Layer) error
Types ¶
type ConnectionConfig ¶
ConnectionConfig describes which network to use when sending packets
type DNSPacketConfig ¶
type EthernetPacketConfig ¶
type EthernetPacketConfig struct { SrcMAC string `mapstructure:"src_mac"` DstMAC string `mapstructure:"dst_mac"` }
EthernetPacketConfig describes ethernet layer configuration
type ICMPV4PacketConfig ¶
type IPPacketConfig ¶
type IPPacketConfig struct { SrcIP string `mapstructure:"src_ip"` DstIP string `mapstructure:"dst_ip"` NextProtocol *int `mapstructure:"next"` }
IPPacketConfig describes ip layer configuration
type LayerConfig ¶
type Packet ¶
type Packet struct { Link gopacket.LinkLayer Network gopacket.NetworkLayer Transport gopacket.TransportLayer Payload gopacket.Layer }
type PacketConfig ¶
type PacketConfig struct { Link LayerConfig Network LayerConfig Transport LayerConfig Payload LayerConfig }
func (PacketConfig) Build ¶
func (c PacketConfig) Build() (result Packet, err error)
type TCPFlagsConfig ¶
type TCPFlagsConfig struct { SYN bool ACK bool FIN bool RST bool PSH bool URG bool ECE bool CWR bool NS bool }
TCPFlagsConfig stores flags to be set on tcp layer
type TCPPacketConfig ¶
type TCPPacketConfig struct { SrcPort int `mapstructure:"src_port,string"` DstPort int `mapstructure:"dst_port,string"` Seq uint32 Ack uint32 Window uint16 Urgent uint16 Flags TCPFlagsConfig }
TCPPacketConfig describes tcp layer configuration
type UDPPacketConfig ¶
type UDPPacketConfig struct { SrcPort int `mapstructure:"src_port,string"` DstPort int `mapstructure:"dst_port,string"` }
UDPPacketConfig describes udp layer configuration
Click to show internal directories.
Click to hide internal directories.