You are browsing as a guest. Sign up (or log in) to start making projects!

dnp3 Parser and Simulator

  • 7 Devlogs
  • 20 Total hours

Reads, Produces, Analyzes, and Simulates dnp3 packets passing between mutliple master and client instances. dnp3 is a protocol used often in EE with SCADA systems

Open comments for this post

6h 59m 16s logged

DNP3 Parser

I genuinely dont know how its been 7 hours. I feel like the majority of my time is fixing bugs and trying to get my code to compile.

Where I’ve Been

It’s been a while since my last devlog, and I have spent the past 7 hours adding a good bit. Main thing is that almost the entire packet is now being parsed, or atleast the hard part.

The entire header, dlc byte, transport header, and application header are parsed, so the only thing left is the Object headers and the data itself.

I also created a new struct to hold all of these functions, so you can just pass in a hex and get all this data out, no need to call each portions functionality anymore.

Whats Next

Moving forward, I have a couple goals/milestones I have to hit before I can ship this project:

  1. Parse the rest of the packet
  2. Check validity on entire packet (using CRC bytes)
  3. Finish Parser UI (almost done, but still some more to be done)
  4. Create Control/Main Station UI
  5. Create RTU/Secondary Station UI
  6. Link backend and frontend using network sockets
  7. Create systems for creating packets (I believe this will be much more difficult than parsing them)
  8. Simulate “Conversations” between the main and outstations
  9. Create binaries for Windows, Mac, and Linux

DNP3 Parser

I genuinely dont know how its been 7 hours. I feel like the majority of my time is fixing bugs and trying to get my code to compile.

Where I’ve Been

It’s been a while since my last devlog, and I have spent the past 7 hours adding a good bit. Main thing is that almost the entire packet is now being parsed, or atleast the hard part.

The entire header, dlc byte, transport header, and application header are parsed, so the only thing left is the Object headers and the data itself.

I also created a new struct to hold all of these functions, so you can just pass in a hex and get all this data out, no need to call each portions functionality anymore.

Whats Next

Moving forward, I have a couple goals/milestones I have to hit before I can ship this project:

  1. Parse the rest of the packet
  2. Check validity on entire packet (using CRC bytes)
  3. Finish Parser UI (almost done, but still some more to be done)
  4. Create Control/Main Station UI
  5. Create RTU/Secondary Station UI
  6. Link backend and frontend using network sockets
  7. Create systems for creating packets (I believe this will be much more difficult than parsing them)
  8. Simulate “Conversations” between the main and outstations
  9. Create binaries for Windows, Mac, and Linux

Replying to @arnabm

0
12
Open comments for this post

1h 17m 56s logged

Just did a little rework to move all header files to the inc/ folder. This should make it less cluttered, but we will see how this holds up.

Next things on the chopping block are:

  1. Implement Transport Header Parsing
  2. Implement Application Header Parsing
  3. Check all CRC bytes in entire packet

Check out the GitHub! https://github.com/arnabmondal-eg/dnp3

Just did a little rework to move all header files to the inc/ folder. This should make it less cluttered, but we will see how this holds up.

Next things on the chopping block are:

  1. Implement Transport Header Parsing
  2. Implement Application Header Parsing
  3. Check all CRC bytes in entire packet

Check out the GitHub! https://github.com/arnabmondal-eg/dnp3

Replying to @arnabm

0
1
Open comments for this post

5h 38m 14s logged

Its been a while…

Hello! I have been working on the parser for a while. This post will be an explanation of where I am in the project so far.

I wouldn’t go as far as to say that I am close to done yet, but I’m definitely nearing the halfway point.

The past 2 days I have reworked how packets are interpreted, as well as adding some new helper utilities/functions to make future decoding easier. I also implemented a full bit-by-bit decomposition of the DLC byte in a header!

This was super fun and rewarding as I learned a lot about bit-wise operations in C, as well as strengthening my understand of memory and how it is transferred through a program.

