ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/libstatgrab/docs/network.txt
(Generate patch)

Comparing projects/libstatgrab/docs/network.txt (file contents):
Revision 1.2 by pajs, Mon May 12 13:37:44 2003 UTC vs.
Revision 1.3 by tdb, Thu Jun 5 16:02:43 2003 UTC

# Line 1 | Line 1
1   Network Statistics
2 + ==================
3  
4 < All network statistics return a network_stat_t structure.
4 > Data Structure
5 > --------------
6  
7 + All network statistics return a structure of type network_stat_t that
8 + looks like this:
9 +
10   typedef struct{
11          char *interface_name;
12          long long tx;
# Line 9 | Line 14 | typedef struct{
14          time_t systime;
15   }network_stat_t;
16  
17 < Interface name is the name known to the OS. E.g. eth0 on linux.
18 < tx is a long long with the number of bytes transmitted.
19 < rx is a long long with the number of bytes recieved.
20 < sysname is time_t covering the time the amount of data in rx/tx was
21 < generated.
17 > interface_name  is the name know to the operating system.
18 >                (eg. on linux is might be eth0)
19 > tx              is the number of bytes transmitted.
20 > rx              is the number of bytes received.
21 > sysname         is the time period over which tx and rx were
22 >                transferred.
23  
24 + Functions
25 + ---------
26  
27   network_stat_t *get_network_stats(int *entries);
28  
29   network_stat_t *get_network_stats_diff(int *entries);
30  
31 < Both calls take a pointer to an int, "entries". This is filled with the number
32 < of network interfaces the machine has. You need to know this to know how
33 < many network_stat_t have been returned.
31 > Both calls take a pointer to an int, "entries", which is filled with
32 > the number of network interfaces the machine has. This is needed to
33 > know how many network_stat_t structures have been returned. A pointer
34 > is returned to the first network_stat_t.
35  
36 < get_network_stats returns the network traffic stored in the kernel. E.g.
37 < since bootup as long as the way it is stored in the kernel can store a large
38 < enough number. Solaris 7 can not, it only stores it in a 32bit int, so it
39 < can only store upto 4gb before it will wrap around. Solaris 8 upwards stores
40 < it in a 64bit int and so is a very large number :)
36 > get_network_stats returns the network traffic stored in the kernel
37 > which holds the amount of data transferred since bootup. On some
38 > platforms, such as Solaris 7, this value is stored in a 32bit int, so
39 > wraps around when it reaches 4GB. Other platforms, such as Solaris 8,
40 > hold the value in a 64bit int, which wraps somewhere near 17 million
41 > terabytes.
42  
43   get_network_stats_diff is the same as get_network_stats except it will
44   return the difference since the last call. So, for instance a call to
# Line 37 | Line 47 | time, 20 bytes of traffic was transmitted and 10 bytes
47   store 20, rx will store 10 and systime will store 5. This function copes
48   with wrap arounds by the O/S so should be seemless to use.
49  
50 < Bugs:
51 < 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 < 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).
50 > Bugs
51 > ----
52  
53 < Very basic example in examples/network_traffic.c
53 > On the very first call get_network_stats_diff will return the same as
54 > get_network_stats. After the first call it will always return the
55 > difference.
56 >
57 > On operating system that hold only 32bits of data there is a problem if
58 > the values wrap twice. For example, on Solaris 7 if 9GB is transferred
59 > and the operating system wraps at 4GB, the get_network_stats_diff
60 > function will return 5GB.
61 >
62 > Example
63 > -------
64 >
65 > A very basic example can be found in examples/network_traffic.c
66  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines