Search code examples
headerip

Changing identification field in IP header


I'm currently developing an ICMP traffic generator using jnetPcap (which is basically Java version of WinPcap). At first, I tried to use ping command from Windows prompt, capture packet that was sent (I use WireShark for capturing), copy its bytes, build the same packet using these bytes in my program and than send it again. That works pretty fine, the packet was sent and a reply was received. I could send 100 packet with the same ID - no problem.

But when I tried to change ID field from, let's say 3039 to 3038, I don't get a reply from the server anymore. And I can't always use the same ID, because even if it works for one single website, it won't work for anothers.

What is the problem? How should I generate this ID? Thank you in advance.


Solution

  • Well, it seems like I finally found a solution! The problem I was having was caused by the fact, that when you change any field in your IP header, you always need to recalculate its checksum, which I totally forgot to do. Now I changed it, and everything works pretty well.