<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Simone Greci’s blog</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/simgreci/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/simgreci/feed.xml</link>
    <description>Data Insights PFE but also a passionate rock climber and skier.</description>
    <lastBuildDate>Wed, 17 Apr 2019 04:12:09 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>SQLServer Resolution Protocol Packets Anatomy</title>
      <link>https://docs.microsoft.com/archive/blogs/simgreci/ssrp-packets-anatomy</link>
      <pubDate>Wed, 13 Jul 2016 18:55:49 GMT</pubDate>
      <dc:creator><![CDATA[Simone Greci PFE]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/simgreci/?p=115</guid>
      <description><![CDATA[SSRP (acronym for SQLServer Resolution Protocol) is a protocol defined by Microsoft and introduced...]]></description>
      <content:encoded><![CDATA[SSRP (acronym for SQLServer Resolution Protocol) is a protocol <a href="https://msdn.microsoft.com/en-us/library/cc219703.aspx" target="_blank">defined</a> by Microsoft and introduced long time ago with SQLServer 2000 to support multiple engine instances installations on the same server.

SQLServer client libraries leverages on SSRP to make easier find SQLServer in the network (using packet broadcasting/multicasting) and connect to a SQLServer Named or Clustered Istance endpoint trasparently.

SSRP is an application-layer protocol (<a href="https://en.wikipedia.org/wiki/OSI_model">OSI</a>'s stack Level 7) based on request/response UDP packets, 1434 port is assigned by <a href="https://www.iana.com/assignments/service-names-port-numbers/service-names-port-numbers.xhtml?search=1434" target="_blank">Internationl Standards</a>. It does not provide or support security, authentication and negotiation.

SSRP can be used to discover a single-istance SQLServer endpoint:

<img class="alignnone size-full wp-image-125" src="https://msdnshared.blob.core.windows.net/media/2016/07/image162.png" alt="image1" width="576" height="241" />

or multiple-istances SQLServer endpoints (broadcast/multicast):

<img class="alignnone size-full wp-image-135" src="https://msdnshared.blob.core.windows.net/media/2016/07/image210.png" alt="image2" width="563" height="306" />

SSRP communications are implemented by a client and a server: usually the client is a SQLServer client library like ADO.NET or JDBC and the server is a Database Server Discovery Service, commonly implemented in the SQLServer Broswer process (sqlbrowser.exe).
<h2>How it works SSRP?</h2>
It's quite straightforward: SQLServer Browser open a socket and listen on 1434 UDP port, clients send different types of UDP packets asking for SQLServer istances connection protocol information and the SQLBrowser reply or not with a specific UDP packet. SQLServer Browser read data about SQLServer istances configuration from registry hive.

Let's see what are the UDP packets allowed by SSRP and dissect them. My bisturi is <a href="https://www.microsoft.com/en-us/download/details.aspx?id=4865" target="_blank">Microsoft Network Monitor</a> that's able to understand and make human readable SSRP packets. Just set Windows Parser Profile active in the options menu:

<img class="alignnone size-full wp-image-236" src="https://msdnshared.blob.core.windows.net/media/2016/07/image412.png" alt="image4" width="447" height="499" />

Start a network trace, type ssrp on the filter and apply to catch only SSRP messages:

<img class="alignnone size-large wp-image-145" src="https://msdnshared.blob.core.windows.net/media/2016/07/image310-1024x342.png" alt="image3" width="1024" height="342" />

&nbsp;
<h3>Broadcast</h3>
Broadcast feature is used, for example, by SQLServer Management Studio to discover SQLServer istances on the network:

<img class="alignnone size-full wp-image-155" src="https://msdnshared.blob.core.windows.net/media/2016/07/image411.png" alt="image4" width="911" height="409" />

A 1 byte UDP packet <a href="https://msdn.microsoft.com/en-us/library/cc219743.aspx" target="_blank">CLNT_BCAST_EX</a> is broadcasted to 255.255.255.255 ipv4 address:

<img class="alignnone size-full wp-image-245" src="https://msdnshared.blob.core.windows.net/media/2016/07/image610.png" alt="image6" width="954" height="721" />

SQLServer Browser listening on 1434 UDP port catch this message and reply with a variable lenght <a href="https://msdn.microsoft.com/en-us/library/cc219748.aspx" target="_blank">SVR_RESP</a> message containing the list of available istances and and their network protocol connection information:

<img class="alignnone size-full wp-image-247" src="https://msdnshared.blob.core.windows.net/media/2016/07/image710.png" alt="image7" width="967" height="714" />

In the example above the response data contains only information about istance TCP/IP endpoint because is the only communication protocol configured on that istance, but SSRP support sending connection informations also for VIA (discontinued on 2012) and Named Pipes. Enabling Named Pipes on my SQLServer 2016 test istance the response data contained in the <a href="https://msdn.microsoft.com/en-us/library/cc219748.aspx">SVR_RESP</a> packet is slightly different:

<img class="alignnone size-full wp-image-295" src="https://msdnshared.blob.core.windows.net/media/2016/07/image811.png" alt="image81" width="949" height="725" />
<h3>Named Instance resolution</h3>
SSRP is behind the automatic resolution of TCP port for named istances and is widely used by all SQLServer client libraries. In the example below Management Studio is connecting to a named instance called <em>INST2016</em>:

<img class="alignnone size-full wp-image-315" src="https://msdnshared.blob.core.windows.net/media/2016/07/image1011.png" alt="image101" width="492" height="321" />

The client message involved in this mechanism is <a href="https://msdn.microsoft.com/en-us/library/cc219746.aspx" target="_blank">CLNT_UCAST_INST</a>. When a SQLServer client library try to open a connection to a named istance first send a variable lenght <a href="https://msdn.microsoft.com/en-us/library/cc219746.aspx" target="_blank">CLNT_UCAST_INST </a>message to resolve TCP port:

<img class="alignnone size-full wp-image-305" src="https://msdnshared.blob.core.windows.net/media/2016/07/image914.png" alt="image91" width="963" height="725" />

The SQLServer Browser reply always with a <a href="https://msdn.microsoft.com/en-us/library/cc219748.aspx" target="_blank">SVR_RESP</a> message and act with the same behavior explained before.
<h3>Named Istance and DAC</h3>
DAC is the acronym for Dedicated Administrator Console and it's configured to listen on 1434 TCP port for default SQLServer installations. SSRP support port resolution also for DAC with a couple of UDP packets. As documented on technet:

<em>"...the DAC avoids using a SQL Server Resolution Protocol (SSRP) request to the SQL Server Browser Service when connecting. It first connects over TCP port 1434. If that fails, it makes an SSRP call to get the port."</em>

This is the case when DAC is not listening on standard 1434 TCP port, from SQLServer Error Log:

<img class="alignnone size-full wp-image-316" src="https://msdnshared.blob.core.windows.net/media/2016/07/image1021.png" alt="image102" width="818" height="76" />

Connect using the admin prefix using SQLServer Management Studio:

<img class="alignnone size-full wp-image-325" src="https://msdnshared.blob.core.windows.net/media/2016/07/image1031.png" alt="image103" width="492" height="321" />

The client send a variable lenght <a href="https://msdn.microsoft.com/en-us/library/cc219744.aspx" target="_blank">CLNT_UCAST_DAC</a> message, containing the instance name:

<img class="alignnone size-full wp-image-335" src="https://msdnshared.blob.core.windows.net/media/2016/07/image1041.png" alt="image104" width="961" height="715" />

The SQLBrowser reply with a <a href="https://msdn.microsoft.com/en-us/library/cc219749.aspx" target="_blank">SVR_RES_DAC</a> message:

<img class="alignnone size-full wp-image-345" src="https://msdnshared.blob.core.windows.net/media/2016/07/image1051.png" alt="image105" width="962" height="728" />

The right DAC TCP port is inside the response data and of course match with the Error Log entry above.]]></content:encoded>
    </item>
    <item>
      <title>SQLServer 2016 AlwaysOn and new Log Transport behavior</title>
      <link>https://docs.microsoft.com/archive/blogs/simgreci/sqlserver-2016-alwayson-and-new-log-transport-behavior</link>
      <pubDate>Fri, 17 Jun 2016 16:32:17 GMT</pubDate>
      <dc:creator><![CDATA[Simone Greci PFE]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/simgreci/?p=45</guid>
      <description><![CDATA[Hello, my name is Simone Greci and I'm an Italian Premier Field Engineer on SQLServer. My first post...]]></description>
      <content:encoded><![CDATA[Hello, my name is Simone Greci and I'm an Italian Premier Field Engineer on SQLServer. My first post is about new AlwaysOn log transport behavior and related trace flags. Let's dig deeper.

A customer of mine request me to understand how much is transaction log transport compression ratio for the new SQLServer 2016, useful information if you want to size correctly your network between two replicas. Consider the following test environment:
<ul>
	<li>SQLServer 2016 RTM on Windows Server 2012 R2 (local Hyper-V lab).</li>
	<li>Availability Group configured in Synchronous Replication, Automatic Failover and Automatic Seeding.</li>
</ul>
I added a database to the Availability Group and made some tests with <a href="https://www.hammerdb.com" target="_blank">HammerDB</a>, an open source benchmark utility to simulate a consistent read/write workload based on TPC-C standard.

During the test I registered on PerfMon the following performance counter objects on the primary replica:
<ul>
	<li>Databases\<strong>Log Bytes Flushed/sec</strong></li>
	<li>Availability Replica\<strong>Bytes Sent to Replica/sec</strong></li>
</ul>
In my environment with SQLServer 2016 what I can see is that <em>Bytes Sent to Replica/sec </em>is basically the same as<em> Log Bytes Flushed/sec</em>, looks like no compression is done:

<img class="alignnone size-large wp-image-55" src="https://msdnshared.blob.core.windows.net/media/2016/06/pic11-1024x730.jpg" alt="pic1" width="1024" height="730" />

But according to this MSDN Blog <a href="https://blogs.msdn.microsoft.com/saponsqlserver/2013/04/24/sql-server-2012-alwayson-part-12-performance-aspects-and-performance-monitoring-ii/">article</a> (actually for SQLServer 2012):

<em>“... besides encrypting the data which goes over the network to secondary replicas, <strong>SQL server also compress the data sent to the replicas in order to reduce network bandwidth requirements</strong>. In our example case we saw the following values:</em>
<ul>
	<li><em>Bytes Sent to Replica/sec for one specific replica: 850KB/sec</em></li>
	<li><em>Log Bytes Flushed/sec for the only database in the AG: 1950KB/sec</em></li>
	<li><em>Means all in all we are looking into a compression rate of around 2.3”</em></li>
</ul>
The same test with HammerDB utility has been done also on SQLServer 2014 SP1 (12.0.4100.1) on Windows Server 2012 R2 and I got expected results:

<img class="alignnone size-large wp-image-65" src="https://msdnshared.blob.core.windows.net/media/2016/06/pic2-1024x733.jpg" alt="pic2" width="1024" height="733" />

With SQLServer 2014 compression is done on the log transport, Log Bytes flushed to transaction log are twice the Bytes sent to replicas. But why not on the new SQLServer version?

The reason for this difference is that defaults for AlwaysOn log transport compression are changed on SQLServer 2016:
<ol>
	<li>Log stream compression is disabled by default for Sync replicas to ensure sync replication does not slow down OLTP relative to standalone. Compression adds latency, hence off by default. Flip it by using -T9592.</li>
	<li>Log stream compression is enabled by default for Async replicas to reduce ingress\egress costs for geo replication so compression is enabled by default for async. Flip it by using -T1462.</li>
	<li>Compression is disabled by default for Automatic Seeding to reduce CPU usage on primary. Flip it by using -T9567.</li>
</ol>
New trace flags will be on MSDN soon, stay tuned.

&nbsp;

&nbsp;

&nbsp;]]></content:encoded>
    </item>
  </channel>
</rss>