1 |
48 |
alirezamon |
*------------------------------------------------------------------------------
|
2 |
|
|
* Netrace: A network packet trace reader
|
3 |
|
|
*
|
4 |
|
|
* Joel Hestness
|
5 |
|
|
* hestness@cs.utexas.edu
|
6 |
|
|
* Computer Architecture and Technology Laboratory
|
7 |
|
|
* Department of Computer Science
|
8 |
|
|
* University of Texas - Austin
|
9 |
|
|
*------------------------------------------------------------------------------
|
10 |
|
|
|
11 |
|
|
Netrace is a network packet trace reader library for use with network
|
12 |
|
|
simulators. It reads packets from tracefiles of a standardized, flexible
|
13 |
|
|
file format. This README contains information about compilation and use
|
14 |
|
|
of the netrace library.
|
15 |
|
|
|
16 |
|
|
EXAMPLE CODE:
|
17 |
|
|
-------------
|
18 |
|
|
There is an example of how netrace can be used in the file `main.c'. It
|
19 |
|
|
implements a simple cycle-driven network simulator with queuing of
|
20 |
|
|
packets. To build and run it, simply run make:
|
21 |
|
|
> make
|
22 |
|
|
> ./main testraces/shrtex.tra.bz2
|
23 |
|
|
|
24 |
|
|
TRACE VIEWER:
|
25 |
|
|
-------------
|
26 |
|
|
This package also contains a utility to dump information about the network
|
27 |
|
|
traces to the command line. It is called `trace_viewer' and can be found in
|
28 |
|
|
the `util' directory:
|
29 |
|
|
> cd util
|
30 |
|
|
> make
|
31 |
|
|
> ./trace_viewer ../testraces/example.tra.bz2
|
32 |
|
|
Here, the header of the tracefile is printed, including the benchmark name,
|
33 |
|
|
the number of packets and cycles for the trace, notes about the trace,
|
34 |
|
|
and phase information.
|
35 |
|
|
|
36 |
|
|
API:
|
37 |
|
|
----
|
38 |
|
|
Netrace implements a very simple example programming interface. In general,
|
39 |
|
|
the use of the reader proceeds as follows: (1) open tracefile, (2) seek to
|
40 |
|
|
the phase of interest in the tracefile, (3) read packets from the tracefile,
|
41 |
|
|
(4) when a packet is to be injected, check if all upward dependences
|
42 |
|
|
have been cleared, (5) upon eject of packet, clear its downward
|
43 |
|
|
dependences, and free packet, (6) close the tracefile. Each of these
|
44 |
|
|
steps is represented by a function call to the reader library as described
|
45 |
|
|
here:
|
46 |
|
|
|
47 |
|
|
* Interface Functions:
|
48 |
|
|
--------------------
|
49 |
|
|
void nt_open_trfile()
|
50 |
|
|
|
51 |
|
|
To open a tracefile, call `nt_open_trfile'. The character string passed
|
52 |
|
|
should be the path to the tracefile. Note that the reader only handles
|
53 |
|
|
bzip2 traces in an effort to keep files small.
|
54 |
|
|
|
55 |
|
|
void nt_seek_region( nt_regionhead_t* )
|
56 |
|
|
|
57 |
|
|
To seek to a particular portion of the trace specified by a region
|
58 |
|
|
header, call `nt_seek_region', passing the region header. Use the
|
59 |
|
|
trace_viewer to see the phase information for a tracefile.
|
60 |
|
|
|
61 |
|
|
nt_packet_t* nt_read_packet( void )
|
62 |
|
|
|
63 |
|
|
To read a packet from the tracefile, call `nt_read_packet'. The read
|
64 |
|
|
function returns packets in chronological order by cycle. Packet cycle
|
65 |
|
|
is determined through simulation of a full-system, and the cycle
|
66 |
|
|
represents the earliest time that the packet could be injected into the
|
67 |
|
|
network.
|
68 |
|
|
|
69 |
|
|
int nt_dependencies_cleared( nt_packet_t* )
|
70 |
|
|
|
71 |
|
|
Once a packet has been returned from `nt_read_packet', it is live and
|
72 |
|
|
can be injected into the network. However, if injection of this packet
|
73 |
|
|
is dependent on the receipt of another packet, it should be held in
|
74 |
|
|
wait while the packets on which it depends are in flight in the network.
|
75 |
|
|
To that end, we provide `nt_depends_cleared', a function to test if
|
76 |
|
|
the upward dependences of a packet have been cleared. The trace reader
|
77 |
|
|
tracks all packet dependences, and quickly returns 1 if the packet
|
78 |
|
|
passed has no more upward dependences, or 0 if it still depends on
|
79 |
|
|
packets that have not been ejected from the network.
|
80 |
|
|
|
81 |
|
|
void nt_clear_dependencies_free_packet( nt_packet_t* )
|
82 |
|
|
|
83 |
|
|
This function should be called when a packet is ejected from the network.
|
84 |
|
|
`nt_clear_depends_free' clears all of the downward dependences of the
|
85 |
|
|
packet that is passed (i.e. if it is the last packet on which packet "A"
|
86 |
|
|
depends, then a further call to `nt_depends_cleared(A)' will return true,
|
87 |
|
|
indicating that A can be injected into the network). After clearing its
|
88 |
|
|
dependences, this function frees the packet that is passed.
|
89 |
|
|
|
90 |
|
|
If 'nt_init_cleared_packets_list' was called at the beginning of tracing,
|
91 |
|
|
the packets whose dependencies have been cleared will be added to the
|
92 |
|
|
cleared packets list.
|
93 |
|
|
|
94 |
|
|
void nt_close_trfile( void )
|
95 |
|
|
|
96 |
|
|
As the name suggests, this function closes the currently open tracefile,
|
97 |
|
|
or returns immediately if one is not open. It also resets all dependency
|
98 |
|
|
tracking structures.
|
99 |
|
|
|
100 |
|
|
void nt_disable_dependencies( void )
|
101 |
|
|
|
102 |
|
|
Disable dependency tracking. Use this function if you are just reading
|
103 |
|
|
and using packets, but do not care about the dependencies between them.
|
104 |
|
|
|
105 |
|
|
void nt_init_cleared_packets_list()
|
106 |
|
|
|
107 |
|
|
Instead of testing each live packet each cycle to see if it can be
|
108 |
|
|
injected into the network, we provide a cleared packets list that can
|
109 |
|
|
be read each cycle. This list contains the set of packets whose
|
110 |
|
|
upward dependencies were cleared since the last time that
|
111 |
|
|
'nt_empty_cleared_packets_list' was called. For more details on using
|
112 |
|
|
the cleared packets list, see main.c.
|
113 |
|
|
|
114 |
|
|
nt_packet_list_t* nt_get_cleared_packets_list()
|
115 |
|
|
|
116 |
|
|
Call this function to get the cleared packets list each cycle. Packets
|
117 |
|
|
in the list can be injected into the network because all of their
|
118 |
|
|
dependencies have been cleared.
|
119 |
|
|
|
120 |
|
|
void nt_empty_cleared_packets_list()
|
121 |
|
|
|
122 |
|
|
Call this function after reading the cleared packets list to empty the
|
123 |
|
|
list for the next period of network activity.
|