By: Arshad Ali | Updated: 2011-03-08 | Comments (2) | Related: More > SQL Server Configurations
I know that SQL Server and its clients interact with each other using different Net-Libraries or network protocols. But what are these Net-Libraries that SQL Server uses and how do each of these differ from the others. Also, in which scenario is one preferred over the others?
SQL Server provides different Net-Libraries, known as Dynamic-Link Library (DLL), to let clients communicate with SQL Server using different network protocols. These Net-Libraries specify which networking protocols to use while exchanging data back and forth between SQL Server and the clients. SQL Server provides Net-Libraries for almost all the commonly used networking protocols namely TCP/IP, Named Pipes, Shared Memory, etc... These Net-Libraries transparently send the requests from the client to SQL Server and return responses back from SQL Server to the clients.
Depending on what Net-Libraries you have enabled on the SQL Server, it starts listeners for these Net-Libraries. You can configure SQL Server to listen simultaneously on any combination of Net-Libraries. In other words, when the net-library listener on the server receives the TDS (Tabular Data Stream which is the format in which client requests are broken/formatted before sending it to the server as well as server responses broken/formatted before sending it back to clients) packets from the network, it reassembles them into original client requests and passes it up for processing. Please note each specific type of SQL Server Net Library listener will listen for the client requests if they are coming from the same type of Net Library (a matching pair of Net-Libraries must be enabled on both SQL Server and clients) and a connection from the client can be done using a single protocol only. For example, if the client sends the request to SQL Server using TCP/IP then on the server only the TCP/IP Net Library listener will pick up this request. Also, SQL Server will use the same network stack, over which the request was received, to send the response back to the client.
These are the different Net-Library options that are available:
When you have a client which is on the same physical machine as your SQL Server, you can use this simplest net library which provides faster communication than other Net-Libraries as it bypasses the physical network stack. The reason is, it uses the Windows Shared Memory feature to communicate between SQL Server and the client. You might use this Net-Library while troubleshooting if other Net-Libraries are not working properly. This Net-Library is by default enabled and used when you specify either a period or (local) as your machine name or localhost or machine name or by prefixing machine\instance name with lpc: when connecting to a SQL Server instance, you can find more details here.
TCP/IP (Transmission Control Protocol/Internet Protocol) is the default protocol on the clients running on the Windows platform. It allows communication across interconnected networks of computers with diverse hardware and operating systems. TCP/IP is considered as the first choice after Shared Memory, because of its inherent network traffic routing standards and advanced security features.
Named Pipes protocol uses a part of memory of one process to store/pass the information to another process, it means the output of one process becomes the input for another process. The other process could be either on the local machine or could be on a remote machine (networked machine). This protocol is used in fast local area networks for better performance.
VIA stands for Virtual Interface Adaptor. This protocol works with VIA hardware. Please refrain from using this protocol in your newer development as it has been deprecated and will be removed in future releases of SQL Server.
Normally TCP/IP is the preferred protocol in a slow LAN, WAN or dial up network whereas Named Pipes is more considerable in fast local area networks, to learn more about these differences click here.
The script provided in script #1 below gives the details about existing connections like when the connection was established and what protocol is being used by that particular connection.
SELECT connection_id, connect_time, net_transport, net_packet_size, client_net_address
You use SQL Server Configuration Manager to configure the client net libraries as well as server net libraries. As shown in the image below, go to SQL Native Client Configuration (on SQL Server 2008 and R2) and specify a default Net-Library for all the connections being made by this client or specify a specific Net-Library to connect to a specific SQL Server instance:
Likewise you can use SQL Server Configuration Manager to configure server net libraries as well. As shown in the image below, go to SQL Server Network Configuration (on SQL Server 2008 and R2), choose the specific instance name for which you want to configure Net-Libraries and then enable or disable the Net-Libraries (network protocols) on which this particular SQL Server instance will listen for incoming requests.
- SQL Server needs to be restarted to enable or disable a protocol.
- In failover clustered environments only TCP/IP and Named Pipes network libraries are supported.
- Once you have installed SQL Server native client on your client machine you are ready to connect to your SQL Server. By default all protocols except VIA (its deprecated and should not be used in newer development) are enabled on the client, and connections are attempted in the following protocol order: shared memory, TCP/IP, named pipes.
- After enabling or disabling protocols, SQL Server must be restarted for the changes to take effect.
- Review Choosing a Network Protocol article on msdn
- Review tip Network communications mechanisms for SQL Server
- Review tip Overview of the SQL Server Browser service
Last Updated: 2011-03-08
About the author
View all my tips