ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/libstatgrab/docs/network.txt
Revision: 1.2
Committed: Mon May 12 13:37:44 2003 UTC (21 years, 6 months ago) by pajs
Content type: text/plain
Branch: MAIN
Changes since 1.1: +5 -2 lines
Log Message:
Typo fixed, added another bug

File Contents

# User Rev Content
1 pajs 1.1 Network Statistics
2    
3     All network statistics return a network_stat_t structure.
4    
5     typedef struct{
6     char *interface_name;
7     long long tx;
8     long long rx;
9     time_t systime;
10     }network_stat_t;
11    
12     Interface name is the name known to the OS. E.g. eth0 on linux.
13     tx is a long long with the number of bytes transmitted.
14     rx is a long long with the number of bytes recieved.
15     sysname is time_t covering the time the amount of data in rx/tx was
16     generated.
17    
18    
19     network_stat_t *get_network_stats(int *entries);
20    
21     network_stat_t *get_network_stats_diff(int *entries);
22    
23 pajs 1.2 Both calls take a pointer to an int, "entries". This is filled with the number
24 pajs 1.1 of network interfaces the machine has. You need to know this to know how
25 pajs 1.2 many network_stat_t have been returned.
26 pajs 1.1
27     get_network_stats returns the network traffic stored in the kernel. E.g.
28     since bootup as long as the way it is stored in the kernel can store a large
29     enough number. Solaris 7 can not, it only stores it in a 32bit int, so it
30     can only store upto 4gb before it will wrap around. Solaris 8 upwards stores
31     it in a 64bit int and so is a very large number :)
32    
33     get_network_stats_diff is the same as get_network_stats except it will
34     return the difference since the last call. So, for instance a call to
35     get_network_stats_diff is made, and called again 5 seconds later. Over that
36     time, 20 bytes of traffic was transmitted and 10 bytes received. Tx will
37     store 20, rx will store 10 and systime will store 5. This function copes
38     with wrap arounds by the O/S so should be seemless to use.
39    
40     Bugs:
41     get_network_stats_diff on very first call will return the same as
42     get_network_stats. After first call it will always return the difference.
43 pajs 1.2 On machines that hold only 32bits of information, if the call is made 2x
44     wrap around (eg sol7 9gb has been transferred, and it wraps at 4gb) it will
45     return incorrect results (case above, it would say 5gb transferred).
46 pajs 1.1
47     Very basic example in examples/network_traffic.c
48