ms-tds protocol and test suite - microsoft · ms-tds protocol and test suite introduction baoming...

32

Upload: others

Post on 20-May-2020

20 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: MS-TDS Protocol and Test Suite - Microsoft · MS-TDS Protocol and Test Suite Introduction Baoming Yu SQL OIPI Test Development Team. Agenda TDS Introduction Transport Layers Typical
Page 2: MS-TDS Protocol and Test Suite - Microsoft · MS-TDS Protocol and Test Suite Introduction Baoming Yu SQL OIPI Test Development Team. Agenda TDS Introduction Transport Layers Typical

MS-TDS Protocol and Test Suite Introduction

Baoming Yu

SQL OIPI Test Development Team

Page 3: MS-TDS Protocol and Test Suite - Microsoft · MS-TDS Protocol and Test Suite Introduction Baoming Yu SQL OIPI Test Development Team. Agenda TDS Introduction Transport Layers Typical

Agenda

TDS Introduction

Transport Layers

Typical Message Sequence

Typical Protocol Objects

Test Suite Overview

Test Suite Architecture

Resource

Page 4: MS-TDS Protocol and Test Suite - Microsoft · MS-TDS Protocol and Test Suite Introduction Baoming Yu SQL OIPI Test Development Team. Agenda TDS Introduction Transport Layers Typical

What is TDS?The Tabular Data Stream (TDS) protocol is an application layer request/response protocol that facilitates interaction with a database server and provides for the following:

✓ Authentication and channel encryption negotiation.

✓ Specification of requests in SQL (including Bulk Insert).

✓ Invocation of a stored procedure or user-defined function,

also known as a remote procedure call (RPC).

✓ The return of data.

✓ Transaction manager requests.

Page 5: MS-TDS Protocol and Test Suite - Microsoft · MS-TDS Protocol and Test Suite Introduction Baoming Yu SQL OIPI Test Development Team. Agenda TDS Introduction Transport Layers Typical

How does TDS work?

Disco

nn

ect

Time Line

* N

Page 6: MS-TDS Protocol and Test Suite - Microsoft · MS-TDS Protocol and Test Suite Introduction Baoming Yu SQL OIPI Test Development Team. Agenda TDS Introduction Transport Layers Typical

Agenda

TDS Introduction

Transport Layers

Typical Message Sequence

Typical Protocol Objects

Test Suite Overview

Test Suite Architecture

Resource

Page 7: MS-TDS Protocol and Test Suite - Microsoft · MS-TDS Protocol and Test Suite Introduction Baoming Yu SQL OIPI Test Development Team. Agenda TDS Introduction Transport Layers Typical

The TDS protocol does not prescribe a specific underlying transport protocol to use on the Internet or on other networks. TDS only presumes a reliable transport that guarantees in-sequence delivery of data.

Transport Layers

The chosen transport can be either stream-oriented or message-oriented. If a message-

oriented transport is used, any TDS packet sent from a TDS client to a TDS server MUST be

contained within a single transport data unit.

The current version of the TDS protocol has implementations over the following transports:

✓ TCP [RFC793].

✓ A reliable transport over the Virtual Interface Architecture (VIA) interface [VIA2002].

✓ Named Pipes [MSDN-NP].

✓ Shared memory [MSDN-TDSENDPT].

Page 8: MS-TDS Protocol and Test Suite - Microsoft · MS-TDS Protocol and Test Suite Introduction Baoming Yu SQL OIPI Test Development Team. Agenda TDS Introduction Transport Layers Typical

Transport LayersTransport LayersOptionally, the TDS protocol has implementations for the following two protocols on top of the preceding transports:

✓ Transport Layer Security (TLS)

[RFC2246]/Secure Socket Layer (SSL), in

case TLS/SSL encryption is negotiated.

✓ Session Multiplex Protocol (SMP) [MC-

SMP], in case the Multiple Active Result

Sets (MARS) feature [MSDN-MARS] is

requested.

TDS

Network Transport(TCP/IP)

Page 9: MS-TDS Protocol and Test Suite - Microsoft · MS-TDS Protocol and Test Suite Introduction Baoming Yu SQL OIPI Test Development Team. Agenda TDS Introduction Transport Layers Typical

Demo

FOR MARS

Page 10: MS-TDS Protocol and Test Suite - Microsoft · MS-TDS Protocol and Test Suite Introduction Baoming Yu SQL OIPI Test Development Team. Agenda TDS Introduction Transport Layers Typical

Agenda

TDS Introduction

Transport Layers

Typical Message Sequence

Typical Protocol Objects

Test Suite Overview

Test Suite Architecture

Resource

