Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lazy parsing on a packet stream #15

Open
rick2047 opened this issue Nov 19, 2020 · 0 comments
Open

Lazy parsing on a packet stream #15

rick2047 opened this issue Nov 19, 2020 · 0 comments

Comments

@rick2047
Copy link
Contributor

I am trying to parse a binary file format which is made up of packets. I have figured out the packet grammar, and if I have a file with the stream saved in it I can parse all packets from it. But this is incredibly slow as each file can be several GBs long. To speed it up I was wondering if I can only parse specific packets selected by their ID which is right at the top of the structure. A minimum example of a packet would look like this

MAGIC NUM
ID: ID1
DATA1: VALUE 1
DATA2: VALUE 2

I want to parse till ID and then decide if I want to parse any further.

One approach I tried was to write a header parser. But the problem is since I don't know the size of the packets, I end up writing a negative look ahead for the magic number. This is equally as slow as just parsing the struct (this does feel like one of those good problems doesn't it :P).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant