51 Commits

Author SHA1 Message Date
Fletcher Dunn 7db494c6e7 Compiler warnings
P4:10650618
(cherry picked from commit f7e8d96de3)
2026-05-18 15:43:46 -07:00
Fletcher Dunn 537bdcc4d6 Tests: remove netloopback_throughput from suite-quick 2026-04-28 17:24:07 -07:00
Fletcher Dunn b6480e71b0 Fix how tests are checking the returned message number 2026-04-28 16:20:06 -07:00
Fletcher Dunn 676e0c95ea Add "test_connection send_buffer_full" 2026-04-28 16:15:58 -07:00
Fletcher Dunn 4fbfe83ef4 Semantic change to ISteamNetworkingSockets::SendMessages
Added bDeleteFailedMessages.  By setting this to false, the caller has
the opportunity to retry failed messages, which is an especially
reasonably thing to do in the case of the send buffer being full.

Also clarified expected (and enforced) expected behaviour on
how subsequent messages on a connection are handled after a failed
message send.  Previously, there was a fairly significant bug, which is
that we would coutinue to try to send messages, which is bad because
it can break fundamental guarantees about message delivery order.  Now,
we will always stop at the first failure.

This fixes issue #317
2026-04-28 10:11:25 -07:00
Fletcher Dunn 75451a0c52 trivial formatting issues 2026-04-28 10:11:25 -07:00
Fletcher Dunn e3034ee400 Add "test_connection pipe"
It exercises some basic functionality of the pipe connection and
confirms that huge messages can be sent and are zero-copy.
2026-04-28 10:11:25 -07:00
Fletcher Dunn 57ed3fa8c1 CreateSocketPair: add identity checks to tests 2026-04-26 20:52:40 -07:00
Fletcher Dunn 82557feb2d test_connection now explicitly tests IPv4/v6 variations
I added a connection test mode 'cursory' which just makes
sure we can bind and exchange packets.  We don't need to
test every variation with a soak or even quick test.
2026-04-25 14:11:01 -07:00
Fletcher Dunn e4b7cdcf6a Add accessors for other platform identities.
This is in the public SDK, it's not trade secret stuff.
2024-03-13 16:13:54 -07:00
Fletcher Dunn 3849f3a2c7 Fix for Switch
P4:7248965
2022-06-08 10:39:47 -07:00
Fletcher Dunn ab091afd62 Fixes to connection test
- Make sure we tell the connection what send buffer size to use, and then
  don't exceed it.
- Rename some stuff to be more clear

P4:7219096
2022-04-26 15:59:46 -07:00
Fletcher Dunn 293bda2899 Temporarily disabling some tests 2021-11-15 09:54:39 -08:00
Fletcher Dunn 7d3ea9db0f Assert that test finishes in a reasonable amount of time.
P4:6894669
2021-11-12 18:53:53 -08:00
Fletcher Dunn f6c05bb2db Improve throughput test.
Go up to 60MB/sec.
Turn up log level for dropped packets
Tweak output.

P4:6877980
2021-11-05 13:43:46 -07:00
Fletcher Dunn 1ec23499b8 Fix memory leak in test
The code was allocating a message but not actually sending it.

p4:6877324
2021-11-05 09:23:09 -07:00
Fletcher Dunn 6c0cea36ab Add test lane_quick_priority_and_background
p4:6871641
2021-11-02 18:16:06 -07:00
Fletcher Dunn f410482d50 Added test netloopback_throughput.
WIP.  It could definitely do more, but this code at least exercises the library
at a relatively high bitrate.

Also, rename lane_basics to lane_quick_queueanddrain

p4:6869017
2021-11-01 18:13:44 -07:00
Fletcher Dunn 340ce8d75b Added really simple concept of "test suites"
P4:6865684
2021-10-29 17:40:45 -07:00
Fletcher Dunn 999b2f778e Make the "quick" connection test not be *quite* so quick.
P4:6865680
2021-10-29 17:37:49 -07:00
Fletcher Dunn 9efdab59ce Multiple lane support working!
Visible changes:
- Uncomment ConfigureConnectionLanes
- Rename GetQuickConnectionStatus to GetConnectionRealTimeStatus, and change
  the prototype to return information about multiple lanes.
