LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   How to connect two systems via virtual network devices like tap in linux. (https://www.linuxquestions.org/questions/linux-networking-3/how-to-connect-two-systems-via-virtual-network-devices-like-tap-in-linux-4175457620/)

Kalamram 04-10-2013 05:03 AM

How to connect two systems via virtual network devices like tap in linux.
 
Hi,

I have two systems host-A and host-B.
I want to communicate these two host systems via virtual ethernet devices like tap.

I have using to spilt a data strem to two using NIC bonding. Here, my two ethernet cards are eth0 and eth1.
After creating bond0, my two ethernet interfaces attached with bond0.
Now, I have a application stack called GNUradio installed in host-A.Same, GNURadio installed in host-B.

So, I created two tap interfaces in both host-A and host-B. _________
So, if suppose I send 10000 tcp packets from host-A to host-B, it should go through the __________
bond0 |-> eth0 -> tap0 ->| |
-> eth1 -> tap1 ->|GNU Radio | |_________|

So, in GNu radio, I am sending both the tap0 output to OFDM mod and send outside via wireless devices.

Same setup is in other end and it will receive and demodulate and receive on the two tap interfaces and using same NIC bonding mechanism I am combine the data strem at host-B.

In host-A I created a tap0 and tap1 interface and create a bridge interface br0 and br1 to connect with eth0 and eth1.

Here my requirement is whatever ethernet frame/packets comes it should go through eth0 -> tap0 -> Gnuradio OFDM1, same like eth1 -> tap1 -> Gnuradio OFDM2 pathg.

I tried with linux bridging with examle setup.

I created tap0 and attach with br0 which already have eth0 if attached. I try to send some tcp packets to remote host via this bridge, bridge have IP address and subnet mask. I removed IP address to both eth0 and tap0.
When I send packets to remote host, it goes through bridge , but tap0 not seen any packets.I checked via tcpdump.

Whether my approach right?. If mistake correct me.

How to stream data to gnuradio stack via eth0 -> tap0.

Thank you,
SJK

nini09 04-12-2013 02:48 PM

You can use the "tap" virtual ethernet driver which lets a userspace program pretend to be an ethernet interface. This is a standard kernel feature for some time now (it might not be enabled in your kernel though).

Kalamram 04-18-2013 01:09 PM

Hi nini,
thank you.
I tried the tunctl mechanism and created tap devices.
But, not able to send packets via tap.

Is it correct or any method available.

Can I bond two ethernet inetrfaces and forward each interface packets to tap devices.
This I tried, but not able to forward ethernet packets to tap devices.

What is the problem with the setup.
please correct me.

thanks,
SJK

nini09 04-18-2013 02:24 PM

Tun/tap interfaces are software-only interfaces, meaning that they exist only in the kernel and, unlike regular network interfaces, they have no physical hardware component (and so there's no physical "wire" connected to them). You can think of a tun/tap interface as a regular network interface that, when the kernel decides that the moment has come to send data "on the wire", instead sends data to some userspace program that is attached to the interface (using a specific procedure, see below). When the program attaches to the tun/tap interface, it gets a special file descriptor, reading from which gives it the data that the interface is sending out. In a similar fashion, the program can write to this special descriptor, and the data (which must be properly formatted, as we'll see) will appear as input to the tun/tap interface. To the kernel, it would look like the tun/tap interface is receiving data "from the wire".
The difference between a tap interface and a tun interface is that a tap interface outputs (and must be given) full ethernet frames, while a tun interface outputs (and must be given) raw IP packets (and no ethernet headers are added by the kernel). Whether an interface functions like a tun interface or like a tap interface is specified with a flag when the interface is created.

nini09 04-19-2013 02:53 PM

Following link could help you to understand and learn.
http://backreference.org/2010/03/26/...face-tutorial/


All times are GMT -5. The time now is 02:58 AM.