[Mono-list] UDP and ICMP
P Oscar Boykin
boykin@pobox.com
Thu, 5 Feb 2004 10:45:16 -0800
--/04w6evG8XlLl3ft
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Thu, Feb 05, 2004 at 11:21:15AM +0100, Marco Canini wrote:
> On Thu, 2004-02-05 at 05:41, P Oscar Boykin wrote:
> > Hello All.
> >=20
> > I am using using mono to send udp packets between two hosts. At some
> > point, one host may go offline. If I watch the network (using ethereal)
> > I see the UDP packet go from A->B, and host B responds with a ICMP
> > destination unreachable packet. However, I don't see how I can get
> > access to that packet in my application.
> Sorry but if B goes down how do you see the ICMP packets from B?
Obviously if the host B is down, no ICMP packet will be sent from it.
However, if the program is closed, or crashes unexpectedly, the host is
still active, but no process is Binded to the socket, and thus the host
will reply with an ICMP packet.
> Anyway you can make B send UDP packets to A as an acknowledge, setting a
> timeout to wait for B responses in A
Sure, I could do more work using only UDP to have acknowledgements,
etc., however, in the cases where the ICMP is sent by B, I would like A
my program running on A to know about it.
There are APIs that throw errors when the ICMP message comes in. =20
For instance, in Java there is the PortUnreachableException:
http://klomp.org/mark/classpath/doc/api/html/java/net/PortUnreachableExcept=
ion.html
It seems like people are saying that they think that A simply ignores
the ICMP message and the .Net framework has no way of passing that
information to the user (without being root and listening for the raw
Icmp packets)
In fact, when I look up this issue for winsock the following page
says:
http://tangentsoft.net/wskfaq/articles/bsd-compatibility.html
"UDP Behavior (Added 2001.03.26)
According to Ilpo Ruotsalainen, "...most BSD socket implementations do
not pass delayed UDP errors (ICMP port unreachable at least, maybe
others too) to recvfrom() while Winsock 2 [under Windows 2000 but not
Windows 98] does. Linux [behaves like Windows 2000] too, but provives
SO_BSDCOMPAT setsockopt() for being compatible with the BSD style."
In other words, a portable program has to be prepared for the
possibility of error codes for non-immediate problems from recvfrom(),
but it can't depend on receiving them."
This guy says Winsock 2 on win2000 throws a ECONNRESET error in this
case:
http://www.openh323.org/pipermail/openh323/2000-January/003223.html
This page also says the Winsock behavior is to give an error here:
http://www.danielclarke.com/peermonitor/winsockcodes.shtml#WSAECONNRESET
And the .Net framework says it uses Winsock2 error codes:
http://msdn.microsoft.com/library/default.asp?url=3D/library/en-us/cpref/ht=
ml/frlrfsystemnetsocketssocketexceptionclasstopic.asp
I don't have access to a windows machine, but it seems like (from what I
have read) that the ReceiveFrom should throw an exception when the host
gets a "destination unreachable" ICMP message.
Can this be considered a bug?
POB.
--=20
boykin@pobox.com http://pobox.com/~boykin jabber: johnynek@jabber.org
fingerprint=3DD250 4AD9 4544 B7D2 A17C 911D D608 D387 6718 D75F
Consumer Rights: http://www.consumerwatchdog.org/
--/04w6evG8XlLl3ft
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)
iD8DBQFAIo881gjTh2cY118RAjlUAJ4jppOivkKhZkmUXxEi+To0CS5q/QCeMtFe
YjILY4ABtJkpqOMa1j2jvRs=
=zWQC
-----END PGP SIGNATURE-----
--/04w6evG8XlLl3ft--