Subject: 32547 UNIX Systems Programming, Autumn 2017 Assignment Submission The completed assignment is due by 5:00pm of Friday 9 June 2017. Title: Summary of network usage statistics with Perl In this assignment, you will write a Perl program which parses a file containing information about the network usage of a Unix computer and outputs summary information. These are the specifications for your Perl program: It must be named net_stat.pl It must be invoked as: net_stat.pl option net_usage_file The program must check that: a) it is invoked with the appropriate number of arguments, and b) the values for the option argument are as described below, and c) that the net_usage_file argument is a readable file. The examples below clarify the valid invocations. In all other cases, the program must print a message to the standard output explaining to the user how the program should be invoked correctly, and exit. File net_usage_file can have any arbitrary name. It must be a file of text with the following format: The first line contains names of fields. The first line is followed by an arbitrary number of other lines (including, possibly, zero lines). Each of the lines after the first must contain seven fields aligned as in the example below. The seven fields are: Interface: the name of the interface; width: 10 characters; Rx-ok: the number of correctly received units; width: 8 characters; Rx-err: the number of units received with errors; width: 8 characters; • Rx-drp: the number of received units dropped; width: 8 characters; Tx-ok: the number of correctly transmitted units; width: 8 characters; Tx-err: the number of units transmitted with errors; width: 8 characters; Tx-drp: the number of transmitted units dropped; width: 8 characters. The Interface field is a string of characters. Acceptable characters include: lower case letters, upper case letters, and digits. The same string can appear only in one line. Every other field is a string of decimal digits. The following is an example of file net_usage_file: Interface Rx-ok Rx-err Rx-drp Tx-ok Tx-err Tx-drp eth0 2450012 12 20 640000 0 0 lo 16356 0 0 44333 0 0 wlan0 4800000 898 645 7812167 345 0 Very important note: your program is not expected to verify that file net_usage_file complies with the above specifications. It will only be tested with compliant files. Your program can be invoked with option: -n. In this case, it must print the following: Interfaces: Example with the example net_usage_file given above: Command line: net_stat.pl -n net_usage_file Output: Interfaces: eth0 lo wlan0 In the case in which file net_usage_file contains only the first line, your program must instead only print: No interfaces present Your program can be invoked with option: -r. In this case, it must only print the following string: Total number of units received: Example with the example net_usage_file given above: Command line: net_stat.pl –r net_usage_file Output: Total number of units received: 7267943 In the case in which file net_usage_file contains only the first line, your program must print: Total number of units received: 0 Your program can be invoked with option: -t. In this case, it must only print the following string: Total number of units transmitted: Example with the example net_usage_file given above: Command line: net_stat.pl –t net_usage_file Output: Total number of units transmitted: 8496845 In the case in which file net_usage_file contains only the first line, your program must print: Total number of units transmitted: 0 Your program can be invoked with option: -i . In this case, it must print: Interface : Total number of units received: Percentage of correctly received units: Total number of units transmitted: Percentage of correctly transmitted units: Example with the example net_usage_file given above: Command line: net_stat.pl –i wlan0 net_usage_file Output: Interface wlan0: Total number of units received: 4801543 Percentage of correctly received units: 99.968% Total number of units transmitted: 7812512 Percentage of correctly transmitted units: 99.996% If the percentage of correctly received units or correctly transmitted units is below 99%, the program must also add the following line to the output above: Attention: significant errors over this interface In the case in which interface interface’s name is not present in net_usage_file, your program must print: Interface not found Your program can be invoked with option: -v. In this case, it must only print your name, surname, student ID and date of completion of your assignment, using a format of your choice. No options can be used simultaneously. This means that your program can only be invoked with one of the options at a time. Zip your file net_stat.pl into a file named USP__.zip and submit it with the modalities specified above. Several free zip utilities are available on the WWW.