16 June 2008

How does basic networking work in Hyper-V?

While it is possible to create some complex networking environments in Hyper-V, the basic concepts are relatively straight forward. This post walks some simple scenarios and how the main components operate in terms of the flow of data.

Let’s start by setting a level playing field and a “best practice”.

  • When adding the Hyper-V role in a full installation of Windows Server 2008, you have the option to create one or more external virtual network switches. (This option is not available in server core installations of Windows Server 2008). I’m going to assume that no external virtual network switches were created during installation, and the Hyper-V role is enabled.
  • Our recommendation, in a simple deployment, is to have at least two physical NICs in a physical machine– one (or more) dedicated to the physical machine, and one (or more) for virtual machines. The reason will become obvious as you work through this post.

To constrain the starting point, I’m assuming (for simplicity, not by recommendation) the physical machine contains a single physical NIC.

If you open Network Connections (Start/Control Panel/Network and Sharing Center, or Start ncpa.cpl), you would see something like below – a single connection.

1


And to get some more information, I’ve used View/Detail in the next screenshot:

2

Let’s look at the network bindings by selecting the NIC, right-clicking and choosing properties. Notice that (in this simple example), all protocols are bound to the NIC except the Microsoft Virtual Network Switch Protocol.

3

Let’s see what changes when we create an External Virtual Network Switch. Here, I’m using Hyper-V Manager, selected Virtual Network Manager, added an External Virtual Network named “Test External Network” and selected my single Physical NIC in the drop-down.  On hitting apply, you will get a warning that you may temporarily lose network connectivity while we reconfigure everything.

4 

5
Now let’s go back to Network Connections and see what has changed.

6

Notice that there are now two network connections listed, but with different Device Names. Let’s look at the top one first which has the device name matching the type of physical device and open the properties to examine the bindings. 

 7

Notice that nothing is bound except the Microsoft Virtual Network Switch Protocol. Now let’s open the other bottom one which has the device name matching the name I entered when creating the external virtual network switch, “Test External Network”.

8

Notice that everything is bound except the Microsoft Virtual Network Switch Protocol.

So what does this mean? Well, to explain, let’s take a physical switch. Let’s pretend it’s a simple “unmanaged” switch – the type you can buy as a commodity $30 device down at your local computer store. It typically has 8 ports on it. You can’t add ports to it. You can’t take them away. It has, and will only ever have 8 ports.

Now go “virtual” for one moment and in your mind create a Virtual network switch. It’s still conceptually a box with ports. Where things get a little different is that in the virtual world, ports can be added and removed dynamically as needed, without the need for a soldering iron.

Now let’s map this into what we just did above.

  • We created a new virtual network switch with two ports.
  • We added another NIC to the physical computer (it just happens that it’s a Virtual NIC, not a physical NIC)
  • We logically labeled the switch “Test External Network”.
  • We ran a couple of bits of “virtual” network plumbing
    • A pseudo virtual CAT5 cable from the virtual network switch to the physical NIC. (*)
    • A virtual CAT5 cable from the Virtual NIC into the virtual network switch
  • We re-jigged some network bindings.

(*) Bear with me on this point – it will make sense soon why there’s some software magic in this bit of virtual cable. Obviously words are nowhere as easy to understand as a picture. Here’s what we’ve done:

9 

On the top right, there is a networking application. Let’s assume it’s “ping”. What ping does is send a IP packet out to somewhere, and waits for a response to come back. With some gross over-simplification, here’s the steps:

  • Ping uses the Windows networking stack to determine where the IP protocol is bound. There is only one choice – it’s on the Virtual NIC.
  • An IP packet is sent down to the networking stack bound to the Virtual NIC. This is the flow labeled “1”.
  • The Virtual NIC has a bit of virtual CAT5 cable plugged into it. The virtual NIC does what any physical NIC would do:  Put the packet on the (virtual) wire. This is the flow labeled “2”.
  • The other end of the virtual CAT5 cable is plugged into a (virtual) port on the Virtual Network Switch called “Test External Network”. The packet appears at the switch port.
  • (Simplying again…) The Virtual Network Switch does what a physical counterpart would do and routes the packet to its destination. Without going into the detail of routing and learning algorithms, suffice to say it makes the packet makes it’s way to the other virtual port on the switch, coloured in blue. This is the flow labeled “3”.
  • At this point, remember that we’re dealing with a virtual network switch. This switch knows about the Microsoft Virtual Network Switch Protocol, and can therefore do some “magic” in software. The magic is basically getting the packet to the physical NIC. That’s the flow labeled “4”.
  • Once on the physical NIC, we’re down to physical networking, so the flows marked 5 and 6 show the data entering the physical world in the form of a Physical Network Switch and then onwards to some other server.
  • A packet coming the other way follows the same path in reverse.

