PC Review


Reply
Thread Tools Rate Thread

Broadcast UDP paket with wrong source ip address

 
 
Mali Findik
Guest
Posts: n/a
 
      15th Nov 2007
Hi @ll,

i've got problems with sending an UDP broadcast datagramm over two
network interfaces.

The code is like this:
<Code>
UdpClient client = new UdpClient();
IPEndPoint remoteEndPoint =
new IPEndPoint(IPAddress.Parse("255.255.255.255"), 1234);
byte [] data = {(byte)42};
client.Send(data, data.Length, remoteEndPoint);
</Code>

I've got two network interfaces, let us say for example:
interface_1 with ip 192.168.0.1
interface_2 with ip 10.1.0.1

Now, if I sniff on the interface_1 I got the correct source ip
192.168.0.1, but I sniff on the second interface, i got 192.168.0.1 as
source ip, anyway

Does somebody know, how to fix that problem?

Best regards,

Mali
 
Reply With Quote
 
 
 
 
Peter Duniho
Guest
Posts: n/a
 
      15th Nov 2007
On 2007-11-15 05:31:51 -0800, Mali Findik <(E-Mail Removed)> said:

> [...]
> I've got two network interfaces, let us say for example:
> interface_1 with ip 192.168.0.1
> interface_2 with ip 10.1.0.1
>
> Now, if I sniff on the interface_1 I got the correct source ip
> 192.168.0.1, but I sniff on the second interface, i got 192.168.0.1 as
> source ip, anyway
>
> Does somebody know, how to fix that problem?


Not really. You don't have control over how data is sent from your
application; only in how it's received. You can bind to a specific IP
address to make the socket only receive on that address, but when
sending the network driver will determine what it thinks is the best
route for the data, and that's how the data will be sent.

There are ways to manipulate the routing, but IMHO it's not a good idea
to do so and I'm not aware of anything in .NET that allows that
directly anyway.

One possible workaround would be to use multicast instead of broadcast.
If I recall correctly (and I might not), you can configure the
multicast group on a specific adapter to ensure the source IP address
is as you desire.

But if you really need broadcast datagrams, I don't think there's a
good way to change the behavior the way you want to.

Pete

 
Reply With Quote
 
Mali Findik
Guest
Posts: n/a
 
      16th Nov 2007
Peter Duniho schrieb:
> On 2007-11-15 05:31:51 -0800, Mali Findik <(E-Mail Removed)> said:
>
>> [...]
>> I've got two network interfaces, let us say for example:
>> interface_1 with ip 192.168.0.1
>> interface_2 with ip 10.1.0.1
>>
>> Now, if I sniff on the interface_1 I got the correct source ip
>> 192.168.0.1, but I sniff on the second interface, i got 192.168.0.1 as
>> source ip, anyway
>>
>> Does somebody know, how to fix that problem?

>
>
> Not really. You don't have control over how data is sent from your
> application; only in how it's received. You can bind to a specific IP
> address to make the socket only receive on that address, but when
> sending the network driver will determine what it thinks is the best
> route for the data, and that's how the data will be sent.
>
> There are ways to manipulate the routing, but IMHO it's not a good idea
> to do so and I'm not aware of anything in .NET that allows that directly
> anyway.
>
> One possible workaround would be to use multicast instead of broadcast.
> If I recall correctly (and I might not), you can configure the multicast
> group on a specific adapter to ensure the source IP address is as you
> desire.
>
> But if you really need broadcast datagrams, I don't think there's a good
> way to change the behavior the way you want to.
>
> Pete
>



Thank you for your reply, Pete.

But it is not applicable for me to use multicast instead of broadcast.
Cause the receivers of the broadcast may be not in the same subnet.
They will rearrange their ip address depending on the source ip address
of the broadcast paket. And this is exact my problem.

Maybe there are some win api calls to manipulatethe udp packet directly?

Mali
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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
Windows 2000/2003 gets the network broadcast address wrong Bruce Richardson Windows Networking 0 9th Jun 2004 12:33 PM
Online Broadcast video source selection Francisco Microsoft Powerpoint 3 7th Apr 2004 01:57 AM
Source address wrong for network share Andrew Athan Windows XP Networking 1 8th Jan 2004 08:27 AM
Source IP address wrong for net share Andrew Athan Windows XP General 0 7th Jan 2004 08:25 AM
Wrong broadcast in route table ?A Nicolas Helleringer Microsoft Windows 2000 Networking 2 7th Nov 2003 11:46 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:32 AM.