473,396 Members | 2,039 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Broadcast UDP paket with wrong source ip address

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
Nov 15 '07 #1
2 6353
On 2007-11-15 05:31:51 -0800, Mali Findik <bl*****@gmx.netsaid:
[...]
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

Nov 15 '07 #2
Peter Duniho schrieb:
On 2007-11-15 05:31:51 -0800, Mali Findik <bl*****@gmx.netsaid:
>[...]
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
Nov 16 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Olivier Hoarau | last post by:
Hello, I have build a client/server application with the socket module. The server mades UDP broadcasting and the client only reads UDP broadcast messages. All work fine. Now I want to use for...
1
by: Lincoln Yeoh | last post by:
Hi, If I have a program listening on 0.0.0.0:(someport) on all interfaces, how do I know which network interface a broadcast packet is coming in on - assuming Linux and _many_ interfaces. And...
6
by: pekspro | last post by:
I need some code that gets the address from a server. I read somewhere that you could do this by starting some broadcast server using UDP. The client should send an broadcast message, and when the...
8
by: Frank Esser | last post by:
Hello! I have got machines that answer a certain UDP broadcast request with certain information about them. Some years ago I wrote a VB6 application that just sent out this UDP broadcast...
0
by: Ed | last post by:
I've attached some VB.NET code I've hacked together (some taken from MS examples & newsgroup postings) that will perform a ping or IcmpSendEcho using the icmp.dll (see this for more info:...
2
by: Gunnar_Frenzel | last post by:
Hello, this might be an easy question, but I don't have any handy solution at hand. I have an application that is supposed to send UDP broadcast. So far so easy, I did: Socket sockSendBroadcast...
1
by: Larry.Martell | last post by:
I am trying to send UDP broadcast packets over a specific interface and I am having trouble specifying the interface: host='192.168.28.255' sock = socket.socket(socket.AF_INET,...
4
by: Giovanni | last post by:
Hello community, I'm currently writing a broadcast sender class in C# .NET (using .NET Framework 3.5). On my computer there are more than one local network interface and if I send a broadcast,...
2
by: OBones | last post by:
Hi all, I'm currently trying to receive replies to a UDP broadcast that I sent and I can't get it to work. I know the datagrams are sent as I see them with WireShark, but my C# code does not see...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.