MarkJoel60
MarkJoel60

Reputation: 557

Sending UDP Packets over Verizon Aircard

I apologize if this has been asked and answered elsewhere. I searched and read through all of the close topics, and didn't find a hit...

Here's my situation. My client has software that sends and receives UDP packets. The end user software runs on a laptop connected via a Verizon aircard. (I'll explain why that matters later...) They want me to request a report from the server on a set interval, so they don't have to remember to request it from the server. To do this, I have to trick the server into thinking I'm its client software, and to honor my request. It is not as bad as it sounds.

My program sends its request up to the server via a UDP packet. The server thinks the request came from it's own client software, and sends a result back down to the client. Their mobile client processes the info, and my program idles until the next interval. Everyone's happy. I got this working by putting wireshark on the system and watching the packets going to and fro, and then dissecting the UDP packets.

According to wireshark, the client sends its packet out on Port 6767, and the server receives it on port 6868. I was able to get this working while I was attached to their network directly (as a test). However, when I moved my software to their mobile unit, running on the verizon aircard, it does not work. As far as I can tell, the packets are still going up, but they are not being recognized by the server. And the problem is that Wireshark will not capture packets on the Verizon aircard, so I can't compare bytes -- as I did on the network. My customer -- who seems a little woozy when discussing network things -- tells me that the ports stay the same, whether they are on the network or the aircard.

The simple code I am running looks like this:

public void transmitUDPDataPacket(string IP, string portStr)
 {
    Int32 port = 0;
    try
     {
          port = Convert.ToInt32(portStr);
      }
    catch (Exception ex)
      {
         resultFailed("FAILED: transmitDataPacket " + ex.Message);
         return;
      }
    Socket sending_socket = new Socket(AddressFamily.InterNetwork, 
                          SocketType.Dgram, ProtocolType.Udp);
    IPAddress send_to_address = IPAddress.Parse(IP);
    IPEndPoint sending_end_point = new IPEndPoint(send_to_address, port);
     try
      {
        sending_socket.SendTo(data, data.Length, SocketFlags.None, sending_end_point);
      }
etc.

So, some questions:

  1. I know how I specify an endpoint (i.e. 6868) in my UDP command. But I don't see where I specify what port it goes out on from my end (i.e. 6767). Is there such a thing?
  2. Short of buying special software, is there anyway to capture a Verizon Aircard's packets?
  3. What kind of SocketType Enumeration should I be using? Currently, I am using Dgram, but I thought of switching to RDM -- though I don't think that would make any difference here, anyway, it was a thought.

Upvotes: 1

Views: 345

Answers (1)

sarnold
sarnold

Reputation: 104050

For point #1: You're looking for the Bind() method.

For point #3: Stick to Dgram, that will translate roughly to UDP. There are other datagram methods available: RUDP, UDP-lite, DCCP, RDS, but plain old UDP will transfer over the public Internet far easier than any of the other alternatives.

Upvotes: 1

Related Questions