How can I see the output of Ethernet?

I have built a board with “EMX” module, and the board is on basis of "Cobra"
I want to test the UDP send. Where can I check the output of Ethernet?

the code is as follow:



using System;
using System.Net;
using System.Text;
using System.Threading;
using System.Net.Sockets;

using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;

using GHIElectronics.NETMF.FEZ;
using GHIElectronics.NETMF.Net.NetworkInformation;



namespace Okotemp5000_FEZ_Board
{
    public class Program
    {
        static int i=0;
        static String msg = "Hello PC" +i;
        static byte[] bytesToSend = Encoding.UTF8.GetBytes(msg);

        static IPAddress DestinationIP = new IPAddress(new byte[] { 192, 168, 1, 56 });
        static IPEndPoint DestinationEndPoint = new IPEndPoint(DestinationIP, 2000);

        static Socket mySocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);

        static void RunMe_1(object o)
        {
            msg = "Hello PC" + i;
            bytesToSend = Encoding.UTF8.GetBytes(msg);
            
            mySocket.SendTo(bytesToSend, bytesToSend.Length, SocketFlags.None, DestinationEndPoint);
            Debug.Print(new String(Encoding.UTF8.GetChars(bytesToSend))); 

            i++;

            if (i == 100) i = 0;

            
        }



        public static void Main()
        {

            Timer MyTimer_1 = new Timer(new TimerCallback(RunMe_1), null, 5000, 1000);


            if (Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces().Length < 1)
            {

                Debug.Print("No Active network interfaces. Bombing out.");

                Thread.CurrentThread.Abort();

            }

            Microsoft.SPOT.Net.NetworkInformation.NetworkInterface NI = Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()[0];

            NI.EnableStaticIP("192.169.1.200", "255.255.255.0", "192.169.1.56");


            Debug.Print("hello");

            Debug.Print("The timer will fire in 5 seconds and then fire priodically every 1 second");
            Thread.Sleep(Timeout.Infinite);
            
        }
    }
}


The parameter “bytesToSend” is what I want to send,

I can see something about “Debug.Print” In “output Window” of “Visual Studio” as follow:


hello
The timer will fire in 5 seconds and then fire priodically every 1 second
Hello PC0
Hello PC1
Hello PC2
Hello PC3
Hello PC4
Hello PC5

I find that my timer doesn’t run after about 5 second.

I waited about 10 seconds and saw timer run again, but only a few seconds, then timer stopped, after about 2 minutes, run again…

in "output " of “Visual Studio” I can see as follow:

Hello PC7
Hello PC8
Hello PC9
Hello PC10
Hello PC11
Hello PC12
Hello PC13
Hello PC14
.......................
.......................

I don’t know why?

Should the timer run every 1 second period?

How can I sure, if the parameter “bytesToSend” is sent successfully?

Open a UDP socket on port 2000 on the machine with address 192.168.1.56 and see what comes in. You could probably use a tool such as netcat for this, or you could write a custom piece of software.

Start Wireshark on the destination pc and start capture. You can filter to just UDP if you want

wireshark can be found here http://www.wireshark.org/

@ Nubiarn -

thanks a lot!!!
it works well and I have seen what the ethernet sent.