How does networking work under Virtual PC / Virtual Server?

I regularly get asked about how networking works under Virtual PC and Virtual Server – so today I will attempt to provide generic overview of how virtual networking works.

Each virtual machine is created with one emulated network adapter by default (and can have up to 4 emulated network adapters).  These network adapters are assigned psuedo-unique MAC addresses in the 00-03-FF-xx-xx-xx range (there is potential for conflict here – though we do try to avoid this).  We then use our ‘Virtual Machine Network Services’ driver to move packets to and from the emulated network card.

The ‘Virtual Machine Network Services’ driver is an intermediate NDIS filter that is installed on the physical network adapter.  It is responsible for three things:

  1. Placing the physical network adapter into ‘promiscuous’ mode.  Normally Ethernet adapters will only accept network packets that are destined for their own MAC address.  In promiscuous mode an Ethernet adapter will accept all network packets irregardless of the destination.  Normally there is a performance degradation associated with promiscuous mode, because the upper protocols have to deal with processing all the packets – however we avoid this by ensuring that only packets destined for the physical computer are sent to the higher level protocols.
  2. Examining incoming packets and redirecting packets that are destined for a virtual machine to that virtual machine.  N.B. An interesting thing to note is that because the ‘Virtual Machine Network Services’ driver is installed below the protocols on the physical adapter – which means that any packet sniffers on the physical computer will not see packets destined for the virtual machines as our driver will intercept them first.
  3. Taking outbound packets created by the virtual machines, with their MAC address and transmitting it onto the network.

All of this means that virtual machines have their own unique MAC address and appear and function like completely separate computers on the network.  Anything that you can do with a physical computer on a network – we expect to work with a virtual machine.  It is also worth pointing out that we are only tracking networking at the MAC level (OSI Layer 2) – so that anything higher than that (like TCP/IP, IPX, NetBIOS, etc…) should ‘just work’.