Now as I said, I’ve over simplified.  Let’s take a look at one aspect of this model. First, you’ll notice that I’m running the networking application, ping, on the physical computer, not in a virtual machine. Notice that all networking traffic from the physical computer is going through the Virtual NIC and the Virtual Network Switch. Hopefully, it therefore becomes obvious why I stated at the top that it is our “recommendation to have at least two physical NICs in a physical machine.


Here’s the diagram where two physical NICs are in the physical machine, and a single external Virtual Network Switch has been created:

10

If a networking application running on the physical computer, or parent partition to put it into Hyper-V terminology, tries to access a separate physical server, the path to get “out” is much shorter. Of course, the astute among you may have noticed that there’s a second longer path as shown below:

11 

Whereas this alternate path may be used while the networking stack has not learnt the best (least cost) route, it will generally only be used for a very short period of time. As soon as the least cost route is learnt, the first path with be used.

As we’ve covered the basics from the parent partition perspective, let’s introduce a virtual machine. After all, chances are if you’ve read this far, you want to know how virtual machines interact.

Here’s an extension to the previous diagrams. At the top, we have a virtual machine with a virtual NIC. To distinguish this virtual NIC from the Virtual NIC in the parent partition, I’ll call it a Virtual Machine NIC. It doesn’t matter if this is a “synthetic” or “legacy” network adapter from the virtual machine configuration perspective; the concepts for data flow are the same.

The Virtual Machine NIC has a virtual piece of CAT5 cable connected from it to a new port on the external virtual network switch.

12

In the diagram, a networking application is running in the virtual machine and trying to connect to something externally. The data flows are very similar to before and hopefully the diagram speaks for itself.


You may ask, what if the virtual machine is communicating with the parent partition? Well, there’s two options for this, again the actual one used is a routing decision, but this time inside the Virtual Network Switch. Let’s start with the longer route where the packets from the virtual machine are sent out on the physical wire. Here, the physical switch routes the packets back up to the server using Physical NIC #2.

13 

And in the more efficient route:

14 


The essential difference between the last two diagrams is what happens inside the Virtual Network Switch. In both cases, it’s the flow labeled “3” which is interesting. The Virtual Network switch includes a learning algorithm. When it knows the most efficient virtual switch port to direct traffic to, it will do exactly that. However, for a short period of time, it does not know, so will act as a “hub” rather than a switch and send packets out on all virtual switch ports.

Cheers,
John.

P.S. Thanks to my colleague, Keith Mange, for his assistance with this post :)

 

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# 16 Down » How does basic networking work in Hyper-V? said:

PingBack from http://16down.morelyrics.co.uk/2008/06/16/how-does-basic-networking-work-in-hyper-v/

16 June 08 at 8:24 PM
# Peter Forster said:

Hi John,

wow, thanks for this impressive overview of the networking feature within Hyper-V, real good job!

Greetings from Austria (not Australia) *gg*

Peter Forster

MVP Virtual Machine

17 June 08 at 2:42 AM
# Dan Stolts Blog Home said:

I had a discuss a couple days ago at TechEd with some people about Blogs and what information was "appropriate"

17 June 08 at 2:25 PM
# Lance Fishre said:

Hi, I followed your excellent instructions on getting Hyper-V to work on a Server Core installation.  I'm now running two Server 2008 VMs on it, and they seem to run great.  Thanks!

I recently created a Ubuntu Server VM to host a wiki, and it runs really slow.  Could this be because I have only one NIC in the server?  The wiki on the Ubuntu server is using a DB on one of the Server 2008 VMs.  Or is the slowness probably just that the Ubuntu server doesn't have the advantage of integration services?  How would I go about measuring for the bottleneck?  Thanks for any tips.

17 June 08 at 7:56 PM
# John Howard said:

If you followed yesterdays post explaining the basics of networking in Hyper-V, you may be wondering

17 June 08 at 9:10 PM
# jhoward said:

