I'm trying to develop a software in which I'm capturing packets from my network interface, changing them, and writing the altered packets to my local disc (to an output file).
Thing is, when I open the output file, I see that the changes that I made were not committed. for example, I've captured an IP packet and changed the source ip address to be 0.0.0.0. Afterwards, I've saved the altered packet in the output file. When I've opened the output file, I've seen that the source ip address was the same as it was before I have changed it.
if (packet instanceof TCPPacket) {
try {
((IPPacket)packet).src_ip = InetAddress.getByName("0.0.0.0");
} catch (UnknownHostException e) {
e.printStackTrace();
}
System.out.println(packet);
outputFile.writePacket(packet);
}
What am I missing?