Documentation ¶
Overview ¶
pkg/pktgen/af_inet.go
pkg/pktgen/af_inet.go
pkg/pktgen/af_packet.go
pkg/pktgen/af_packet.go
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildPacket ¶
func BuildPacket(c *PacketConfig) ([]byte, error)
BuildPacket constructs the packet based on the PacketConfig. It automatically includes the Ethernet layer if both SrcMAC and DstMAC are provided.
func GetCurrentTXQueues ¶
GetCurrentTXQueues returns the number of TX queues for the specified interface
Types ¶
type AFInetSyscallSender ¶
type AFInetSyscallSender struct {
// contains filtered or unexported fields
}
AFInetSyscallSender is a Sender that uses the syscall package to send packets
func NewAFInetSyscallSender ¶
func NewAFInetSyscallSender(dstIP net.IP, dstPort, payloadSize int) *AFInetSyscallSender
NewAFInetSyscallSender creates a new AFInetSyscallSender
type AFPacketSender ¶
type AFPacketSender struct {
// contains filtered or unexported fields
}
AFPacketSender implements the Sender interface using AF_PACKET
func NewAFPacketSender ¶
func NewAFPacketSender(iface string, srcIP, dstIP net.IP, srcPort, dstPort, payloadSize int, srcMAC, dstMAC net.HardwareAddr) *AFPacketSender
NewAFPacketSender creates a new AFPacketSender with specified parameters
type AFPcapSender ¶
type AFPcapSender struct {
// contains filtered or unexported fields
}
AFPcapSender implements the Sender
func NewAFPcapSender ¶
func NewAFPcapSender(iface string, srcIP, dstIP net.IP, srcPort, dstPort, payloadSize int, srcMAC, dstMAC net.HardwareAddr) *AFPcapSender
NewAFPcapSender creates a new NewAFPcapSender with specified parameters
type AFXdpSender ¶
type AFXdpSender struct {
// contains filtered or unexported fields
}
AFXdpSender implements the Sender interface using AF_XDP
func NewAFXdpSender ¶
func NewAFXdpSender(iface string, srcIP, dstIP net.IP, srcPort, dstPort, payloadSize int, srcMAC, dstMAC net.HardwareAddr, queueID int) *AFXdpSender
NewAFXdpSender creates a new AFXdpSender with specified parameters
type BatchConnSender ¶
type BatchConnSender struct {
// contains filtered or unexported fields
}
func NewBatchConnSender ¶
func NewBatchConnSender(dstIP net.IP, dstPort, payloadSize int) *BatchConnSender
type NetConnSender ¶
type NetConnSender struct {
// contains filtered or unexported fields
}
AFInetSender is a Sender that uses the net package to send packets
func NewNetConnSender ¶
func NewNetConnSender(dstIP net.IP, dstPort, payloadSize int) *NetConnSender
NewAFInetSender creates a new AFInetSender
type PacketConfig ¶
type PacketConfig struct {
SrcIP, DstIP net.IP
SrcPort, DstPort layers.UDPPort
SrcMAC, DstMAC net.HardwareAddr
PayloadSize int
}
PacketConfig stores configuration for building a packet.
func NewPacketConfig ¶
func NewPacketConfig(opts ...PacketOption) (*PacketConfig, error)
NewPacketConfig creates a new PacketConfig with specified options.
type PacketOption ¶
type PacketOption func(*PacketConfig) error
PacketOption is a function that applies a configuration to a PacketConfig.
func WithEthernetLayer ¶
func WithEthernetLayer(srcMAC, dstMAC net.HardwareAddr) PacketOption
WithEthernetLayer enables the Ethernet layer in the packet.
func WithIpLayer ¶
func WithIpLayer(srcIp, dstIp net.IP) PacketOption
WithIpLayer enables the IP layer in the packet.
func WithPayloadSize ¶
func WithPayloadSize(size int) PacketOption
WithPayloadSize sets the payload size for the packet.
func WithUdpLayer ¶
func WithUdpLayer(srcPort, dstPort int) PacketOption
WithUdpLayer enables the UDP layer in the packet.
type RawSocketSender ¶
type RawSocketSender struct {
// contains filtered or unexported fields
}
RawSocketSender implements the Sender interface using raw sockets
func NewRawSocketSender ¶
func NewRawSocketSender(srcIP, dstIP net.IP, srcPort, dstPort, payloadSize int) *RawSocketSender
NewRawSocketSender creates a new RawSocketSender with specified parameters