Lance - I confess, I've never installed or run Ubuntu. Emulation will be relatively significant in terms of overhead compared to synthetic devices, particularly on the send path (receive is somewhat better than send). Can you define a little clearer what "slow" means? On receive, on send? Have you looked at the logical processor and virtual processor counters in perfmon in the root partition - they may give some indication if you are bottlenecked on CPU. Have you compared performance between a supported child operating system and Ubuntu?

Having only one physical NIC won't affect performance of networking in a virtual machine - however it's not recommended as it affects networking  performance from the root partition. Have you tried running a steady n/w load test inside the VM to measure the throughput and/or LP load?

One other thing - what sort of physical NIC is in the machine. Could it be a case of needing later drivers for the physical NIC or changing the offload settings for it. I've seen a few reports (on Dell 2950s with Broadcom Nics IIRC) that offload settings can affect network performance.

Thanks,

John.

18 June 08 at 12:37 AM
# News said:

While it is possible to create some complex networking environments in Hyper-V, the basic concepts are

18 June 08 at 4:03 AM
# Simone said:

Hi John.

In you article there is no mention to subnets. Indeed if you create two Internal (or Private) Networks in H-V and put two Virtual machines on separate IP Subnet they cannot communicate each other. In other words, the virtual switch works at level 2 only.

Is there a way to have a layer 3 routing within H-V? I need this cause i'm trying to simulate a scenario with a DMZ and a LAN using one Host only.

20 June 08 at 5:29 AM
# Lior Arviv's Blog said:

Getting Started with Microsoft Hyper-V Understanding Hyper-V partitions and device drivers Migrating

20 June 08 at 2:05 PM
# jhoward said:

Simone - indeed, you are correct and that was deliberate. So far, I was just explaining the possible traffic flows under different circumstances. However, yes, you are correct, virtual network switches operate at level 2 in the OSI stack, below TCP/IP. To achieve routing at higher levels, you need to use a router, the same as you do in a physical environment. You can use ISA 2006 to achieve this very successfully using Hyper-V (I have run this many times in a variety of scenarios).

Thanks,

John.

21 June 08 at 12:25 AM
# Virtualization said:

U zadnje vrijeme sam imao podosta obaveza pa ne stigoh osvjeziti blog novostima, stoga slijedi izvjestaj

23 June 08 at 4:38 PM
# Ask the Core Team said:

With the RTM release of Hyper-V just around the corner, I thought it would be a good idea to re-visit

25 June 08 at 7:40 AM
# Martin Herbener said:

John,

If I look at the tcp/ip properties of the host/root partition's virtual NIC, they are unusual -  using a 169... address that our DHCP servers certainly didn't give out, no default gateway, etc.  Is there any reason to ever touch this NIC's configuration?  Is it a good idea or a bad idea to remove this virtual NIC if there is a 2nd physical NIC for host machine traffic (and assuming we will not use internal or private configs)?

thanks!

Martin

25 June 08 at 10:16 PM
# jhoward said:

Martin - 169.x.x.x address are APIPA address and get assigned when you can't get a "real" IP address from a DHCP server. The most common reason is an unplugged network cable. Before you created the external switch, were you able to get a "real" IP address on that physical NIC? That would rule out a faulty network cable.

As for touching the configuration on the virtual NIC - that's really so dependent on what you're trying to do and how your environment is setup. When you have a second physical NIC though, you probably don't even need a virtual NIC on the first external switch - you really want a "dedicated" switch where no virtual network is present (see my related second post - explains that a little more).

Thanks,

John.

26 June 08 at 12:20 AM
# Martin said:

John,

Not sure what the sequence would have been in my existing case.

In general, if I have a physical NIC with a valid, complete tcp/ip config, and I create a external virtual network using that NIC, should the resultant virtual NIC adopt the tcp/ip config of the physical NIC?

Also, re your second post, any guess when we would have info on how to create a dedicated switch?

thanks

Martin

26 June 08 at 8:44 AM
# jhoward said:

Martin - there are a couple of known bugs around the area of copying across the IP settings in RC1 builds, so this may have to be done manually.

I haven't had a chance to put a script together yet, sorry. It's on my list though.... (along with many other things!).

Thanks,

John.

26 June 08 at 8:52 AM
# Martin said:

John,

But by design/intention, the virtual NIC should get the physical NIC's config?

thanks

Martin

26 June 08 at 9:07 AM
# jhoward said:

Correct (for ipv4).

Cheers,

John.

26 June 08 at 9:11 AM
# Andrew said:

