mirror of
https://github.com/Devolutions/IronRDP.git
synced 2026-11-23 08:25:56 +00:00
36a848e085
## Summary - The Network Characteristics Byte Count store was incremented by the payload length alone, so every counted Bandwidth Measure message was reported 8 bytes short. - [MS-RDPBCGR] 3.2.5.14 says to increment it "by the value specified in the **payloadLength** field plus the size of the header fields (8 bytes)", on each Bandwidth Measure Payload and on the 0x002B Stop. 2.2.14.1.3 pins that 8 by requiring `headerLength` to be 0x08. - The Start and Stop arms now check the request type rather than matching every variant. ## Those two increments are the whole of the connect-time byte count Worth stating, because 3.2.5.14 also contains a rule that counts every byte received while a window is open, and it's easy to assume it applies here. It doesn't. That rule belongs to the 0x0014 and 0x0114 Starts, which are the reliable and lossy UDP variants. Connect-time is 0x1014, and its step list says only to clear the stores and start the timer. So on this path the Payload and Stop increments are the entire count, and no framing-layer accumulation is needed. ## Why the request-type check is required, not tidying 2.2.14.1.4 sets `headerLength` to 0x08 for the 0x002B Stop and 0x06 otherwise. A fixed 8-byte addend is therefore only correct once the type is known, which makes the check part of the byte-count fix rather than separate from it. It has two further effects that are worth having. A continuous-detection Start no longer opens a connect-time window, and a continuous Stop is no longer answered with a connect-time result on the main channel when 3.2.5.14 routes those to a multitransport channel under a different procedure. That procedure also requires a sequence-number correlation on the 0x0629 Stop which this phase does not track, so ignoring is the conservative response. This overlaps the automated reviewer's fifth finding on #1530, which suggested exactly this narrowing. I'd offered there to fold it into that PR or take it separately; the conditional header size settled it, since the byte count is wrong without it. ## This is deliberately not FreeRDP's arithmetic FreeRDP counts the whole PDU length at the framing layer, `bandwidthMeasureByteCount += length` in `libfreerdp/core/rdp.c` after `rdp_read_header`, for any window including connect-time, and then adds `payloadLength` again in `libfreerdp/core/autodetect.c` for the Payload and the Stop. On the connect-time path that counts the payload twice and adds framing bytes the spec doesn't ask for. I went with the spec rather than the reference here. The reported figure is an informational QoS hint and the server proceeds on receipt either way, so there's no interop cost to being correct. The divergence is called out in a comment at the helper so nobody later "fixes" it toward FreeRDP. ## Depends on #1530 Stacked. #1530 introduces the bandwidth window state (`connect_time_bw_started_at`, `connect_time_bw_bytes`) that this counts into; on master there's nothing to accumulate. The branch carries #1530's commits, so it builds and tests on its own, and the merge order is #1530 then this. Because it carries them, the diff shown here is cumulative. This pull request's own change is 3 files, +180/-21: `crates/ironrdp-connector/src/connection.rs`, `crates/ironrdp-connector/src/lib.rs` and one connector test. The size label is computed on the cumulative diff, so it counts #1530's four commits too. Raised by the automated reviewer on #1530, where the prescribed fix is the arithmetic used here. ## The reported byte count is measurement-gated Worth stating for consumers, because it is a deliberate deviation. 3.2.5.14 states the Bandwidth Measure Payload increment unconditionally. Here the Payload bytes are accumulated only while a window is open, which means a driver that reports no arrival times never counts them and its Results carry the Stop's own payload alone against the untimed floor. A full count paired with a `timeDelta` the client never measured yields a bandwidth figure that grows with whatever the server chose to send, so this under-reports rather than over-reports. The practical consequence is that a server acting on 3.3.5.14 will pick conservative bandwidth-dependent settings for such a client. Of the drivers in tree only the FFI connector is in that position. ## Breaking changes Two, both in `ironrdp-connector`, and `cargo semver-checks -p ironrdp-connector --baseline-rev master` reports exactly these two and nothing else: - `Sequence::step` takes a third parameter, `received_at: Option<MonotonicInstant>`. This breaks every external implementor and every caller of the trait. `step_no_input` keeps its signature and passes `None`. - `ClientConnector` gains two private fields, `connect_time_bw_started_at` and `connect_time_bw_bytes`, so the struct is no longer constructible by literal downstream. The clock stays in the driver because a sequence must not read one, which is what keeps the sans-I/O invariant intact. A defaulted trait method would avoid the signature break but would let an implementor override only the old entry point and silently never receive an arrival time, so the required parameter is the safer of the two. ## Validation - `cargo xtask check fmt/lints/tests/typos/locks` all pass on the pinned toolchain, plus `cargo xtask wasm check`, with `fuzz/` built before the lock check. - Four existing expectations move by exactly 8 per counted message: 3584 to 3608 (two Payloads and a Stop), 512 to 520 (one Stop), and two at 1536 to 1552 (a Payload and a Stop each), the second of which is the window-reset test #1530 added after this branch was first filed. A fifth, 4096 to 4104, went with the redundant test #1530 dropped in review. - Two tests added for the guards: continuous Start, Payload and Stop produce no reply and leave the phase running; and a connect-time Stop arriving after a continuous Start reports the untimed floor against its own payload alone, since the continuous Start opened no window. - Eleven connect-time auto-detect tests pass.
IronRDP FFI
Diplomat-based FFI for IronRDP.
Currently, only the .NET target is officially supported.
How to build
-
Install required tools:
cargo xtask ffi install- For .NET, note that
dotnetis also a requirement that you will need to install on your own.
- For .NET, note that
-
Build the shared library:
cargo xtask ffi build(alternatively, in release mode:cargo xtask ffi build --release) -
Build the bindings:
cargo xtask ffi bindings
At this point, you may build and run the examples for .NET:
dotnet run --project Devolutions.IronRdp.ConnectExampledotnet run --project Devolutions.IronRdp.AvaloniaExample