By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,388 Members | 1,822 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,388 IT Pros & Developers. It's quick & easy.

packet sniffer code in C

P: 2
this is kali a new member to this forum..
iam an undergrad studd and wrking with a opacket sniffer to capture data transmitted using a hardware...
the file saved in the sniffer is a binary file with the following format:
the first [4] bytes is the packet count
the enxt [4] bytes are time stamp
the next [128]bytes is payload..
iam interested in decoding or rather parsing the time stamp which is in microseconds.
any help in the form a C code wud be gr8tly appreciated...
thanx
Jun 20 '06 #1
Share this Question
Share on Google+
2 Replies


Banfa
Expert Mod 5K+
P: 8,916
You mean something like

Expand|Select|Wrap|Line Numbers
  1. unsigned long milliseconds = 0;
  2.  
  3. milliseconds |= ((unsigned long)packet[4])<<24;
  4. milliseconds |= ((unsigned long)packet[5])<<16;
  5. milliseconds |= ((unsigned long)packet[6])<<8;
  6. milliseconds |= (unsigned long)packet[7];
  7.  
Jun 21 '06 #2

P: 2
You mean something like

Expand|Select|Wrap|Line Numbers
  1. unsigned long milliseconds = 0;
  2.  
  3. milliseconds |= ((unsigned long)packet[4])<<24;
  4. milliseconds |= ((unsigned long)packet[5])<<16;
  5. milliseconds |= ((unsigned long)packet[6])<<8;
  6. milliseconds |= (unsigned long)packet[7];
  7.  
iam not sure if that is what is want...but it is like parsing a binary file....
since i have no experience in programming iam finding it a bit tough..
Jun 21 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.