PDA

View Full Version : Making sense of OutSim UDP packets


Prospero
25th August 2005, 17:29
Hi all,

I'm afraid I'm very new to this, but I hope you can help.

I have enabled the OutSim feature and captured some of the OutSim data as a text file using a program called SmartSniff.

Now, I am aware of the format the OutSim data takes. Each UDP packet is made up of 17 values:

unsigned int, float, float, float, float, float, float, float, float, float, float, float, float, int, int, int, int

OK, so here is what I get from SmartSniff when I log 10 consecutive UDP packets as a text file:

SMSNF100 À¨  \ Œò“ùû¨ÅE \›· €‡À¨ À¨ [ï2 H‰z8ð xäKºZë.<ÿ'ˆ¼µÓ¼Œ|<Â_E:XÈ–¹4*.¸oÓ}8'–ù·À{’º}3ä9ç»þcµ + \ @·˜ùû¨ÅE \›¼ €‚À¨ À¨ [ï2 HZ±Vð „?Kº0å2<f燼µÓ¼Œ|<Â_E:?¶³¹uðɶ«ôi8=íb¸?ª’º?³ä9ç»þ`µ + \ ô{?ùû¨ÅE \›Á €}À¨ À¨ [ï2 H-·tð üJºPõ5<¸*‡¼µÓ¼Œ|<Â_E:‚·¹p{¿7«ÔY8[*¸Ï’ºÊå9ç»þ]µ + \ NÞŸùû¨ÅE \›Â €|À¨ À¨ [ï2 Hö#ˆð w‰Jº ¨7<©Œ‡¼Æö¼,Š|<«×F:90™:_¡Ý8b3a8Á•66Ð’º¨aå9ç»þ[µ + \ £¤ùû¨ÅE \›Æ €xÀ¨ À¨ [ï2 HíÊœð `DºÛ*5<Ãÿ…¼Æö¼,Š|<«×F:Ì:…×69ÍAÎ70Ó8Éè?º
4â9ç»þYµ + \ j,®ùû¨ÅE \›Ê €tÀ¨ À¨ [ï2 HcØð *ùBºù-9<=Æ‚¼Æö¼,Š|<«×F:µÄZ:tô8pÈÕ7Â
Ý8“T?ºn$â9ç»þSµ + \ ÄŽ°ùû¨ÅE \›Ò €lÀ¨ À¨ [ï2 HUÉöð .UBºa
><Ðg?¼Æö¼,Š|<«×F:?`?¸
ò8‰Ø7¯á·"ò?º]¶â9ç»þPµ + \ xSµùû¨ÅE \›Ó €kÀ¨ À¨ [ï2 H?ñ ‰Aºž=B<¨€¼Æö¼,Š|<«×F:ôú
º ¸Ð5nÇÝ7¡B¹îw?ºØ=ã9ç»þMµ + \ ,ºùû¨ÅE \›Ö €hÀ¨ À¨ [ï2 HŠ2ñ ??@ºEVD<u}¼Æö¼,Š|<«×F:ÓŽ°¹"µê7†¨ 8`\¹‘ô?ºÿµã9ç»þJµ + \ àܾùû¨ÅE \›Ú €dÀ¨ À¨ [ï2 HnoFñ –¼?º“–D<Fž{¼Æö¼,Š|<«×F:¥×¨8—Ù$8v¿8pHޏ@9‘ºFä9ç»þHµ +

PLEASE NOTE: I assume that the first few characters - "SMSNF100" - have been added by SmartSniff.

Could anyone give me some pointers on how to convert this to human-readable ASCII state data? Am I correct in saying that the UDP packets are binary (I imagine they are)? Or hex? Or...?

Any help greatly appreciated. I just need a bit of advice to get me started!

Cheers,

Prospero
http://forum.rscnet.org/images/statusicon/user_offline.gif

GeForz
25th August 2005, 18:17
as written in the README.txt


Motion Simulator Support : (OutSim)
--------------------------
The user's car in multiplayer or the viewed car in single player or
single player replay can output information to a motion system while
viewed from an internal view.

This is controlled by four lines in the cfg.txt file :

OutSim Mode 0 :0-off 1-driving 2-driving+replay
OutSim Delay 1 :minimum delay between packets (100ths of a sec)
OutSim IP 0.0.0.0 :IP address to send the UDP packet
OutSim Port 0 :IP port
OutSim ID 0 :if not zero, adds an identifier to the packet

Each update sends the following UDP packet :

unsigned int :time in milliseconds (to check order)
Angular Velocity :3 floats
Orientation :3 floats Heading, Pitch, Roll
Acceleration :3 floats X, Y, Z
Velocity :3 floats X, Y, Z
Position :3 ints X, Y, Z (metres x 65536)
Game ID :1 int (optional ID - if specified in cfg.txt)

Note 1 : X and Y axes are on the ground, Z is up.

Note 2 : Motion simulators can be dangerous. The developers of the
Live for Speed racing simulator do not support any motion systems in
particular and cannot accept responsibility for any injuries or death
connected with the use of such machinery.

GhostVE
25th August 2005, 18:36
Yes you are right to think that it is binary data... Viewing in ASCII won't help you much....
Use a hex editor (try google, there a lot freeware) or if you have Visual Studio 6.0 rename the .txt to .dat and open in there to see the byte values.

Prospero
25th August 2005, 19:27
as written in the README.txt

One sometimes wonders why one bothers to ask... Do you think I haven't read the README?

the_angry_angel
25th August 2005, 19:37
Prospero - what language are you trying to interface with In/OutSim? What is your longer term goal? If you can give us some more specifics we maybe beable to help me.

Prospero
25th August 2005, 19:45
Hi Angry Angel,

It's all about learning for me.

Two goals:

1) Initially, to get LFS's OutSim UDP packets displayed in "user-readable ASCII" via some free 3rd party sniffer software. I have never done any TCP/UDP network programming before, so I'm treating this as a good introductory exercise in to it...

2) To recreate the same by writing my own routines from scratch in Visual Basic 6.

Any help (or links to good articles) greatly appreciated!

Prospero

dUmAsS
25th August 2005, 19:49
you need to read the packet in binary and put the data into the floats. you cant just dump the packet into a text editor. doesnt work like that :)

Prospero
25th August 2005, 19:58
you need to read the packet in binary and put the data into the floats. you cant just dump the packet into a text editor. doesnt work like that :)

OK, here's a question. I understand what you say, but can't one take the ASCII dump and translate it... or... oh god... I am lost. I'm looking to get the 17 numerical values contained within an OutSim UDP packet in ASCII. Surely someone can just tell me what to do???

Oh, and how do I open a .dat file in VB6?

I need someone to set me straight here. I'm sorry if this is very naive.

Please, plain English chaps. Imagine you're trying to explain to a spastic why it's unwise to attempt crossing a motorway at rush hour.

Prospero

dUmAsS
25th August 2005, 20:17
no, converting pure data to ascii corrupts it.

do you know how to work with data and binary files? loading floats from files etc?

Prospero
25th August 2005, 21:48
no, converting pure data to ascii corrupts it.

do you know how to work with data and binary files? loading floats from files etc?

Answer: No.

I've never had to parse binary files. So... help?

;)

Prospero

dUmAsS
25th August 2005, 21:54
i would recommend how to load up binary files and working with variables before diving into this

Prospero
25th August 2005, 22:25
You patronizing ****.

Darn, maybe if I spell **** in binary, you'll be able to **** *** ** ** ********* *****.

:)

