86
you are viewing a single comment's thread
view the rest of the comments
[-] Buddahriffic@lemmy.world 2 points 8 months ago

This is simplified, like it assumes routers handle everything when that's not really the case but hopefully it still illustrates the idea.

Your network might have 5 devices connected to it. To uniquely represent those 5 devices, they need 5 addresses. If all that exists is your own network, then any 5 addresses would work, as long as they are unique. 0.0.0.0 through 0.0.0.4 would work.

But your network is connected to a larger network, probably your ISP's network. Let's say your ISP also has 5 clients. If they gave their clients the 0.0.0.0 through 0.0.0.4 addresses, they would clash with your own network addresses. So maybe they'd use 0.0.0.0 through 0.0.4.0 instead.

Your ISP is also connected to another network, which is connected to another one, and so on.

Each destination on the large network made up of all these smaller networks needs to have a unique address for other devices to find them. Part of the address will be assigned by higher level routers and part of it will be assigned by the router directly connected to the device.

The subnet mask (or network mask) basically lets the router know which parts of the address have been assigned to it by higher powers and which ones it can use to assign unique addresses to its own clients. It's a bit mask where each 1 means the higher network "owns" that bit in the address (and the router can't change it for any of its clients) and a 0 means the router can use that bit to uniquify its own clients.

So a subnet mask of 255.255.255.0 means that the first three numbers of that IP address have been assigned to the router and the last one is free for it to assign to up to 256 clients.

If ( ( myaddress xor targetaddress ) bitwise-and mask ) gives a non-zero result, then the address isn't on the router's client network and the packet needs to be sent upstream. If it gives a zero, then ( not ( mask ) bitwise-and targetaddress ) will give a number that can be used to look up the physical port (or wifi info) that the router needs to use to make contact with the destination.

this post was submitted on 25 Mar 2024
86 points (96.7% liked)

[Outdated, please look at pinned post] Casual Conversation

6470 readers
1 users here now

Share a story, ask a question, or start a conversation about (almost) anything you desire. Maybe you'll make some friends in the process.


RULES

Related discussion-focused communities

founded 1 year ago
MODERATORS