Scoket problem

Hi friends,

There are two interfaces in my Windows XP Professional system, one is
Wireless LAN and the other Ethernet. I would like refer them as Interface A
and Interface B; they have IPv4 address IP A and IP B and MAC address MAC A
and MAC B respectively.

±-------------+ ±--------------+
| Interface A | | Interface B |
| IP A | | IP B |
| MAC A | | MAC B |
±-------------+ ±---------------+

I wrote a network program, which opens two UDP sockets. I hope these two UDP
sockets can bind with different interface, for example, Socket A will bind
with Interface A, and Socket B with Interface B. I mean I hope all the
packets from socket A will go through Interface A, and all the packets
coming from socket B will go through Interface B.

So I wrote my program in this way:

  1. Create socket A, bind with interface A ( call bind() function, with IP A
    as a parameter, I hope it can make all packets from this socket will go
    throught interface A)

  2. Create socket B, bind with interface B (call bind () function, with IP B
    as parameter, hope all the packet will go through interface B)

Guess what took place! All the packets going through interface A are OK. But
all the packets which should go through interface B, actually still go
through interface A. These packets have interface A’ s MAC address, but with
interface B 's IP address. How could it happen?

±--------------------------------+
| MAC A | IP B | UDP |
±--------------------------------+

How can it be? So I checked the routing table, and found two default router,
one is the gateway through interface A, the other is the gateway through
interface B. But the default router throught interface A has a high
priority, because it has a smaller metric. That 's why all the packet still
go through interface A.

My point is how I can solve this problem. I think I already choose the
interface for my packet by using bind(). Am I missing something? or
Microsoft did a ugly job of its TCP/IP stack.

Please don’t think it is a problem in the user space, Actually I came across
this problem in kernel first, so I would like to try in user space. But same
thing happened.

Regards
Elton, Dong Li

You might have to try source routing, using socketopt, since you have
essentially multihomed (if), and you have two router, try using source
route ( and possibly strict src route )

-prokash

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Li Dong
Sent: Thursday, April 01, 2004 7:44 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Scoket problem

Hi friends,

There are two interfaces in my Windows XP Professional system, one is
Wireless LAN and the other Ethernet. I would like refer them as Interface A
and Interface B; they have IPv4 address IP A and IP B and MAC address MAC A
and MAC B respectively.

±-------------+ ±--------------+
| Interface A | | Interface B |
| IP A | | IP B |
| MAC A | | MAC B |
±-------------+ ±---------------+

I wrote a network program, which opens two UDP sockets. I hope these two UDP
sockets can bind with different interface, for example, Socket A will bind
with Interface A, and Socket B with Interface B. I mean I hope all the
packets from socket A will go through Interface A, and all the packets
coming from socket B will go through Interface B.

So I wrote my program in this way:

  1. Create socket A, bind with interface A ( call bind() function, with IP A
    as a parameter, I hope it can make all packets from this socket will go
    throught interface A)

  2. Create socket B, bind with interface B (call bind () function, with IP B
    as parameter, hope all the packet will go through interface B)

Guess what took place! All the packets going through interface A are OK. But
all the packets which should go through interface B, actually still go
through interface A. These packets have interface A’ s MAC address, but with
interface B 's IP address. How could it happen?

±--------------------------------+
| MAC A | IP B | UDP |
±--------------------------------+

How can it be? So I checked the routing table, and found two default router,
one is the gateway through interface A, the other is the gateway through
interface B. But the default router throught interface A has a high
priority, because it has a smaller metric. That 's why all the packet still
go through interface A.

My point is how I can solve this problem. I think I already choose the
interface for my packet by using bind(). Am I missing something? or
Microsoft did a ugly job of its TCP/IP stack.

Please don’t think it is a problem in the user space, Actually I came across
this problem in kernel first, so I would like to try in user space. But same
thing happened.

Regards
Elton, Dong Li


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@garlic.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Also sendto would be another choice, finally if the socket family
has any perticular type for wireless…

One of those has to work. No,it might be one of the best implementation
of TCP/IP

-prokash

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Li Dong
Sent: Thursday, April 01, 2004 7:44 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Scoket problem

