Hmm, I hadn't considered the problem of TCP reassembly, I thought TCP guaranteed the order of packets. I'll have to rethink how I'm doing this!
I do have one question though, one issue I've got is getting data out of the TCP Layer. I'm really not sure which methods to call, like getNextLayer, parseNextLayer, getData etc. For the HTTP Message layer it worked fine to do this:
p = (pcpp::PayloadLayer*) httpResponse->getNextLayer();
Then p->getPayload()
and this got me a pointer to the data. When the images are sufficiently small, this does indeed return the full image.
Of course the next packets coming through are TCP packets and have no HTTP header. So I'm currently doing this:
tcpLay->parseNextLayer();
p = (pcpp::PayloadLayer*) tcpLay->getNextLayer();
p->getPayload();
And it doesn't seem to be working really. Am I using the correct combination of functions or have I misunderstood the documentation here? If this is the correct way to do this then that means the problem is elsewhere (i.e. packet reassembly or some such problem), just wanted to make sure I was doing this correctly.
Thanks.