473,396 Members | 1,921 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

packet sniffer code in C

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
2 8533
Banfa
9,065 Expert Mod 8TB
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
kali
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

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

Similar topics

2
by: flywave | last post by:
hi,who can help me ?i came into a problem that how can i get a packet which was send in the LAN.in a word ,how the sniffer works. I once used the rawsocket in win2000 or xp,and it do catch. but...
3
by: nexus024 | last post by:
I am trying to write a program that will continuously sniff eth0 for a specific UDP packet thats being sent to a specific destination IP, alter the data of the packet, and finally transmit it to the...
3
by: haribuvanesh | last post by:
Im working with a packet sniffer program and i get following exception on compilation. Plz help me out.... Exception in thread "main" java.lang.Error: Unresolved compilation problem: The method...
1
by: Ken Fine | last post by:
I have been investigating programmatically downloading FLV content from various sites ("video scraping"??) Many interactive GUI tools do this, such as the Orbit downloader. At the heart of them...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.