473,385 Members | 1,796 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,385 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 6350
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.