Ejemplo n.º 1
0
        /**
         * handle the connection handshake:<br/>
         * <ul>
         * <li>set initial sequence number</li>
         * <li>send response handshake</li>
         * </ul>
         * @param handshake
         * @param peer
         * @throws IOException
         */
        protected void HandleHandShake(ConnectionHandshake handshake)
        {
            ConnectionHandshake responseHandshake = new ConnectionHandshake();
            //compare the packet size and choose minimun
            long clientBufferSize      = handshake.PacketSize;
            long myBufferSize          = datagramSize;
            long bufferSize            = Math.Min(clientBufferSize, myBufferSize);
            long initialSequenceNumber = handshake.InitialSeqNo;

            this.initialSequenceNumber = initialSequenceNumber;
            this.DatagramSize          = (int)bufferSize;
            // setDatagramSize((int) bufferSize);
            responseHandshake.PacketSize     = bufferSize;
            responseHandshake.UdtVersion     = 4;
            responseHandshake.InitialSeqNo   = initialSequenceNumber;
            responseHandshake.ConnectionType = -1;
            responseHandshake.MaxFlowWndSize = handshake.MaxFlowWndSize;
            //tell peer what the socket ID on this side is
            responseHandshake.SocketID      = mySocketID;
            responseHandshake.DestinationID = this.destination.SocketID;
            //cd 2018-08-28
            if (this.cookie == 0)
            {
                this.cookie = CreateCookie();
            }
            responseHandshake.Cookie = cookie;

            responseHandshake.SetSession(this);
            FlashLogger.Info("Sending reply " + responseHandshake);
            endPoint.DoSend(responseHandshake);
        }
Ejemplo n.º 2
0
        //2nd handshake for connect
        protected void SendConfirmation(ConnectionHandshake hs)
        {
            ConnectionHandshake handshake = new ConnectionHandshake();

            handshake.ConnectionType = -1;
            handshake.SocketID       = ConnectionHandshake.SOCKET_TYPE_DGRAM;
            handshake.InitialSeqNo   = hs.InitialSeqNo;
            handshake.PacketSize     = hs.PacketSize;
            handshake.SocketID       = mySocketID;
            handshake.MaxFlowWndSize = flowWindowSize;
            //cd 2018-08-28
            handshake.Cookie = hs.Cookie;
            handshake.PeerIP = hs.PeerIP;
            //
            handshake.SetSession(this);
            FlashLogger.Info("Sending confirmation " + handshake);
            endPoint.DoSend(handshake);
        }
Ejemplo n.º 3
0
        //handshake for connect
        protected void SendHandShake()
        {
            ConnectionHandshake handshake = new ConnectionHandshake();

            handshake.ConnectionType = ConnectionHandshake.CONNECTION_TYPE_REGULAR;
            handshake.SocketType     = ConnectionHandshake.SOCKET_TYPE_DGRAM;
            long initialSequenceNo = SequenceNumber.Random();

            initialSequenceNumber    = initialSequenceNo;
            handshake.InitialSeqNo   = initialSequenceNo;
            handshake.PacketSize     = datagramSize;
            handshake.SocketID       = mySocketID;
            handshake.MaxFlowWndSize = flowWindowSize;
            //cd 2018-08-28
            handshake.SetPeerIP(this.endPoint.GetLocalAddress().Address.ToString());
            handshake.SetSession(this);
            FlashLogger.Info("Sending " + handshake);
            endPoint.DoSend(handshake);
            connectNum++;
        }