473,385 Members | 1,387 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

UDP Blues

I am trying to send a UDP packet out over the internet to a device.
This device is NOT on a local network or LAN or WAN. Just a random IP
address on the internet somewhere.

For whatever reason, the UDP message does not arrive there the first
time I send it (after starting the app). It arrives fine for any
attempt afterwards, but never the first time.

What could the problem? I am kind of new to UDP, so I am at a loss. Do
I perhaps have to establish a route to the IP address or something like
(I am grasping, I know).

Meanwhile, if I send a message to a device on a local network, the
messages get there every time. Here is the code I use to send a message:

Socket sockUDP = New Socket(AddressFamily.InterNetwork,
SocketType.Dgram, ProtocolType.Udp)

Dim sendBytes As Byte() = Encoding.ASCII.GetBytes(Data)
Dim IpEndPoint As New IPEndPoint(IPAddress.Parse(Host), Port)

sockUDP.Connect(IpEndPoint)
sockUDP.SendTo(sendBytes, 0, sendBytes.Length, SocketFlags.None, IpEndPoint)

Thanks.
Nov 16 '05 #1
8 1767
SB
I assume it has something to do with packetloss since the packets arrive ok
on your LAN. Regardless of what's causing the packet to be dropped...when
using UDP, you HAVE to write your code assuming there will be packetloss.
If it is essential that your packet be received, you have to have the device
on the other end acknowledge receiving it. Then, if you don't get a reply,
you just keep resending it periodically until you do.

Note that I've written several UDP apps...but none in C#. However, the
above still applies.

HTH
-sb

"Frank Rizzo" <no**@none.com> wrote in message
news:OA**************@TK2MSFTNGP09.phx.gbl...
I am trying to send a UDP packet out over the internet to a device. This
device is NOT on a local network or LAN or WAN. Just a random IP address
on the internet somewhere.

For whatever reason, the UDP message does not arrive there the first time
I send it (after starting the app). It arrives fine for any attempt
afterwards, but never the first time.

What could the problem? I am kind of new to UDP, so I am at a loss. Do I
perhaps have to establish a route to the IP address or something like (I
am grasping, I know).

Meanwhile, if I send a message to a device on a local network, the
messages get there every time. Here is the code I use to send a message:

Socket sockUDP = New Socket(AddressFamily.InterNetwork, SocketType.Dgram,
ProtocolType.Udp)

Dim sendBytes As Byte() = Encoding.ASCII.GetBytes(Data)
Dim IpEndPoint As New IPEndPoint(IPAddress.Parse(Host), Port)

sockUDP.Connect(IpEndPoint)
sockUDP.SendTo(sendBytes, 0, sendBytes.Length, SocketFlags.None,
IpEndPoint)

Thanks.

Nov 16 '05 #2
UDP provides no guarantee of delivery. RFC 768 http://www.faqs.org/rfcs/rfc768.html

--
....Carl Frisk
Anger is a brief madness.
- Horace, 20 B.C.
http://www.carlfrisk.com
"Frank Rizzo" <no**@none.com> wrote in message news:OA**************@TK2MSFTNGP09.phx.gbl...
I am trying to send a UDP packet out over the internet to a device.
This device is NOT on a local network or LAN or WAN. Just a random IP
address on the internet somewhere.

For whatever reason, the UDP message does not arrive there the first
time I send it (after starting the app). It arrives fine for any
attempt afterwards, but never the first time.

What could the problem? I am kind of new to UDP, so I am at a loss. Do
I perhaps have to establish a route to the IP address or something like
(I am grasping, I know).

Meanwhile, if I send a message to a device on a local network, the
messages get there every time. Here is the code I use to send a message:

Socket sockUDP = New Socket(AddressFamily.InterNetwork,
SocketType.Dgram, ProtocolType.Udp)

Dim sendBytes As Byte() = Encoding.ASCII.GetBytes(Data)
Dim IpEndPoint As New IPEndPoint(IPAddress.Parse(Host), Port)

sockUDP.Connect(IpEndPoint)
sockUDP.SendTo(sendBytes, 0, sendBytes.Length, SocketFlags.None, IpEndPoint)

Thanks.

Nov 16 '05 #3
Carl Frisk wrote:
UDP provides no guarantee of delivery. RFC 768
http://www.faqs.org/rfcs/rfc768.html


I realize that, but why does it fail the first time, every time. Yet,
I've never (ever) had it fail the second or third or fourth time. Does
it have to do with the route?
Nov 16 '05 #4
I think we would need to know more about what it is sending it to. You may have a firewall issue. You may have a
router issue. You may have an issue on the receiving machine.

I'd start with putting a sniffer on the other machine to see if the packet is getting there on the first try. You may
also want to analyze the first two packets that are sent out from your local machine. Check your firewall logs on the
receiving machine.

--
....Carl Frisk
Anger is a brief madness.
- Horace, 20 B.C.
http://www.carlfrisk.com
"Frank Rizzo" <no****@nospam.com> wrote in message news:ew**************@TK2MSFTNGP10.phx.gbl...
Carl Frisk wrote:
UDP provides no guarantee of delivery. RFC 768 http://www.faqs.org/rfcs/rfc768.html


I realize that, but why does it fail the first time, every time. Yet, I've never (ever) had it fail the second or
third or fourth time. Does it have to do with the route?