- Adding a test case to send data on more than one lane and make sure we get
  the priorities we expect.
- Also refactored the test-connection so that you specify what test(s) to
  run on the command line, instead of using the LIGHT_TESTS compile-time
  option.
- Bump interface version numbers.

Internal changes/bugfixes:
- Fix bug with my implementation of fair queuing.  I was always calculating
  the finish time for a lane based on the current virtual time.  But really
  it must be calculated from the time when the previous message in the same
  lane finishes.  Otherwise you don't share the bandwidth properly when it
  alternates lanes.  To keep the implementation simple, I just tag each
  message with the virual finish time.  I believe that this can actually
  cause the virtual time to go in reverse if you queue a message on an idle
  lane and we swap the active lane while sending is in progress.  But I
  think it's OK right now, and we will actually do the right thing and get
  back on track after a message or two.  To make room for this variable,
  I shuffled around how we had shoved in reliable bookkeeping in
  CSteamNetworkingMessage.
- Fix bug selecting the next message to send.  We were ignoring the priority
  classes and just using virtual time!
- Fix some bad hex math encoding and decoding the lane select frame.
- Fix some bugs that were confused about which set of links were used to
  track the list of messages in a particular lane
- Fix bug when serializing segments from multiple lanes, only one of the
  lanes will get to take advantage of the special segment encoding where
  the segment length is implied by the packet size.
- Reorder the fields in SSNPSenderState::Lane to pack them a bit better

Fixes issue #95.

P4:6865294
2021-10-29 16:46:11 -07:00
Fletcher Dunn a419be3d1f Fix win32 compile 2020-09-02 20:21:04 -07:00
Fletcher Dunn 1205aa893b Start P2P test. WIP.
Moved some common stuff out of test_connection.cpp to test_common.cpp.
2020-08-31 10:55:26 -07:00
Fletcher Dunn 4c71718263 Changed callback mechanism.
Now you can register standard function pointers, instead of deriving
from a special class.  This means that Steam and the opensource code
can now work the same, so this fixed issue #124
2020-07-03 18:02:21 -07:00
Steven Noonan fbcef3a326 test_connection: reduce LIGHT_TESTS runtime to < 5s
This should unbreak the Travis builders, which were taking more than an
hour to finish before. And since Travis changed the maximum runtime to
50 minutes, we hit the time limit and broke.

We just need to ensure these things run without crashing and try to hit
as many code paths as possible with various compilers/sanitizers, not do
long running tests with unusual network conditions.

Signed-off-by: Steven Noonan <steven@valvesoftware.com>
2020-06-12 10:38:38 -07:00
Steven Noonan 20adcbeb8a test_connection: fix thread data race
As observed here: https://travis-ci.org/ValveSoftware/GameNetworkingSockets/jobs/639936441

We were setting the debug output function while the internal
SteamNetworkingSockets thread was reading the value. No reason to not
just set it up *before* using SteamNetworkingSockets.

Signed-off-by: Steven Noonan <steven@valvesoftware.com>
2020-01-21 05:32:58 -08:00
Steven Noonan a4c96c87b1 test_connection: abort on failure to send message
Signed-off-by: Steven Noonan <steven@valvesoftware.com>
2020-01-08 01:24:09 -08:00
Steven Noonan a38ce07300 test_connection: constrain to 40 seconds when doing light tests
Travis is taking far too long to give us data, and we just want to do
quick sanity test runs on there.

