SpinQuic Explicit ALPN Improvements
@@ -761,7 +761,9 @@ main(int argc, char **argv)
Settings.Ports = std::vector<uint16_t>({dstPort});
}
TryGetValue(argc, argv, "target", &Settings.ServerName);
- TryGetValue(argc, argv, "alpn", &Settings.AlpnPrefix);
+ if (TryGetValue(argc, argv, "alpn", &Settings.AlpnPrefix)) {
+ SessionCount = 1; // Default session count to 1 if ALPN explicitly specified.
+ }
TryGetValue(argc, argv, "sessions", &SessionCount);
}
@@ -775,7 +777,6 @@ main(int argc, char **argv)
for (uint32_t i = 0; i < RepeatCount; i++) {
-
for (size_t i = 0; i < BufferCount; ++i) {
Buffers[i].Length = MaxBufferSizes[i]; // TODO - Randomize?
Buffers[i].Buffer = (uint8_t*)malloc(Buffers[i].Length);
@@ -800,6 +801,21 @@ main(int argc, char **argv)
const QUIC_REGISTRATION_CONFIG RegConfig = { "spinquic", QUIC_EXECUTION_PROFILE_LOW_LATENCY };
EXIT_ON_FAILURE(MsQuic->RegistrationOpen(&RegConfig, &Registration));
+ if (SessionCount == 1) {
+ QUIC_BUFFER AlpnBuffer;
+ AlpnBuffer.Length = (uint32_t)strlen(Settings.AlpnPrefix);
+ AlpnBuffer.Buffer = (uint8_t*)Settings.AlpnPrefix;
+
+ HQUIC Session;
+ EXIT_ON_FAILURE(MsQuic->SessionOpen(Registration, &AlpnBuffer, 1, nullptr, &Session));
+ Sessions.push_back(Session);
+
+ // Configure Session
+ auto PeerStreamCount = GetRandom((uint16_t)10);
+ EXIT_ON_FAILURE(MsQuic->SetParam(Session, QUIC_PARAM_LEVEL_SESSION, QUIC_PARAM_SESSION_PEER_BIDI_STREAM_COUNT, sizeof(PeerStreamCount), &PeerStreamCount));
+ EXIT_ON_FAILURE(MsQuic->SetParam(Session, QUIC_PARAM_LEVEL_SESSION, QUIC_PARAM_SESSION_PEER_UNIDI_STREAM_COUNT, sizeof(PeerStreamCount), &PeerStreamCount));
+
+ } else {
QUIC_BUFFER AlpnBuffer;
AlpnBuffer.Length = (uint32_t)strlen(Settings.AlpnPrefix) + 1; // You can't have more than 2^8 SessionCount. :)
AlpnBuffer.Buffer = (uint8_t*)malloc(AlpnBuffer.Length);
@@ -821,6 +837,7 @@ main(int argc, char **argv)
}
free(AlpnBuffer.Buffer);
+ }
QUIC_THREAD Threads[2];
QUIC_THREAD_CONFIG Config = { 0 };
