Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8736793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:22:27+00:00 2026-06-13T10:22:27+00:00

From a linux OS I am trying to write my own data usage monitor

  • 0

From a linux OS I am trying to write my own data usage monitor in C or python. I’ve searched and researched for a couple of days now. Currently I am trying to adapt sniffex.c to suit my needs. I’ve succeeded in verifying the total bytes sent and received during a few ftp sessions.

In sniffex.c the tcp packet size is calculated. My question is how do you calculate the UDP packet size? I’ve searched on this topic, but have not found anything. Does this question make sense?

Update:

The function where the packet sizes are computed looks like this:

got_packet(u_char *args, const struct pcap_pkthdr *header, const u_char *packet)
{
...
int size_payload;
...
case IPPROTO_UDP:
    printf("   Protocol: UDP\n");
    size_payload = header->len;
...
}

Do I still need to add 4 to size_payload?

The callback to this function looks like this:

/* now we can set our callback function */
pcap_loop(handle, num_packets, got_packet, NULL);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T10:22:28+00:00Added an answer on June 13, 2026 at 10:22 am

    If you have an UDP datagram, you can get its size from its header.

    For example if you have a pointer char *hdr to UDP datagram header, you can get its length by such a construction

    int length = *(int *)(hdr + 4);
    

    More about UDP http://en.wikipedia.org/wiki/User_Datagram_Protocol

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently trying to write an application that displays live video from a
I'm trying to write a program that will fetch data from a SQL Server
I'm trying to move a MySQL database from a Linux machine to one running
I am trying to simulate linux command ls using linux api from c. Looking
I am trying to port an application from Windows to Linux. In Windows I
I'm trying to execute an external program from inside my Linux C++ program. I'm
I`m trying to execute linux commant 'cat' from java code, but it does not
I'm trying to understand this line from an strace on linux: sendto(10, \24\0\0\0\26\0\1\3\233\274\362O\0\0\0\0\0\0\0\0, 20,
I'm a linux newbie coming from a Windows background and I am trying to
I'm using GNU/Linux, C++, SDL 1.3 I'm trying to write the code for a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.