I am writing a lua dissector for a propietary protocol. The packets include bytes of embedded .png images that are contained in a tvb (buffer) object that I need to write to a .png file. In order to successfully write them to a file, below are couple of ways attempted. Both required "walking through" each byte of the buffer with string.char, making them VERY SLOW performing. Is there a better way to do this in lua, maybe with a fwrite-like single call to write the entire range of buffer bytes?
asked 04 Aug ‘15, 19:02 mfbaker edited 04 Aug ‘15, 19:12 Hadriel |
One Answer:
Yes: in Wireshark/tshark version 1.12 the So if you know the beginning offset in the
(plus the other stuff to open/close the file, which is presumably being done outside your dissector function anyway) answered 04 Aug '15, 19:27 Hadriel |
Thank you so much, Hadriel -- using the "raw()" API worked, with ~4x performance improvement! A capture file that I was testing had 5300 images, which before the change took about 23 seconds to load. With using raw() API instead, the same file took 5.9 seconds -- an awesome improvement!
If an answer has solved your issue, please accept the answer for the benefit of other users by clicking the checkmark icon next to the answer. Please read the FAQ for more information.
Question is answered, thanks again, Hadriel!