private void EnviandoMensaje(string mensaje, int contador)
        {
            int numPart = Convert.ToInt32((mensaje).Length / tamañoMaximoMensajeDeTrama);

            if (numPart < 16777215)
            {
                if ((mensaje).Length % tamañoMaximoMensajeDeTrama != 0)
                {
                    numPart += 1;
                }
                //TRAMA DE INFORMACION
                Trama info = new Trama(0xf, contador, 0, numPart, "");
                puerto.Write(info.getTramaCompleta(), 0, 1024);

                Trama parte;
                for (int i = 1; i <= numPart; i++)
                {
                    if (i != numPart)
                    {
                        parte = new Trama(0xb, contador, i, 0, mensaje.Substring(1014 * (i - 1), 1014));
                    }
                    else
                    {
                        parte = new Trama(0xb, contador, i, 0, mensaje.Substring(1014 * (i - 1)));
                    }
                    puerto.Write(parte.getTramaCompleta(), 0, 1024);
                }
            }
        }
        private void EnviandoArchivo(string nombreArchivo, int contador)
        {
            //MessageBox.Show("lego a enviando archivo");
            using (System.IO.Stream f = new System.IO.FileStream(nombreArchivo, FileMode.Open))
            {
                int    offset = 0;
                long   len    = f.Length;
                byte[] buffer = new byte[1014];

                if (f.Length / tamañoMaximoMensajeDeTrama + 1 < 16777215)
                {
                    int numPart = Convert.ToInt32(f.Length / tamañoMaximoMensajeDeTrama);

                    if (f.Length % tamañoMaximoMensajeDeTrama != 0)
                    {
                        numPart += 1;
                    }
                    if (f.Length == 0)
                    {
                        numPart = 1;
                    }
                    int porcentaje = Convert.ToInt32((16777215 / numPart));

                    Trama info = new Trama(0xf, contador, 0, numPart, nombreArchivo);
                    puerto.Write(info.getTramaCompleta(), 0, 1024);
                    int   readLen = 1014; // leer pedazos de 1024
                    Trama parte;
                    int   i = 1;
                    while (offset != len)
                    {
                        if (offset + readLen > len)
                        {
                            readLen = (int)len - offset;
                        }
                        offset += f.Read(buffer, 0, readLen);

                        parte = new Trama(0xa, contador, i, 0, buffer, readLen);

                        Console.WriteLine("--------------");
                        Console.WriteLine("enviando trama " + parte.getCabezeraString());
                        Console.WriteLine(contador.ToString() + "  " + porcentaje.ToString());
                        Console.WriteLine("--------------");

                        puerto.Write(parte.getTramaCompleta(), 0, 1024);

                        onLlegoArchivo("", porcentaje.ToString(), contador.ToString(), "11");
                        buffer = new byte[1014];
                        i++;
                    }
                }
                else
                {
                    // generar un error por q el archivo es demasiado grande para enviar :v
                }
            }
        }