VOGONS


First post, by superfury

User metadata
Rank l33t++
Rank
l33t++

I know that if you send a packet to a subnet broadcast address, everyone on that local subnet receives it(e.g. from 192.168.1.1/24 to 192.168.1.255 is received by 192.168.1.*).

But what happens if you send a packet to .o on a /24 subnet?
Like from 192.168.1.1/24 to 192.168.1.0(the dst field in the IPv4 header)?

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io

Reply 1 of 5, by Jo22

User metadata
Rank l33t++
Rank
l33t++

Reality will fall apart? 😉

https://www.youtube.com/watch?v=UBxBRTcZVis&t=120

Seriously though, I don't know. Never tried so far. 🤷‍♂️

"Time, it seems, doesn't flow. For some it's fast, for some it's slow.
In what to one race is no time at all, another race can rise and fall..." - The Minstrel

//My video channel//

Reply 2 of 5, by superfury

User metadata
Rank l33t++
Rank
l33t++

Where does said packet end up? Does nobody receive said packet? Or is something like the broadcast (.255 in the example) on the subnet supposed to happen? Or a black hole for the packet?

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io

Reply 3 of 5, by Meatball

User metadata
Rank Oldbie
Rank
Oldbie

https://serverfault.com/questions/135267/what … -x-x-0-used-for

"...many OSes treat the first address as a broadcast. For example, pinging x.x.x.0 from OS X, Linux, and Solaris on my local (/24) network gets responses. Windows doesn't let you ping the first address by default ..."

Reply 4 of 5, by dr_st

User metadata
Rank l33t
Rank
l33t

Dunno how to tell you, but... The address you write into the packet means nothing. Nothing at all.
The packet will be received where the physical layer takes it, and exactly there.

Which means - on a half duplex network - by everyone (as long as it does not get corrupted by the medium).
And on a full duplex network - only by the port on the other end of the wire where the packet was sent.

What happens next - depends solely on what the hardware/firmware/software of the port on the other end decides to do with it. Which is controlled by many different configuration parameters. Whether it accepts the packet, forwards it to someone else or discards it - is decided by the driver/firmware controlling the port. It may process the packet directly or set up a rule in the hardware to do something automatically (and then the software/firmware may never see the packet at all). This is very implementation-specific.

You can read the protocol specification and figure out what is supposed to happen. And with a protocol as old and mature as IP, you can expect that most implementations are compliant. But, even then, you can have surprises.

Now, one exception, as you can see, e.g., in the preceding post - is that the software (firmware in some cases) can be configured so that the upper layers will filter out a packet that they don't like even before it gets to the hardware. So it will never be sent.

In most cases, you can write a custom driver / traffic generator that will bypass the normal network stack and send such packets (or completely malformed ones) anyway. Such tools are frequently used for testing and validating the correct behavior of networks and network devices.

https://cloakedthargoid.wordpress.com/ - Random content on hardware, software, games and toys

Reply 5 of 5, by superfury

User metadata
Rank l33t++
Rank
l33t++

Well, what UniPCemu's server builds currently do is just inspect the destination IP address, then:
- If it's on the same subnet as the client, send it to the client receiver.
- Otherwise, send it to the default gateway configured.

Then, when receiving packets:
- Anything received from the host network for the client's IP address is received. All other traffic is ignored (for IPv4 packets. IPX packets are always received at this stage).
- Anything received from other clients (above subnet sending) or the specific IP address from the host network (the client's IP address) is matched against itself(receiving it for the client's own IP address) and the client's own subnet-mask based broadcast address (received only if originating from the client network's send function). The IPv4 broadcast address (255.255.255.255) also is received on all clients that are connected, but ignoring the IPv4 address and subnet mask of the client completely (always received).

Note that the host's subnet-based broadcast IP as well as the host's 255.255.255.255 received packets (from the host network) are filtered at the receiver for the host network itself. Thus all those 255.255.255.255 and *.255 packets(from the example, using a /24 subnet mask) are guaranteed to be from the client network. Each client, when trying to receive the packet (this happens in parallel on all the clients at the same time), checks the IP address against the three possibilities to determine if it's to receive it:
1. If it's for it's own IP address, receive it.
2. If it's for it's own subnet's broadcast address (for example, configured for it's /24 mask and matching it's broadcast address with the host bits all set), receive it.
3. If it's for 255.255.255.255, check if the source IP of the packet is on the same subnet. If it matches the subnet, receive it.

If 1, 2 and 3 aren't matched, the packet is discarded in the main loop parsing the packet. This point is where all the receivers for the connected clients on the server handle their sending and receiving of packets (the receiving part in this case). This happens for all connected clients in parallel (so if any clients is to receive the packet, all other clients must finish sending their packets to their clients first before this can start at all. Then all clients get the packet buffered in their own IPv4 buffer and a new packet can arrive (with this step only being retriggered once all clients have nothing to parse anymore). Finally, each client will then check their own buffers for available IPv4 packets and if invalid (according to the above rules) throws it away for a new packet to be able to arrive in parallel with all other clients.
If it's valid for a client on the other hand, it will start sending the packet to the client and remove it's buffered packet once it's completely sent to the client (allowing for all clients to receive a new packet once all other clients have cleared their buffers this or the above mentioned way as well).

So basically, it's receiving it like this:
1. sendpkt -> (host network (ARP-based or default gateway) or loopback buffer (for non-routable packets), depending on the general ARP result(loopback is used for any broadcast from the client as well as the subnet of the destination matching the subnet of the client)).
2. (host network or loopback buffer(priority)) to global receive buffer for IPv4 or IPX.
3. (IPv4 or IPX) global receive buffer to all clients's local buffer in parallel (to provide for broadcasting and the like).
4. Each client then checks it's own buffer for the packet type (round robin-style for priority resolving), discards it if filtering (not own IP, global broadcast(255.255.255.255) or it's own subnet source with subnet broadcast destination), otherwise starts sending it to the client, after which it will discard the packet in it's own packet buffer.

The .0 address isn't being used in any of those checks. So basically, to a client, only it's own IP, destination on it's own subnet and broadcast on it's own subnet are received back on it's interface, with other clients with their subnets receiving if subnet broadcast matches rule 4 with source address in it's own subnet or during a global broadcast(255.255.255.255)).

Also, sending (step 1) to it's own subnet won't perform an actual ARP. Instead, it'll just send the packet to the loopback buffer with the destination MAC address either broadcast (for an subnet broadcast (for example *.255)) or the first MAC address, which is reserved for the loopback to receive it's looped back packets on).
This first MAC address is protected against being the same as the host MAC, and will increase by 1 if it matches it. This MAC address is discarding the packet if received on the host's network, but accepted when on the loopback buffer (it's reserved for the loopback case to be properly detected, which acts like a normal ff:ff:ff:ff:ff:ff broadcast MAC just for the loopback).

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io