KCA150/151 Background You should be paying attention in class, but, oh, the Internet is such a distraction. What with Governments to hack, a Census to fail, Google to search, cat pictures to peruse,...

Description in docx file


KCA150/151 Background You should be paying attention in class, but, oh, the Internet is such a distraction. What with Governments to hack, a Census to fail, Google to search, cat pictures to peruse, YouTube to waste time on, and Snapchat to send coded messages on, there’s very little University wifi bandwidth left for actual work. Why is that? I’ve identified a way to examine which web sites students visit when they’re using their laptops on campus. We’ll look at just a 24-hour period of these and discover what people are up to based on sessions they initiate with particular web servers. You’ll have the date and time, the web server name, and the IP address of the student’s laptop. You will need to store data in collections organised by server. The collection should be ordered in a first-come-first-served manner, i.e. the first server identified would be the first group in the collection, the second server identified would be second, and so on. Each group would store the name of the server and a cluster of session information. Each cluster of sessions should be ordered chronologically, i.e. earliest times first, latest times last. You will need to provide some summary data (e.g. number of sessions per hour and total number of sessions per server), and an ability to display all sessions containing particular text (e.g. source IP address, date/time, or destination). Task Based only on the information above: a Which underlying data structure (array or linked-list) will you use as a basis to model the overall collection of sessions? In two–three sentences, justify your answer. b Which kind of abstract data type (binary tree, general tree, array, stack, priority queue, double-ended queue, set, list, etc.) would you use to model the collection? In two–three sentences, justify your answer by indicating the functionality required. c Which underlying data structure (array or linked-list) will you use as a basis to model the cluster of sessions for each server? In two–three sentences, justify your answer. d Which kind of abstract data type (binary tree, general tree, array, stack, priority queue, double-ended queue, set, list, etc.) would you use to model the cluster of sessions for each server? In two–three sentences, justify your answer by indicating the functionality required. The types required will now be presented. A session is defined as follows: struct session_int { char date[20]; char source_IP[16]; char destination[50]; }; typedef struct session_int *session; and you may assume the existence of those types and the following functions: void init_session(session *sp, char *when, char *from, char *to); char *get_date(session s); char *get_source_IP(session s); char *get_destination (session s); void set_date(session s, char *when); void set_source_IP(session s, char *from); void set_destination(session s, char *to); char *to_string(session s); A server is defined as follows: struct server_int { char name[50]; cluster sessions; }; typedef server_int *server; and you may assume the existence of those types and the following functions: void init_server(server *sp, char *who); char *get_name(server s); cluster get_sessions(server s); void set_name(server s, char *who); void set_sessions(server s, cluster c); A cluster is a group of sessions. You must define the cluster type based upon your answer to (c) above. For example: typedef ??? cluster; You must also define what the type collection is based upon your answers to (a). This will be a group of servers (as defined above) which consist of the server’s name and a cluster. For example: typedef ??? collection; Finally, with those types defined, a variable (called archive in the below) can be defined to be of type collection. collection archive; e You must complete assig_two119.h and assig_two119.c by adding the cluster, and collection types from above, and also the functions to store sessions in your cluster, servers in your collection, and to search and display the results. Function stubs are already present; you must complete these and may add others. If your answer to (a) or (c) above is a linked-list then you will also need to write node.h and node.c and add them to the project. Provisions A Visual Studio project is available on MyLO for you to download and use as a starting point. This comprises the following files: · session.h and session.c — the Session ADT as specified above. These files are complete; · server.h and server.c — the Server ADT as specified above. These files are complete; · assig_two119.h — the file into which you should declare the cluster and collection types; and · assig_two119.c — the file which contains the main() function and other functions which you write to implement the required task. Program specification First you must obtain the data. (In this case the data is generated by a function which is provided.) This data must be stored (one session at a time) in appropriate collections. At the top level there should be a collection of servers and for each of these servers there should be a cluster of the sessions (stored in ascending order by date and time). Once the data have been stored in the collections, a menu should be presented offering four choices. The user should be able to view summary information by server, summary information by hour, all sessions containing specified text, or to quit. The code to manage this menu is provided. Hint: the provided code contains a function, to_lower(), to convert text to lowercase so that case-insensitive comparison may be made. The comparison can be made using strstr() which looks for its second parameter within its first. You’ll need to check the date, source IP address, and destination (server name). You may also find strtok() and strcpy() from and atoi() from useful functions. Sample output (see below) illustrates the required behaviour: Program Style The program you write for this assignment must be contained in six–eight files as follows: · the six files provided; and · node.h and node.c for nodes of linked lists (if this data structure has been selected). Your program should follow the following coding conventions: · no function should be longer than about half a screen-full or so of code; · const variable identifiers should be used as much as possible, should be written all in upper case and should be declared before all other variables; · #defined symbols should be used for constant values only if const is inappropriate · global variables should be used sparingly with parameter lists used to pass information in and out of functions. · local variables should only be defined at the beginning of functions and their identifiers should start with a lower case letter; · every if and if-else statement should have a block of code (i.e. collections of lines surrounded by { and }) for both the if part and the else part (if used) · every do, for, and while loop should have a block of code (i.e. {}s) · the keyword continue should not be used; · the keyword break should only be used as part of a switch statement; · opening and closing braces of a block should be aligned; · all code within a block should be aligned and indented 1 tab stop (or 4 spaces) from the braces marking this block; · commenting: · There should be a block of header comment which includes at least · file name · student name · student identity number · a statement of the purpose of the program · date o Each variable declaration should be commented · There should be a comment identifying groups of statements that do various parts of the task · Comments should describe the strategy of the code and should not simply translate the C into English Marking scheme Task/Topic Maximum mark Design ADTs chosen wisely 3 Data structures correct and justified 3 Program operates as specified node.c correctly completed (if required, or array equivalent) 6 assig_two119.c correctly completed — • initialise_archive() to initialise the archive variable 2 • add_existing() to o add a session to a non-empty cluster 2 o in chronological order 2 • add_session() to o add a session to an empty archive 1 o add a session to a new server (adding the server in first-in-first-out order) 2 o call add_existing() to add a session to a non-empty cluster 1 • show_servers() to display the summary for menu option 1 4 • show_times() to display the summary for menu option 2 4 • show_selection() to display all relevant sessions for menu option 3 6 Program Style Does not unnecessarily repeat tests or have other redundant/confusing code 4 Uses correctly the C naming conventions 4 Alignment of code and use of white space makes code readable 4 Always uses blocks in branch and loop constructs 4 Meaningful identifiers 4 Variables defined at the start of functions 4 Header comments for the program (author, date etc.) 4 Each variable declaration is commented 4 Comments within the code indicate the purpose of sections of code (but DO NOT just duplicate what the code says) 4 1/9 1/9 1/7
Apr 30, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here