From beb6383e72f25db6d4fdf94525e132a49b634c95 Mon Sep 17 00:00:00 2001 From: xiongguangjie Date: Sat, 27 Aug 2022 12:46:35 +0800 Subject: [PATCH] optimize srt handle shake --- srt/SrtTransport.cpp | 45 ++++++++++++++++++++++++++++++++++++++------ srt/SrtTransport.hpp | 2 ++ 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/srt/SrtTransport.cpp b/srt/SrtTransport.cpp index 2d75fc73..3c663055 100644 --- a/srt/SrtTransport.cpp +++ b/srt/SrtTransport.cpp @@ -116,14 +116,41 @@ void SrtTransport::inputSockData(uint8_t *buf, int len, struct sockaddr_storage } } } - +bool SrtTransport::isSameCon(HandshakePacket &pkt) { + if (_handleshake_res) { + if (_handleshake_res->handshake_type == HandshakePacket::HS_TYPE_INDUCTION) { + if (pkt.srt_socket_id == _handleshake_res->dst_socket_id + && pkt.initial_packet_sequence_number == _init_seq_number) { + return true; + } + // TraceL << getIdentifier() << " new client from same udp connection"; + return false; + } else if (_handleshake_res->handshake_type == HandshakePacket::HS_TYPE_CONCLUSION) { + if (pkt.srt_socket_id == _handleshake_res->dst_socket_id && _sync_cookie == pkt.syn_cookie) { + return true; + } + // TraceL << getIdentifier() << " new client from new same udp connection "; + return false; + } else { + WarnL << "not reach this"; + } + return false; + } + return true; +} void SrtTransport::handleHandshakeInduction(HandshakePacket &pkt, struct sockaddr_storage *addr) { // Induction Phase - TraceL << getIdentifier() << " Induction Phase "; if (_handleshake_res) { - TraceL << getIdentifier() << " Induction handle repeate "; - sendControlPacket(_handleshake_res, true); + if(isSameCon(pkt)){ + TraceL << getIdentifier() <<" Induction repeate "<