Воспроизвести пакетный захват UDP - PullRequest
3 голосов
/ 25 января 2012

У меня есть захват пакета UDP, который я захватил, используя wireshark в сети N1. Этот перехват содержит пакеты, идущие от порта 4000 по IP-адресу IP1 к порту 4000 по IP-адресу IP2.

Сейчас я воспроизводю эти пакеты с помощью Colasoft Packet Player в сети N2, отправляя пакеты с IP-адреса IP3 на IP-адрес P4.

Поскольку я переигрываю пакеты, я предполагаю, что они будут отправлены и получены через порт 4000. Это было подтверждено захватом переигранных пакетов с помощью wireshark.

Однако я не вижу ни одного из этих пакетов на UDP-сервере, который я написал на C # (который из-за соображений конфиденциальности компании я не могу разместить здесь). Чтобы исключить любые подозрения в ошибке на стороне моего кода, я скачал следующий код из онлайн-примера:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;

// SERVER.CS
// This is a simple UDP server that receives a UDP datagram containing a random word to a server on the local computer
// usage server.exe [PORT], where [PORT] is the sever UDP port number of the local PC

namespace UDPLocalServer
{
    class ProgramServer
    {
        static void Main(string[] args)
        {
                if (args.Length != 1)
            {
                Console.WriteLine("USAGE: client.exe [PORT] [MESSAGE]");
                Environment.Exit(1);
                }

            byte[] message = new byte[128];

            String server_name         = Dns.GetHostName();             // Get the name     of the sever
            IPHostEntry server_host    = Dns.GetHostEntry(server_name); // Internet host address information
            IPAddress server_ip        = server_host.AddressList[0];    // IP address of the server
            IPEndPoint server_endpoint = new IPEndPoint(server_ip, Convert.ToInt16(args[0])); // IP and PORT pairing of the server

            // Creates an IPEndPoint to capture the identity of the client when we'll use the Socket.ReceiveFrom Method
            IPEndPoint remote_endpoint = new IPEndPoint(IPAddress.Any, 4000);   // IP and PORT pairing of the client

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

            // Bind the Socket to the local endpoint
            server_udp_socket.Bind(server_endpoint);

            // Receive message from the remote local client
            EndPoint ep = (EndPoint)remote_endpoint;
            server_udp_socket.ReceiveFrom(message, ref ep);

            Console.WriteLine(System.Text.Encoding.Unicode.GetString(message));
            Console.WriteLine(ep.ToString());
            Console.WriteLine(message this program is not able to show me any udp communication, while wireshark is showing me incoming packets.

Я действительно не понимаю, почему это происходит, и я был бы признателен за любую помощь по этому вопросу.

Спасибо

...