Learning Python Network Programming

(Sean Pound) #1

Network Programming and Python


An interface is usually assigned only one IP address, and each interface in a device
has a different IP address. So, going back to the purposes of IP addresses discussed
in the preceding section, we can now more accurately say that their first main
function is to uniquely address each device's connection to a network.


Every device has a virtual interface called the loopback interface, which you can
see in the preceding listing as interface 1. This interface doesn't actually connect to
anything outside the device, and only the device itself can communicate with it.
While this may sound a little redundant, it's actually very useful when it comes to
local network application testing, and it can also be used as a means of inter-process
communication. The loopback interface is often referred to as localhost, and it is
almost always assigned the IP address 127.0.0.1.


Assigning IP addresses


IP addresses can be assigned to a device by a network administrator in one of two
ways: statically, where the device's operating system is manually configured with
the IP address, or dynamically, where the device's operating system is configured by
using the Dynamic Host Configuration Protocol (DHCP).


When using DHCP, as soon as the device first connects to a network, it is
automatically allocated an address by a DHCP server from a predefined pool. Some
network devices, such as home broadband routers provide a DHCP server service
out-of-the-box, otherwise a DHCP server must be set up by a network administrator.
DHCP is widely deployed, and it is particularly useful for networks where different
devices may frequently connect and disconnect, such as public Wi-Fi hotspots or
mobile networks.


IP addresses on the Internet


The Internet is a huge IP network, and every device that sends data over it is
assigned an IP address.


The IP address space is managed by an organization called the Internet Assigned
Numbers Authority (IANA). IANA decides the global allocation of the IP address
ranges and assigns blocks of addresses to Regional Internet Registries (RIRs)
worldwide, who then allocate address blocks to countries and organizations. The
receiving organizations have the freedom to allocate the addresses from their
assigned blocks as they like within their own networks.

Free download pdf