Hi friends,

There are two interfaces in my Windows XP Professional system, one is
Wireless LAN and the other Ethernet. I would like refer them as Interface A
and Interface B; they have IPv4 address IP A and IP B and MAC address MAC A
and MAC B respectively.

±-------------+ ±--------------+
| Interface A | | Interface B |
| IP A | | IP B |
| MAC A | | MAC B |
±-------------+ ±---------------+

I wrote a network program, which opens two UDP sockets. I hope these two UDP
sockets can bind with different interface, for example, Socket A will bind
with Interface A, and Socket B with Interface B. I mean I hope all the
packets from socket A will go through Interface A, and all the packets
coming from socket B will go through Interface B.

So I wrote my program in this way:

  1. Create socket A, bind with interface A ( call bind() function, with IP A
    as a parameter, I hope it can make all packets from this socket will go
    throught interface A)

  2. Create socket B, bind with interface B (call bind () function, with IP B
    as parameter, hope all the packet will go through interface B)

Guess what took place! All the packets going through interface A are OK. But
all the packets which should go through interface B, actually still go
through interface A. These packets have interface A’ s MAC address, but with
interface B 's IP address. How could it happen?

±--------------------------------+
| MAC A | IP B | UDP |
±--------------------------------+

How can it be? So I checked the routing table, and found two default router,
one is the gateway through interface A, the other is the gateway through
interface B. But the default router throught interface A has a high
priority, because it has a smaller metric. That 's why all the packet still
go through interface A.

My point is how I can solve this problem. I think I already choose the
interface for my packet by using bind(). Am I missing something? or
Microsoft did a ugly job of its TCP/IP stack.

Please don’t think it is a problem in the user space, Actually I came across
this problem in kernel first, so I would like to try in user space. But same
thing happened.

Regards
Elton, Dong Li


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@garlic.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Finally, is not it that bind is for the server socket !!!

-prokash

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Li Dong
Sent: Thursday, April 01, 2004 7:44 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Scoket problem

Hi friends,

There are two interfaces in my Windows XP Professional system, one is
Wireless LAN and the other Ethernet. I would like refer them as Interface A
and Interface B; they have IPv4 address IP A and IP B and MAC address MAC A
and MAC B respectively.

±-------------+ ±--------------+
| Interface A | | Interface B |
| IP A | | IP B |
| MAC A | | MAC B |
±-------------+ ±---------------+

I wrote a network program, which opens two UDP sockets. I hope these two UDP
sockets can bind with different interface, for example, Socket A will bind
with Interface A, and Socket B with Interface B. I mean I hope all the
packets from socket A will go through Interface A, and all the packets
coming from socket B will go through Interface B.

So I wrote my program in this way:

  1. Create socket A, bind with interface A ( call bind() function, with IP A
    as a parameter, I hope it can make all packets from this socket will go
    throught interface A)

  2. Create socket B, bind with interface B (call bind () function, with IP B
    as parameter, hope all the packet will go through interface B)

Guess what took place! All the packets going through interface A are OK. But
all the packets which should go through interface B, actually still go
through interface A. These packets have interface A’ s MAC address, but with
interface B 's IP address. How could it happen?

±--------------------------------+
| MAC A | IP B | UDP |
±--------------------------------+

How can it be? So I checked the routing table, and found two default router,
one is the gateway through interface A, the other is the gateway through
interface B. But the default router throught interface A has a high
priority, because it has a smaller metric. That 's why all the packet still
go through interface A.

My point is how I can solve this problem. I think I already choose the
interface for my packet by using bind(). Am I missing something? or
Microsoft did a ugly job of its TCP/IP stack.

Please don’t think it is a problem in the user space, Actually I came across
this problem in kernel first, so I would like to try in user space. But same
thing happened.

Regards
Elton, Dong Li


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@garlic.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Thank you for your reply.

Let put my question more clearly and simply in another way.

Q: Why a packet can be sent, in which IP address and MAC address belong to
different interfaces!!!

Regards
Elton

P/S
First, from my understanding, we can call bind(), whatever socket it is,
server or client. bind()'s responsiblity is only to choose a local source
address for the socket.

