What happens when two machines have same MAC address in a network? - network-programming

How the communication between two pc will be done and how the communication in the network will be done ? How do they bot coneect to the internet??
I m assuming may be one pc has spoofed another pc address.

It depends how the machines' MAC address appear onto mac routing table.
https://superuser.com/questions/17696/what-happens-when-two-pcs-have-the-same-mac-adress

Exactly. What eRIZ said.
Sometimes the machines will refuse to connect due collision OR one computer will connect before the another bouncing the other one of the network.
But yeah, it depends how they are configured.

Related

Find out if a device is turned on in LAN using its MAC address without an IP

On a local network I'm sending a WOL (Wake-On-LAN) packet using sendto to the target MAC address. The code for that works without any problems and the target machine is turned on correctly. The problem is, that I don't know if the target machine has a LAN cable attached or not. If it's not attached, then the whole process fails. Unfortunately, sendto is unidirectional, so I don't know if my magic packet arrived.
I'm wondering about the best and fastest way to find out if WOL succeeded or not. Waiting for the device to boot up completely so I find out get and ping its IP address takes way too long.
Is there a way to "ping" a MAC address, i.e. get some sort of Layer-2-reply?
I need this solution for a Delphi application, but if you have a solution for a different language at hand you're welcome to post that as well. Thank you!

Local vs. remote accessing Pi from iOS

I have a Raspberry Pi with a hat to control my sunscreens. Works very well when I use the normal internet connection.
I have added code to detect when I'm on the local network and even using mDNS / Bonjour I detect the Raspberry Pi from iOS and get it's local IP address. But then if I do a request to the Pi using the local IP address I get a (kCFStreamErrorDomainSSL, -9824) error. The cause is obvious: the SSL certificate on the Pi has the FQDN in it and of course that is not the same as 192.168.2.13 or whatever.
But then the big question: how to solve this.
One idea could be to make sure from outside the router resolves to my FQDN, from the inside I should make sure that the FQDN resolves to the local address my Pi is on. But the only way I could imagine how I pull that off is making the Pi a DNS and DHCP server. Although I could do that of course I am starting to think that I make it way too difficult and there should be other solutions.
One maybe easier option might be to bring another server process in the air on the pi and if I detect the Pi using bonjour not go through the http(s) route but use the alternative solution (sockets?)? Any suggestions appreciated.

Establishing LAN connection between Ubuntu laptops

I am trying to establish LAN connection between my two laptops using Ubuntu on both. But it shows auto is connected on one laptop but other remains disconnected.
Is there any a hardware issue or a software issue? Am I forgetting something else?
Are you directly connecting them, or using a switch in between? If you're directly connecting them you need a crossover cable and not a straight. Also make sure they're both in the correct subnet.
https://learningnetwork.cisco.com/thread/13249
Also check out the following link; http://en.kioskea.net/forum/affich-25120-how-to-connect-two-laptops-using-lan-cable

The uniqueness of MAC addresses

Looking at this related SO question, I can't help but wonder about the uniqueness of MAC addresses.
How unique are MAC addresses?
I'm using them to semi-uniquely identify users. I have a website that users of virtually any device (PC, Mac, iPhone, Android phone, etc.) and any OS can hit via an HTTP request. I use a combination of IP address and MAC address to identify unique users.
I assume the following cases can exist:
A device has no MAC address (unlikely, sure, but anyway)
A device has a unique MAC address
A device has multiple unique MAC addresses
Two or more devices have the same MAC address
The first three of these cases are unique (the third because I only need a single unique MAC address). For the fourth case, how likely is this?
That is: given 100 random users (perhaps Windows users for any Windows OS), how many of them can I expect to have the same MAC address? Is it just generally because of the limited length of MAC addresses? Or is it dependent on some sort of purposeful configuration change (MAC address spoofing)?
I'm okay with MAC addresses being semi-unique, I just want some clarity on how to interpret the data.
(I'm using the C# code against .NET 2.0 in the linked question against .NET 2.0.)
This is only true on the same network.
MAC addresses are resolved locally using ARP to route local packets at a hardware level. ARP is not a routable protocol and is not resolved across subnets.
If your webserver is behind a router with port mapping and all the incoming traffic to it is coming from that router, then every connection will appear to come from the MAC address of the router, you won't 'see' the MAC address of the original machine, not unless you can pick it up with a web page somehow (i'm not a web genius so don't ask me on that one, but Im guessing you'd need some heavy lifting at the client end with Java, or some other kind of active component to interrogate the local machine, easier to use a cookie)
You can find out the Public IP address of the remote machine where the outgoing NAT took place, but once again, there could be multiple device connecting from behind a router which would limit the usefulness of this method, and it means need to look into IP packets, which I have no idea how you can do that from a web server (probably can't?).
Anyway, this is what cookies are for, a way of leaving an identifier on a remote machine so you can see where traffic came from. If people don't accept cookies, unless you start getting very very creative you aren't going to be able to uniquely identify them.
(BTW Mac address are always unique (ok, you can occasionally find a reused MAC, but its extremely rare, or at least needs to be for networking to work!), thats the purpose of them, it's just not much help in this scenario if you are not on the same network)
100 random users (perhaps Windows users for any Windows OS), how many
of them can I expect to have the same MAC address?
Zero. And when they are in the same network, they could not communicate with the same MAC-Address, since Ethernet uses them to find the Computer. They are pretty unique. Producers of network cards get ranges of addresses they may assign to their products.
But: There are ways to manipulate your MAC Address, and there are scenarios where people do just that! For example when you want to enter a network, which is restricted to certain MAC-Addresses, you can manipulate your own to match one of those (if you find out, which ones are on the whitelist). Since I don't know, what your szenario is, (what you wnat to accomplish), I can not tell you if that is relevant for yout.
You just need to understand the difference between a MAC Address (that can be changed) and the identifier of your hardware [your Network Interface Controler to be precise] (that is forever assigned by its the manufacturer).
MAC address is the name of your device when it connects to the internet (through a rooter or a switch). You can change your MAC Address, but by default, this ID uses the identifier assigned by the manufacturer of the network interface controller (NIC) (e.g. your Wifi antena)
Exemple: I've changed my MAC address for my two computers using the same MAC Address: 00:01:02:03:04:06. My computers seems to be the same when connected to the same router but the identifier of their wifi antena remain unchanged and different.

Create a multicast router

How can i make my laptop to act as a multicast router.
I need to stream video content to other computers with in same network. How can i make my laptop to work as a multicast router.
There are some tools like that iou,iou2net.pl
It's simple - write a simple app to recieve multicast on one network card and simply re-send it on another one. One packet in - one packet out. And this way you can make userspace multicast router. Very easy. Just dont forget to register IGMP on these sockets.
This way you can also send it to multiple networks at once, etc etc.
Say you install Cisco IOU on a VM (ubuntu) or directly if you already use ubuntu.
Every instance you run (level 3 bin files for routers and level 2 for switches) is dealt with as a seperate physical machine.
This way you can:
create a network within one machine.
save up on memory as IOUs don't really take that much (64mb by default)
do any type of testing you need locally and for free.
iou2net.pl for instance is a tool you use to link an IOU instance to external networks.
This way you can use a real router/switch or network setting up the IOU either as one or a group or client OR your server itself.

Resources