mirror of
https://github.com/ValveSoftware/GameNetworkingSockets.git
synced 2026-05-29 16:20:34 +00:00
Collapse ProcessPlainTextDataChunk and SNP_RecvDataChunk.
Plumb through the transport that received the packet, and pass it to new virtual method ProcessSNPPing. I'll need this to be able to track end-to-end ping per transport separately.
This commit is contained in:
@@ -1940,22 +1940,6 @@ int64 CSteamNetworkConnectionBase::DecryptDataChunk( uint16 nWireSeqNum, int cbP
|
||||
return nFullSequenceNumber;
|
||||
}
|
||||
|
||||
bool CSteamNetworkConnectionBase::ProcessPlainTextDataChunk( int64 nFullSequenceNumber, const void *pDecrypted, uint32 cbDecrypted, int usecTimeSinceLast, SteamNetworkingMicroseconds usecNow )
|
||||
{
|
||||
|
||||
// Pass on to reassembly/reliability layer. It may instruct us to act like we never received this
|
||||
// packet
|
||||
if ( !SNP_RecvDataChunk( nFullSequenceNumber, pDecrypted, cbDecrypted, usecNow ) )
|
||||
{
|
||||
SpewDebug( "[%s] discarding pkt %lld\n", GetDescription(), (long long)nFullSequenceNumber );
|
||||
return false;
|
||||
}
|
||||
|
||||
// Packet is OK. Track end-to-end flow.
|
||||
m_statsEndToEnd.TrackProcessSequencedPacket( nFullSequenceNumber, usecNow, usecTimeSinceLast );
|
||||
return true;
|
||||
}
|
||||
|
||||
EResult CSteamNetworkConnectionBase::APIAcceptConnection()
|
||||
{
|
||||
// Must be in in state ready to be accepted
|
||||
@@ -2807,6 +2791,11 @@ void CSteamNetworkConnectionBase::ThinkConnection( SteamNetworkingMicroseconds u
|
||||
{
|
||||
}
|
||||
|
||||
void CSteamNetworkConnectionBase::ProcessSNPPing( int64 nPktNum, CConnectionTransport *pTransport, int msPing, SteamNetworkingMicroseconds usecNow )
|
||||
{
|
||||
m_statsEndToEnd.m_ping.ReceivedPing( msPing, usecNow );
|
||||
}
|
||||
|
||||
SteamNetworkingMicroseconds CSteamNetworkConnectionBase::ThinkConnection_FindingRoute( SteamNetworkingMicroseconds usecNow )
|
||||
{
|
||||
return k_nThinkTime_Never;
|
||||
|
||||
@@ -408,7 +408,7 @@ public:
|
||||
int64 DecryptDataChunk( uint16 nWireSeqNum, int cbPacketSize, const void *pChunk, int cbChunk, void *&pDecrypted, uint32 &cbDecrypted, SteamNetworkingMicroseconds usecNow );
|
||||
|
||||
/// Process a decrypted data chunk
|
||||
bool ProcessPlainTextDataChunk( int64 nFullSequenceNumber, const void *pDecrypted, uint32 cbDecrypted, int usecTimeSinceLast, SteamNetworkingMicroseconds usecNow );
|
||||
bool ProcessPlainTextDataChunk( int64 nPktNum, const void *pPlainText, int cbPlainText, int usecTimeSinceLast, CConnectionTransport *pTransport, SteamNetworkingMicroseconds usecNow );
|
||||
|
||||
/// Called when we receive an (end-to-end) packet with a sequence number
|
||||
bool RecvNonDataSequencedPacket( int64 nPktNum, SteamNetworkingMicroseconds usecNow );
|
||||
@@ -632,7 +632,6 @@ protected:
|
||||
SteamNetworkingMicroseconds SNP_GetNextThinkTime( SteamNetworkingMicroseconds usecNow );
|
||||
SteamNetworkingMicroseconds SNP_TimeWhenWantToSendNextPacket() const;
|
||||
void SNP_PrepareFeedback( SteamNetworkingMicroseconds usecNow );
|
||||
bool SNP_RecvDataChunk( int64 nPktNum, const void *pChunk, int cbChunk, SteamNetworkingMicroseconds usecNow );
|
||||
void SNP_ReceiveUnreliableSegment( int64 nMsgNum, int nOffset, const void *pSegmentData, int cbSegmentSize, bool bLastSegmentInMessage, SteamNetworkingMicroseconds usecNow );
|
||||
bool SNP_ReceiveReliableSegment( int64 nPktNum, int64 nSegBegin, const uint8 *pSegmentData, int cbSegmentSize, SteamNetworkingMicroseconds usecNow );
|
||||
int SNP_ClampSendRate();
|
||||
@@ -654,6 +653,9 @@ protected:
|
||||
SSNPSenderState m_senderState;
|
||||
SSNPReceiverState m_receiverState;
|
||||
|
||||
/// Called from SNP layer when it decodes a packet that serves as a ping measurement
|
||||
virtual void ProcessSNPPing( int64 nPktNum, CConnectionTransport *pTransport, int msPing, SteamNetworkingMicroseconds usecNow );
|
||||
|
||||
private:
|
||||
|
||||
void SNP_GatherAckBlocks( SNPAckSerializerHelper &helper, SteamNetworkingMicroseconds usecNow );
|
||||
|
||||
@@ -469,7 +469,7 @@ EResult CSteamNetworkConnectionBase::SNP_FlushMessage( SteamNetworkingMicrosecon
|
||||
return k_EResultOK;
|
||||
}
|
||||
|
||||
bool CSteamNetworkConnectionBase::SNP_RecvDataChunk( int64 nPktNum, const void *pChunk, int cbChunk, SteamNetworkingMicroseconds usecNow )
|
||||
bool CSteamNetworkConnectionBase::ProcessPlainTextDataChunk( int64 nPktNum, const void *pPlainText, int cbPlainText, int usecTimeSinceLast, CConnectionTransport *pTransport, SteamNetworkingMicroseconds usecNow )
|
||||
{
|
||||
#define DECODE_ERROR( ... ) do { \
|
||||
ConnectionState_ProblemDetectedLocally( k_ESteamNetConnectionEnd_Misc_InternalError, __VA_ARGS__ ); \
|
||||
@@ -541,8 +541,8 @@ bool CSteamNetworkConnectionBase::SNP_RecvDataChunk( int64 nPktNum, const void *
|
||||
SpewType( nLogLevelPacketDecode, "[%s] decode pkt %lld\n", GetDescription(), (long long)nPktNum );
|
||||
|
||||
// Decode frames until we get to the end of the payload
|
||||
const byte *pDecode = (const byte *)pChunk;
|
||||
const byte *pEnd = pDecode + cbChunk;
|
||||
const byte *pDecode = (const byte *)pPlainText;
|
||||
const byte *pEnd = pDecode + cbPlainText;
|
||||
int64 nCurMsgNum = 0;
|
||||
int64 nDecodeReliablePos = 0;
|
||||
while ( pDecode < pEnd )
|
||||
@@ -875,8 +875,7 @@ bool CSteamNetworkConnectionBase::SNP_RecvDataChunk( int64 nPktNum, const void *
|
||||
// Clamp, if we have slop
|
||||
if ( msPing < 0 )
|
||||
msPing = 0;
|
||||
m_statsEndToEnd.m_ping.ReceivedPing( msPing, usecNow );
|
||||
// FIXME - should let transport know
|
||||
ProcessSNPPing( nPktNum, pTransport, msPing, usecNow );
|
||||
|
||||
// Spew
|
||||
SpewType( m_connectionConfig.m_LogLevel_AckRTT.Get(), "[%s] decode pkt %lld latest recv %lld delay %.1fms elapsed %.1fms ping %dms\n",
|
||||
@@ -903,7 +902,7 @@ bool CSteamNetworkConnectionBase::SNP_RecvDataChunk( int64 nPktNum, const void *
|
||||
// Decrease flush delay the more blocks they send us.
|
||||
// FIXME - This is not an optimal way to do this. Forcing us to
|
||||
// ack everything is not what we want to do. Instead, we should
|
||||
// use a seperate timer for when we need to flush out a stop_waiting
|
||||
// use a separate timer for when we need to flush out a stop_waiting
|
||||
// packet!
|
||||
SteamNetworkingMicroseconds usecDelay = 250*1000 / nBlocks;
|
||||
m_receiverState.QueueFlushAllAcks( usecNow + usecDelay );
|
||||
@@ -1076,7 +1075,15 @@ bool CSteamNetworkConnectionBase::SNP_RecvDataChunk( int64 nPktNum, const void *
|
||||
|
||||
// Update structures needed to populate our ACKs
|
||||
bool bScheduleAck = nDecodeReliablePos > 0;
|
||||
return SNP_RecordReceivedPktNum( nPktNum, usecNow, bScheduleAck );
|
||||
if ( !SNP_RecordReceivedPktNum( nPktNum, usecNow, bScheduleAck ) )
|
||||
{
|
||||
// Do NOT mark that we received this packet
|
||||
return false;
|
||||
}
|
||||
|
||||
// Packet is OK. Track end-to-end flow.
|
||||
m_statsEndToEnd.TrackProcessSequencedPacket( nPktNum, usecNow, usecTimeSinceLast );
|
||||
return true;
|
||||
|
||||
// Make sure these don't get used beyond where we intended them toget used
|
||||
#undef DECODE_ERROR
|
||||
|
||||
@@ -747,7 +747,7 @@ void CConnectionTransportUDPBase::Received_Data( const uint8 *pPkt, int cbPkt, S
|
||||
return;
|
||||
|
||||
// Process plaintext
|
||||
if ( !m_connection.ProcessPlainTextDataChunk( nFullSequenceNumber, pDecrypted, cbDecrypted, 0, usecNow ) )
|
||||
if ( !m_connection.ProcessPlainTextDataChunk( nFullSequenceNumber, pDecrypted, cbDecrypted, 0, this, usecNow ) )
|
||||
return;
|
||||
|
||||
// Process the stats, if any
|
||||
|
||||
Reference in New Issue
Block a user