how to change packet length in the packet header for every incoming packet
I am getting "Frame 1 too long(18109400 bytes)" error. How to solve this? Thanks in advance.
Either 1) you really do have packets that large or 2) somehow the file you're trying to read got damaged, and there may be other problems with the file, even if you change the packet headers. How was that file produced?
We are sending the global and packet headers to the pipe directly without writing to a file. The error pops up while writing the packet header.
What program is writing the headers to the pipe? That program may be buggy. What happens if you run the program, send its output to a file rather than a pipe, and then try to read the file with Wireshark?
I tried writing to file but when I tried to open the pcap file, it says "The file "test.pcap" isn't a capture file in a format Wireshark understands."
I have attached my entire code above. Could you please have a look at it and suggest changes, if any?
I've rolled back your massive change of question. This is not the place to dump source code. Use other public accessible sites for this, e.g., GitLab, GitHub, pastbin or similar.