vcan0 interface linux communication - linux

Linux is supporting virtual can interface. it was enabled by:
modprobe vcan
sudo ip link add dev vcan0 type vcan
sudo ifconfig vcan0 up
While using cam-utils such as camsniffer and cansend
cansend vcan0 321#1212
cansniffer vcan0
I could able to see can packets; but only within same host. I tried Ubuntu VirtualBox machine. Both guest and host OS are interconnected using host-only adapter vboxnet0.
Also tried SocketCAN socket(PF_CAN, SOCK_RAW, CAN_RAW) but not able to receive on other machine(works within same machine) While trying with broadcast manager socket(PF_CAN, SOCK_DGRAM, CAN_BCM) on executing stderr says `operation not supported
Simply, could one send and receive CAN packets between Linux hosts? Doesn't matter its Virtual Machine (vboxnet0) or physically connected (Ethernet).
Note: I used Ubuntu 16.04 and 12.04 as Host and Guest OS respectively.

CAN uses its own physial bus. The vcan devices are designed for testing software that communicates over the bus without requiring an actual physical connection, they're not actually supplied by the hypervisor, but are a part of SocketCAN.
By the looks of it, you're attempting to establish a Virtual CAN bus in Virtualbox, connecting multiple machines together as though they all had CAN controllers and were connected to a physical bus. I've looked, but it appears that such functionality doesn't exist, and beyond writing an extension for VirtualBox, is probably not likely to.
Is there a specific reason you're looking to use CAN? Trying to pull data from an ECU or communicate with embedded hardware that has a CAN controller? As far as desktop pc communication, ethernet is much more convenient, faster,a nd well supported.

Related

Ubuntu server 20.04 not detecting device over eth0

I am running a C# application on a ubuntu server 20.04 (running on a raspberry pi) which communicates with a controller. Both devices are connected via an ethernet cable and afterwards using a socket i search for its set ip 169.254.255.254 which remains always the same.
The application behaves the same as if the two devices are not connected throwing an exception "A socket operation was attempted to an unreachable network."
The connection worked on a raspberry pi os (latest version) but i can't use it because of a driver issue with a different component. I am also able to connect to the controller from a windows machine. Sadly i am very new to linux, ubuntu and networking and i can't figure out what could cause this issue.
Is there some kind of a setting that i need to set in order to be able to communicate with the controller?
If more information is needed please ask and i will provide.
Any IP within 169.254.x.x is problematic - in fact, according to this article, it indicates that the device is not connected to the network at all.

Linux: talk to different devices with same mac on different interfaces

I have multiple devices with the same hardware mac address (in factory reset mode) that all call a tftp server in order to get a proper mac.
On the same nic, there would obviously be no way to differentiate the devices, however, i have one device per nic. I evaluated these options to use that fact:
SO_BINDTODEVICE
Binding the tftp server on each nic separately would probably still not give me a way to respond with a package to the sender, since linux' arp table would be confused about which nic to send that package out from.
net namespaces
Linux does not allow bringing physical interfaces into a net namespace. only veths, which again would need to be bridged on the 'host' side, which will probably not work with the same mac appearing on multiple physical nics.
Am i missing an option here?

Capturing packets on VMware machines

I have a windows PC installed VMware Workstation and Linux run on it. I want When windows communicate with Internet I can capture packets in Linux, how can I do that?
The vmware network is Bridge, and I set eth0 use command "ifconfig eth0 procmisc".
linux IP is 192.168.0.103, windows IP is 192.168.0.102
Run "tcpdump not host 192.168.0.103" with no result.
Thank you for you time and please help me
While I haven't used VMWare workstation before, I have used Oracle VirtualBox in a similar setup as you describe.
I suspect that the problem is that your network adaptor on the Linux VM is not actually accessing the physical network adaptor directly. You will be using one of the network mapping types described in http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1006480 instead.
As such, you are not getting all the traffic that is going to your physical network adaptor. Instead you are getting the reduced set of traffic that VMWare is passing on to your guest.
The only way to get that is to do the snoop on your Windows host, using something like https://www.wireshark.org/

Virtual box based development for Embedded Linux

I am new to embedded linux development.I have inherited a particular way of Embedded linux development from the previous developer.
I was just wondering if there is a more industry standard way of working.
This is how he was working,
There is an ARM embedded linux board which is not on the corporate network and has a fixed IP address of 192.168.0.52.I have a virtualbox based linux host which is connected directly to this linux board via an Ethernet cable.This host has an NFS shared with the target for running the cross compiled binaries.I have to set a fixed IP address for the host of 192.168.0.50.Then I can telnet with the target to run the compiled binaries on the NFS folder. Also as the VM host is not connected to the corporate network.I cannot use the company issued SVN for version control.So what I do is have a shared folder via virtual box between Windows and Linux host and I manually keep transferring the files which I have to commit/test.
What I would I ideally like, is both networks connected to the corporate network,so that I can update the OS,use version control.Is there way by which the VM on Windows access the corporate network and also be connected to the target.IT is not willing to give a static IP to the target.If we connect the target via DHCP what is the best way to discover it on the network.Also IT is concerned about the traffic it will generate.Can I use a switch to create a subnetwork,so that the target can have a fixed address?
Another question is they are open to a linux based host as well.Is a VM based linux any worse off than a Linux PC.The only problem I have been having are networking based issues,not really Virtualbox issues.But I am curious to know if there are any limitations at all.
In order to have the VM connected to the corporate network, you can setup the VM network adapter in bridge mode.
In order to discover the embedded device, you can use the arp command (for instance: arm -i eth0 -a).
If you have got two network interfaces you could also connect the remote device directly through this interface and setup a dhcp server in your VM.
Personally, I think that with the VM you can do everything that you need (cross-compiling the Kernel and bootloader and creating the remote File System). I have been using a VM for embedded linux development on a AT91SAM board without problems at all.

VMWare Server Under Linux Secondary NIC connection

With VMWare Server running under Linux (Debain), I would like to have the following setup:
1st: NIC being used by many of the
images running under VMWare, as well
as being used by the Linux OS
2nd: NIC being used by only 1 image and to be unused by the Linux OS (as its part of a DMZ)
Although the second NIC won't be used by Linux, it is certainly recognised as a NIC (e.g. eth1).
Is this possible under VMWare Server, and if so, is it as simple as not binding eth1 under Linux and then bridging it to the image under VMWare Server?
I believe you can set the desired solution up by rerunning the vmware configuration script. And doing a custom network setup, so that both NIC's are mapped to your vmware instance. I would recommend making eth0 the 2nd NIC since it will be easier for Linux to use by default. Then make eth1 the 1st NIC.

Resources