Exemple #1
0
        public void SmbdNegotiate_Redundancy()
        {
            const ushort CREDIT_REQUESTED  = 10;
            const uint   MAX_SEND_SIZE     = 1024;
            const uint   MAX_RECEIVE_SIZE  = 1024;
            const uint   MAX_FRAGMENT_SIZE = 131072;
            const int    NEGOTIATE_SIZE    = 512; // it is the size of receive size after server accept the connection

            BaseTestSite.Log.Add(LogEntryKind.TestStep, "Connect to server over RDMA.");
            NtStatus status = smbdAdapter.ConnectToServerOverRDMA();

            BaseTestSite.Assert.AreEqual <NtStatus>(status, NtStatus.STATUS_SUCCESS, "Status of SMBD connection is {0}.", status);

            BaseTestSite.Log.Add(LogEntryKind.TestStep, "Create SMBD Negotiate request.");
            SmbdNegotiateRequest request = new SmbdNegotiateRequest();

            request.MinVersion        = SmbdVersion.V1;
            request.MaxVersion        = SmbdVersion.V1;
            request.Reserved          = 0;
            request.CreditsRequested  = CREDIT_REQUESTED;
            request.PreferredSendSize = MAX_SEND_SIZE;
            request.MaxReceiveSize    = MAX_RECEIVE_SIZE;
            request.MaxFragmentedSize = MAX_FRAGMENT_SIZE;

            BaseTestSite.Log.Add(LogEntryKind.TestStep, "Add 492 redundancy bytes.");
            byte[] requestBytes = TypeMarshal.ToBytes <SmbdNegotiateRequest>(request);
            byte[] allbytes     = new byte[NEGOTIATE_SIZE];
            Array.Copy(requestBytes, allbytes, requestBytes.Length);

            // post receive
            status = smbdAdapter.ClientConnection.Endpoint.PostReceive(NEGOTIATE_SIZE);
            BaseTestSite.Assert.AreEqual <NtStatus>(status, NtStatus.STATUS_SUCCESS, "Status of Post Receive is {0}.", status);

            BaseTestSite.Log.Add(LogEntryKind.TestStep, "Send SMBD negotiate request.");
            status = smbdAdapter.SendDataOverRdma(allbytes);
            BaseTestSite.Assert.AreEqual <NtStatus>(status, NtStatus.STATUS_SUCCESS, "Status of Send SMBD negotiate is {0}.", status);

            BaseTestSite.Log.Add(LogEntryKind.TestStep, "Receive and verify NEGOTIATE response.");
            byte[] responseData;
            smbdAdapter.ReceiveDataOverRdma(
                TimeSpan.FromSeconds(SmbdConnection.ACTIVE_NEGOTIATION_TIMEOUT),
                out responseData);
            SmbdNegotiateResponse response = TypeMarshal.ToStruct <SmbdNegotiateResponse>(responseData);

            smbdAdapter.DisconnectRdma();

            NegotiateBasicChecker(
                response,
                CREDIT_REQUESTED,
                MAX_RECEIVE_SIZE,
                MAX_SEND_SIZE,
                MAX_FRAGMENT_SIZE);
        }