Networking Forums

Networking Forums > Computer Networking > Linux Networking > UDP packet strange behavior

Reply
Thread Tools Display Modes

UDP packet strange behavior

 
 
richard.krehbiel@gmail.com
Guest
Posts: n/a

 
      08-10-2006, 06:50 PM
(Fedora Core 4)

I've got a computer A with two Ethernets, connected to two distinct
networks (one corporate, one for development only). I make a socket
for UDP, and I "connect" this socket to a the IP of computer B that's
reached via one of those interfaces.

So I "send" one packet. Recipient B gets it, but it's source IP names
A's other interface! The recipient has no route to get a reply packet
back.

I "send" another packet. This time I get errno=113 - network
unreachable.

What is going on?

 
Reply With Quote
 
 
 
 
Rick Jones
Guest
Posts: n/a

 
      08-10-2006, 07:22 PM
(E-Mail Removed) wrote:
> I've got a computer A with two Ethernets, connected to two distinct
> networks (one corporate, one for development only). I make a socket
> for UDP, and I "connect" this socket to a the IP of computer B that's
> reached via one of those interfaces.


> So I "send" one packet. Recipient B gets it, but it's source IP names
> A's other interface! The recipient has no route to get a reply packet
> back.


> I "send" another packet. This time I get errno=113 - network
> unreachable.


> What is going on?


I suspect that when you called connect() on your datagram socket, it
did the implicit bind for you but happened to do it to the other IP on
the system. But you probably already figured-that out.

To be certain of the source IP, you probably need to bind() to it
first before you call connect(). Doing so will make your application
no longer dependent on stack-specific behaviour such as whether or not
it is a "strong" or a "weak" end-system model.

rick jones
--
The computing industry isn't as much a game of "Follow The Leader" as
it is one of "Ring Around the Rosy" or perhaps "Duck Duck Goose."
- Rick Jones
these opinions are mine, all mine; HP might not want them anyway...
feel free to post, OR email to rick.jones2 in hp.com but NOT BOTH...
 
Reply With Quote
 
David Schwartz
Guest
Posts: n/a

 
      08-11-2006, 04:11 AM

(E-Mail Removed) wrote:
> (Fedora Core 4)
>
> I've got a computer A with two Ethernets, connected to two distinct
> networks (one corporate, one for development only). I make a socket
> for UDP, and I "connect" this socket to a the IP of computer B that's
> reached via one of those interfaces.
>
> So I "send" one packet. Recipient B gets it, but it's source IP names
> A's other interface! The recipient has no route to get a reply packet
> back.
>
> I "send" another packet. This time I get errno=113 - network
> unreachable.
>
> What is going on?


How is one computer supposed to know that the other can only reach it
using one particular interface? By what magic would you expect this to
automatically work?

 
Reply With Quote
 
Richard Krehbiel
Guest
Posts: n/a

 
      08-11-2006, 10:41 AM

David Schwartz wrote:
> (E-Mail Removed) wrote:
> > (Fedora Core 4)
> >
> > I've got a computer A with two Ethernets, connected to two distinct
> > networks (one corporate, one for development only). I make a socket
> > for UDP, and I "connect" this socket to a the IP of computer B that's
> > reached via one of those interfaces.
> >
> > So I "send" one packet. Recipient B gets it, but it's source IP names
> > A's other interface! The recipient has no route to get a reply packet
> > back.
> >
> > I "send" another packet. This time I get errno=113 - network
> > unreachable.
> >
> > What is going on?

>
> How is one computer supposed to know that the other can only reach it
> using one particular interface? By what magic would you expect this to
> automatically work?


I had expected it to supply the IP of the interface that transmitted
the packet.

 
Reply With Quote
 
Lew Pitcher
Guest
Posts: n/a

 
      08-11-2006, 12:18 PM
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


