Deutsche Version

With VirtualNetwork is it possible to install a virtual network card on a Windows system. A four port switch will be simulated on this network card. Over a API is it possible to send and receive packets on the mac level.

    VirtualNetwork is used to simulate and test netzwork protocols on MAC level dirctly in Windows. It is also possible to run TCP stacks such as LWIP on a VirtualNetwork interface. Against the loopback interface which only allows accesses on the ip level, VirtualNetwork send and receive all packets on the MAC level. The full network traffic can be recorded with tools such as Wireshark.  

    The sourcecode contains following files :

    Datei Funktion
    VirtualNetworkTools.h Header for the VirtualNetwork API
    VirtualNetworkTools.c Source for the VirtualNetwork API
    SimpleNetwork.cpp A small UDP Stack with ping functionality
    NtpTools.cpp Plug in for the NTP protocol
    ScannerTools.cpp Plug in for the SCN protocol
    Main.cpp Demo program for VirtualNetwork
    NtpRouter.cpp Router for NTP packets from port 124 to the internet
    Driver/* Sources of the VirtualNetwork driver
    System/* Sources for thread and sockets access
    Install/* Installation documentation

The next sample code shows the access to a VirtualNetwork interface :

        BYTE        aPacket[1514];
    LPBYTE      pMac;
    VnetHandle  hVnet;
    unsigned    uTurn;
    int         iSize;
    int         iRet;


            hVnet = VnetOpen();
    if(!hVnet)                        // open a port on the virtual switch
    printf("can't open driver (err=%i)\n",VnetLastError());
    return -1;


        pMac = VnetMac(hVnet);
    printf("connected to the port %i\n",VnetPort(hVnet));
    printf("own mac: %02X-%02X-%02X-%02X-%02X-%02X\n",pMac[0],pMac[1],pMac[2],pMac[3],pMac[4],pMac[5]);

        memcpy(aPacket+0 ,"\xFF\xFF\xFF\xFF\xFF\xFF",6);
    memcpy(aPacket+6 ,pMac,6);

        iRet = VnetSend(hVnet,aPacket,16); // send a packet 

        for(uTurn=0;uTurn<1000;uTurn++)    // loop for receiving packets                   
    iSize = VnetRecv(hVnet,aPacket,sizeof(aPacket));

            printf("receive %04i bytes\n",iSize);


        printf("connection closed\n");

    The LWIP-Demo contains a proting from the LWIP TCP-Stacks 1.4.1 with several extensions. One feature is to prior several TCP ports. The sockets for the select funktion are optimized. In the full stack realtime logs will be recorted. This logs (see at TcpTester.cpp) will be stored as a *.tte format. The viewer for this format isn't in the demo.

      Download C++ Sourcecode and Divers

      Download Demo mit LWIP TCP-Stack


      Extract all files from the Zip file in your MyProjects folder.
      Install the driver such a described in ./Install/Installation.htm
      Set the ip address of your virtual network adapter to /
      A documentation for the API exists in VirtualNetwork.chm
      Open VirtualNetwork.dsw , compile it, and start the program
      Over a console window you can ping the demo on over the network card.
      Additional the project NtpRouter.dsw can be started.
      Now the VirtualNetwork demo can send a time synchronization over the NtpRouter.
      A small WEB server is on "" implemented.

      Extract the LWIP demo from the ZIP file in your MyProjects folder.
      Compilie and start the project LwipDemo.dsw.
      On the IP address at TCP port 7 is an ECHO server installed.

    Build the Driver:

    A WDK (Windows Driver Kit) must be installed.
    Start ./Driver/makeall.bat and the *.sys files will be build in ./Driver/obj????/<cpu>/...

    Anton Zechner