I see, interesting. If you were *only* adding/removing a trailer from the packets, then a LWF would be the right way to go. However, my understanding is that for PRP, you’ll also want to get all packets cloned out onto two separate network interfaces.
When you’re talking about trying to join together two separate network interfaces, then you might want to use an NDIS MUX driver instead.
I am hesitant, because it sounds like you might prefer faster development time over maximum performance of the solution. (I’m guessing this because your other implementation round-tripped packets through usermode via libpcap.) In this case, you might be able to develop a solution faster if you build a LWF + protocol, since you can use an off-the-shelf protocol.
So here’s two alternatives:
- Use a MUX driver. This will have maximum performance and will integrate very cleanly into the Windows stack. However, MUX drivers are notoriously difficult to write. The final architecture will look like this:
[TCPIP]
|
[Your MUX]
/ \
[NIC0] [NIC1]
The advantage here is that TCPIP sees a single network interface, yet physically all packets go out two network ports. Your MUX can trivially append the PRP field to each packet’s payload. Your MUX also has the opportunity to eliminate duplicate frames from the receive path, so TCPIP gets a clean packet stream.
- Use a combination of LWF + protocol. This will probably be quicker to develop. The architecture looks like this:
[TCPIP] [Your protocol]
| |
[Your LWF] |
| |
[NIC0] [NIC1]
The behavior isn’t so clear from just the diagram, so let’s go over the behavior more carefully:
2.a. When NIC0 receives a packet, it goes through the LWF. The LWF strips the PRP footer and passes the packet along.
2.b. When NIC1 receives a packet, it is received to your protocol driver. The protocol shunts the packet to your LWF, and the LWF indicates the packet up to TCPIP again.
2.c. When TCPIP sends a packet, the LWF intercepts it and adds a PRP footer. The LWF sends the packet out to NIC0. The LWF also sends the packet over to your protocol driver, which sends the packet again on NIC1.
I would go with option #2 if you need a low-cost solution. Option #1 is the “industrial-strength” solution, and it’s also cleaner. (Even my crude ascii-art diagrams illustrate how much cleaner #1 is.)
You may be able to avoid writing kernel code, if you can find an off-the-shelf LWF that supports packet injection and interception from usermode. In that case, you can use either netmon or winpcap to capture & route traffic to your usermode app, and then use the injection LWF to re-inject the traffic onto the right stack. Any solution that goes to usermode for each packet, though, won’t scale very well, and I can’t really recommend for heavy production use.
Also note that there are several NDIS driver consultants who would be happy to sell you their expertise. This list is not to be used for commercial purposes, but you should be able to find them without spamming the list.