I want to have any Traffic generator(say iperf,D-ITG or even ping) to send data to a tun interface. This tun interface should automatically forward to NIC which is binded to DPDK. I want to run l3fwd example which picks up data from the interface.
I used the option --vdev=net_tun0 in commandline which creates tun interface. I thought tun/tap PMD will automatically poll the packets at tun/tap interface and redirect to/from NIC. But, that's not happening. I am not able to receive any packets.
I require dpdk and traffic generator to run on the same PC. DPDK should pick the traffic at the userspace.
Since the question is not that clear (whether it is DPDK RX-TX or Kernel RX-TX), here are the answers for DPDK application point of view
DPDK TUN PMD allows creating Kernel TUN interface with ip layer
onwards (there is no MAC Layer). just like all PMD devices, you have
to poll with rte_eth_rx_burst and use rte_eth_tx_burst inside
DPDK Application.
Similarly, if you plan to use TAP PMD, dpdk will create Kernel TAP
the interface which has to be polled with rte_eth_rx_burst and
rte_eth_tx_burst inside DPDK application.
Once you use vdev=net_tap0 this creates Kernel tap interface dtap0. So to grab packets received to Kernel interface you have call rte_eth_rx_burst to send a specific packet to Kernel TAP interface you need to use rte_eth_tx_burst.
as per your requirement which is to direct any traffic generator to kernel to TAP interface, then send to physical NIC bound with DPDK, this what you have to do
make use a simple application like examples/skeleton or testpmd or examples/l2fwd with no mac update`
ensure you pass the vdev=net_tap0,iface=<your desired name for interface> to the DPDK application.
Using ip or ifconfig bring up the interface with ip address and the state as up (Promisc mode is optional).
ensure your destination address route is through tap interface by cross-checking route -n.
now kick start your traffic generator with dest-ip and interface as required.
Note: In my deployment case, I ended up setting static ARP too.
This will send the packet to kernel TAP interface, which is then intercepted by DPDK application via rx_burst calls. Using port to port forward behaviour this is then forwarded to DPDK Physical NIC. In reverse direction, the packet received from physical nic is bought into the application by rx_burst and then tx_burst to TAP PMD. this will then inject to the kernel TAP interface.
I am trying to build an application that will send 802.11 management frames and data frames together from the userspace using raw sockets. I am being able to send data frames using the the sendto() function, but I need to send management frames as well, where I am mostly stuck. Is there any possible way of doing it?
In order to send management, data or any type of pure raw packet from a wireless interface you have to do the following:
Make sure the wireless interface hardware supports packet injection in monitor mode.
Set the wireless interface in monitor mode. e.g.
sudo ifconfig wlan0 down
sudo iwconfig wlan0 mode monitor
Or you can also create a new virtual monitor interface.
sudo iw dev wlan0 interface add mon0 type monitor
Now open a raw socket to this monitor mode interface.
Finally, Build and append at the beginning, the appropriate radiotap header while building your wireless 802.11 packet for management and control frames. Since you are basically bypassing all lower lever wireless drivers (which handles management and control frames), it becomes your job to include the radiotap header.
"INADDR_ANY binds the socket to all available interfaces."
This is the statement i Encountered.I found it here
What is interface here? Is it a port number or something else?
And another question is
Is interface and channel or one and same?
Usually your host (your computer) has more than one interfaces. For example, (older) computer without network would have only IPv4 loopback interface.
If you add and configure IPv4 network to that PC, you'll get another interface: eth0, or net0 or something similar.
When you install VPN, it will create you yet another interface, as instead of sending packets into unsecured network, you send it into logical VPN interface, and that one forwards data to eth0 after some processing.
Every time, when you add a hardware link (with driver) to a network, or create logical network, it creates you a new interface. For example, if you use VMVare, and create virtual machine, the system would provider you some set of interfaces needed to route data between your host, network, and virtual machine.
When routing IPv4, every interface is assigned IPv4 address. Even loopback (127.0.0.1). The address can be static, or obtained from server when your system boots.
So you can listen only on one interface. For example, if you bind to loopback, you will not be able to access any network, and network hosts will not be able to access your socket (assuming routing is not broken). But you connect multiple processes on your host to each other.
If you bind to particular network interface, it means you want to work with systems, that are connected to that network (directly or indirectly).
If you bind to any, for server sockets it means you let system to accept connections from anywhere, considering that anywhere can ping you.
As per my understanding the socket interface is something like this
Gives a file system like abstraction to the capabilities of the
network.
Each transport protocol offers a set of services. The socket API
provides the abstraction to access these services
The API defines function calls to create, close, read and write
to/from a socket.
Also something like this also
A network interface is the point of interconnection between a computer and a private or public network. A network interface is generally a network interface card (NIC), but does not have to have a physical form. Instead, the network interface can be implemented in software.
For example, the loopback interface (127.0.0.1 for IPv4 and ::1 for IPv6) is not a physical device but a piece of software simulating a network interface. The loopback interface is commonly used in test environments
Examples for interfaces:
your LAN card where you can plug a network cable,
a wifi adapter,
a (software-only) thing which provides an imaginary network between your main system and a virtual machine
the (software-only) loopback adapter which sends everything you send to it "back" to your own computer
etc. If you´re writing a socket server, you can choose
where the client connections may come from.
Only from a virtual machine, but no real computer outside?
Only wifi, but no cable-bound LAN? Or just all together?
I have a situation where I create a tap interface on linux using C program. I can configure an ipv6 address on this interface as well using the ioctl command SIOCSIFADDR. and it gets set correctly.
But wat i want is to configure only Link-Local address (thats wat i set by above SIOCSIFADDR). and then Let the kernel do the global address allocation through SLAAC procedure. but I only succeed in setting the Link-local address. If I do a service network restart I can see the eth0 interface going UP and i can see the Router Solicitation requests too. but nothing for the interface that i bring up through programming.
Is it possible to create an interface and let kernel manage its ipv6 interfaces itself.
I am trying to listen for a specific discovery packet that will be sent over UDP destined for a known MAC address. This MAC address will not be the same as the MAC address of the interface I am receiving on.
I have tried Beej's UDP listener but it only receives packets with the correct MAC.
When I listen with tcpdump I can see the packets are making it to the device.
It looks like I could receive on a raw socket (although haven't got that working yet) but would there be a way to filter only the destination MAC I want?
Can anyone give me any guidance with this?
Your interface does not normally receive packets that are not sent to its own address. It just ignores them.
You need to set your network interface in promiscuous mode and use a packet capture interface provided by Linux.
Have a look at libpcap, the manual page is here.
This is the same mechanism that tcpdump uses. It is a library which provides an interface and a filter to the packet capture mechanism in the kernel.