Upload
others
View
23
Download
0
Embed Size (px)
Citation preview
COMPUTER NETWORK PROGRAMMING(Python Network Programming)
Dr.Edi Surya Negara,M.Kom.
Postgraduate Program, Informatics Engineering (S2)
December 20, 2017
References :
• Computer Networks - A Tanenbaum - 5th edition (2011)
• Data Communications and Networking - Behrouz A.Forouzan -4th edition (2007)
• Cisco System Inc - 2011 - Cisco Configuration Profesional UserGuide.
• Python Network Programming - David M Beazley (2010)
Chapter 7: Objectives
This course focuses on the essential details of network programmingthat all Python programmers should probably know, students will beable to:
• Low-level programming with sockets.
• High-level client modules.
• How to deal with common data encodings.
• Simple Server & Client A : Basics.
Computer Network Programming
• Computer network programming involves writing computerprograms that enable processes to communicate with each otheracross a computer network.
• Network programming is a major use of Python and C/C++
Python Network Programming
• Python standard library has wide support for network protocols,data encoding/decoding, and other things you need to make itwork (sockets).
• Python provides two levels of access to network services. At a lowlevel, you can access the basic socket support in the underlyingoperating system, which allows you to implement clients andservers for both connection-oriented and connectionless protocols.
• Python also has libraries that provide higher-level access tospecific application-level network protocols, such as FTP, HTTP,and so on.
Sockets
• Sockets are the endpoints of a bidirectional communicationschannel. Sockets may communicate within a process, betweenprocesses on the same machine, or between processes on differentcontinents.
Sockets
• Programming abstraction for network code.
• Socket: A communication endpoint.
• Supported by socket library module.
• Allows connections to be made and data to be transmitted ineither direction.
Sockets Basic
The Promblem
• Communication between computers.
• It’s just sending/receiving bits.
Sockets Basic
Two Main Issues• Addressing.
• Specifying a remote computer and service.• Machines have a hostname and IP address.• Programs/services have port numbers
• Data transport. Moving bits back and forth.
Data Transport
• There are two basic types of communication.
• Streams (TCP): Computers establish a connection with eachother and read/write data in a continuous stream of bytes—like ale. This is the most common.
• Datagrams (UDP): Computers send discrete packets (ormessages) to each other. Each packet contains a collection ofbytes, but each packet is separate and self-contained.
TCP Server.py
TCP Client.py