Page 11: MS-TDS Protocol and Test Suite - Microsoft · MS-TDS Protocol and Test Suite Introduction Baoming Yu SQL OIPI Test Development Team. Agenda TDS Introduction Transport Layers Typical

Disco

nn

ect

* N

Page 12: MS-TDS Protocol and Test Suite - Microsoft · MS-TDS Protocol and Test Suite Introduction Baoming Yu SQL OIPI Test Development Team. Agenda TDS Introduction Transport Layers Typical

TLS

/SSL

Tra

nsp

ort

Lay

er T

LS/S

SL T

ransp

ort Laye

r

Typical Message Sequence (Pre-login)

Created connection successfully (Pre-login state)

Initial Pre-Login Request with ENCRYPTION_ON

Initial Pre-Login Response with ENCRYPTION_ON

Login state

TLS Exchange 1 Request

TLS Exchange 1 Response

TLS Exchange 2 Request

TLS Exchange 2 Response

Page 13: MS-TDS Protocol and Test Suite - Microsoft · MS-TDS Protocol and Test Suite Introduction Baoming Yu SQL OIPI Test Development Team. Agenda TDS Introduction Transport Layers Typical

TLS Handshakes

• Client Hello

• Client Key Exchange• Change Cipher Spec• Client Finished Message• …

• Server Hello• Server Certificate• Server Hello Done• …

• Change Cipher Spec• Server Finished Message

Page 14: MS-TDS Protocol and Test Suite - Microsoft · MS-TDS Protocol and Test Suite Introduction Baoming Yu SQL OIPI Test Development Team. Agenda TDS Introduction Transport Layers Typical

Typical Message Sequence (Login State)

Created connection successfully (Pre-login state)

Login7 Request with SPNEGO Exchange 1

SPNEGO Exchange 1 Response

SPNEGO Exchange 2 Request

Login7 Response (LOGINACK)

Post-Login Success State

Page 15: MS-TDS Protocol and Test Suite - Microsoft · MS-TDS Protocol and Test Suite Introduction Baoming Yu SQL OIPI Test Development Team. Agenda TDS Introduction Transport Layers Typical

Disco

nn

ect

* N

Page 16: MS-TDS Protocol and Test Suite - Microsoft · MS-TDS Protocol and Test Suite Introduction Baoming Yu SQL OIPI Test Development Team. Agenda TDS Introduction Transport Layers Typical

Typical Message Sequence (Post-Login Success)

Post-Login Success State

(Server is now ready to accept command from client)

SQL Command Request

Table Response

SQL Command Request

Table Response with attention acknowledgement

Attention Request

Post-Login Success State

(Server is now ready to accept command from client)

Page 17: MS-TDS Protocol and Test Suite - Microsoft · MS-TDS Protocol and Test Suite Introduction Baoming Yu SQL OIPI Test Development Team. Agenda TDS Introduction Transport Layers Typical

Typical Message Sequence (Post-Login Success)Post-Login Success State

(Server is now ready to accept command from client)

Remote Procedure Call Request

Table Response

Remote Procedure Call Request

Table Response with attention acknowledgement

Attention Request

Post-Login Success State

(Server is now ready to accept command from client)

Page 18: MS-TDS Protocol and Test Suite - Microsoft · MS-TDS Protocol and Test Suite Introduction Baoming Yu SQL OIPI Test Development Team. Agenda TDS Introduction Transport Layers Typical

Typical Message Sequence (Post-Login Success)Post-Login Success State

(Server is now ready to accept command from client)

Transaction Manager Request

Table Response

Transaction Manager Request

Table Response with attention acknowledgement

Attention Request

Post-Login Success State

(Server is now ready to accept command from client)

Page 19: MS-TDS Protocol and Test Suite - Microsoft · MS-TDS Protocol and Test Suite Introduction Baoming Yu SQL OIPI Test Development Team. Agenda TDS Introduction Transport Layers Typical

Typical Message Sequence (Post-Login Success)Post-Login Success State

(Server is now ready to accept command from client)

SQL Command with Insert Bulk

Table Response

SQL Command with Binary Data (Bulk Load Data)

Table Response

Post-Login Success State

(Server is now ready to accept command from client)

SQL Command with Insert Bulk

Table Response

SQL Command with Binary Data (Bulk Load Data)

Table Response with attention acknowledgement

Attention Request

Page 20: MS-TDS Protocol and Test Suite - Microsoft · MS-TDS Protocol and Test Suite Introduction Baoming Yu SQL OIPI Test Development Team. Agenda TDS Introduction Transport Layers Typical

Demo

FOR BULK INSERT

