How to decode and read unity udp packets? - android

I am capturing the udp traffic of my mobile device to understand how the unity messages are sent, with what format, etc.
Currently I am not being able to even read them, I only see their hexadecimal value and if I want to transform it into ascii it does not make any sense. Only sometimes do you see a meaningful value like my username.
As I was able to speak with the developers of the game, unity sends by udp packages values ​​such as the position, the speed with which the character moves, the strength of the shots etc. But I need to be able to see those values ​​and now I can't figure out how.
Most of the packets are short and look like this:
Hexa: 450000282e4c40002711d6cb12c07b11c0a80034b55aeeff00146cac000185649a8b002080000000
Ascii: E(.L#'ÖËÀ{À¨4µZîÿl¬d
The biggest one with some information are similar to this:
Hexa:450002f6d07040002c1115bf12d79214c0a800349c8aff0a02e2d47a0001974c02cf0020c0000000ff82cb00020082c60201000c000001000c00016302030001604df870f965340ea85076954c4641b5cdcccdc20ad7233dcdcc90c2340200000000cdcccdc20ad7233dcdcc90c20100b44200000000000000000100b4420100b442fa000000803f010000000000000000000000000000000400c236ee4343498644a42ef08bbd67c4e8f168eb9d20563004c96d41d68b427abdd2843fe59f909904f8e91cc9b542033100000c00546573747465737474657374000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000020000001300000010000000510200004b000000e1fb64def58d5524fbaf9b5cf0547b9a0001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000006cd5317f111d42141a2481f7e95223c005000000dba0d79272a295c4a9a968a669a3650905000000fd301ab653c6cc548bb9862b0f9b3aa005000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000006cd5317f111d42141a2481f7e95223c00500000000000000000000000000000000000000dba0d79272a295c4a9a968a669a365090500000000000000000000000000000000000000fd301ab653c6cc548bb9862b0f9b3aa005000000000000000000000000000000000000000000000000000080f404353f00000080f204353f02000400010036000a0002010000000000000000000000002600000000000000000000000000010000000000000000000000000000000000000000000000000010000a0003020000000000000000000000000000
Ascii: EöÐp#,¿×À¨4ÿ âÔzLÏ ÀÿËÆc`Møpùe4¨PvLFAµÍÌÍ ×#=ÍÌÂ4ÍÌÍ ×#=ÍÌ´B´B´Bú?Â6îCCID¤.ð½gÄèñhë V0ÉmAÖBz½Ò?åøéɵB1TesttesttestQKáûdÞõU$û¯\ðT{lÕ1B$÷éR#ÀÛ ×r¢Ä©©h¦i£e ý0¶SÆÌT¹+: lÕ1B$÷éR#ÀÛ ×r¢Ä©©h¦i£e ý0¶SÆÌT¹+: ô5?ò5?6 &
Where Testtesttest is my Username
Any ideas?

Related

"Best" way for Android Arduino communication via ethernet

I have an Arduino and an Android app which are communicating to each other via ethernet. The arduino shows a very simple webpage with only some values and an ID as seen below.
$1$201 //Value 1 ($1$): Temperature 20.1 degrees
$2$66 //Value 1 ($2$): Humidity 66%
$2$1 //Value 2 ($2$): Heating relay is on (1)
etc. up to 50 values
The Android app will read the data from this webpage as a string using a HTTP get request, filters the data and shows the values on a custom made screen. It is also possible to send some data to the arduino to change some settings or switch a relay or something. You can see is as some kind of thermostat. So far so good.
The "problem" is that I need to manualy update the data using a button. The question is: How can I update my values automatically?
I was thinking to just send a httpRequest every few seconds (polling), but I'm not sure if this is the way to go because it seems to use of lot of data.
Who can advise me what would be a good solution?
Regards,
Bas
The 'best' choice here will depend on your goals. Polling is easy to implement on the client (android) side. You could experiment with the optimal polling time depending on how 'fresh' your data needs to be compared to how much data you want your app to use. Alternatively, you could find or implement an http socket server such as ArduinoWebsocketServer, keeping in mind that the processor in your Arduino may or may not have the power needed to run this.

filter packet data based on the type of content they carry

I want to filter the packet data based on the type of data they carry. I mean is it possible to recognize whether the packet carries text/audio/video/other type of information by analyzing the packet header or the payload?
Also, I want to be able to do this in real time; so that I can keep track of How much of data has been used up in text/audio/video etc.. Can these things be done using tcpdump? I want to run in a tizen/android phone..
A few things might be needed to achieve this.
In Tizen, you need su access to the device and install tcpdump and a host of other libraries like libpcap for example.
For HTTP you could rely on MIME headers.
You could use pre-defined standard ports in certain cases.
For Audio and Video you could examine the payload and see if the header matches and then classify.
But to generalize it across all data formats is going to take some work beyond simply reusing existing tools like tcpdump.

how much size of data can be send in tidtcpclient in delphi xe7

I'm using Delphi XE7 for developing mobile application. And I'm using TIdtcpClient component to interact with the Server application. And I need to know for Android mobile & iOs mobile app, what is maximum size of data which I can send at a time to server. Or it depends on the speed of the internet. Please help me in this
TCP sockets are data streams, the length of the transmitted data is unlimited. For data with fixed length, client and server have to know when the stream ends, either by sending length information first before sending the actual data, or by using a end-of-data symbol / terminator sequence. You can also send an 'endless' stream, for example live audio / video data, which continues until one side disconnects.
There is no theoretical size limit to data that you can sent. Limitations are because of system resources/processing power, bandwidth availability and of course time that it takes to send.
System resources in the case of mobile devices will be memory, cpu power and data availability (cost per data) as it will most probably be for other platforms as well. Another resource that influences performance is the developer; the worst he writes the app the worst it will perform.
Bandwidth availability will determine how fast that chunk of data can be sent which directly influences the time it takes. Who wants to wait forever, right?
One more thing that is important, is the recipient. How patient the recipient is and how much resources he has also influences how much data you can send him.
So if you have plenty of time and resources then you will be able to send large amounts of data.
The Indy suite which TidTCPClient is part of, uses TidBytes as a memory data container into which an array of bytes is stored (the bytes that make up your data). Those TidBytes arrays are used to hold the data that you send or the data that you receive. They are handed to TidTCPClient when sending or receiving. The size of TidBytes arrays are once again limited by resources of the sender/receiver. If that causes an issue then you can break the data into smaller chunks then send them one-after-the-other. As long as you indicate to the recipient how big each chunk is, as mentioned by mjm and in the case of segmented sends you must also indicate which segment goes where in the complete data stream. A way of indicating to the recipient is to prefix the size of the data as either a byte, word or integer to the start of the entire package that you will send and as long as the server knows to either read the first byte, word or integer he will know how much data will follow that indicator and thus know how much data to expect as actual usable data.
Seeing that you might not know how much resources the recipient has it is wise to always break large amounts of data up into smaller chunks. This unfortunately is something that you will have to test to figure out how large. Also keep in mind the technology that will be used to send it across. For example Ethernet has certain packet sizes and if data is broken up into too small sizes it might cause too much overhead. The trick is to try and find the balance. Do not worry about that too much but do read up on it.

how to request OBD parameters and receive them

I'm new to android and I thought to develop a bluetooth app to retrieve parameters from an OBDII device. I have downloaded the sample bluetooth chat application and configured it. The problem is how and what is the message that I need to send to the OBDII device in order to receive the parameters? and how should I handle them in the application side?
Thank you.
You're question is not very specific, but I will give you some guidelines.
First of all, test with an exisiting OBD-II reader application if your car actually works.
The ELM327-bluetooth-connector you have (I assumed it's a ELM327) translates ASCII commands to voltages. So all you have to do, is send some ASCII commands, and you get ASCII-values back.
The OBD protocol knows several modes and parameter's, but I will explain to get real-time data. That's mode 1.
Mode 1 Sending
This is kinda simple as it is.
Mode 1 is '01'.
After that part, you have to send a parameter ID with it. 0C is for RPM, 0D is for speed. (Look into the link below).
And after each command you have to send a Carriage Return. (CR = '\r')
So basically, for speed, you have to send:
'010D\r'
Receiving Mode 1
The answer you will get back from a Mode 1 query, starts with '41'.
After that the parameter ID is returned, and then the value.
The value is most of the time in hex. You will have to do some conversion to read a human readable value. For more information, see the link, as formula's to convert are provided too.
Example:
'410D17'
So 17 is the value of your current speed in hex. 17 to decimal is 23, so you're driving with 23 km/h.
This wikipedia page has some good information about it:
OBD-II Parameters

android-serialport-api reading from serial port

I am trying to read data from a serial port in the below given opencv
link, I have no problem with
sending bytes. Everything works fine. There is a problem when i
receive bytes. Every time a read a byte from ttymxc0 something happens
and the byte is not only read for the first time it is sending some
junk data but after pressing the the two enter keys it is able to
read the data correctly but my concern to read the data without
pressing any enter keys in the beginning only.
http://code.google.com/p/android-serialport-api/source/checkout
So could any body provide sme corrected code to get rid of this
annoying serial port read problem,
Am new to this android applications development,
"Android-SerialPort" application works straight forward without any modification, I am not sure what you mean by two key presses required for receiving data. Can you paste code snippet, it is hard to reply to such questions.

Categories

Resources