Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Say I have the ip and mac address of a computer inside a network and I wish to send him a UDP message. By initializing the mac and ip addresses of the sent message to the given, when the network router recives the message he should pass it to the computer with the same mac address...right?

Im asking becuase a program I write dosent seem to handle this limitation. it works great when its on the same network, but otherwise ...nada.

Thanks

share|improve this question

3 Answers 3

If you are creating an app that opens a UDP socket and sends traffic to a particular target the only thing you need to concern yourself with is the ip-addresses. If your listener works on layer 2. i.e. when both systems are on the same subnet, then it should work exactly the same way when you move to layer 3 provided your network is correctly set up. If that fails then try using something to test it that you know works. There are plenty of diagnostic apps out there but the easiest is probably netcat, install that and try this:

On your target system:

nc -l -u -p 1234 

On your source system

nc -u -p 1234

Change the port number to the one you're using for your app and if you should be able to see anything you type on the source appear on the destination console provided your layer-3 network is set up properly and isn't blocking UDP over that port.

If you are embedding the MAC address in the payload then that's one thing but the source (and destination) MAC addresses embedded in the Ethernet frame will be changed by the router, that's how it works. If your app expects them to remain the same at both ends of the conversation then it will fail but in general you should not be digging that deep into the network stack. What are you using to build this?

share|improve this answer

You have two cases:

1- If you are sending the packet to a host within the same subnet, it will be sent directly to it using the MAC and IP addresses of the destination machine.

2- If you are sending it to a host in another subnet, it should be sent to your router. So, the destination MAC will be the one of the router and destination IP will be the one of the final destination.

You know which one is your case by examining the IP and subnet mask.

share|improve this answer
    
Thanks for the quick response. So if I have a server that receives a message from another network(the second case) , how can he send a message to the computer in the network which sent him the message ? cause the infromation he has is the IP and mac of the network router –  Dan Dec 23 '10 at 15:13
    
That is enough. You need only the router MAC address and the server IP. –  Khaled Dec 23 '10 at 15:24

If your computers are in the same subnet, there is no router needed to communicate. If you ran to the router, the router change the source MAC address to the router MAC. When the router receive the packet, it change back to the internal MAC.

share|improve this answer
    
Er? That doesn't make sense, you seem t obe treating L2 addressing (MACs) like L3 addressing (in this case, NAT). The source MAC is always replaced on forwardíng through an L3 device (but shouldn't be, when sent through an L2 device). –  Vatine Dec 23 '10 at 15:11
    
You are right it is exactly what I try to explain. Sorry if it is not clear... –  Dom Dec 23 '10 at 15:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.