<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>NetIOC Archives - LucD notes</title>
	<atom:link href="https://www.lucd.info/tag/netioc/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.lucd.info/tag/netioc/</link>
	<description>My PowerShell ramblings</description>
	<lastBuildDate>Thu, 15 Dec 2011 21:21:35 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9</generator>

<image>
	<url>https://www.lucd.info/wp-content/uploads/2018/12/cropped-120px-Tibetan_Dharmacakra-32x32.png</url>
	<title>NetIOC Archives - LucD notes</title>
	<link>https://www.lucd.info/tag/netioc/</link>
	<width>32</width>
	<height>32</height>
</image> 
<atom:link rel="hub" href="https://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="https://pubsubhubbub.superfeedr.com"/><atom:link rel="hub" href="https://websubhub.com/hub"/>	<item>
		<title>vSphere 5 Top 10 &#8211; NetIOC</title>
		<link>https://www.lucd.info/2011/12/15/vsphere-5-top-10-netioc/</link>
					<comments>https://www.lucd.info/2011/12/15/vsphere-5-top-10-netioc/#respond</comments>
		
		<dc:creator><![CDATA[LucD]]></dc:creator>
		<pubDate>Thu, 15 Dec 2011 21:16:42 +0000</pubDate>
				<category><![CDATA[2011]]></category>
		<category><![CDATA[Dutch]]></category>
		<category><![CDATA[dvSwitch]]></category>
		<category><![CDATA[NetIOC]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[VMUG]]></category>
		<category><![CDATA[vSphere]]></category>
		<guid isPermaLink="false">http://www.lucd.info/?p=3747</guid>

					<description><![CDATA[Another post from our Dutch VMUG Event 2011 presentation. This time it&#8217;s about [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Another post from our <a href="https://vmug.nl/cms/index.php?option=com_content&amp;view=section&amp;layout=blog&amp;id=5&amp;Itemid=55" target="_blank">Dutch VMUG Event 2011 presentation</a>. This time it&#8217;s about number 5 in the Top-10, Network I/O Control. This feature allows <strong>user-defined network resource pools</strong> and end-to-end <strong>QoS</strong>.</p>
<p>Note that this feature requires <strong>distributed Switches</strong> (dvSwitch). In fact I could have also written this post in my <a href="https://www.lucd.info/tag/dvswitch/" target="_blank">dvSwitch series</a> with the title <strong>dvSwitch scripting – Part 10 – NetIOC</strong>.</p>
<h2><span id="more-3747"></span>The script</h2>
<p></p><pre class="urvanov-syntax-highlighter-plain-tag">function New-dvSwNetworkResourcePool{
&lt;#
.SYNOPSIS Create a user-defined network resource pool
.DESCRIPTION The function will create a user-defined
  resourcepool on a specific dvSwitch.
.NOTES  Author:  Luc Dekens
.PARAMETER dvSw
  The dvSwitch on which the user-defined network resource pool
  will be created.
.PARAMETER Name
  The name of the user-defined network resource pool.
.PARAMETER Description
  The description of the user-defined network resource pool.
.PARAMETER QoSTag
  The QoSTag that will be assigned to the user-defined
  network resource pool. A value from the range 0-7.
.PARAMETER Limit
  The QoSTag that will be assigned to the user-defined
  network resource pool. A value from the range 0-7.
.PARAMETER Shares
  The number of shares allocated. Can be &quot;low&quot;,&quot;normal&quot;,&quot;high&quot;
  or a number (a relative value compared with the shares value
  on other resource pools in case of contention)
.EXAMPLE
  PS&gt; New-dvSwNetworkResourcePool -dvSw $dvSw -Name &quot;NetPool1&quot; `
  PS&gt;&gt; -Description &quot;Dutch VMUG 2011&quot;
.EXAMPLE
  PS&gt; New-dvSwNetworkResourcePool -dvSw $dvSw -Name &quot;NetPool2&quot; `
  PS&gt;&gt; -Description &quot;Dutch VMUG 2011&quot; -Shares 75 -QoSTag 3
#&gt;
  param(
  [parameter(Position = 0, Mandatory = $true, ValueFromPipeline = $true)]
  [VMware.Vim.VmwareDistributedVirtualSwitch]$dvSw,
  [parameter(Position = 1, Mandatory = $true)]
  [string]$Name,
  [parameter(Position = 2)]
  [string]$Description,
  [string]$QoSTag,
  [long]$Limit = -1,
  [string]$Shares = &quot;normal&quot;
  )

  $spec = New-Object VMware.Vim.DVSNetworkResourcePoolConfigSpec
  $spec.Name = $Name
  $spec.Description = $Description
  $spec.Key = &quot;dummy&quot;
  $spec.allocationInfo = New-Object VMware.Vim.DVSNetworkResourcePoolAllocationInfo
  $spec.allocationInfo.Limit = $Limit
  $spec.allocationInfo.priorityTag = &amp;{if($QoSTag){[int]$QoSTag}}
  $spec.allocationInfo.Shares = New-Object VMware.Vim.SharesInfo
  if(&quot;high&quot;,&quot;low&quot;,&quot;normal&quot; -contains $Shares){
    $spec.allocationInfo.Shares.Level = $Shares
  }
  else{
    $spec.allocationInfo.Shares.Level = &quot;custom&quot;
    $spec.allocationInfo.Shares.Shares = [int]$Shares
  }

  $dvSw.AddNetworkResourcePool(@($spec))
}

function Remove-dvSwNetworkResourcePool{
&lt;#
.SYNOPSIS Remove a user-defined network resource pool
.DESCRIPTION The function will remove a user-defined
  resource pool from a specific dvSwitch.
.NOTES  Author:  Luc Dekens
.PARAMETER dvSw
  The dvSwitch on which the user-defined network resource pool
  shall be removed.
.PARAMETER Name
  The name of the user-defined network resource pool.
.EXAMPLE
  PS&gt; Remove-dvSwNetworkResourcePool -dvSw $dvSw -Name &quot;NetPool1&quot;
#&gt;
  param(
  [parameter(Position = 0, Mandatory = $true, ValueFromPipeline = $true)]
  [VMware.Vim.VmwareDistributedVirtualSwitch]$dvSw,
  [parameter(Position = 1, Mandatory = $true)]
  [string]$Name
  )

  $pool = $dvSw.NetworkResourcePool | where {$_.Name -eq $Name}
  if($pool){
    $dvSw.RemoveNetworkResourcePool($pool.Key)
  }
}

function Get-dvSwNetworkResourcePool{
&lt;#
.SYNOPSIS Retrieve user-defined network resource pool(s)
.DESCRIPTION The function return all or a specific set
  of user-defined network resource pools from a dvSwitch
.NOTES  Author:  Luc Dekens
.PARAMETER dvSw
  The dvSwitch from which the user-defined network resource pool
  shall be retrieved.
.PARAMETER Name
  The name of the user-defined network resource pool.
  If no name is specified, all user-defined network
  resource pools on the dvSwitch will be returned.
.EXAMPLE
  PS&gt; Get-dvSwNetworkResourcePool -dvSw $dvSw
.EXAMPLE
  PS&gt; Get-dvSwNetworkResourcePool -dvSw $dvSw -Name &quot;Net*&quot;
#&gt;
  param(
  [parameter(Position = 0, Mandatory = $true, ValueFromPipeline = $true)]
  [VMware.Vim.VmwareDistributedVirtualSwitch]$dvSw,
  [parameter(Position = 1)]
  [string]$Name = &quot;*&quot;
  )

  $dvSw.UpdateViewData()
  $dvSw.NetworkResourcePool | where {$_.Name -like $Name} | %{
    New-Object PSObject -Property @{
      Name = $_.Name
      Description = $_.Description
      Limit = $_.AllocationInfo.Limit
      QoSTag = &amp;{if($_.AllocationInfo.PriorityTag -eq 0){&quot;none&quot;}else{$_.AllocationInfo.PriorityTag}}
      Shares = &amp;{if($_.AllocationInfo.Shares.Level -eq &quot;custom&quot;){$_.AllocationInfo.Shares.Shares}else{$_.AllocationInfo.Shares.Level}}
    }
  }
}

function Set-dvSwSIOC{
&lt;#
.SYNOPSIS Enable/disable NetIOC on a dvSw
.DESCRIPTION The function will enable or disable
  I/O Control on a dvSwitch
.NOTES  Author:  Luc Dekens
.PARAMETER dvSw
  The dvSwitch on which I/O Control will be
  enabled/disabled
.PARAMETER Enabled
  A switch that allows control of I/O Control. When
  the switch is $True, IOC will be enabled. If $False
  IOC will be disabled
.EXAMPLE
  PS&gt; Set-dvSwSIOC -dvSw $dvSw -Enabled
#&gt;
  param(
  [parameter(Position = 0, Mandatory = $true, ValueFromPipeline = $true)]
  [VMware.Vim.VmwareDistributedVirtualSwitch]$dvSw,
  [parameter(Position = 1)]
  [switch]$Enabled
  )

  $dvSw.EnableNetworkResourceManagement($Enabled)
}

function Get-dvSwSIOC{
&lt;#
.SYNOPSIS Retrieve the IOC status
.DESCRIPTION Returns the status of IOC on a dvSwitch
.NOTES  Author:  Luc Dekens
.PARAMETER dvSw
  The dvSwitch from which the status of I/O Control will be
  returned
.EXAMPLE
  PS&gt; Get-dvSwSIOC -dvSw $dvSw -Enabled
#&gt;
  param(
  [parameter(Position = 0, Mandatory = $true, ValueFromPipeline = $true)]
  [VMware.Vim.VmwareDistributedVirtualSwitch]$dvSw
  )

  $dvSw.UpdateViewData()
  New-Object PSObject -Property @{
    Name = $dvSw.Name
    SIOCEnabled = $dvSw.Config.NetworkResourceManagementEnabled
  }
}</pre><p></p>
<h4>Annotations</h4>
<p><strong>Line 38</strong>: Although the QosTag is an [int], we use the [string] cast. Otherwise the absence of the parameter would set QosTag to 0, which is a valid 802.1p value.</p>
<p><strong>Line 38-40</strong>: The absence of these 3 parameters on a call to the function will create a user-defined network resource pool with the same settings as if the resource pool was created in the vSphere Client.</p>
<p><strong>Line 51-57</strong>: If the Shares parameter is not set to &#8220;normal&#8221;, &#8220;high&#8221; or &#8220;low&#8221;, it will be set to &#8220;custom&#8221; and the Shares value will be used as an [int] value.</p>
<p><strong>Line 80</strong>: The removal of a user-defined network resource pool requires the Name parameter to be set.</p>
<p><strong>Line 111</strong>: If no Name parameter is used, all the user-defined network resource pools on the dvSwitch will be returned.</p>
<p><strong>Line 114</strong>: To get the most recent data, the script refreshes the dvSwitch object.</p>
<p><strong>Line 120</strong>: This test will make sure, that the function returns the same values as displayed in the vSphere Client.</p>
<p><strong>Line 121</strong>: When the Shares level is &#8220;custom&#8221;, the [int] value of the share will be returned.</p>
<h2>Sample usage</h2>
<p>We start with an empty dvSwitch. The Get-dvSwitch function can be found in my <a href="https://www.lucd.info/2009/10/12/dvswitch-scripting-part-2-dvportgroup/" target="_blank">dvSwitch scripting – Part 2 – dvPortgroup</a> post.</p>
<p><a href="https://lucd.info/wp-content/uploads/2011/12/NETIOC-initial.png"><img fetchpriority="high" decoding="async" class="alignnone size-full wp-image-3754" title="NETIOC-initial" src="https://lucd.info/wp-content/uploads/2011/12/NETIOC-initial.png" alt="" width="490" height="196" srcset="https://www.lucd.info/wp-content/uploads/2011/12/NETIOC-initial.png 612w, https://www.lucd.info/wp-content/uploads/2011/12/NETIOC-initial-300x120.png 300w" sizes="(max-width: 490px) 100vw, 490px" /></a></p>
<p>First we get the dvSwitch and we get a list of the current network resource pools.</p>
<p></p><pre class="urvanov-syntax-highlighter-plain-tag">$dvSw = Get-dvSwitch -DatacenterName &quot;DC1&quot; -dvSwitchName &quot;dvSw1&quot;
Get-dvSwNetworkResourcePool -dvSw $dvSw | ft -AutoSize</pre><p></p>
<p>This will return the system network resource pools.</p>
<p><a href="https://lucd.info/wp-content/uploads/2011/12/NETIOC-respools-system-cli.png"><img decoding="async" class="alignnone size-full wp-image-3755" title="NETIOC-respools-system-cli" src="https://lucd.info/wp-content/uploads/2011/12/NETIOC-respools-system-cli.png" alt="" width="620" height="135" srcset="https://www.lucd.info/wp-content/uploads/2011/12/NETIOC-respools-system-cli.png 775w, https://www.lucd.info/wp-content/uploads/2011/12/NETIOC-respools-system-cli-300x65.png 300w" sizes="(max-width: 620px) 100vw, 620px" /></a></p>
<p>The same information as we can see in the vSphere Client under <strong>System network resource pools</strong>.</p>
<p>Note that NetIOC is <strong>not enabled</strong> by default.</p>
<p><a href="https://lucd.info/wp-content/uploads/2011/12/NETIOC-respools-system2.png"><img decoding="async" class="alignnone size-full wp-image-3758" title="NETIOC-respools-system" src="https://lucd.info/wp-content/uploads/2011/12/NETIOC-respools-system2.png" alt="" width="626" height="302" srcset="https://www.lucd.info/wp-content/uploads/2011/12/NETIOC-respools-system2.png 782w, https://www.lucd.info/wp-content/uploads/2011/12/NETIOC-respools-system2-300x145.png 300w" sizes="(max-width: 626px) 100vw, 626px" /></a></p>
<p>Next we create a number of user-defined network resource pools.</p>
<p></p><pre class="urvanov-syntax-highlighter-plain-tag">New-dvSwNetworkResourcePool -dvSw $dvSw -Name &quot;NetPool1&quot; -Description &quot;Dutch VMUG 2011&quot;
New-dvSwNetworkResourcePool -dvSw $dvSw -Name &quot;NetPool2&quot; -Description &quot;Dutch VMUG 2011&quot; -Shares 75 -QoSTag 3
New-dvSwNetworkResourcePool -dvSw $dvSw -Name &quot;NetPool3&quot; -Description &quot;Dutch VMUG 2011&quot; -Limit 4500
Get-dvSwNetworkResourcePool -dvSw $dvSw | ft -AutoSize</pre><p></p>
<p>The result shows the 3 newly created network resource pools.</p>
<p><a href="https://lucd.info/wp-content/uploads/2011/12/NETIOC-respools-user.png"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-3759" title="NETIOC-respools-user" src="https://lucd.info/wp-content/uploads/2011/12/NETIOC-respools-user.png" alt="" width="634" height="177" srcset="https://www.lucd.info/wp-content/uploads/2011/12/NETIOC-respools-user.png 793w, https://www.lucd.info/wp-content/uploads/2011/12/NETIOC-respools-user-300x83.png 300w" sizes="auto, (max-width: 634px) 100vw, 634px" /></a></p>
<p>And we see the same in the vSphere Client.</p>
<p><a href="https://lucd.info/wp-content/uploads/2011/12/NETIOC-respools-user-VC.png"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-3761" title="NETIOC-respools-user-VC" src="https://lucd.info/wp-content/uploads/2011/12/NETIOC-respools-user-VC.png" alt="" width="630" height="342" srcset="https://www.lucd.info/wp-content/uploads/2011/12/NETIOC-respools-user-VC.png 788w, https://www.lucd.info/wp-content/uploads/2011/12/NETIOC-respools-user-VC-300x162.png 300w" sizes="auto, (max-width: 630px) 100vw, 630px" /></a></p>
<p>As we noticed earlier, NetIOC is not enabled by default. Let&#8217;s display the current setting.</p>
<p></p><pre class="urvanov-syntax-highlighter-plain-tag">Get-dvSwSIOC -dvSw $dvSw | ft -AutoSize</pre><p></p>
<p><a href="https://lucd.info/wp-content/uploads/2011/12/NetIOC-disabled.png"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-3760" title="NetIOC-disabled" src="https://lucd.info/wp-content/uploads/2011/12/NetIOC-disabled.png" alt="" width="306" height="66" srcset="https://www.lucd.info/wp-content/uploads/2011/12/NetIOC-disabled.png 383w, https://www.lucd.info/wp-content/uploads/2011/12/NetIOC-disabled-300x65.png 300w" sizes="auto, (max-width: 306px) 100vw, 306px" /></a></p>
<p>We change the setting and retrieve the value again</p>
<p></p><pre class="urvanov-syntax-highlighter-plain-tag">Set-dvSwSIOC -dvSw $dvSw -Enabled
Get-dvSwSIOC -dvSw $dvSw | ft -AutoSize</pre><p></p>
<p>This gives</p>
<p><a href="https://lucd.info/wp-content/uploads/2011/12/NetIOC-enabled.png"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-3762" title="NetIOC-enabled" src="https://lucd.info/wp-content/uploads/2011/12/NetIOC-enabled.png" alt="" width="226" height="61" /></a></p>
<p>To conclude we will clean up the demo pools and disable NetIOC again.</p>
<p></p><pre class="urvanov-syntax-highlighter-plain-tag">Set-dvSwSIOC -dvSw $dvSw -Enabled:$false

Remove-dvSwNetworkResourcePool -dvSw $dvSw -Name &quot;NetPool1&quot;
Remove-dvSwNetworkResourcePool -dvSw $dvSw -Name &quot;NetPool2&quot;
Remove-dvSwNetworkResourcePool -dvSw $dvSw -Name &quot;NetPool3&quot;</pre><p></p>
<p>Enjoy !</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.lucd.info/2011/12/15/vsphere-5-top-10-netioc/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
