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(IPAd dress.Parse("25 5.255.255.255") , 1234);
byte [] data = {(byte)42};
client.Send(dat a, 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 2 6370
On 2007-11-15 05:31:51 -0800, Mali Findik <bl*****@gmx.ne tsaid:
[...]
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
Peter Duniho schrieb:
On 2007-11-15 05:31:51 -0800, Mali Findik <bl*****@gmx.ne tsaid:
>[...] 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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 the same thing the socketserver module, it's ok
for the client, but I don't succeed in making work the server :-((
Here is the client (which works)
|
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 how do I set which
interface a frame will leave on, assuming I'm sending a raw frame (no
IP address, just the ethernet address).
If I use C, it seems I'm to use the IP_PKTINFO socket options,
send/recv the ancillary messages and set/check the ...
|
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 server answering
the client gets the address. But how do I implement this?
I did this simple quick-hack:
Server:
Socket server = new Socket(AddressFamily.InterNetwork,
SocketType.Dgram, ProtocolType.Udp);
|
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 request and received all machine information to display all
available machines in a grid.
Now I want to write the same application in C# but so far with no success.
|
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:
http://support.microsoft.com/default.aspx?scid=kb;en-us;170591 ).
The problem I have is in order to perform a discovery/ping of an
entire subnet (192.168.1.* for instance) I have to do a FOR loop to
itterate through all of the addresses. That it seems...
| |
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 = null;
IPEndPoint ipeSendBroadcast = null;
ipeSendBroadcast = new IPEndPoint(IPAddress.Broadcast, iSomePort);
|
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, socket.SOCK_DGRAM)
sock.bind(('',0))
sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_IF,
socket.inet_aton(host))
|
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, the UdpClient class choose "randomly" a source ip-address from a network interface.
Does anybody knows a possibility to set a specific sender ip-address?
Thank you in advance!
|
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 them.
Here is how I intended things to work:
Socket socket = new Socket(AddressFamily.InterNetwork,
SocketType.Dgram, ProtocolType.Udp);
try
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |