Connection Loop With "Ethernet to USB" adapters problem - android

I have a problem with my video streaming connection setup.
I'm trying to create a cabled connection setup. But I have a problem.
My setup is between two android devices and here is the connections;
Device A -> usb-ethernet adapter -> ethernet cable -> ethernet-usb adapter -> Device B
I can create a connection and send pings between both devices but there is no smooth values on it.
E.g My exceptation is about 1ms but there is 10-13 ms and sometimes it can be 1500ms and etc. And because of it I lost my video streaming and see unsafe connection.
I think there is a loop between two ethernet to usb adapter and source of my problem is that loop.
That is the question, how can I prevent that loop and create stable connection with this setup? Is there any idea about it?
Thanks.

Device A -> usb-ethernet adapter -> ethernet cable -> ethernet-usb adapter -> Device B
There's no loop. A loop requires a bridge/switch and an additional (redundant) link.
Any round-trip delay beyond 1 ms indicates a larger problem: bad cable, duplex mismatch, crappy USB adapters, crappy TCP/IP stack, network congestion, CPU overload.
A simple IPv4 over Ethernet ping (default 32 bytes data) has a total size of 8(L1) + 18(L2) + 20(L3) + 8(ICMP) + 32(data) = 86 bytes. Even over 10 Mbit/s that's just .14 ms plus processing overhead (perhaps another .1 ms).

Related

Sending and receiving data in parallel on socket android

I am currently working on file transfer between two mobile devices. For this, i am using socket communication. On socket using DataInput and Data Output Stream, i am able to get approximately 6 MB/s speed. But as per my use case user can select all images, videos, apk's, documents to transfer. so let's say user selected 2GB data to transfer with my app he has to wait for more than 6 minutes. so I have done some modifications.
1] On receiver side I opened up 5 ports (one for image, one for video and so on)
2] Sender will send appropriate files on corresponding ports.
3] I am sending all the files at a time parallelly using async task and receiver is receiving data in 5 different thread.
But the problem is speed still is same for 2GB it's approximately 6MB/s.
So my question is:
1] Will multiport socket increase performance?
2] if I am doing something wrong, then how can I send data parallelly on different ports on a socket?
Android devices cannot go more than 7mb/s as per my experience. Use some data monitor start file transfer on lan. You will notice its maximum speed is approximately 7mb.
Sorry i cannot comment yet so added as answer.

Bluedroid hangs up for >45 ms during channel switch

I have an application that needs to transmit bursts of data to android device.
A sequence of packets during this burst is attached. We observe that during channel change, stack goes too busy and does not transmit anything for ~45-48 ms.
This leads to data loss on transmitting device. We cannot hold that amount of data on transmitter to cope with delay in bluedroid.
Are there any suggested changes in AOSP / bluedroid that can improve this situation? Any suggestions on where to start looking?
Target device is Nexus 7 2013 (flo) with AOSP 5.1.1_r14
This is probably hardware specific behavior. Perhaps the hardware buffer is limited to 4 packets, and driver delivers/fetches packets only during interrupt on CI elapse.
MD column is "More Data" it tells if transmitter has more data to send. In this case, Slave sets MD=0 on 4th transmitted packet on every CI and so master goes away. Master checks back in next CI with empty packet.
In my application, somehow this gap is 46 ms due to issue in negotiating ConnInterval, so master defaults to 48.75 ms CI. And so it sleeps for ~46ms
My data loss is happening due to issue mentioned by #Gaurav, but on Slave, i.e. Slave LL is dropping packets fed to it while it already has 4 packets. [This is a guess] I'll confirm and update.
Update
Looks like CONNECT_IND contained transmitWindowSize of 2.5ms in the captured log, transmission of 4 packets will take 2.3+ms, and 5th packet wont fit in 2.5 ms. transmitWindowSize might be the real reason why no more than 4 packets are transmitted per CI, still doesn't explain MD=0 in 4th packet though.

To discover other device IP:Port in same wifi network using ZeroMQ

