TCP/IP devices behave differently if they're communicating with devices on their own subnet. On Ethernet LANs, for example, if one device wants to talk to a device on a different subnet, it will forward that traffic to its default gateway, which is simply a local router.
If a device wants to talk to another device on its own subnet, however, it will send a broadcast ARP request to try to get the MAC address. If it receives a reply, it will populate its ARP cache with the destination address and proceed with unicast communication.
IP devices are configured with an IP address and a subnet mask. The IP address uniquely identifies the device in the network, while the subnet mask allows you to determine which part of the IP address is the network address.
In your example, a subnet mask of 255.255.255.0 means that the first three octets (bytes) of the IP address are the network address and the last octet is the host address.
Follow the link that vipergg provided. It will explain this all in much more detail.