The Building Blocks: Stacks And Libraries

Application Layers

Speaking The Protocol

A Raw Network Conversation

Turtles All The Way Down

An important lesson taken from the previous sections is that implementing network protocols correctly is difficult and that you should use the Standard Library or third-party libraries whenever possible. This comes with the caveat that just because you are using an external package for networking, that does mean you cannot understand how the package works. Specifically, be attentive of how errors are thrown especially when the lower networking layers.

Encoding And Decoding

The Internet Protocol

The fundamental unit of sharing among network devices, is the packet. A packet is a byte string whose length might range from a few bytes to a few thousand bytes, which is transmitted as a single unit between network devices. A packet often only has two properties at the physical level: the byte-string data and an address to which it needs to be delivered.

Expanding the concept to a large set of interconnected computers, the internet protocol is a scheme for imposing a uniform system of addresses on all of the Internet-connected computers in the entire world and to make it possible for packets travel from one end to the other.

IP Addresses

Generally, traditional IP addresses can be read from left to right: the first one or two bytes specify an organization, and then the next byte often specifies the particular subnet on which the target machine resides. the last byte narrows down the address to that specific machine or service.

Routing

Most, or perhaps all, of the Python code you write during your career will be running on hosts out at the edge of the Internet, with a single network interface that connects them to the rest of the world. For such machines, routing becomes a quite simple decision.

Packet Fragmentation

Packet fragmentation allows large pieces of data being sent over the network to be broken down into smaller packets. If the "don't fragment" (DF) flag is set, then the protocol will attempt to send the data in one monolithic packet. If the data is too large, 1'500-bytes for ethernet for example, and the DF flag is set, an error is returned. The largest packet that an internet subnet can transmit is the maximum transmit unit (MTU).