I want to discover all Android devices IP and Port in same wifi network using ZeroMQ?
My app basically connect all device in same wifi network (no internet needed) and message to each other. Once ip and port I know I am send message successfully but how to know all device internet Protocol (ip) Using ZeroMQ?
Principle
Part A)
Every IEEE 802.x CSMA/CD network "collision domain" ( wifi AP/SSID is such one ) has to be managed so as to work well. Thus the Address Resolution Protocol [ARP] will help you in the task to find all ISO-OSI-Layer-3 IP Addresses. Wifi Access Point [AP] host, to which all live devices register and handshake with, is the choice to start with.
HG520i> ip arp status
received 54205 badtype 0 bogus addr 0 reqst in 12105 replies 196 reqst out 14301
cache hit 63152696 (24%), cache miss 19455672 (23%)
IP-addr Type Time Addr stat iface
192.168.0.230 10 Mb Ethernet 290 00:15:af:e6:b1:79 41 enif0
192.168.0.62 10 Mb Ethernet 300 00:0c:29:98:d4:3b 41 enif0
192.168.0.55 10 Mb Ethernet 300 00:27:0e:07:c5:9e 41 enif0
192.168.0.255 10 Mb Ethernet 0 ff:ff:ff:ff:ff:ff 43 NULL
num of arp entries= 4
Part B)
Scanning all the ports on all the known IP hosts is a dumb brute force approach to the second issue.
Scanning just a subset of "reasonable" ones would save you both the time and efforts on peer-recognitions.
Using some smarter, active "visibility self-advertisement policy" will save you even more.
Solution
Decide on multi-party system architecture, whether an individual passive scan, a central/distributed proxy-assisted scan or an active self-advertisement policy will be used to build and maintain live records in a neighbouring hosts register.
ZeroMQ per-se brings you a lot of power for the smart solutions, while the dumb-force solutions would have to wait till fully fledged ZeroMQ services will be ready. Low level L2/L3-inspections will have to bring their fruit before ZeroMQ can first .bind()/.connect()
Needless to say, that uncoordinated CSMA/CD networks do not guarantee that all the L2-visible hosts will have "compatible" L3-ip-adddress ( will belong to / have the same L3-ip-network address ).
Thus you never know about all IP addresses without a truly low-level sniffer.

Dataloss at connection android tablet -> lan - RS232 converter, but not on android tablet ->winpc pc -> converter