Secondly, I am using sendto();

Thirdly, I tried to use setsockopt() with SO_DONTROUTE socketopt, but this
one doesn’t work either.

Finally, I don’t think Microsoft’s implementation is good, if this can
happen!!!

----- Original Message -----
From: “Prokash Sinha”
To: “Windows System Software Devs Interest List”
Sent: Friday, April 02, 2004 1:24 PM
Subject: RE: [ntdev] Scoket problem

> Finally, is not it that bind is for the server socket !!!
>
> -prokash
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com]On Behalf Of Li Dong
> Sent: Thursday, April 01, 2004 7:44 PM
> To: Windows System Software Devs Interest List
> Subject: [ntdev] Scoket problem
>
>
> Hi friends,
>
> There are two interfaces in my Windows XP Professional system, one is
> Wireless LAN and the other Ethernet. I would like refer them as Interface
A
> and Interface B; they have IPv4 address IP A and IP B and MAC address MAC
A
> and MAC B respectively.
>
> ±-------------+ ±--------------+
> | Interface A | | Interface B |
> | IP A | | IP B |
> | MAC A | | MAC B |
> ±-------------+ ±---------------+
>
> I wrote a network program, which opens two UDP sockets. I hope these two
UDP
> sockets can bind with different interface, for example, Socket A will bind
> with Interface A, and Socket B with Interface B. I mean I hope all the
> packets from socket A will go through Interface A, and all the packets
> coming from socket B will go through Interface B.
>
> So I wrote my program in this way:
> 1. Create socket A, bind with interface A ( call bind() function, with IP
A
> as a parameter, I hope it can make all packets from this socket will go
> throught interface A)
>
> 2. Create socket B, bind with interface B (call bind () function, with IP
B
> as parameter, hope all the packet will go through interface B)
>
> Guess what took place! All the packets going through interface A are OK.
But
> all the packets which should go through interface B, actually still go
> through interface A. These packets have interface A’ s MAC address, but
with
> interface B 's IP address. How could it happen?
>
> ±--------------------------------+
> | MAC A | IP B | UDP |
> ±--------------------------------+
>
> How can it be? So I checked the routing table, and found two default
router,
> one is the gateway through interface A, the other is the gateway through
> interface B. But the default router throught interface A has a high
> priority, because it has a smaller metric. That 's why all the packet
still
> go through interface A.
>
> My point is how I can solve this problem. I think I already choose the
> interface for my packet by using bind(). Am I missing something? or
> Microsoft did a ugly job of its TCP/IP stack.
>
> Please don’t think it is a problem in the user space, Actually I came
across
> this problem in kernel first, so I would like to try in user space. But
same
> thing happened.
>
> Regards
> Elton, Dong Li
>
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@garlic.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@i2r.a-star.edu.sg
> To unsubscribe send a blank email to xxxxx@lists.osr.com

Q: Why a packet can be sent, in which source IP address and source MAC
address belong to
different local interfaces!

----- Original Message -----
From: “Li Dong”
To: “Windows System Software Devs Interest List”
Sent: Friday, April 02, 2004 2:15 PM
Subject: Re: [ntdev] Scoket problem

