November 24, 2015 | Article | 1 Comment
Last article, we have discussed about what is socket. This article will give a quick presentation about network before start learning socket programming.
Internet Protocol (IP) Address and Subnetwork
Internet Protocol (IP) Address or IP Address is simply an address. Like address in real world, IP address determine how your device can be reach from other device. IP address set a complex message transferring system in internet which is called routing, and responsible to route data packets from one end to another end.
There are 2 type of IP address used in public: IPv4 (IP version 4) and IPv6 (IP version 6).
IPv4 has 32 bit length with representation series of decimal numbers separated by dot. For example 192.168.1.1 is IPv4 address. With IPv4 there would be 2^32 addresses or 4,294,967,296 (approximately 4 billion address). These addresses are currently running out so an alternative address named IPv6 is developed.
IPv6 has 128 bit length with representation series of hexadecimal numbers separated by colon. For example 2001:0db8:c9d2:0012:0000:0000:0000:0051. With IPv6 there would be 2^128 addresses for entire planet. This is relatively huge, far more huge than older IPv4 way.
There is an organization Internet Assigned Number Authority (IANA, http://www.iana.org/) that manages global IP allocation and delegates it to five Regional Internet Registries (RIRs) to allocate IP block to Local Internet Registries (LIRs) and other organization. So RIR are IANA’s delegation to manages all IP address around the world. Those 5 regions are:
- African Network Information Center (AfriNIC) for Afrika.
- American Registry for Internet Numbers (ARIN) for United States, Canada, and some region of Caribbean.
- Asia-Pacific Network Information Center (APNIC) for Asia, Australia, New Zealand, and surrounding nation.
- Latin America and Caribbean Network Information Center (LACNIC) for Latin America and some region of Caribbean.
- Réseaux IP Européens Network Coordination Centre (RIPE) for Europe, Middle East, and Middle Asia.
While LIRs are organization in every nation. They allocate IP address for customer in each nation but still under supervisor of their own RIR.
Subnetwork or subnet is a logically visible subdivision of an IP network. All computers that belong to a subnet are addressed with a common, identical, most-significant bit-group in their IP address. This results in the logical diviion of an IP address into two fiels: a network or routing prefix and the rest field or host identifier. The rest field is identifier for a specific host or network interface.
The routing prefix is expressed in CIDR notation and written as the first address of a network followed by a slash character (/), and ending with the bit-length of prefix. For example 184.108.40.206/24 is the prefix of the IPv4. The example for IPv6 is 2001:db8::/32 is a large network with 2^96 address, having a 32-bit routing prefix. In IPv4 the routing prefix is also specified in the form of the subnet mask, which is expressed in quad-dotted decimal representation like an address, for example: 255.255.255.0 is network mask for 24-bit routing prefix.
In computer network, a port is a logical gateway to exchange information to the world. Like a port in real world, incoming and outgoing packet are visiting port each time. Therefore it is a vital part for communication.
Port Number is a number that associated with kernel. A port number is 16-bit number that is like local address for the connection.
We can associate IP address like address of a building (apartment), while port number is room number for each attendant (a program). A message passed from one program to another program can be in same building (same machine) or different building (different machine) via postal agent (internet).
Port number is also differentiate services on a server, such as mail server and web server.
Different services on internet have different well-known post numbers. There is a big list maintained by IANA or if you are on Unix machine you can see the list on /etc/services file. HTTP (web) is port 80, telnet is 23, SMTP is 25, and so on.
There are two way computer might store number, in Big-Endian or Little-Endian. A Big-Endian system store number with big end first. While Little-Endian is the reverse. Intel and Intel-compatible processor store data in Little-Endian. Therefore, a number in hexadecimal 0xb34f would be stored in memory as sequential 4f followed by b3. In Big-Endian, 0xb34f would be stored in memory in two sequential bytes b3 followed by 4f.
The computer dependent number presentation (can be Little-Endian or Big-Endian depend on processor) is called Host Byte Order. The data across network is standardized using Big-Endian for clarity. The byte order for network is called Network Byte Order.networking, programming, socket