Modifying TCP packets on the fly

1.8k Views Asked by At

I'm currently writing a Java application where I'm running a primary sever along with a backup one (using VMs). In order to get the backup server to take over as the primary (if the primary crashes) while being completely transparent to the client, I need to get the same application running on both the primary and the backup and both must have the same state.

To do this I have to synchronize the backup with the primary so that it receives the same sequence of packets from the client and sends the same (suppressed) replies. For this I need to get the initial TCP sequence number of the backup to match up with the initial sequence number of the primary.

In order to achieve this I thought of intercepting the packets to and from the backup server and modifying the sequence number in their TCP header so it matches up with that of the primary. Thus I need an application that -

  • Lets me intercept TCP packets on the fly
  • Allows me to modify them and then forward them to their original destination
  • Ensures that the original unmodified packet is dropped
  • Something that can be embedded in Java applications is a huge plus but this isn't a major requirement

Is there any way to achieve this?

1

There are 1 best solutions below

0
On BEST ANSWER

To anyone who's facing the same problem, I finally managed to do this using ettercap - http://ettercap.github.io/ettercap/

More specifically, I used the ARP poisoning mode to intercept the packets to and from the server and used a custom ettercap plugin to modify them appropriately