> Thank you for your reply.
>
> Let put my question more clearly and simply in another way.
>
> Q: Why a packet can be sent, in which IP address and MAC address belong
to
> different interfaces!!!
>
> Regards
> Elton
>
> P/S
> First, from my understanding, we can call bind(), whatever socket it is,
> server or client. bind()‘s responsiblity is only to choose a local source
> address for the socket.
>
> Secondly, I am using sendto();
>
> Thirdly, I tried to use setsockopt() with SO_DONTROUTE socketopt, but this
> one doesn’t work either.
>
> Finally, I don’t think Microsoft’s implementation is good, if this can
> happen!!!
>
>
>
>
>
> ----- Original Message -----
> From: “Prokash Sinha”
> To: “Windows System Software Devs Interest List”
> Sent: Friday, April 02, 2004 1:24 PM
> Subject: RE: [ntdev] Scoket problem
>
>
> > Finally, is not it that bind is for the server socket !!!
> >
> > -prokash
> >
> > -----Original Message-----
> > From: xxxxx@lists.osr.com
> > [mailto:xxxxx@lists.osr.com]On Behalf Of Li Dong
> > Sent: Thursday, April 01, 2004 7:44 PM
> > To: Windows System Software Devs Interest List
> > Subject: [ntdev] Scoket problem
> >
> >
> > Hi friends,
> >
> > There are two interfaces in my Windows XP Professional system, one is
> > Wireless LAN and the other Ethernet. I would like refer them as
Interface
> A
> > and Interface B; they have IPv4 address IP A and IP B and MAC address
MAC
> A
> > and MAC B respectively.
> >
> > ±-------------+ ±--------------+
> > | Interface A | | Interface B |
> > | IP A | | IP B |
> > | MAC A | | MAC B |
> > ±-------------+ ±---------------+
> >
> > I wrote a network program, which opens two UDP sockets. I hope these two
> UDP
> > sockets can bind with different interface, for example, Socket A will
bind
> > with Interface A, and Socket B with Interface B. I mean I hope all the
> > packets from socket A will go through Interface A, and all the packets
> > coming from socket B will go through Interface B.
> >
> > So I wrote my program in this way:
> > 1. Create socket A, bind with interface A ( call bind() function, with
IP
> A
> > as a parameter, I hope it can make all packets from this socket will go
> > throught interface A)
> >
> > 2. Create socket B, bind with interface B (call bind () function, with
IP
> B
> > as parameter, hope all the packet will go through interface B)
> >
> > Guess what took place! All the packets going through interface A are OK.
> But
> > all the packets which should go through interface B, actually still go
> > through interface A. These packets have interface A’ s MAC address, but
> with
> > interface B 's IP address. How could it happen?
> >
> > ±--------------------------------+
> > | MAC A | IP B | UDP |
> > ±--------------------------------+
> >
> > How can it be? So I checked the routing table, and found two default
> router,
> > one is the gateway through interface A, the other is the gateway through
> > interface B. But the default router throught interface A has a high
> > priority, because it has a smaller metric. That 's why all the packet
> still
> > go through interface A.
> >
> > My point is how I can solve this problem. I think I already choose the
> > interface for my packet by using bind(). Am I missing something? or
> > Microsoft did a ugly job of its TCP/IP stack.
> >
> > Please don’t think it is a problem in the user space, Actually I came
> across
> > this problem in kernel first, so I would like to try in user space. But
> same
> > thing happened.
> >
> > Regards
> > Elton, Dong Li
> >
> >
> >
> >
> > —
> > Questions? First check the Kernel Driver FAQ at
> > http://www.osronline.com/article.cfm?id=256
> >
> > You are currently subscribed to ntdev as: xxxxx@garlic.com
> > To unsubscribe send a blank email to xxxxx@lists.osr.com
> >
> >
> >
> >
> > —
> > Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
> >
> > You are currently subscribed to ntdev as: xxxxx@i2r.a-star.edu.sg
> > To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@i2r.a-star.edu.sg
> To unsubscribe send a blank email to xxxxx@lists.osr.com

First, if I recall, that your local ip might not be tied to any
interface(MAC). Also if I can recall,
bind on a client socket does not do anything. And route-table is first
dynamic, second non-deterministic,
so it is not just that it might go wired traffic thru wireless interface,
and viceversa. This is the way UDP
works, the routing is hop-by-hop. If wired/wireless are available for the
same address family, it can bind to
any at IP level at a per tcp packet segment.

If you do source routing properly, with just the first level to either your
wireless AP, or Enet router address, it would not have any choice but to
follow, after that it would take whatever route(s) it likes.

If you find any RFC, that explains this the way you are saying, report to
MS, but I think we would be proved wrong !!

Also I’m not sure if there is any specific sub-family defined for addr
family, then that would solve the problem.

-prokash

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Li Dong
Sent: Thursday, April 01, 2004 10:27 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Scoket problem

Q: Why a packet can be sent, in which source IP address and source MAC
address belong to
different local interfaces!

----- Original Message -----
From: “Li Dong”
To: “Windows System Software Devs Interest List”
Sent: Friday, April 02, 2004 2:15 PM
Subject: Re: [ntdev] Scoket problem