I also learned I can’t spell! Wrote valid as “vaild” over 10 times! I also learned that C doesn’t pass the size of an array automatically! Super fun bugs! \s

Feel free to critique my code on the GitHub! https://github.com/arnabmondal-eg/dnp3

Its been a while…

Hello! I have been working on the parser for a while. This post will be an explanation of where I am in the project so far.

I wouldn’t go as far as to say that I am close to done yet, but I’m definitely nearing the halfway point.

The past 2 days I have reworked how packets are interpreted, as well as adding some new helper utilities/functions to make future decoding easier. I also implemented a full bit-by-bit decomposition of the DLC byte in a header!

This was super fun and rewarding as I learned a lot about bit-wise operations in C, as well as strengthening my understand of memory and how it is transferred through a program.

I also learned I can’t spell! Wrote valid as “vaild” over 10 times! I also learned that C doesn’t pass the size of an array automatically! Super fun bugs! \s

Feel free to critique my code on the GitHub! https://github.com/arnabmondal-eg/dnp3

Replying to @arnabm

0
1
Open comments for this post

1h 20m 17s logged

Finished reworking the Parser UI. It uses a split pane so you can get as much or as little space as you need. Features a text input area on the left with a parse button on the bottom, and a tree view on the right (to see the parsed packet contents) with a valid indicator on the bottom.
Nothing is hooked up yet to logic, so that is coming up soon on the list!
Swing is definitely kind of tedious to write though!

Check out the github: https://github.com/arnabmondal-eg/dnp3

Finished reworking the Parser UI. It uses a split pane so you can get as much or as little space as you need. Features a text input area on the left with a parse button on the bottom, and a tree view on the right (to see the parsed packet contents) with a valid indicator on the bottom.
Nothing is hooked up yet to logic, so that is coming up soon on the list!
Swing is definitely kind of tedious to write though!

Check out the github: https://github.com/arnabmondal-eg/dnp3

Replying to @arnabm

0
1
Open comments for this post

2h 32m 9s logged

Just finished writing the final portion of the header validity checker, which uses a brand new CRC byte calculator!

Very Fun to make, as I really got to dig deep into bit-wise operations for the first time, but definitely challenging!

In terms of the backend, there is still much to do, but I am getting close to completion. The frontend still is in rough shape however.

Making Good Progress!

Just finished writing the final portion of the header validity checker, which uses a brand new CRC byte calculator!

Very Fun to make, as I really got to dig deep into bit-wise operations for the first time, but definitely challenging!

In terms of the backend, there is still much to do, but I am getting close to completion. The frontend still is in rough shape however.

Making Good Progress!

Replying to @arnabm

0
1
Open comments for this post

1h 11m 40s logged

Improved project structure, worked on README, added tasks to make compiling easier.

Really want this to be usable, so I am putting in the work to make it simple to understand and use.

Also I hated writing this project tree. Leme know if there is some tool i can use to do this automatically in the future

Improved project structure, worked on README, added tasks to make compiling easier.

Really want this to be usable, so I am putting in the work to make it simple to understand and use.

Also I hated writing this project tree. Leme know if there is some tool i can use to do this automatically in the future

Replying to @arnabm

0
1
Open comments for this post

1h 16m 12s logged

Working on the parser backend.
Currently planning for all the backend to be in C, while I handle the frontend in Java using Swing.

While this may seem like an ancient technology, most production SCADA applications use Swing for its long term support. And Java and C are obvious choices aswell.

Heres a pic of the header part of the interpreter, and some work in progress ui. Much more work to come!

Working on the parser backend.
Currently planning for all the backend to be in C, while I handle the frontend in Java using Swing.

While this may seem like an ancient technology, most production SCADA applications use Swing for its long term support. And Java and C are obvious choices aswell.

Heres a pic of the header part of the interpreter, and some work in progress ui. Much more work to come!

Replying to @arnabm

0
1

Followers

Loading…