Nov 16 '05 #5
You may want to try InterNetworkV6 also.

--
....Carl Frisk
Anger is a brief madness.
- Horace, 20 B.C.
http://www.carlfrisk.com
"Frank Rizzo" <no****@nospam.com> wrote in message news:ew**************@TK2MSFTNGP10.phx.gbl...
Carl Frisk wrote:
UDP provides no guarantee of delivery. RFC 768
http://www.faqs.org/rfcs/rfc768.html


I realize that, but why does it fail the first time, every time. Yet,
I've never (ever) had it fail the second or third or fourth time. Does
it have to do with the route?

Nov 16 '05 #6
Carl,

Basically I am sending a packet to a wireless modem on the TMobile
network. There isn't a firewall issue, because I don't have a firewall.
And I know that the data isn't arriving because I have a sniffer
cable connected to the actual device and I don't see the data.

However, the sample vb6 app that comes with the device sends the data
fine. They are using a 3rd party component (dart, I believe) to send
UDP data, so I don't have access to the source.

Carl Frisk wrote:
I think we would need to know more about what it is sending it to. You
may have a firewall issue. You may have a router issue. You may have
an issue on the receiving machine.

I'd start with putting a sniffer on the other machine to see if the
packet is getting there on the first try. You may also want to analyze
the first two packets that are sent out from your local machine. Check
your firewall logs on the receiving machine.

Nov 16 '05 #7
Frank Rizzo wrote:
I am trying to send a UDP packet out over the internet to a device. This
device is NOT on a local network or LAN or WAN. Just a random IP
address on the internet somewhere.

For whatever reason, the UDP message does not arrive there the first
time I send it (after starting the app). It arrives fine for any
attempt afterwards, but never the first time.

What could the problem? I am kind of new to UDP, so I am at a loss. Do
I perhaps have to establish a route to the IP address or something like
(I am grasping, I know).

Meanwhile, if I send a message to a device on a local network, the
messages get there every time. Here is the code I use to send a message:

Socket sockUDP = New Socket(AddressFamily.InterNetwork,
SocketType.Dgram, ProtocolType.Udp)

Dim sendBytes As Byte() = Encoding.ASCII.GetBytes(Data)
Dim IpEndPoint As New IPEndPoint(IPAddress.Parse(Host), Port)

sockUDP.Connect(IpEndPoint)
sockUDP.SendTo(sendBytes, 0, sendBytes.Length, SocketFlags.None,
IpEndPoint)

Thanks.


Sorry about my UDP ignorance, but can you set the TTL for UDP packets? If so,
bump it up a bunch to see if it makes a difference, and if it does, then I'd
surmise that you have a (initial) routing issue.
Nov 16 '05 #8
Julie wrote:
Frank Rizzo wrote:
I am trying to send a UDP packet out over the internet to a device.
This device is NOT on a local network or LAN or WAN. Just a random IP
address on the internet somewhere.
Sorry about my UDP ignorance, but can you set the TTL for UDP packets?
If so, bump it up a bunch to see if it makes a difference, and if it
does, then I'd surmise that you have a (initial) routing issue.


Julie,

You might just be right. You can set the TTL using the SetSocketOption.
I'll try it out. Thanks.
Nov 16 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Dalibor Karlovic | last post by:
I need to access exaclty one of the superglobals arrays and don't want to use $_REQUEST. Having the name of the form method used on submit in $this->sMethod and the name of the feild submited in...
0
by: Geoff Berrow | last post by:
Just been checking out odbc. The notion of simply being able to upload an Access file seemed cool, but writing the queries is far from straightforward. Firstly there is the reserved word problem....
1
by: Heath | last post by:
Howdy, I am really struggling with the basics here. PHP/MySQL I have a database with three columns: ID, Name, Phone
1
by: john | last post by:
The python libraries like urllib and httplib do not support ssl through a proxy. Urllib2 supports http through a proxy or https alone, but not https through a proxy. A while ago my wife...
1
by: Dietrich | last post by:
Hi. I can't reread a file handle after I have copied it on another file handle for output. Here is the code snippet. Please let me know if you need more. Lines 26 & 27 are my attempts to get...
9
by: {AGUT2}=IWIK= | last post by:
Hello all, It's my fisrt post here and I am feeling a little stupid here, so go easy.. :) (Oh, and I've spent _hours_ searching...) I am desperately trying to read in an ASCII...
1
by: Frank | last post by:
Hi, we are using oracle clients (Release 9.0.1.0.1 - Production) on an NT4 (Service Pack6) computers. the server is a W2K, (Oracle9i Enterprise Edition Release 9.0.1.1.1 - Production With the...
0
by: Bogdan TARU | last post by:
Hi guys, I've got a weirdo problem with replicating a database. Sometimes I get some duplicate keys problems for _only_ one table. There is nothing special about this table, it looks like: ...
0
by: Landers, Jason | last post by:
I have two tables, meetings and tasks. In the meetings table I have meeting information and a meeting index called id. In the tasks table I have task information that is associated with various...
2
by: Marc Champagne | last post by:
Hi folks! I have built a VB project in VS.NET 7 which also includes a deployment project. Everything builds ok. When I install the setup package, it installs without a glitch.
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.