Page 21: MS-TDS Protocol and Test Suite - Microsoft · MS-TDS Protocol and Test Suite Introduction Baoming Yu SQL OIPI Test Development Team. Agenda TDS Introduction Transport Layers Typical

Agenda

TDS Introduction

Transport Layers

Typical Message Sequence

Typical Protocol Objects

Test Suite Overview

Test Suite Architecture

Resource

Page 22: MS-TDS Protocol and Test Suite - Microsoft · MS-TDS Protocol and Test Suite Introduction Baoming Yu SQL OIPI Test Development Team. Agenda TDS Introduction Transport Layers Typical

Typical Protocol Objects

LOGIN7: Defines the authentication rules for use between client and server.

• Packet Header type 0x10.• The length of a LOGIN7 stream

MUST NOT be longer than 128K-1(byte) bytes.

• …

Page 23: MS-TDS Protocol and Test Suite - Microsoft · MS-TDS Protocol and Test Suite Introduction Baoming Yu SQL OIPI Test Development Team. Agenda TDS Introduction Transport Layers Typical

LOGINACK: Used to send a response to a login request (LOGIN7) to the client.

LOGINACK

The identifier of the stream LOGINACK

The total length of the stream LOGINACK

The interface type accepted by server

The TDS version used by server side

The server name

The server version number

Typical Protocol Objects

Page 24: MS-TDS Protocol and Test Suite - Microsoft · MS-TDS Protocol and Test Suite Introduction Baoming Yu SQL OIPI Test Development Team. Agenda TDS Introduction Transport Layers Typical

Agenda

TDS Introduction

Transport Layers

Typical Message Sequence

Typical Protocol Objects

Test Suite Overview

Test Suite Architecture

Resource

Page 25: MS-TDS Protocol and Test Suite - Microsoft · MS-TDS Protocol and Test Suite Introduction Baoming Yu SQL OIPI Test Development Team. Agenda TDS Introduction Transport Layers Typical

Test Suite Production Workflow

Test Suite(Simulates protocol client)

Requirement SpecificationOpen Specification

Page 26: MS-TDS Protocol and Test Suite - Microsoft · MS-TDS Protocol and Test Suite Introduction Baoming Yu SQL OIPI Test Development Team. Agenda TDS Introduction Transport Layers Typical

Agenda

TDS Introduction

Transport Layers

Typical Message Sequence

Typical Protocol Objects

Test Suite Overview

Test Suite Architecture

Resource

Page 27: MS-TDS Protocol and Test Suite - Microsoft · MS-TDS Protocol and Test Suite Introduction Baoming Yu SQL OIPI Test Development Team. Agenda TDS Introduction Transport Layers Typical

Test Suite Architecture

Test Case

Protocol Adapter

SUT Control Adapter

Transport Layer

Server

SUT

SQL Server

Client

Page 28: MS-TDS Protocol and Test Suite - Microsoft · MS-TDS Protocol and Test Suite Introduction Baoming Yu SQL OIPI Test Development Team. Agenda TDS Introduction Transport Layers Typical

Test Suite Architecture

Test Case

Protocol Adapter

SUT Control Adapter

Transport Layer

Server

SUT

SQL Server

Client

Page 29: MS-TDS Protocol and Test Suite - Microsoft · MS-TDS Protocol and Test Suite Introduction Baoming Yu SQL OIPI Test Development Team. Agenda TDS Introduction Transport Layers Typical

Agenda

TDS Introduction

Transport Layers

Typical Message Sequence

Typical Protocol Objects

Test Suite Overview

Test Suite Architecture

Resource

Page 30: MS-TDS Protocol and Test Suite - Microsoft · MS-TDS Protocol and Test Suite Introduction Baoming Yu SQL OIPI Test Development Team. Agenda TDS Introduction Transport Layers Typical

Resource

MS-TDS Protocol:

https://docs.microsoft.com/en-us/openspecs/windows_protocols/MS-

TDS/b46a581a-39de-4745-b076-ec4dbb7d13ec

TLS/SSL Details:

https://docs.microsoft.com/en-us/previous-versions/windows/it-

pro/windows-server-2003/cc785811(v=ws.10)

Named Pipes:

https://docs.microsoft.com/en-us/windows/desktop/ipc/named-pipes

Page 31: MS-TDS Protocol and Test Suite - Microsoft · MS-TDS Protocol and Test Suite Introduction Baoming Yu SQL OIPI Test Development Team. Agenda TDS Introduction Transport Layers Typical
Page 32: MS-TDS Protocol and Test Suite - Microsoft · MS-TDS Protocol and Test Suite Introduction Baoming Yu SQL OIPI Test Development Team. Agenda TDS Introduction Transport Layers Typical