Hi,

If I understood correctly Windows Sever 2008 Core has no support for any of these features? So one has to bind each VM to a physical NIC? If so this would be a disappointment as Sever Core 2008 with Hyper-V seemed to be a good alternative to ESXi.

26 June 08 at 4:13 PM
# robertplant said:

If you may,please clarify one or two points...

one physical nic on host -> local area connection

one virtual external nic on the child partition with server 2008 -> local area connection 3

every nic (physical,virtual on host and vmbus on guest) is on defaults automatic / dhcp configuration

1.you mentioned that no bindings except virtual switch is to be enabled on the physical nic

what is the case when using 3d party firewall/antivirus

like eset smart security/kaspersky antivirus which both add bindings?

if left unchecked, is the physical connection still protected by the firewall/antivirus or is it in passthrough mode?

I'm concerned about the protection on both the host and the guest,that's why I'm asking.

26 June 08 at 7:09 PM
# robertplant said:

2.I've had some trouble figuring out the ideal configuration

That's the situation:(everything on dhcp) when nothing is connected (no cable at all) the host reports that the virtual nic has IP 169.254.163.198 and the guest shows for vmbus net adapter IP 169.254.56.11 both with netmask 255.255.0.0 (same subnet right?)

26 June 08 at 7:24 PM
# Tim said:

Configuration... 2008 Full Version, running on 2008 Core.

Will not load the VMBus drivers.  System just says "This device cannot start. (Code 10)" in the Device Manager.  Using an External Network Type on the Hyper-V Network.

22 July 08 at 8:29 PM
# jhoward said:

Tim - was the VHD originally built under virtual server or virtual pc? If so, see this entry: http://blogs.technet.com/jhoward/archive/2008/02/29/vmbus-fails-to-load-device-cannot-find-enough-free-resources-code-12-on-a-windows-server-2008-x86-virtual-machine-under-hyper-v.aspx

Thanks,

John.

22 July 08 at 8:32 PM
# Tim said:

John,