Signed-off-by: Steven Noonan <steven@valvesoftware.com>
2020-01-07 23:42:56 -08:00
Fletcher Dunn aa50330f1f Add method to send a messgae without copying payload.
Fixes #51
2019-09-23 14:13:08 -07:00
Fletcher Dunn 140498490e API to atomically set initial options.
Added a mechanism to set initial options when creating a listen socket or
connection.
2019-09-02 14:34:11 -07:00
Fletcher Dunn addd70f182 More compatibility fixes for Switch. 2019-09-02 12:51:45 -07:00
Fletcher Dunn e8bba6ade1 Added interface for app to provision cert.
Also:
- STEAMNETWORKINGSOCKETS_STEAM now mens "running on steam", not "running using
  the steam client".  STEAMNETWORKINGSOCKETS_STEAMCLIENT is for that.
- Refactored stats stuff, moved it into the namespace.  At one point I thought
  I might expose some stuff in a public interface.  For now, keeping it internal.
- Removed concept of Steam "universe" from this branch of the code.
- Don't use OVERRIDE, override works.
2019-08-29 13:42:17 -07:00
Fletcher Dunn 59868d382c Fix typo in unit test. 2019-02-26 15:14:56 -08:00
Fletcher Dunn 1df31431e1 Improve SteamNetworkingIdentity text format.
- Print CSteamIDs in 64-bit, to be consistent and make them easy to
  print/parse without linking in anything.
- Actually implement the parsing, instead of the function body being
  Assert(false)
- Added an (extremely bare bones) unit test, in a place in the code
  that is totally inapproriate, but also totally convenient.