(Think ....no uncertain terms)...

sdether
25th August 2005, 22:29
Answer: No.

I've never had to parse binary files. So... help?

;)

Prospero

How you do it varies from language to language, but the basic concept is that you read data byte by byte and then copy byte ranges into the datatypes it needs to go in.

To illustrate on the actual Outsim packet:

unsigned int :time in milliseconds (to check order)

unsigned int is 4 bytes, so read the first byte then cast that array of bytes to an unsigned int (using typed language lingo. Not sure how you'd do it in untyped languages like VB)

Angular Velocity :3 floats

Each float is 4 bytes, so read the next 4 bytes, cast the array of bytes to a float, repeat twice more

and so on

In C and C# (and probably other languages) you can just create a struct of that matches the packet, then read all entire packet and copy that byte array into the struct, and voila, everything is properly populated :)

dUmAsS
25th August 2005, 23:18
You patronizing ****.

Darn, maybe if I spell **** in binary, you'll be able to **** *** ** ** ********* *****.

:)

(Think ....no uncertain terms)...

well you may think that but from my experiance. if you havnt done the basics you will struggle through the rest

colcob
26th August 2005, 08:04
You patronizing ****.

Darn, maybe if I spell **** in binary, you'll be able to **** *** ** ** ********* *****.

:)

(Think ....no uncertain terms)...

Oh dear. No help for you now.
Thats not really the right attitude.

the_angry_angel
26th August 2005, 08:40
As has been sort of said, I would really recommend writing your VB stuff to interface with In/OutSim, then try and understand it as you go along.

Loading it and attempting to read it all through a hex editor may not been the best way to learn; its all a bit abstract, although you can certainly do it. My favourite hex editor is XVI32 - you may wish to try and open your dump's with that, and see if you get any more luck with your understanding.

Prospero
26th August 2005, 17:50
well you may think that but from my experiance. if you havnt done the basics you will struggle through the rest

I suppose English isn't your first language. Not to worry. We all have our crosses to bear. I hope, for your sake, that your binary's more fluent.

Many thanks to sdether and angry_angel for giving me the info I need. Situation sorted - with great effort;)

Cheers,

Prospero

dUmAsS
26th August 2005, 18:05
I suppose English isn't your first language. Not to worry. We all have our crosses to bear. I hope, for your sake, that your binary's more fluent.

yes lets hope my programming is better then my english. my compiler doesnt like me writing proper sentances in english...

if your trying to get a flame war out of me, or make me cry with those oh so harsh comments, its not going to work :)

BlackSpider
26th August 2005, 20:40
Ah, the god of Trade and Wealth versus Dumass... *Chin*.. Sorry, Prospero, I have my money on Dumass. And yes, he's right, diving in to complex matters when you don't understand the basics is a daft idea, and will only make things harder in the long run.

And no, I don't care if you call me names. I enjoy it, actually. It makes me drool with pleasure. So, please, go ahead.

P.S: If they begin with 'w', 'r' or 'f', they make me really ... Nevermind.