Question: Read the input file log.txt . Create a hash table whose key is the network ( the first two numbers of the IP address
Read the input file "log.txt
Create a hash table whose key is the network the first two numbers of the IP address and whose value is a summary of that network.
This summary must include the number of accesses, the number of connections unique IPs as well as the IPs of that domain ordered in ascending order NOT Adjusted to digits.
The table size must be the largest prime number that is less than
If it happens that the table fills up and can no longer receive more data, send an error message "Table full, impossible to enter more data"
You must propose the hash function to use, and justify this in the code as a comment
Make a method that, given a network, returns the value associated with it displaying the information in the way shown in the output examples
Your program receives as input a number N followed by N domains
The output is for each domain, the domain summary
This is my code, help me fulfill what is requested
#include iostream
#include fstream
#include sstream
#include vector
using namespace std;
struct Log
string month, hour, message;
int day, port, network network host host;
Logstring month, int day, string hour, int network int network int host int host int port, string message :
monthmonth hourhour messagemessage dayday portport networknetwork networknetwork hosthost hosthost
;
int convmonthconst string& month
if month "Jan" return ;
if month "Feb" return ;
if month "Mar" return ;
if month "Apr" return ;
if month "May" return ;
if month "Jun" return ;
if month "Jul" return ;
if month "Aug" return ;
if month "Sep" return ;
if month "Oct" return ;
if month "Nov" return ;
if month "Dec" return ;
return ;
struct NetworkNode string network;
vector hosts;
;
class Graph vector networks;
NetworkNode searchNetworkconst string& redkey for self& red : networks if redred redkey return &red;
return nullptr;
vector searchHostNetworkNode networkNode, const string& hostkey for self& host : networkNodehosts if hostfirst hostkey return &host.second;
return nullptr;
bool recordExistsconst vector& records, const Record& reg for const auto& r : records if rday reg.day && rmonth reg.month && rtime reg.time && rport reg.port && rmessage reg.message return true;
return false;
public: void insertRegistry& reg string redkey tostringregred tostringregnet;
string hostkey tostringreghost tostringreghost;
NetworkNode networkNode networksearchredkey;
if rednode networks.pushbackredkey;
networknode &networks.back;
self host searchHostnetworknode hostkey;
if host networknodehosts.pushbackhostkey, ;
host &networknodehosts.backsecond;
if registrationExistshost reg hostpushbackreg;
void networkswithhighestoutdegree int maxdegree ;
for self& network : networks int degree ;
for self& host : red.hosts degree host.second.size;
maxdegree degree maxdegree degree : maxdegree;
for self& network : networks int degree ;
for self& host : red.hosts degree host.second.size;
if degree maxdegree cout red.red endl;
void iphavingmostaccess int maxaccess ;
string maxip;
for self& network : networks for self& host : network.hosts int access host.second.size;
if access maxaccess maxaccess access;
maxip network.net host.first;
cout maxip endl;
;
int main ifstream filebtxt;
if file.isopen cout "Error opening file." endl;
return ;
string line;
Graph graph;
while getlinefile line stringstream ssline;
string month, time, message, ip;
int day, port, network network host host;
ss month day hour ip;
getliness message;
message message.substr;
stringstream ipstrip;
string inpt;
getlineipstr inpt, ; red stoiinpt;
getlineipstr inpt, ; red stoiinpt;
getlineipstr inpt, ; host stoiinpt;
getlineipstr inpt, :; host stoiinpt;
port stoiinpt;
Register regmonth day, time, network network host host port, message;
graph.insertreg;
file.close;
graph.networkswithhighestoutdegree;
cout endl;
graph.ipthathasmostaccess;
return ;
NOTE: Use the same libraries, it is forbidden to change or add any other
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
