I modify gretunnel to just monitor incoming packet without do anything, but when I send just 5000 UDP packet with 200 byte size, I loose server connection for 2 min! I will be useless for me in such case.
My server is Windows 2008 R2 x64 on HyperV
My code compiled as 32 bit application
My network is 2Mbit internet connection
If I dont run the code I have not such issue, it mean there is not relate to firewall or routers
I am using the latest version of WinpkFilter 3.0.8.0
Code:
int main(int argc, char* argv[])
{
Test(5, 100);
}
void Test(int index, int counter)
{
ETH_REQUEST Request;
INTERMEDIATE_BUFFER PacketBuffer;
ether_header* pEthHeader = NULL;
iphdr* pIpHeader = NULL;
if(!api.IsDriverLoaded())
{
printf ("Driver not installed on this system of failed to load.\n");
return;
}
api.GetTcpipBoundAdaptersInfo ( &AdList );
if ( iIndex + 1 > AdList.m_nAdapterCount )
{
printf("There is no network interface with such index on this system.\n");
return;
}
ADAPTER_MODE Mode;
Mode.dwFlags = MSTCP_FLAG_SENT_TUNNEL|MSTCP_FLAG_RECV_TUNNEL;
Mode.hAdapterHandle = (HANDLE)AdList.m_nAdapterHandle[iIndex];
// Create notification event
hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
// Set event for helper driver
if ((!hEvent)||(!api.SetPacketEvent((HANDLE)AdList.m_nAdapterHandle[iIndex], hEvent)))
{
printf ("Failed to create notification event or set it for driver.\n");
return;
}
atexit (ReleaseInterface);
// Initialize Request
ZeroMemory ( &Request, sizeof(ETH_REQUEST) );
ZeroMemory ( &PacketBuffer, sizeof(INTERMEDIATE_BUFFER) );
Request.EthPacket.Buffer = &PacketBuffer;
Request.hAdapterHandle = (HANDLE)AdList.m_nAdapterHandle[iIndex];
api.SetAdapterMode(&Mode);
while (counter != 0)
{
WaitForSingleObject ( hEvent, INFINITE );
while(api.ReadPacket(&Request))
{
bool send = PacketBuffer.m_dwDeviceFlags == PACKET_FLAG_ON_SEND;
//ether_header_ptr ethHeader = (ether_header*)Request.EthPacket.Buffer->m_IBuffer;
counter--;
if (counter%100==0)
printf("Counter:%d\n", counter);
if (send)
{
// Place packet on the network interface
api.SendPacketToAdapter(&Request);
}
else
{
// Indicate packet to MSTCP
api.SendPacketToMstcp(&Request);
}
if (counter == 0)
{
printf ("Filtering complete\n");
break;
}
}
ResetEvent(hEvent);
}
}