(E-Mail Removed) wrote:
> (Fedora Core 4)
>
> I've got a computer A with two Ethernets, connected to two distinct
> networks (one corporate, one for development only). I make a socket
> for UDP, and I "connect" this socket to a the IP of computer B that's
> reached via one of those interfaces.
>
> So I "send" one packet. Recipient B gets it, but it's source IP names
> A's other interface! The recipient has no route to get a reply packet
> back.
>
> I "send" another packet. This time I get errno=113 - network
> unreachable.
>
> What is going on?


Please, on your Linux "computer A",
echo 1 >/proc/sys/net/ipv4/ip_forward
and try again

- --
Lew Pitcher

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (MingW32) - WinPT 0.11.12

iD8DBQFE3HV7agVFX4UWr64RAoT0AJ4+D3oF+7HTMAZY3IpMg4 IsQO0OfgCeK85Z
vP814x9OKnzshJ1dv58+aI0=
=lyDQ
-----END PGP SIGNATURE-----

 
Reply With Quote
 
Richard Krehbiel
Guest
Posts: n/a

 
      08-11-2006, 12:52 PM

Lew Pitcher wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
>
> (E-Mail Removed) wrote:
> > (Fedora Core 4)
> >
> > I've got a computer A with two Ethernets, connected to two distinct
> > networks (one corporate, one for development only). I make a socket
> > for UDP, and I "connect" this socket to a the IP of computer B that's
> > reached via one of those interfaces.
> >
> > So I "send" one packet. Recipient B gets it, but it's source IP names
> > A's other interface! The recipient has no route to get a reply packet
> > back.
> >
> > I "send" another packet. This time I get errno=113 - network
> > unreachable.
> >
> > What is going on?

>
> Please, on your Linux "computer A",
> echo 1 >/proc/sys/net/ipv4/ip_forward
> and try again


Actually, I probably shouldn't. I'm not allowed to route packets from
one interface to the other. The development network is supposed to be
somewhat isolated from the production network (and my machine's
existence on both is barely tolerated).

OTOH, the IP addresses don't overlap, and I'm sure I could achieve the
same effect with iptables. But ip_forward=0 was just so much easier...

 
Reply With Quote
 
Rick Jones
Guest
Posts: n/a

 
      08-11-2006, 04:59 PM
>> Please, on your Linux "computer A",
>> echo 1 >/proc/sys/net/ipv4/ip_forward
>> and try again


> Actually, I probably shouldn't. I'm not allowed to route packets
> from one interface to the other. The development network is
> supposed to be somewhat isolated from the production network (and my
> machine's existence on both is barely tolerated).


Besides, by default, even without ip_forward set, the Linux system
with two NICs will accept traffic addressed to either IP on either
interface. The question is how to get the remote system to know to
reach that "remote" IP it should use the first system's other IP as a
gateway. So, that is where a static route added on the remote system
would come into play.

That, or having the application on the first system make that bind()
call to bind to the IP in the subnet common to both systems.

rick jones
--
Wisdom Teeth are impacted, people are affected by the effects of events.
these opinions are mine, all mine; HP might not want them anyway...
feel free to post, OR email to rick.jones2 in hp.com but NOT BOTH...
 
Reply With Quote
 
David Schwartz
Guest
Posts: n/a

 
      08-11-2006, 07:51 PM

Richard Krehbiel wrote:

> I had expected it to supply the IP of the interface that transmitted
> the packet.


You should think about packets as passing through interfaces.

Most operating systems will use the primary IP address of the "closest
interface" when they originate a packet. They also transmit the packet
on the closest interface. This assumes you didn't do something to
change this, such as 'bind'ing the socket to another address.

DS

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Strange Routing Behavior Jim Garrison Network Routers 2 09-04-2006 03:12 PM
Strange VPN behavior Bjarni Windows Networking 1 07-03-2006 05:09 PM
Strange VPN Behavior JamFan Windows Networking 3 02-28-2006 01:39 AM
Strange behavior Dennis P. Smith Windows Networking 5 05-18-2005 07:48 PM
Strange VPN behavior =?Utf-8?B?QnJ1Y2UgQnJvd24=?= Broadband Hardware 3 02-26-2005 03:24 AM



1 2 3 4 5 6 7 8 9 10 11