Tutorial on Network Programming with Python
The TCP/IP network protocol suite is the standard method for intermachine communication. Though originally integral only to the UNIX operating system, its usage spread to all OS types, and it is the basis of the entire Internet. This document will briefly introduce the subject of TCP/IP programming using the Python language. See http://heather.cs.ucdavis.edu/~matloff/Networks/Intro/ NetIntro.pdf for a more detailed introduction to networks and TCP/IP.
1.1 Networks and MAC Addresses
A network means a Local Area Network. Here machines are all on a single cable, or as is more common now, what amounts to a single cable (e.g. multiple wires running through a switch). The machines on the network communicate with each other by the MAC addresses, which are 48-bit serial numbers burned into their network interface cards (NICs). If machine A wishes to send something to machine B on the same network, A will put B’s MAC address into the message packet. B will see the packet, recognize its own MAC address as destination, and accept the packet.
1.2 The Internet and IP Addresses
An internet-note the indefinite article and the lower-case i-is simply a connection of two or more networks. One starts, say, with two networks and places a computer on both of them (so it will have two NICs). Machines on one network can send to machines on the other by sending to the computer in common, which is acting as a router. These days, many routers are not full computers, but simply boxes that do only routing. One of these two networks can be then connected to a third in the same way, so we get a three-network internet, and so on. In some cases, two networks are connected by having a machine on one network connected to a machine on the other via a high-speed phone line, or even a satellite connection.
The Internet-note the definite article and the capital I-consists of millions of these networks connected in that manner.
On the Internet, every machine has an Internet Protocol (IP) address. The original ones were 32 bits wide, and the new ones 64. If machine A on one network wants to send to machine Z on an distant network, A sends to a router, which sends to another router and so on until the message finally reaches Z’s network. The local router there then puts Z’s MAC address in the packet, and places the packet on that network. Z will see it and accept the packet. Note that when A sends the packet to a local router, the latter may not know how to get to Z. But it will send to another router “in that direction,” and after this process repeats enough times, Z will receive the message. Each router has only limited information about the entire network, but it knows enough to get the journey started.
…
Website: heather.cs.ucdavis.edu | Filesize: 133kb
No of Page(s): 17
Click here to download Tutorial on Network Programming with Python.
Related Tutorial
Tags: networking, TCP/IP
Comments
Leave a Reply