-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
speedynet-1.1.4.cpp
141 lines (116 loc) · 5.25 KB
/
speedynet-1.1.4.cpp
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#include <iostream>
#include <vector>
#include <chrono>
#include <cstdlib>
#include <ctime>
#include <stdexcept>
struct Server {
std::string name;
std::string address;
// Constructor para inicialización de objetos Server
Server(const std::string& serverName, const std::string& serverAddress)
: name(serverName), address(serverAddress) {}
};
double measureDownloadSpeed(const Server& server) {
return (std::rand() % 500) 1;
}
double measureUploadSpeed(const Server& server) {
return (std::rand() % 500) 1;
}
int measureLatency(const Server& server) {
return std::rand() % 100;
}
double measurePacketLoss(const Server& server) {
return (std::rand() % 10) / 10.0;
}
void displayIntro() {
std::cout << "\n";
std::cout << "╔══╗──────╔╗─╔═╦╗─╔╗\n";
std::cout << "║══╬═╦═╦═╦╝╠╦╣║║╠═╣╚╗\n";
std::cout << "╠══║╬║╩╣╩╣╬║║║║║║╩╣╔╣\n";
std::cout << "╚══╣╔╩═╩═╩═╬╗╠╩═╩═╩═╝\n";
std::cout << "───╚╝──────╚═╝\n";
std::cout << "************************************\n";
std::cout << "* SpeedyNet *\n";
std::cout << "* Internet Speed Test Utility *\n";
std::cout << "************************************\n";
std::cout << "\n";
std::cout << "With love from Chile\n";
std::cout << "Developed by Felipe Alfonso González - Computer Science Engineer\n";
std::cout << "Contact: [email protected]\n";
std::cout << "GitHub: github.com/felipealfonsog\n";
std::cout << "\n";
std::cout << "This software is licensed under the MIT License.\n";
std::cout << "\n";
}
void displayResults(const Server& selectedServer, double downloadSpeed, double uploadSpeed, int latency, double packetLoss) {
std::cout << "\nTest Results:\n";
std::cout << "Selected Server: " << selectedServer.name << " (" << selectedServer.address << ")\n";
std::cout << "Download Speed: " << downloadSpeed << " Mbps\n";
std::cout << "Upload Speed: " << uploadSpeed << " Mbps\n";
std::cout << "Latency: " << latency << " ms\n";
std::cout << "Packet Loss: " << packetLoss * 100 << "%\n";
}
void handleError(const std::string& errorMessage) {
std::cerr << "Error: " << errorMessage << std::endl;
}
std::vector<Server> getServers() {
std::vector<Server> servers;
servers.push_back(Server("Google DNS", "8.8.8.8"));
servers.push_back(Server("Cloudflare DNS", "1.1.1.1"));
servers.push_back(Server("Movistar Chile", "speedtest.movistar.cl"));
servers.push_back(Server("VTR", "speedtest.vtr.net"));
servers.push_back(Server("Claro Chile", "speedtest.clarochile.cl"));
servers.push_back(Server("Entel Chile", "speedtest.entel.cl"));
servers.push_back(Server("Gtd Manquehue", "speedtest.gtdinternet.com"));
servers.push_back(Server("Coopeuch", "speedtest.coopeuch.cl"));
servers.push_back(Server("IFX Networks", "speedtest.ifxnetworks.cl"));
servers.push_back(Server("Libre Net", "speedtest.librenet.cl"));
servers.push_back(Server("Netline", "speedtest.netline.cl"));
servers.push_back(Server("Telsur", "speedtest.telsur.cl"));
servers.push_back(Server("Google", "speedtest.google.com"));
servers.push_back(Server("Cloudflare", "speed.cloudflare.com"));
servers.push_back(Server("Fast.com", "fast.com"));
servers.push_back(Server("Speedtest.net", "speedtest.net"));
servers.push_back(Server("Comcast", "speedtest.xfinity.com"));
servers.push_back(Server("AT&T", "speedtest.att.com"));
servers.push_back(Server("Verizon", "speedtest.verizon.com"));
servers.push_back(Server("Spectrum", "speedtest.spectrum.com"));
servers.push_back(Server("Vodafone", "speedtest.vodafone.com"));
servers.push_back(Server("Telefónica", "speedtest.telefonica.com"));
servers.push_back(Server("Movistar", "speedtest.movistar.com"));
servers.push_back(Server("Orange", "speedtest.orange.com"));
servers.push_back(Server("T-Mobile", "speedtest.t-mobile.com"));
servers.push_back(Server("Sprint", "speedtest.sprint.com"));
servers.push_back(Server("Telstra", "speedtest.telstra.com"));
// Agrega más servidores según sea necesario
return servers;
}
Server selectServer() {
std::cout << "Select a server:\n";
std::vector<Server> servers = getServers();
for (size_t i = 0; i < servers.size(); i) {
std::cout << i 1 << ". " << servers[i].name << "\n";
}
int choice;
std::cout << "Enter the number of the server: ";
std::cin >> choice;
if (choice < 1 || choice > static_cast<int>(servers.size())) {
throw std::out_of_range("Invalid server choice");
}
return servers[choice - 1];
}
int main() {
displayIntro();
Server selectedServer = selectServer();
try {
double downloadSpeed = measureDownloadSpeed(selectedServer);
double uploadSpeed = measureUploadSpeed(selectedServer);
int latency = measureLatency(selectedServer);
double packetLoss = measurePacketLoss(selectedServer);
displayResults(selectedServer, downloadSpeed, uploadSpeed, latency, packetLoss);
} catch (const std::exception& e) {
handleError(e.what());
}
return 0;
}