Last active
October 6, 2018 09:12
-
-
Save oscarinom/a6c8a9886f785a87c114d386500cf545 to your computer and use it in GitHub Desktop.
WafflePing v0.1 || C# VS2017
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Net.NetworkInformation; // Importación obligatoria para obtener las clases de Ping | |
| using System.Text; // Esto para manejar los bytes | |
| namespace WafflePingAlpha | |
| { | |
| class Program | |
| { | |
| /* | |
| * | |
| * | |
| * WafflePing v0.1 | |
| * (Build 10052018.1715) | |
| * | |
| * Medidor de Ping en consola con las IP de Gameservers de Riot (sí, no pongo la ip de las webs, sino que a los gs directos) | |
| * | |
| * Agradecimientos al Sebita de LoLArmy por ser el best trapito | |
| * | |
| * | |
| * | |
| */ | |
| const string las = "127.0.0.1"; // La IP de los GS es privada, puedes obtenerla con Wireshark | |
| const string lan = "127.0.0.1"; // La IP de los GS es privada, puedes obtenerla con Wireshark | |
| const int pingAmount = 10; // en volá un poquito más ? igual no quiero saturar los gs xD así que lo dejé en 10 | |
| static void Main(string[] args) | |
| { | |
| Console.WriteLine("WafflePing v0.1 para LoLArmy"); | |
| Console.WriteLine("- el programador de esto es bastante flojo, próximamente le hará interfaz gráfica, disculpe :x -"); | |
| Console.WriteLine("Presiona 1 y luego Enter si estás en LAN"); | |
| Console.WriteLine("Presiona 2 y luega Enter si estás en LAS"); | |
| var server = int.Parse(Console.ReadLine()); | |
| while (server > 2 && server < 1) | |
| { | |
| Console.WriteLine("Error, vuelva a seleccionar una opción correcta (1: LAN / 2: LAS)"); | |
| server = int.Parse(Console.ReadLine()); | |
| } | |
| var url = ""; | |
| var status = "Error"; | |
| if (server == 1) | |
| { | |
| url = lan; | |
| } | |
| else if (server == 2) | |
| { | |
| url = las; | |
| } | |
| else | |
| { | |
| Console.WriteLine("Cómo te saltaste el ciclo vv? da igual, seleccione una opción correcta"); | |
| } | |
| Ping pingSender = new Ping(); | |
| PingOptions options = new PingOptions(); | |
| var failedPings = 0; | |
| var latencySum = 0; | |
| string data = "Hola Riot Games, los quiero mucho"; | |
| byte[] buffer = Encoding.ASCII.GetBytes(data); | |
| for (int i = 0; i < pingAmount; i++) | |
| { | |
| PingReply reply = pingSender.Send(url, 1000, buffer, options); | |
| if (reply != null) | |
| { | |
| if (reply.Status != IPStatus.Success) | |
| { | |
| failedPings += 1; | |
| } | |
| else | |
| { | |
| latencySum += (int)reply.RoundtripTime; | |
| } | |
| } | |
| } | |
| var promedioPing = (latencySum / pingAmount); | |
| var packetLoss = (failedPings / pingAmount) * 100; | |
| var calificacion = "Como el pico"; | |
| if (promedioPing < 50 && promedioPing > 3) | |
| { | |
| calificacion = "Excelente, tu latencia va bien!"; | |
| } | |
| else if (promedioPing < 120 && promedioPing > 49) | |
| { | |
| calificacion = "Media, tu latencia es un poco alta, ve con cuidado!"; | |
| } | |
| else if (promedioPing < 180 && promedioPing > 119) | |
| { | |
| calificacion = "Deplorable, el juego te resultará incómodo debido a tu alta latencia, no deberías jugar!"; | |
| } | |
| else if (promedioPing > 179) | |
| { | |
| calificacion = "Cuidado, tu latencia es casi tan alta como jugar en otro continente. Revisa tu conexión!"; | |
| } | |
| else if (promedioPing == 0 || promedioPing > 300) | |
| { | |
| calificacion = "O estás jugando desde el espacio (latencia extremadamente alta) u ocurrió un error, vuelve a correr el test si es lo último :3"; | |
| } | |
| else | |
| { | |
| calificacion = "Cómo entraste aquí?"; | |
| } | |
| Console.WriteLine("Resultado del test:"); | |
| Console.WriteLine("Servidor : LA" + server); | |
| Console.WriteLine("Latencia : " + promedioPing.ToString() + "ms"); | |
| Console.WriteLine("Calificación : " + calificacion); | |
| Console.WriteLine("Paquetes Perdidos : " + packetLoss.ToString() + "%"); | |
| if (packetLoss > 15) | |
| { | |
| Console.WriteLine("-- Ten cuidado, tienes más de 15% de pérdida de paquetes, esto te puede generar dificultades en la grieta --"); | |
| } | |
| Console.WriteLine("Presiona cualquier tecla para salir (y que te vaya bien en tus rankeds uwu)"); | |
| Console.ReadKey(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment