I have connected to a wifi network i have assigned with an ip:192.168.5.125 subnet:255.255.240.0 . but my gateway is in 192.168.0.1 how could this possible? And i have observed my friend's ip he also connected to the same wifi network. he got 192.168.1.28 and he also have the same gateway 192.168.0.1. And I could able to ping him also. How come this possibe?
The subnet mask is
255.255.240.0 which means 20 bits belong to Network and remaining 12 is for host. The range of IP Address inside the network can be found by running your IP address against Subnet Mask.
Address: 192.168.5.125 11000000.10101000.0000 0101.01111101 Netmask: 255.255.240.0 = 20 11111111.11111111.1111 0000.00000000 => Network: 192.168.0.0/20 11000000.10101000.0000 0000.00000000 (Class C)
The broadcast IP, First Host and Last host IP addresses are:
Broadcast: 192.168.15.255 11000000.10101000.0000 1111.11111111 HostMin: 192.168.0.1 11000000.10101000.0000 0000.00000001 HostMax: 192.168.15.254 11000000.10101000.0000 1111.11111110 Hosts per Network : 4094 (Private Internet)
So your IP address, your friend's IP address and the Gateway IP address all belong to the same network. They should communicate without any trouble.