STEAM GROUP
Payday 2 Mechanics PD2mech
STEAM GROUP
Payday 2 Mechanics PD2mech
9
IN-GAME
65
ONLINE
Founded
27 September, 2015
Showing 11-20 of 20 entries
4
Network Packet Analysis
I've come to the conclusion that based on the way packets are given ids and handled outside of lua, that the header is SteamWorks API based and likely difficult to immitate while also having peers that rely on relaying messages via Steams static IPs for the p2p hole punching, a proxy server to manipulate packets isn't very viable :P

I've considered running my own network code with a native binary library that would be drag/drop DLL to the PD2 directory. I'm not sure how viable setting up FFI is, if even possible it might not be easily distributable in a user friendly way. Another option would be to communicate via REST or websockets to the localhost running a web server to interact with my native code, but again problematic for the common user to deal with probably. Lastly it might be possible to take advantage of the BLT hook technique or through BLT support itself, however I'd still run into the issue of my last point with SteamWorks API relaying messages through static IPs for certain users that need network hole punching. Possible work around would be to enforce port forwarding if needed.

BLT also has a feature to send network messages in JSON format/strings through a hidden chat channel, but when I used this early on in BigLobby I remember it not being reliable in delivery, it either failed to arrive sometimes or was heavily delayed.

So unfortunately, it seems making custom network calls available to everyones mods isn't too feasible. A pdmod will still be required and can break with every update. For supporting multiple mods, generic network methods could be defined with various param combinations to utilize and logic in the handler class to identify intended method that will transform the params to expected format(you might not use all params in their defined order).

Maintenance could be reduced with some automation/tests, where SteamKit or similar is used i na server with a steam account to download the updates when available, extract the asset XML, patch it with generic methods, create the pdmod and commit a PR to a git repo. Webhooks could then forward those to repo's depending on it and create a new release.
7
The Biker heist and Panic room mission files
69
Strings
4
Network Packet Analysis
69
Strings
4
Network Packet Analysis
Not sure if this is useful to anyone but I spent a bit of time with WireShark collecting UDP packets and trying to analyze their structure. I had some success, and thought it worth sharing. If you're not aware, network.network_settings asset is an XML file with network messages defined, the engines Network class reads this in to define RPC methods that the Lua NetworkPeer class uses with send() function.

I wanted to see if I could work around the need for pdmod which breaks with each update by supporting my methods with my own Network class potentially replacing the existing one(or at least some of it's functionality being redirected to mine). This would allow for multiple mods to add or change network messages and mixing them into the main source from OVK avoiding breakage considerably.

Unfortuantely from the looks of it, I'm not sure how possible it is, fairly close, not sure if I can get that information for unit param values via lua or if it's engine access only. It may be possible to proxy the packets and modify the packet data with what I do know however. I'm putting this project on hold for now, but would appreciate help in decoding the rest if anyone is interested!

This could potentially pave the way for dedicated servers or improved netcode or porting to another engine with network compatibility to the original game.


RPC network message definition for example packet below:
<message name="play_distance_interact_redirect" delivery="ordered" receiver="unit"> <param type="unit" /> <param type="string" /> </message>

Example Packet:
010000000000 00 0eea 00001375 0000ecb7 00193c54 5c1f70df 00000017 0000ba00 02 089a 06 88 00 9c08 0a 6d656c65655f6974656d

  • 010000000000 - Seems to be static with all packet data
  • 00 - Only ever seen 00/01 and once 03, may refer to client/host or status? Potentially peer id
  • 0eea - Unknown
  • 00001375 - Increments at a specific amount, value is consistent to target peer for same method, noticed increment values of 11 and 22 for two different peers
  • 0000ecb7 - Like the previous but decreases by the amount instead
  • 00193c54 - Consistent between peers, iterates over time, possibly using game time
  • 5c1f70df - Unknown, 5c was common throughout the same network message, 1f had 4 variations, possibly local peer to target peer identification
  • 00000017 - Packet Length in bytes following
  • 0000ba00 - Increments by 0x0100
  • 02 - Seems to indicate the end of the header? Only seems to occur at the start
  • 089a - Increments by 0x0100 per packet sent, the value consistent to the target peer, possibly two seperate bytes.
  • 06 - Denotes the following byte represents Packet ID
  • 88 - Packet ID based on counting message elements in network.network_settings XML as they appear
  • 00 - Null after packet ID? Param values for this packet id follow in order of their definition
  • 9c08 - Value for unit param
  • 0a - Prior to a string it's length is given
  • 6d656c65655f6974656d - String, in this case "melee_item"
  • Packets may contain additional bytes sometimes, they don't seem relevant/needed, may be old memory in the buffer, sometimes a packet also seems to begin incorrectly when heavily stressing network packets

Additional messages in a packet may be appended, they begin with a Packet ID indicator byte followed by packet ID and so forth like listed above, there is no notion of a repeat message indicator byte(exact same messages repeat in full at packet lengths up to 1400ish?), which is very inefficient.

If there is any checksum it is likely in the header, not sure what type is used or how it is computed, possibly one of the unknowns. One of the other unknowns might be used to indicate packet order or timestamps.
69
Strings
Showing 11-20 of 20 entries