> Is this what you meant?
Something *like* that - but if you know the host and port numbers of both endpoints of the conversation, you should use those rather than hardcoded IP addresses and ports.
> but for some reason wireshark loads the packets as "Bogus Length, must be at least 20".
If that's an error in the IPv4 header, then the IPv4 builder is somehow not setting the length correctly.
If that's an error in the TCP header, then the TCP builder is somehow not setting the length correctly.
You need to do whatever is necessary to make sure that the header length in the IPv4 header, and the data offset field in the TCP header, is set to the appropriate value. The builders probably won't add any options, so the appropriate value is 20 in both cases.
You would also need to do whatever is necessary to make sure that the *total* length in the IPv4 header is set to the appropriate value. Again, the builders probably won't add any options, so the appropriate value would be 20 (for the IPv4 header) + 20 (for the TCP header) + bytesRead (which I'm assuming is the length of the TCP payload).
↧