i have a big problem and i doubt about my intellect... I connected my android tablet (intenso tab814) to a RS232 converter (USR-TCP232-E) via a router (TL-WR740-N) and i send 7 hexadezimal bytes in a block, kinda 03 20 05... with further numbers. My problem is, if i let my tablet send, the converter receives the data, but does not submit it to a listening program on an pc behind the converter complete. There are often complete blocks missing (bnot single Bytes, but the whole command line i send), but if i send my data via tablet to another PC, and let HIM do the sending work to the converter every single byte arrives. It may be a bit dazzling, but i dont know, where this problem could belong to. My App sends every block correctly (the pc is able to receive)
The converters yellow RJ45 port-LED blinks, but i does not give the data to the listening pc.
For better understand:
Tablet(selfpogrammed app) sends data -> router -> converter (everytime blinks) seldom gives the command -> PC(selfwritten listening programm(not written by me, but by the one, i am the follower of, not familiar with language.)
But if i:
Tablet(same app) -> router -> PC (receives all the data) -> router -> converter always give the data to the listening progamm ->pc
What is the matter here? Why does the converter gives the data from app -> pc to listening pc, but not from app to listenign pc?
Tablet is connected via W-Lan to router, the pc's via RJ45-cable, the converter either. Using TCP/IP converter as server.
PLS HELP Q_Q
EDIT:
configuration:
Baud Rate: 115200bits/second
Data Size: 8 bits/characterParity: None NoneOddEvenMarkSpace
Stop Bits: 1bit(s)
Flow Control: None
Local Telnet Port Number: 2001
Remote Telnet Port Number: N/A
Telnet Mode: TCP Server
Telnet Server IP: N/A . . .
Telnet Timeout: 0seconds seconds (< 256, 0 for no timeout)
UART packet Time: 10ms ms (< 256)
UART packet length: 200
EDIT:
forgot sth to mention. the converter is via RS232 to an USB converter from RS232 to USB connected. Its receiving lamp does not blink, when the listening programm does not show my commands, but if the programm spits my lines out, the USB-part blinks too. So the converter receives, but does not give it to the USB. But only if i use my tablet. Same interval all the time.
Was my own fault, forgot to use a bufferedoutputstream, now it works.

Initialization of obd adapter

I am developing a android application which reads Obd data from vehicle's Obd adapter via bluetooth... I am facing issue while initializing the adapter. I have sent following Obd commands in sequence to initialize the obd :
atz (received OK)
atsp0 (Received OK)
ate0 (Received OK)
0100 (This is the part where issue occurs)...
Some times for this command i receive BUSINIT:ERROR.. And after that for every vehicle command (except AT commands) same error is repeated..
I want to know the Exact initialization sequence ?
It seems your obd initialization and obd protocol selection failed. You should follow these steps:
AT D
AT Z
AT E0
AT L0
AT S0
AT H0
AT SP 0
When protocol selection command response without any error like listed below, your connection is OK and you can request new commands like '0100' command.
Errors:
UNABLE TO CONNECT
BUS INIT... ERROR
?
NO DATA
STOPPED
ERROR
Command Explanation:
AT D -> Set all to defaults
AT Z -> Reset Obd
AT E0 -> Echo off
AT L0 -> Line feed off
AT S0 -> Spaces off
AT H0 -> Headers off
AT SP 0 -> Set Protocol to 0 "Auto", search all protocols and connect it with proper protocol for that obd
For AT SP command, if you know your vehicle's obd interface protocol, you can choose that specific protocol other than make Auto and search all possible protocols. You can use different inputs:
Protocol Parameters: Hex[0,1,2, ... ,B,C]
Auto select protocol and save.
AUTO -> 0
41.6 kbaud
SAE_J1850_PWM -> 1
10.4 kbaud
SAE_J1850_VPW -> 2
5 baud init
ISO_9141_2 -> 3
5 baud init
ISO_14230_4_KWP -> 4
Fast init
ISO_14230_4_KWP_FAST -> 5
11 bit ID, 500 kbaud
ISO_15765_4_CAN -> 6
29 bit ID, 500 kbaud
ISO_15765_4_CAN_B -> 7
11 bit ID, 250 kbaud
ISO_15765_4_CAN_C -> 8
29 bit ID, 250 kbaud
ISO_15765_4_CAN_D -> 9
29 bit ID, 250 kbaud (user adjustable)
SAE_J1939_CAN -> A
11 bit ID (user adjustable), 125 kbaud (user adjustable)
USER1_CAN -> B
11 bit ID (user adjustable), 50 kbaud (user adjustable)
USER2_CAN -> C
Just wanted to put my two cents in. I've been recently developing an application in C++ and LabVIEW to communicate to a ELM-327 - based bluetooth module to retrieve information from my car's ECU. Sometimes the initialization sequence fails, sometimes it works. What I've found is that the 'keywords' bytes of the ECU protocol initialization are sometimes not being detected correctly. I think my bluetooth module is the problem, because it turns out is a chinese clon of a legit ELM-327. How do I know that? If you issue the command ATI , it would reply "ELM-327 ver. 1.5", and according to the manufacturer, they NEVER released a 1.5 version =D
What has worked for me is something like this:
Open communication, send ATZ
ATSP0
ATSS (This enables the recommended protocol search order)
010D
If 4. fails, then close communication, wait 3 or more seconds and GO TO 1
More OBD-II or AT-Commands.
The BUSINIT:...ERROR response means that the ELM-327 was unable to finsh the start-up sequence of the ECU protocol. Also, before sending an OBD-II command, like 010C, you can initialize the communications with the ATSI command, if your can happens to use the ISO-9141-2 or ISO-14230-4 KWP protocols.
You can find out what protocol your car uses if you send the command ATDP to the ELM-327 after succesfull automatic detection.
Hope this helps.
"AT E0"
"AT L0"
"AT ST 00"
"AT SP 00"
Works for me.
And one more thing... I send all these commands one after another with the delay of 500ms! Without a delay the initialization fails almost every time, don't forget, this is bluetooth and it requires more time to send and receive responds...
Your initialisation sequence should work if the hardware is fully OBD-II compatible and the car is OBD-II compliant. If you still get errors on the 0100 command, check the ignition is on and the hardware is fully operational.
0100 is the first command which will reach the actual car.
The AT commands are tor the (ELM327)-chip. So something is wrong with the communication between OBD connector and the car. Connection between your app and the connector is fine.
Obdkey is most likely to be right about the OBD-II compatibility. Please try to use an existing app to prove that, if it doesn't work, something is wrong with your car, or connector.
Btw: It's helpfull to state which obd-II adapter you have, and maybe your car.

Categories

Resources