-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
90 lines (81 loc) · 2.7 KB
/
Main.java
File metadata and controls
90 lines (81 loc) · 2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/**
* Project: Solo Lab2 Assignment Networking
* Purpose Details: Network analysis app with options for network ping,
NIC details, port scanning, and viewing the routing table
* Course: IST 242
* Author: Charlie Defelice
* Date Developed: 2/3/24
* Last Date Changed: 2/4/24
* Rev: 2.3
*/
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner scanner = new Scanner(System.in);
int choice;
//Interaction and menu functionality
do
{
displayMenu();
System.out.print("Enter your choice (1-4, 0 to exit): ");
choice = scanner.nextInt();
switch (choice)
{
case 1:
performNetworkPing();
break;
case 2:
showNICDetails();
break;
case 3:
performPortScan();
break;
case 4:
showRoutingTable();
break;
case 0:
System.out.println("Exiting System Network Analyzer. Goodbye!");
break;
default:
System.out.println("Invalid choice. Please enter a number between 0 and 4.");
}
}
while (choice != 0);
}
//Displays the user menu options
private static void displayMenu()
{
System.out.println("User Menu for System Network Analyzer:");
System.out.println("1. Perform a network ping");
System.out.println("2. Show NIC Network Interface card details");
System.out.println("3. Perform a port scan on your local computer and show ports");
System.out.println("4. Show the routing table");
System.out.println("0. Exit");
}
//Pings using the PingExample class
private static void performNetworkPing()
{
PingExample pingExample = new PingExample("www.google.com");
pingExample.performPing();
}
//Show's NIC details using the NetworkInfo class
private static void showNICDetails()
{
NetworkInfo networkInfo = new NetworkInfo();
networkInfo.showNICDetails();
}
//Performs a port scan on the local computer using the PortScanner class
private static void performPortScan()
{
PortScanner portScanner = new PortScanner("localhost");
portScanner.scanPorts();
}
//Shows the routing table using the RoutingTablePrinter class
private static void showRoutingTable()
{
RoutingTablePrinter routingTablePrinter = new RoutingTablePrinter();
routingTablePrinter.printRoutingTable();
}
}