SocketCAN and Incoming Packet Control - linux

I have an application for linux. I am using SocketCAN to talk to the CAN bus. We are doing this on a Beaglebone Black based device we made ourselves.
We have another device we need to listen to traffic from. This device sends a ton of data way faster than we need it or can process it.
I am trying to figure out a good way to slow down the traffic coming from this device to ours over CAN.
I found the document that talks about using traffic control (tc) for linux. I have been trying the examples and not seeing any difference in the incoming traffic.
Everything I have read about this gives examples about limiting the OUTBOUND traffic from an app to the CAN bus.
My question is whether traffic control (tc) can be used to limit incoming traffic to the kernel (and the apps that are listening)?
If not, then is there another tool that can be used for this?
I am ok dropping a percentage of packets. I assume that would have to happen.

Related

Can i intercept traffic of all nearby bluetooth devices with built into the laptop bluetooth dongle?

I know that bluetooth uses hoping, and because of this difficult to intercept traffic.
Сan i put my dong into monitoring mode?
If for example are 30 devices nearby, and i will always listen just one bluetooth channel, and my dongle works in monitor mode, should i get sometimes some data?
Can i use for these purposes Hcidump or tcpdump?
If I understand correctly, if bluetooth device does not have a password, i can directly interact with its services(with hcitool and tmux).?
I read that i can watch the battery level, device name, and other information.
PS: sorry for bad english.
It is possible to monitor traffic between Bluetooth devices but I am quite sure that your default laptop dongle is not capable of doing that.
Before establishing connection between two Bluetooth devices, they send connection request/response packets on primary advertising channels (37th, 38th, 39th channel). You need to capture these packets to learn hopping pattern, connection interval and etc. After receiving packets, you can monitor insecure Bluetooth connections. However it is hard to monitor 30 device simultaneously because you need to make time division between each connection.
Let's answer your questions.
It might be possible but you need to write driver level code.
It might be possible. As I mentioned, it is good approach to capture connection request/response packets before monitoring devices.
I have no idea about these tools.
To manipulate services, you need to know service handle and duplicate GATT client's mac address. I am not sure that, this method will work.

How to brutally interrupt remote network connections in code on Debian Stretch

I am working on a Python communications class running on a Beaglebone that connects to /reconnects to remote hosts from my list of available servers.
To test the reconnecting, I have been physically unplugging my lan from my router to simulate outages.
I would like to do this in code for extended testing.
Essentially I want to create a method called kill_internet(timeout) that will pull the rug out and then restore connectivity at the end of timeout.
requirements:
Must interrupt established socket connections.
Disconnect must be brutal and ugly - no chance for socket to close
gracefully.
Finally - I prefer that lan connections are not interrupted so I can continue to monitor testing over SSH from my PC. Not a true requirement since I can always reconnect and read logfiles later.
Service Networking stop will satisfy #1 but not sure how brutal it is.
I thought about UFW ( iptables) outbound rule but that may not block established connections and same concern about #2.
I suppose I could build a hardware 2-port device to do this at hardware level but that is well - hard.
Any ideas how to proceed?
Thanks
Bill
The best way to do this in your setup is to create and tear down firewall rules on your remote server to reject/deny your client in as many different ways as you can think of. For example:
Reject connection requests with an active refusal (easy to deal with on the client).
Drop a connection mid-flow with a reset packet (again, easy to deal with).
Suddenly stop responding at all to packets from the client's IP, mid connection. This simulates a cable-cut on a part of the network you don't own and it's the hardest one to deal with on the client because you have to consider what is a reasonable timeout.
If you're on Linux, iptables can be scripted to implement these rules.
I stumbled across an easy hardware solution that cost me $22.
Amazon sells these USB controlled relays for $10-$15 - look for UsbRelay2. With this I can easily trigger the relay(s) from code. To interrupt Ethernet violently, all I have to do is cut the power to an Ethernet hub or switch. I got a $10 5-port switch which runs off 5V from a wall wart. I cut one of the 5v power wires and ran it through the relay. Triggering the relay cuts the power to the switch. Since it is all 5V wiring is all safe and no case is needed. It took all of 3 minutes to put it together.

Half-duplex communication with VoIP

I'm trying to set up a half-duplex VoIP communication system. One client is walkie-talkie like radio, the other is a Linux system. My initial attempt was to use Twinkle, but after sniffing the network line through Wireshark, I found out that Twinkle is still sending out packets even if I mute it. The system only allows for half-duplex communication, so the Linux client is hogging the channel.
Is there a way I can either hodgepodge half-duplex on the Linux client or is there a VoIP client with G.711 u-law and PTT that only sends things out when keyed in? I did a search, but I couldn't find anything that had both.
EDIT: I wanted to add I did make a hack of two scripts that blocks all traffic going to the server and unblocks it, but I don't find this solution elegant at all.

Can linux bond (aggregate) several GPRS (sticks)

is it possible to bond (aggregate) multiple connections over GPRS (usb stick) and use it as one link in linux?
It is technically possible. Linux has a module called bonding which can assemble several interfaces into one logical interface. If you set the mode of the bonding interface to balance-rr, it will distribute the packets between the two interfaces. You will also need a server somewhere to reassemble the traffic that will come from your two links.
However, in practice the results with such setups are awful, especially with high latency and high jitter links like GPRS. The main reason is that you get a lot of out of order delivery and protocols like TCP become crazy in these conditions. So the resulting throughput will never reach the total throughput of the two links.

Transfer data using NDIS

I am working on fpga firmware, in which i want to have very fast data transfer using ethernet . I got help from FPGA forum they say that suggest designs for data transfer using light weight internet protocol (LWIP).
How this is different from transfering the data using NDIS. I will be grateful if you can suggest me some guide to interface my visual c++ application to the network guide and tranfer the data.
many greeting in advance.
LWIP is a library for talking IP on a network.
NDIS is a specification for how an OS talks to network cards.
Neither is necessarily what you appear to want.
If you want to transfer data very simply and quickly point-to-point using Ethernet, you need to understand how Ethernet works at the packet level, and form your data into some Ethernet packets. You can make up your own protocol for this if you have control over both ends of the link.
If you want to transfer the data over an existing network topology, you would be better doing it using an existing protocol. UDP/IP might be one such protocol, depending on your requirements for data-rate, latency, software complexity, reliability etc. LWIP is one library which implements UDP, so might be of use.

Resources