24 | | Type 'help;' or '\h' for help. Type '\c' to clear the buffer. |
25 | | |
26 | | mysql> use <DB NAME>; |
27 | | |
28 | | }}} |
29 | | |
30 | | Standard MySQL queries can then be made to manipulate your data. A brief tutorial on how to use MySQL can be found [http://dev.mysql.com/doc/refman/4.1/en/index.html here]. |
31 | | |
32 | | The database name is your experiment ID and is displayed by the nodehandler in the first few lines of your experiment run. It will look something like this: |
33 | | {{{ |
34 | | INFO init: Experiment ID: sb5_2006_01_17_11_45_23 |
35 | | }}} |
36 | | |
37 | | [[BR]] |
38 | | == 2. Using Perl scripts == |
39 | | |
40 | | You can use the following sample Perl script to retrieve the content of a particular table from your experiment database: |
41 | | {{{ |
42 | | #! /usr/bin/perl |
43 | | # |
44 | | # Script: getdata.pl |
45 | | # A simple script that gets all the rows from a single table in the database. |
46 | | # |
47 | | # ./getdata.pl <db_name> <table_name> <outputfile> |
48 | | # |
49 | | # Example: ./getdata.pl zmac1_2005_04_28_00_46_10 sender_otg_senderport out.txt |
50 | | # |
51 | | # To use this script replace the XXXX in DBUSER and DBPASS |
52 | | # with correct username and password for idb1. |
53 | | # |
54 | | # |
55 | | use DBI(); |
56 | | |
57 | | $DBHOST = "idb1"; |
58 | | $DBNAME = $ARGV[0]; |
59 | | $DBUSER = "XXXX"; |
60 | | $DBPASS = "XXXX"; |
61 | | $QUERY = "select * from $ARGV[1]"; |
62 | | $OUTFILE = $ARGV[2]; |
63 | | |
64 | | $dsn = "DBI:mysql:database=$DBNAME;host=$DBHOST"; |
65 | | |
66 | | #Connect to the DB |
67 | | $dbh = DBI->connect($dsn, $DBUSER, $DBPASS, {'RaiseError' => 1}); |
68 | | |
69 | | # Prepare and execute query |
70 | | my $qry = $dbh->prepare($QUERY); |
71 | | $qry->execute(); |
72 | | |
73 | | open(out, ">$OUTFILE"); |
74 | | |
75 | | #Print the column names |
76 | | print out "@{$qry->{'NAME'}} \n"; |
77 | | |
78 | | #Print the data |
79 | | while (my @ref = $qry->fetchrow()) { |
80 | | print out "@ref \n"; |
81 | | } |
82 | | |
83 | | $qry->finish(); |
84 | | # Disconnect from the database. |
85 | | $dbh->disconnect(); |
86 | | }}} |
87 | | |
88 | | A more specific Perl script for OTG/OTR application can be found [wiki:Old/Documentation/OTG/Measurement/DatabaseProcess here] |
89 | | |
90 | | [[BR]] |
91 | | == 3. Using Microsoft Excel == |
92 | | |
93 | | Microsoft Excel can be used to analyze an experiment as shown below. |
94 | | |
95 | | [[Image(Excelexample.PNG)]] |
96 | | |
97 | | The user could import MySQL database to Microsoft Excel and use chart and other tools to analyze the measurements. |
98 | | |
99 | | [[BR]] |
100 | | == 4. Using Matlab == |
101 | | |
102 | | Matlab is another tool can be used. It should be noted that this assumes you have [http://www.die.net/doc/linux/man/man1/mysqldump.1.html exported] the database off of ORBIT and imported to your own MySQL server. |
103 | | {{{ |
104 | | function nsf(dbServer, dbUser, dbPW, database); |
105 | | % Part where we retrieve data from the database; |
106 | | mysql('open',dbServer, dbUser, dbPW); |
107 | | mysql('use', database); |
108 | | output = struct('time',[],'thr_all',[],'node',[]); |
109 | | [output.time, output.thr_all, output.node] = mysql('select timestamp, throughput, node_id from group2'); |
110 | | [thru1_4, time1_4, thru3_1, time3_1] = sort_mysql(output); |
111 | | % Finally, the plotting part |
112 | | subplot(2,1,1); |
113 | | plot(time1_4, thru1_4, '-*'); |
114 | | title('Throughput On Obstructed Link'); |
115 | | xlabel('Time (sec)'); ylabel('Throuhput (bps)'); grid on; |
116 | | subplot(2,1,2); |
117 | | plot(time3_1, thru3_1, '-*'); |
118 | | title('Throughput On Monitor Node'); xlabel('Time (sec)'); |
119 | | ylabel('Throuhput (bps)'); grid on; |
120 | | }}} |
121 | | |
122 | | And the resulting graph is show below: |
123 | | |
124 | | [[Image(Matlabexample.PNG)]] |
| 18 | === Matlab Example === |