Bridge between simulated network and real host - linux

I need to build a bridge (tap) between a simulated network (NS-3) and the real Linux host So when the "bridged" node receive a packet in NS-3, the real Linux host receive the packet.
How i can build such bridge? Could you give example? Thanks.

one way is to use linux bridge. Create a bridge and add the physical host interface & logical interface (tap) in the same bridge.

Related

providing DNS client and Ping client

I have a device firmware which runs on Ubuntu operating system. And the device has Ethernet connectivity and will connected on the network.
Now i need provide these two functionalities on the device
ICMP ping client - so that a device can ping the other devices on the network.
DNS client - for faster hostname to IP resolution instead of going to DNS server all the time.
I am trying to find how can i provide these features ? Do i need to implement these features or i can get some ready made source code or libraries which i can integrate with the existing code and get the features working.
Thanks in advance.
Sagar

multiple ethernet over USB devices

we have an embedded Linux device that primarily uses the Ethernet to communicate. We also allow access via the USB port, to support this our device has a g_ether Linux gadget driver that creates a virtual ethernet port for both our device and the clients host. A DHCP server assigns the client an IP address saving them having to configure this them selves, while the device has a fix IP address. I believe this is much the same as how Android does its tethering
This all works fine until a client wants to use 2 or more devices at once. Both devices come up as distinct network interfaces on the clients machine, but both devices have the same IP address meaning you cannot target the host specifically! A smaller problem is that there is a slight possibility that both devices might assign the clients "distinct" interface the same ip address and cause a conflict there too, but I am less concerned about that as the IP address is random since the DHCP server assigns the address based on the MAC address and g_ether randomly generates this, so a retry should fix the issue (not ideal, but will do)
I would like to know if anyone else has faced a similar problem, and if so how they solved it ?

Virtual networking devices in Linux

Can someone explain in detail what are the differences of veth pairs and tap interfaces and how these devices connect to linux bridge or openvswitch.
I found this:
"Veth is a special net devices which were created in pair, I consider it as a method to change the traffic's direction, that is, when the out direction traffic is sent to veth device from Linux protocol stack, it was sent to another its mirror veth device, so the mirror one treats it as a in direction traffic and put it back to Linux protocol stack for further usage.
Tap device is logical net device but have different with any other one: it allows user space program directly injecting traffic into Linux protocol stack, as well as it can retrieve traffic from the stack. It opens a tunnel to Linux protocol stack at level 2(or tun device at level 3) in user space, the stack will consider data from user space as in direction traffic"
but it didn't gave me the whole picture.
thanks in advance!
Linux tap interfaces created with ip tuntap cannot be used to attach network namespaces to linuxbridges or the openvswitch so we need to depend upon veth pair.
Virtual Ethernet interfaces come in pairs, and they are connected like a tube—whatever comes in one veth interface will come out the other peer veth interface.
As a result, you can use veth interfaces to connect a network namespace to the outside world via the “default” or “global” namespace where physical
interfaces exist.
A TAP device, such as vnet0 is how hypervisors such as KVM and Xen implement a virtual network interface card (typically called a VIF or vNIC).
An Ethernet frame sent to a TAP device is received by the guest operating system.
The purpose of these virtual networking artifacts are similar. But there are subtle differences and hence they are used in different circumstances:
TAP: The user-space application/VM can read or write an ethernet frame to the tap interface and it would reach the host kernel, where it would be handled like any other ethernet frame that reached the kernel via physical (e.g. eth0) ports. You can potentially add it to a software-bridge (e.g. linux-bridge)
VETH: Typically used when you are trying to connect two entities which would want to "get hold of" (for lack of better phrase) an interface to forward/receive frames. These entities could be containers/bridges/ovs-switch etc. Say you want to connect a docker/lxc container to OVS. You can create a veth pair and push the first interface to the docker/lxc (say, as a phys interface) and push the other interface to OVS. You cannot do this with TAP.
Please note that we should not misconstrue that we need to use VETH and not tap when using the OVS. We can always create the internal ports in OVS which behave exactly like the tap interface. But this is not always possible, for instance when you want to connect to an entity that cannot synthesise a tap-like interface. I.e.:
$ ovs-vsctl add-port ovs-switch-name tap0
Now you can use tap0 like we use the tap interfaces.

Finding device on network without its ip

We have developed a device that is connected to our clients network and we would like to be able to get its ip or set the ip without knowing its ip.
The device has a Linux OS.
We can save the device MAC Address before giving it to customers. We can program a service to broadcast the device IP and MAC Address to a certain IP or port/socket. We can listen to a certain port/socket for commands. Is this the right direction? Should we investigate in other network protocols other than TCP/IP?
We have seen this feature in hardware/device manufacturers provide a CD with a software that can locate their devices on a network even if they have been newly added to the network without network or ip configuration.
Best regards,
Hussam Kazah
Using propriety broadcasting protocol is a very common technique for detecting devices on network without knowing it's name.
However there's a better option:
UPNP, is an excellent protocol for achieving your goals.
libupnp can get you started in no time.
There's a standard protocol called DHCP which allows a network device to make a broadcast request for its IP address. This protocol is widely used by network appliances. On the other hand you may scan your local network for all connected devices using ARP (address resolution protocol) using for example arp-scan utility.

Why are external NICs not working on my server (running on Debian 7)?

I have a server running Debian 7. The eth0 interface is configured to use the on-board ethernet card. This is basically used to connect to the internet. As it happens, I had to connect this server to some PCs through a switch, obviously on a different series of IPs. for this, I installed an external NIC in the PCI slot but, strangely it didn't seen to work. The configurations were alright. I checked them more times than I can imagine. So, I disabled my eth0 interface and connected eth1 (external NIC) to the internet. If for the same settings, the on-board card worked, so should the external one. But, it didn't. When I tried to ping some servers like 8.8.8.8, it gives me Destination Host Unreachable and on termination shows, 0 packets "transmitted" and 0 packets received, which is baffling, to say the least. The PCI slot is working because I checked if the drivers were being recognised or not. The NIC itself is working (checked with another machine running Debian 6). Any help/sugesstions would be appreciated.
P.S The NIC in question is D-Link System DGE-530T Gigabit Ethernet Adapter (rev 11)
You need to check to see if the card is being listed in lspci or not. Second, is this a virtual machine?
I would also check to see if the BIOS is handling IRQ's in auto or are they specifically assigned.

Resources