Subject: Re: question about socket with link local addr

From: Stuart Cheshire <[email-masked]>
Date: Wed, 30 Jul 2003 18:30:49 -0700

Mark Yang wrote:
>Hi,
>    This looks like a very simple question,  but I don't know where do 
>ask so I post it here.
>I start my Mac, my "network" setting shows I have IP "10.1.1.157" since 
>I am using DHCP,
>I created a socket, try to connect to a linklocal addr say 
>"169.254.80.220". now I find i am using IP "10.1.1.157" to connect 
>obviously this is not what I want.
>
>    Question is how do I create a socket on mac  such that the packet i 
>send out shows my IP  LL addr?
>    Thanks
>mark

The right place to ask your Mac-specific programming questions is at 
[email-masked]

See <http://www.lists.apple.com/mailman/listinfo/macnetworkprog>

For general developer information, see <http://developer.apple.com/>

Stuart Cheshire <[email-masked]>
 * Wizard Without Portfolio, Apple Computer, Inc.
 * www.stuartcheshire.org

---

From: "Jim Busse" <[email-masked]>
Date: Thu, 31 Jul 2003 09:08:19 -0700

Hi,m Stuart!

Please correct me if I'm wrong, but isn't this question about a generic
socket problem?

I think if I am using ethernet phy and a 10.1.1.157 address with a
relatively standard netmask of 255.255.255.0 and I create a socket, using
Windows stack or Linux stack, to IP address 169.254.80.220, and I am using a
DHCP router, doesn't that packet get forwarded to the router's MAC and then
go nowhere?

And, if I do the same thing but have no router, doesn't the current Windows
and Linux stack just eat the packet and it goes nowhere?  Since there's no
router MAC to forward the packet?

Wasn't there a substantial discussion about this issue?  And wasn't the
resolution that we don't have to care about this situation?

And isn't this a generic socket stack issue, not related to Apple?

Again, please correct me if I'm wrong.

Thanks

Jim Busse

---

From: "Philip Nye" <[email-masked]>
Date: Thu, 31 Jul 2003 17:26:36 +0100

Jim,

Your issue is not with the socket interface but with the behaviour of the
stack.

A stack which conforms to the current spec will know to ARP for the LL
destination and send the packet directly to the destination even if the
source has a routable address. If there is no response to the ARP the packet
will be discarded.

However, since this is a draft spec which has been changing recently, it is
very likely that mainstream stacks such as Mac, Windows or Linux will not
conform to these rules. To find which rules they do follow, you would have
to investigate each stack individually. I would expect to find a wide
variety of behaviours - remember all of these operating systems have been
through many versions and revisions of TCP/IP stack.

Philip Nye

---

From: "Jim Busse" <[email-masked]>
Date: Thu, 31 Jul 2003 15:49:51 -0700

Hi, Philip!

Thanks so much for responding.  I'd love to make sure I understand, I
apologize for being so stupid.  So please let me follow-up:

If I can go back to the original question, paraphrasing slightly, I think it
was
"I created a socket, trying to connect to a linklocal addr (169.254.80.220)
but in the socket creation, I am using  IP "10.1.1.157" to connect.
Question is how do I create a socket such that the packet I send out uses my
IP  LL addr?"

So Mark's assigned or acquired a 169.254.x.x address ("my IP LL addr") in
addition to his DHCP-assigned "10.1.1.157" address.  His question is how
does he create a socket to send out using that 169.254.x.x LinkLocal address
so he can connect to his target (169.254.80.220).

The answer is "I don't think he can do this", and without a LL aware router,
he can never interconnect his 10.1.1.x address to his 169.254.x.x address
using sockets

I think it's not a stack issue at all, it's a sockets issue.  A generic
sockets issue, not a "Mac-only" sockets issue.  And, I think all sockets
apps will fail this interconnectivity as a result.

I think it is possible to accomplish the communication, but you cannot use
sockets.

Maybe an alternative is for someone (more knowledgable than I, I tried it
and failed) to write an arp cache update program such that routes are
discovered and added to the arp cache dynamically.  It could run in the
background and just add hosts as they are found....But again, I think you
can't arp using sockets, because there's no way (that I know of) to pass a
MAC address through a socket.  (That's MAC, not Mac......)

Jim