This is a newly created VM, newly created disk nothing from an old system, or migration  I did do the HAL Detect trick, and the ACPI was showing correct.  None of the errors are (Code 12) errors, but there are three yellow exclaims in device manager.  One under human interface (i'd assume mouse) one under unknown drivers, and one under Networking.

Getting frustrated, as with VMWARE you just load the tools and voila, everthing is there.  It seems like the drivers are not even loaded, but when I search, it says they are up to date.

When I get to the office tomorrow I'll check the other errors.  One was the same (Code 10), the other I can't remember.

Tim

23 July 08 at 12:24 AM
# Tim said:

John,

One more note.  The Core (x64 Enterprise)  was built from the media sent along with the eval kits, and the Full version (x86 Server) on the VM was using Technet media.

Tim

23 July 08 at 12:32 AM
# David Zhang said:

Thanks for such a good resource. This definitely demystifies some of the magic behind networking in Hyper-V.

24 July 08 at 5:11 PM
# Chuck vdL said:

Great stuff John..  Wonderful graphics as well (reminds me of some of what Ben Armstrong put up when he discussed some of the same stuff (but not with this depth) back in Jan08..

For those of us having issues with networking and Hyper-V, what's a good resource for help?  I don't want to bug you here in your blog..

(for reference the problem is that once I have two networks connected as described, when I try to connect to shares on the server from an outside system, or even ping it, the traffic seems to be trying to use the virtual nic, not the physical nic (what would be physical nic 2 in your diagrams above)

25 July 08 at 12:33 PM
# jhoward said:

Chuck. Thanks :)

Sure, either drop me an email using the link at the top of the page with a bit more information (ipconfig /all, a few screenshots if appropriate, configuration done etc). Alternately, there's plenty of helpful folks including others from the product group and MVPs who hang out on the Technet Hyper-V forum http://forums.technet.microsoft.com/en-US/winserverhyperv/threads/.

Cheers,

John.

25 July 08 at 12:42 PM
# Jeff said:

I've got a server configured with two NICs and set up as described. My VM will be active for a while then suddenly lose its connection and I have to jump through the whole configuration dance to get connectivity again.

Any ideas why?

31 July 08 at 5:48 PM
# Chuck vdL said:

Thanks for the tip on the technet forums, I'll try there.  

I tried the MSDN forum for virtualization <http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=2015&SiteID=1> and it was dead.. nobody is even marking things as answered (really un-usual given my experiences in the MSDN forum for VSTS2008 web and load testing, which was very active and you got very rapid answers)

Maybe the technet one will be better..

06 August 08 at 6:36 PM
# jhoward said:

Tim

Have you installed the integration services inside the VM itself, and applied KB950050 on both the parent partition and the VM to get to Hyper-V RTM?

Thanks,

John.

07 August 08 at 1:42 PM
# Tony Nicholls said:

Great article!

I wonder if you could explain/validate something for me.

I have a physical Windows Server 2008 Data Centre with a single physical NIC IP4 addres x.y.z.1 which I have to access via RDP.  I installed Hyper-V, and created an external virtual network. As you described I got a new virtual NIC on the physical server and the physical NIC was bound to just the Virtual Network Switch Protocol. Since I only had a single physical NIC on the server, I lost the abilityy to use RDP so I had to have the IP4 protocol re-attached with IP x.y.z.1 so that I could reach the physical server.

All seemed to work so I then built a few virtual machines for test and set their virtual NIC IP4s: to x.y.x.2, x.y.z.3, x.y.z.4

Now I can access the physical server using RDP against IP4 x.y.z.1, but the physical server cannot access any of the virtual machine IPs. The Hyper-V manager can control everything just fine.

The vitrual machines can all access each other, but they can't access the physical server or the external network.

In the spirit of investigation, I set the virtual NIC on the physical server IP4 to x.y.z.5. Now the physical server can ping x.y.z.1 and x.y.z.5. It seems that the primary partition and the virtual servers are operating on two separate and disconnected networks.

So I guess my question is: "Is it actually essential that there are at least two physical NICs on a Hyper-V server?" One of which must only be bound to the Virtual Network Switch Protocol and the other dedicated to connecting the physical server to the Internet.

Is the fact that I have my only physical NIC bound to both VNSP and IP creating the logical break between my primary partition and virtual servers?

I'm going to get a second physical NIC installed on the physical server and configured but I would appreciate your feedback and comments. Did I correctly understand the problem and will a second NIC fix it?

Cheers, Tony

10 August 08 at 1:24 AM
# jhoward said:

Tony. Thanks!

What you have should work absolutely fine, although obviously not desirable for a production environment. It also means that all traffic to/from the parent partition goes through the external virtual network switch now. I'm a little confused by one bit you state where you say that after setting the IP address on the VNic on the physical server to *.5, you can ping *.1 and *.5. If you can ping *.1, that sounds like another machine.

Can you drop me an email using the link at the top, and include and output of ipconfig /all from the parent partition, and from one of the virtual machines which the parent partition can't communicate with (eg by ping).

If possible, temporarily turn the firewall off on the parent and virtual machine just to validate that it's not simply the firewall getting in the way. Also worth verifying whether the parent and VMs are private not public networks in the network and sharing centre.

Also useful would be ascreenshot of the virtual network in Hyper-V manager, and the settings for one of the VMs highlighting the NIC.

Thanks,

John.

10 August 08 at 2:07 PM
# jhoward said:

Jeff - sorry, I missed you comment from a couple of weeks back.

Can you provide a little more information: First thing to verify is that you are running Hyper-V RTM, not beta, RC0 or RC1 - there are several networking fixes along the line which you could have been hitting.

Assuming you are on RTM, can you describe the symptoms: Is it networking in all VMs that lost, just one VM. What were you doing at the time? Have you got the latest drivers from the OEM installed for the physical NIC? Does the parent partition also lose network connectivity? Can you also confirm whether you are using a legacy NIC in the VM or a synthetic NIC?

Thanks,

John.

14 August 08 at 8:53 PM
# Dave said:

Hi John,

I have a windows 2008 enterprise 2008 server running DNS, AD, Print server, and all the goodies.  The server runs fine but when I install hyper-v into this server all the computers in the domain cannot obtain an IP from the DHCP server.  Is there a workaround for this problem?

23 August 08 at 4:48 PM
# sponder said:

Nice Article!!

Could someone point me in the direction of any good comparisons between Hyper-V and VMWare's version? My company wants to go the VMWare route, but I'm trying to convince them otherwise.

Thanks

Sam

11 September 08 at 11:19 PM

Leave a Comment

Comment Policy: No HTML allowed. URIs and line breaks are converted automatically. Your e–mail address will not show up on any public page.

(required) 
(optional)
(required) 
Page view tracker