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
sample code shows the access to a VirtualNetwork interface :
if(!hVnet) // open a port on the virtual switch
printf("can't open driver (err=%i)\n",VnetLastError());
printf("connected to the port %i\n",VnetPort(hVnet));
printf("own mac: %02X-%02X-%02X-%02X-%02X-%02X\n",pMac,pMac,pMac,pMac,pMac,pMac);
iRet = VnetSend(hVnet,aPacket,16); // send a packet
// loop for receiving packets
iSize = VnetRecv(hVnet,aPacket,sizeof(aPacket));
printf("receive %04i bytes\n",iSize);
Demo mit LWIP TCP-Stack
Extract the LWIP demo from the ZIP file in your MyProjects folder.
Compilie and start the project LwipDemo.dsw.
On the IP address 192.168.99.33 at TCP port 7 is an ECHO server installed.
A WDK (Windows Driver Kit) must be installed.
Start ./Driver/makeall.bat and the *.sys files will be build in ./Driver/obj????/<cpu>/...