Learning Python Network Programming

(Sean Pound) #1

Network Programming and Python


What a packet contains is shown in the following figure:


Some protocols use alternative terms for packets, such as frames, but we'll stick with
the term packets for now. The header includes all the information that the protocol
implementation running on another device needs to be able to interpret what the
packet is and how to handle it. For example, the information in an IP packet header
includes the source IP address, the destination IP address, the total length of the
packet, and the checksum of the data in the header.


Once created, the packets are sent onto the network, where they are independently
routed to their destination. Sending the data in packets has several advantages,
including multiplexing (where more than one device can send data over the network
at once), rapid notification of errors that may occur on the network, congestion
control, and dynamic re-routing.


Protocols may call upon other protocols to handle their packets for them; passing
their packets to the second protocol for delivery. When both the protocols employ
packetization, nested packets result, as shown in the following figure:


This is called encapsulation, and as we'll see shortly, it is a powerful mechanism for
structuring network traffic.

Free download pdf