[SOLVED] C program that will take as input a single binary file containing captured Ethernet d
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Before doing this assignment, you should know the various layers of networking technologies used on the Internet. Specifically, you need to know how headers (and often, footers) are added at each level. These headers contain data such as, oh, MAC and IP addresses.
Study the binary data with a good binary viewer/editor. If offset values are consistent from packet to packet, use offsets. Else, you will have to employ other means. In other words: first determine how you as a human can detect where the germane data are located. Then write your C code accordingly.
You need to understand the layout of your file. There maybe a correlation between your file and the network protocols, in which case understanding them will help but a binary file (if that is what it truly is) could be in any format so you need to get to the bottom of that first.
Thank u all.
The first 14 bytes from the file contains the MAC addresses. I am using fopen and fread to read the data into the array, should i allocate memory for the array? could somebody provide a sample code for creating the array and read in data?
You do need to allocate the memory before you read in the data.
You should be able to get examples of using fread() by a simple search, for example this link reads in the whole file, you don't need to do that but pay close attention to the malloc() and fread() statements along with the two error checking statements that follow them.