I’m trying to implement in a c ++ internet gateway example a bandwidth control. Charge the packets in a buffer and send or discard them according to the determined bandwidth.
I capture packets from adapter 1 (connected to the internet)
The problem is when the timer skips to send a packet with delay and the adapter 2 (LAN) event has been activated. I do not know how to select the adapter to send the data packet to the desired adapter.
Is there any possibility of doing it? Any guidance?
If I’m not mistaken Internet Gateway uses single thread to send/receive packets from both adapters (LAN and WAN) waiting with WaitForMultipleObjects an adapter associated event objects.
So, in order to implement bandwidth management I’d advise launching two threads instead, one per network interface, each waiting with WaitForSingleObject on associated event. This way you should be able to delay packets for the selected network adapter without affecting the second one. Just note to take care about threads synchronization when accessing shared data. You can use Ethernet Bridge source for the reference for thread per network adapter model.