2019-02-26 15:05:38 -08:00
Fletcher Dunn 1d8ce57f92 Run 4 different network conditions in "light mode".
This is not really needed to confirm functionality, but logging the stats is useful to compare changes in performance.  (I'm about to check in a big one.)
2019-02-09 18:42:34 -08:00
Fletcher Dunn ccb7973cdc Tweak output of connection test. 2019-02-09 16:54:51 -08:00
Fletcher Dunn cb911a0277 Adjusted hacks for running without Steam.
(No functional change for opensource version.)
2019-02-09 12:19:16 -08:00
Fletcher Dunn cf12240f9a Tweak init of test/example when linking with Steam.
(No functional change in this lib.)
2019-02-05 13:13:45 -08:00
Steven Noonan 04831cf688 silence some -Wswitch warnings
Signed-off-by: Steven Noonan <steven@valvesoftware.com>
2019-01-30 21:06:14 -08:00
Fletcher Dunn ca91bb89f4 Fix printf
I broke this when I changed some config values from int to float.
2019-01-30 12:06:31 -08:00
Fletcher Dunn 5d20204781 Overhaul how configurtion options are set.
Moved them to ISteamNetworkingUtils, which is now actually shared Steam (mostly) with a real accessor and and interface, and not a dummy interface object with all static methods.

Connection settings have a system of inheritance, so they can be set globally, per SteamNetworkingSockets interface, per listen socket, or per connection.

Deleted the config variable to simulate fake *message* loss.  That is not useful.

Introduced STEAMNETWORKINGSOCKETS_ENABLE_SDR define, to make it more clear why code is being #ifdef'ed out.  (E.g. if we open-sourced that code, we would want that included.)

Replaced ESteamNetworkingSendType with a basic flags bitmask.

Cleaned up a bunch of comments.

Changed SteamNetworkingMessage_t release mechanism.  Now the callback is only to free the buffer, and it's assumed that this API will manage the actual objects.  (This is important because the actual type is a derived type and has extra stuff on the end.)  Also laid some groundwork for user management of message objects.  (Relevant for issue #51.)
2019-01-30 10:58:38 -08:00
Fletcher Dunn e2194a23c7 SetDebugOutputFunction cleanup.
Make it a method of ISteamnetworkingUtils method.  This matches Steam.

Make sure ESteamNetworkingSocketsDebugOutputType is 32-bits, and declare the output callback to take an enum instead of int.
2019-01-23 21:08:10 -08:00
Steven Noonan 1deac8bf64 test_connection: add special parameters when sanitizers are enabled
Signed-off-by: Steven Noonan <steven@valvesoftware.com>
2019-01-17 00:52:06 -08:00
Steven Noonan 3bf5767f78 test_connection: run with much faster parameters when using LIGHT_TESTS
This makes test_connection complete in ~40s. Very useful for quick CI
tests.

Signed-off-by: Steven Noonan <steven@valvesoftware.com>
2019-01-17 00:40:49 -08:00
Steven Noonan 26e8577b76 CMake: add LIGHT_TESTS option
For automated testing.

Signed-off-by: Steven Noonan <steven@valvesoftware.com>
2019-01-16 19:50:40 -08:00
Fletcher Dunn 7872346faa Tweak connection test.
Tweak spew formatting.
Run the test that simulates really bad connectivity first.
2019-01-16 10:15:28 -08:00
Fletcher Dunn 6722034677 Move all public headers to steam folder, matching the Steamworks SDK layout.
Also moved a bunch of Steam-specific stuff to other files, which are not included in this repository.
Moved high level init/kill to a seperate file, so that isteamnworkigsockets.h won't be cluttered with
a bunch of #ifdefs.

Added IClient interface layer, which is useless in this context, butneeded in Steam, since we
provide backwards compatibility for all old ISteamXxx interfaces.
2019-01-11 17:42:05 -08:00
Fletcher Dunn 5a25561336 Break out high level library init and kill to a seperate file.
This doesn't exist in the Steamworks SDK, so moving it to a seperate file means that the files that are in both branches can have fewer differences.

Deleted the "GameServer" interface.  That is a Steamworks thing.  I'll add another method to create additional interfaces later, if we need them.

CreateSocketPair now allows you to assign the identities to each end of the pipe.

Fix some really basic irritating issues trying to use ordinary UDP and loopback connections without an identity.  Make it more straightforward to just use generic identity with no authentication.
2019-01-10 16:38:44 -08:00
Fletcher Dunn d07b7b2eda Sync up with work internally in the Steam code.
* Interface changes:

Replaced all CSteamIDs with SteamNetworkingIdentity, which is an abstract concept.

Added IPv6 support.  This has not been tested at this time, but all the basics
are there and any issues should be small bugfixes.

Improved and standardized connection debug names.  You can set a debug name for a connection,
and the full debug string, which includes the Connection ID, transport-specific data, and
your name (if any) are printed consistently in logging messages and this name is also present
in SteamNetConnectionInfo_t.  Connection handles are now the same as the local ConnectionID
on the wire.  This makes debugging a lot easier.

GetListenSocketInfo renamed to GetListenSocketAddress and now actually does something.

Split out P2P and ordinary UDP listen sockets into two seperate objects.  This simplifies
the opensource code (since P2P is not support)

* Misc internal code cleanup:

Broke up CCrypto monolith, so that we can more easily and cleanly:
- Share what we really want to share with Steam.  Mainly some text parsing of keys, etc.
- Replace the actual crypto primitives with another provider (e.g. libsodium)

Delete a whole bunch of unused and messy cruft that was left when we ripped this out from Steam,
as well as code and messages specific to relayed connections (supported only on Steam)

Switch a bunch of maps to hashmaps instead of red/black tree maps.  The CUtlHashMap class comes
from Steam and is designed to scale to very large size (N in the millions), and if the table
needs to be rehashed, the cost is amortized instead of triggering a large cost all at once.
This functionality is not needed.  Nor do we need stable handles, so it would be better to use
a table based on open addressing.  That would be a small optimization and also allow us to
get rid of bitstring.*, which unfortunately got added as a result of this change.

Added standalone IPv6 address parsing files: ipv6text.*.  These are plain C and do not have
any dependencies, and could be split out, since they are independenctly useful and, unlike
all of our other utility routes (e.g. tier0, tier1, etc), actually worthy of being used
outside of Valve.
2019-01-02 18:27:20 -08:00
Fletcher Dunn 145199aee1 Integrate end-to-end stats tracking acks with SNP data acks.
This not only removes some redundancy, but also is a step towards rejecting duplicate sequence numbers earlier. (#20)

Also rework how hosted dedicated servers are configured, but that is not relevant to the opensource version of this code.
2018-09-10 11:15:28 -07:00