The purpose of this assignment is to practice merging data from two files to generate a report.
The two files to merge are:
This message includes the local port assigned to this conversation. This port will be unique for each conversation in these files.
These messages show details about each packet that is transfered between the router and the external nodes including the time, number of bytes, IP addresses and IP port the packets are transferred between.
Write an application that reads these two files and generates a report by examining each line in the SNMP file and finding all the lines in the tcpdump file that relate to that conversation (have the same port address).
Total the number of bytes sent and received in the conversation and generate a report that looks like this:
Time Rcv Xmit Internal External Service Port
16:02:14 7723 2999 192.168.1.2 -> mail.emich.edu 443
16:02:19 534 2183 192.168.1.2 -> 0.channel41.facebook.com 80
16:02:40 20247 1098 192.168.1.249 -> 204.176.49.116 80
16:03:17 534 2183 192.168.1.2 -> 0.channel41.facebook.com 80
16:04:15 534 2181 192.168.1.2 -> 0.channel41.facebook.com 80
There are some options to the lsearch command that will be required to finish this assignment:
lsearch ?-behavior? list pattern
lsearch
command
-all
| Return the indices of all elements that match the pattern |
-start number
| Return the first element at or after index number |
-inline
| Return the list elements that match the pattern, instead of the index number. |
EXAMPLES
set lst {a1 b2 c3 a4 b5 c6}
lsearch $lst a*
0
lsearch -start 1 $lst a*
6
lsearch -all $lst a*
0 6
lsearch -inline $lst a*
a1
lsearch -all -inline $lst a*
a1 a4
You will need either the -all
or -start
to solve
this problem. Either option can be used sucessfully.
You don't need the -inline
option, but using it will
simplify your code.