socketsnetwork-programmingudpdpdk

Sending packets from Pktgen to UDP socket with specified destination port


Problem

I'm trying to send data packets from the traffic generator Pktgen to an UDP socket I have implemented so that it will forward the packets back to their source. The problem I have run into is that I cannot find any way of sending data packets from Pktgen to the UDP socket as there seems to be no way of specifying the destination port for packets using UDP protocol in Pktgen.

Setup

The UDP socket uses the IP address 192.168.1.100 with port 8080. I verified that it is open for receiving packets and forwarding through using nc -vz -u 192.168.1.100 8080. It is using IPv4 which is also what I'm using for Pktgen.

Pktgen is running on 03:00.0 and is of version 22.07.2. setup

UDP socket is setup on this interface:

udpinterface

What I have tired

I have looked through the Pktgen documentation for commands to set the destination port but can only find support for setting the destination IP address without the port number (set <portlist> src|dst ip ipaddr). Destination port is mentioned a few times in the documentation, but none of the commands seem to work while others are TCP specific. Here are a few that I have tried:

rate <portlist> dport <value>        - Destination port number for TCP
rate 0 dport 8080 - Tried this just in case it worked UDP as well, but unfortunately it didn't

set <portlist> [src|dst] ip ipaddr - Set IP addresses, Source must include network mask e.g. 10.1.2.3/24
set 0 dst ip 192.168.1.100:8000 - Invalid syntax
set 0 dst ip 192.168.1.100 8000 - Invalid syntax
set 0 dst ip 192.168.1.100/8000 - Invalid syntax

It didn't work either to only set the IP address through set 0 dst ip 192.168.1.100 and start sending packets from Pktgen as the packets never reach the socket then.

Setting the range didn't work either.

range <portlist> src|dst port <SMMI> <value>  - Set UDP/TCP source/dest port number
range 0 dst port start 8080 
range 0 dst port min 8079
range 0 dst port max 8081
range 0 dst port inc 1

Previously I have run Pktgen and TestPMD together which worked fine, but in that case I could simply use TestPMD´s MAC address (set <portlist> dst mac <addr>) to help the packets find their way.

Update

I have tried to use try set <portlist> dport NNN and/or set <portlist> sport NNN. More specifically I have tried to use:

Here are the commands I ran in the exact order:

set 0 size 64
set 0 proto udp
set 0 rate 0.1
set 0 dst ip 192.168.1.100
set 0 dport 8080
start 0 
//Nothing happens
stop 0
set 0 sport 8080
start 0
//Nothing happens

Here is how it looked in the end:

image

If don't see any packets (via wireshark or tcpdump) so they are probably being dropped someplace. But without wireshark or tcpdump it is hard to check where the packets are going.

I have heard that some hardware will not accept the destination MAC 00:00:00:00:00:00 as it was a broadcast address years ago. I tried changing the mac destination but it didn't seem to make any difference.

I have two PFs on the NIC, I have Pktgen (03:0a.0) on a VF which was unbound from kernel to the driver vfio-pci using dpdk-devbind.py and the socket is on another VF (enp3s0f1v1) and both connect to the same PF.

image

Could it be some issues with sending packets between VFs? But I don't see why that would be an issue.

Update number 2

I got the UPD socket to receive the packets from Pktgen, through enabling promiscuous mode on the network interface where the socket was located and changing the MAC address so something else then just 0s.

The issue I am having now is that the UDP socket is not forwarding packets back to Pktgen. When using tcpdump it only sees the packets sent by Pktgen to the UDP socket and does not show that the UDP socket is sending anything back to Pktgen.

I have tested the UDP socket through other network interface to make sure that it is responding correctly and in that case I can see via tcpdump that the UDP socket both receives and sends back the packet.

So, could the issue have something to do with Pktgen being bound to a DPDK-compatible driver? Or that it is not using promiscuous mode even though I specified it in the run command with the -P flag.

Questions

Would greatly appreciate some input on why it is not working and how to fix it.


Solution

  • There are several possible reasons why the socket might not be forwarding packets back to Pktgen.

    The most likely one is that you have not set the IP route correctly. Try ip route add 192.168.0.0/24 dev <network interface>. This should add a route for the IP address range 192.168.0.0 - 192.168.0.254 and specifies that any traffic to this IP address range should be sent through the given network interface.