> Thank you for your reply.
>
> Let put my question more clearly and simply in another way.
>
> Q: Why a packet can be sent, in which IP address and MAC address belong
to
> different interfaces!!!
>
> Regards
> Elton
>
> P/S
> First, from my understanding, we can call bind(), whatever socket it is,
> server or client. bind()‘s responsiblity is only to choose a local source
> address for the socket.
>
> Secondly, I am using sendto();
>
> Thirdly, I tried to use setsockopt() with SO_DONTROUTE socketopt, but this
> one doesn’t work either.
>
> Finally, I don’t think Microsoft’s implementation is good, if this can
> happen!!!
>
>
>
>
>
> ----- Original Message -----
> From: “Prokash Sinha”
> To: “Windows System Software Devs Interest List”
> Sent: Friday, April 02, 2004 1:24 PM
> Subject: RE: [ntdev] Scoket problem
>
>
> > Finally, is not it that bind is for the server socket !!!
> >
> > -prokash
> >
> > -----Original Message-----
> > From: xxxxx@lists.osr.com
> > [mailto:xxxxx@lists.osr.com]On Behalf Of Li Dong
> > Sent: Thursday, April 01, 2004 7:44 PM
> > To: Windows System Software Devs Interest List
> > Subject: [ntdev] Scoket problem
> >
> >
> > Hi friends,
> >
> > There are two interfaces in my Windows XP Professional system, one is
> > Wireless LAN and the other Ethernet. I would like refer them as
Interface
> A
> > and Interface B; they have IPv4 address IP A and IP B and MAC address
MAC
> A
> > and MAC B respectively.
> >
> > ±-------------+ ±--------------+
> > | Interface A | | Interface B |
> > | IP A | | IP B |
> > | MAC A | | MAC B |
> > ±-------------+ ±---------------+
> >
> > I wrote a network program, which opens two UDP sockets. I hope these two
> UDP
> > sockets can bind with different interface, for example, Socket A will
bind
> > with Interface A, and Socket B with Interface B. I mean I hope all the
> > packets from socket A will go through Interface A, and all the packets
> > coming from socket B will go through Interface B.
> >
> > So I wrote my program in this way:
> > 1. Create socket A, bind with interface A ( call bind() function, with
IP
> A
> > as a parameter, I hope it can make all packets from this socket will go
> > throught interface A)
> >
> > 2. Create socket B, bind with interface B (call bind () function, with
IP
> B
> > as parameter, hope all the packet will go through interface B)
> >
> > Guess what took place! All the packets going through interface A are OK.
> But
> > all the packets which should go through interface B, actually still go
> > through interface A. These packets have interface A’ s MAC address, but
> with
> > interface B 's IP address. How could it happen?
> >
> > ±--------------------------------+
> > | MAC A | IP B | UDP |
> > ±--------------------------------+
> >
> > How can it be? So I checked the routing table, and found two default
> router,
> > one is the gateway through interface A, the other is the gateway through
> > interface B. But the default router throught interface A has a high
> > priority, because it has a smaller metric. That 's why all the packet
> still
> > go through interface A.
> >
> > My point is how I can solve this problem. I think I already choose the
> > interface for my packet by using bind(). Am I missing something? or
> > Microsoft did a ugly job of its TCP/IP stack.
> >
> > Please don’t think it is a problem in the user space, Actually I came
> across
> > this problem in kernel first, so I would like to try in user space. But
> same
> > thing happened.
> >
> > Regards
> > Elton, Dong Li
> >
> >
> >
> >
> > —
> > Questions? First check the Kernel Driver FAQ at
> > http://www.osronline.com/article.cfm?id=256
> >
> > You are currently subscribed to ntdev as: xxxxx@garlic.com
> > To unsubscribe send a blank email to xxxxx@lists.osr.com
> >
> >
> >
> >
> > —
> > Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
> >
> > You are currently subscribed to ntdev as: xxxxx@i2r.a-star.edu.sg
> > To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@i2r.a-star.edu.sg
> To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@garlic.com
To unsubscribe send a blank email to xxxxx@lists.osr.com