Python Network Programming Cookbook - Second Edition

Discover practical solutions for a wide range of real-world network programming tasks
Preview in Mapt

Python Network Programming Cookbook - Second Edition

Pradeeban Kathiravelu, Dr. M. O. Faruque Sarker

2 customer reviews
Discover practical solutions for a wide range of real-world network programming tasks
Mapt Subscription
FREE
$29.99/m after trial
eBook
$28.00
RRP $39.99
Save 29%
Print + eBook
$49.99
RRP $49.99
What do I get with a Mapt Pro subscription?
  • Unlimited access to all Packt’s 5,000+ eBooks and Videos
  • Early Access content, Progress Tracking, and Assessments
  • 1 Free eBook or Video to download and keep every month after trial
What do I get with an eBook?
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with Print & eBook?
  • Get a paperback copy of the book delivered to you
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with a Video?
  • Download this Video course in MP4 format
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
$0.00
$28.00
$49.99
$29.99p/m after trial
RRP $39.99
RRP $49.99
Subscription
eBook
Print + eBook
Start 30 Day Trial

Frequently bought together


Python Network Programming Cookbook - Second Edition Book Cover
Python Network Programming Cookbook - Second Edition
$ 39.99
$ 28.00
Python GUI Programming Cookbook - Second Edition Book Cover
Python GUI Programming Cookbook - Second Edition
$ 39.99
$ 28.00
Buy 2 for $35.00
Save $44.98
Add to Cart
Subscribe and access every Packt eBook & Video.
 
  • 5,000+ eBooks & Videos
  • 50+ New titles a month
  • 1 Free eBook/Video to keep every month
Start Free Trial
 

Book Details

ISBN 139781786463999
Paperback450 pages

Book Description

Python Network Programming Cookbook - Second Edition highlights the major aspects of network programming in Python, starting from writing simple networking clients to developing and deploying complex Software-Defined Networking (SDN) and Network Functions Virtualization (NFV) systems. It creates the building blocks for many practical web and networking applications that rely on various networking protocols. It presents the power and beauty of Python to solve numerous real-world tasks in the area of network programming, network and system administration, network monitoring, and web-application development.

In this edition, you will also be introduced to network modelling to build your own cloud network. You will learn about the concepts and fundamentals of SDN and then extend your network with Mininet. Next, you’ll find recipes on Authentication, Authorization, and Accounting (AAA) and open and proprietary SDN approaches and frameworks. You will also learn to configure the Linux Foundation networking ecosystem and deploy and automate your networks with Python in the cloud and the Internet scale.

By the end of this book, you will be able to analyze your network security vulnerabilities using advanced network packet capture and analysis techniques.

Table of Contents

Chapter 1: Sockets, IPv4, and Simple Client/Server Programming
Introduction
Printing your machine's name and IPv4 address
Retrieving a remote machine's IP address
Converting an IPv4 address to different formats
Finding a service name, given the port and protocol
Converting integers to and from host to network byte order
Setting and getting the default socket timeout
Handling socket errors gracefully
Modifying a socket's send/receive buffer sizes
Changing a socket to the blocking/non-blocking mode
Reusing socket addresses
Printing the current time from the internet time server
Writing an SNTP client
Writing a simple TCP echo client/server application
Writing a simple UDP echo client/server application
Chapter 2: Multiplexing Socket I/O for Better Performance
Introduction
Using ForkingMixIn in your socket server applications
Using ThreadingMixIn in your socket server applications
Writing a chat server using select.select
Multiplexing a web server using select.epoll
Multiplexing an echo server using Diesel concurrent library
Chapter 3: IPv6, Unix Domain Sockets, and Network Interfaces
Introduction
Forwarding a local port to a remote host
Pinging hosts on the network with ICMP
Waiting for a remote network service
Enumerating interfaces on your machine
Finding the IP address for a specific interface on your machine
Finding whether an interface is up on your machine
Detecting inactive machines on your network
Performing a basic IPC using connected sockets (socketpair)
Performing IPC using Unix domain sockets
Finding out if your Python supports IPv6 sockets
Extracting an IPv6 prefix from an IPv6 address
Writing an IPv6 echo client/server
Chapter 4: Programming with HTTP for the Internet
Introduction
Downloading data from an HTTP server
Serving HTTP requests from your machine
Extracting cookie information after visiting a website
Submitting web forms
Sending web requests through a proxy server
Checking whether a web page exists with the HEAD request
Spoofing Mozilla Firefox in your client code
Saving bandwidth in web requests with the HTTP compression
Writing an HTTP fail-over client with resume and partial downloading
Writing a simple HTTPS server code with Python and OpenSSL
Building asynchronous network applications with Twisted
Building asynchronous network applications with Tornado
Building concurrent applications with Tornado Future
Chapter 5: Email Protocols, FTP, and CGI Programming
Introduction
Listing the files in a remote FTP server
Uploading a local file to a remote FTP server
Emailing your current working directory as a compressed ZIP file
Downloading your Google email with POP3
Checking your remote email with IMAP
Sending an email with an attachment via Gmail SMTP server
Writing a guestbook for your (Python-based) web server with CGI
Finding the mail server from an email address
Writing a simple SMTP server
Writing a secure SMTP client using TLS
Writing an email client with POP3
Chapter 6: Programming Across Machine Boundaries
Introduction
Executing a remote shell command using telnet
Copying a file to a remote machine by SFTP
Printing a remote machine's CPU information
Installing a Python package remotely
Running a MySQL command remotely
Transferring files to a remote machine over SSH
Configuring Apache remotely to host a website
Chapter 7: Working with Web Services – XML-RPC, SOAP, and REST
Introduction
Querying a local XML-RPC server
Writing a multithreaded, multicall XML-RPC server
Running an XML-RPC server with a basic HTTP authentication
Collecting some photo information from Flickr using REST
Searching for SOAP methods from an Amazon S3 web service
Searching Amazon for books through the product search API
Creating RESTful web applications with Flask
Chapter 8: Network Monitoring and Security
Introduction
Sniffing packets on your network
Saving packets in the pcap format using the pcap dumper
Adding an extra header in HTTP packets
Scanning the ports of a remote host
Customizing the IP address of a packet
Replaying traffic by reading from a saved pcap file
Scanning the broadcast of packets
Chapter 9: Network Modeling
Introduction
Simulating networks with ns-3
Emulating networks with Mininet
Distributed network emulation with MaxiNet
Emulating wireless networks with Mininet-WiFi
Extending Mininet to emulate containers
Chapter 10: Getting Started with SDN
Introduction
SDN emulation with Mininet
Developing Software-Defined Networks with OpenDaylight controller
Developing Software-Defined Networks with ONOS controller
Developing Software-Defined Networks with Floodlight controller
Developing Software-Defined Networks with Ryu controller
Developing Software-Defined Networks with POX controller
Developing Software-Defined Networks visually with MiniEdit
Chapter 11: Authentication, Authorization, and Accounting (AAA)
Introduction
Finding DNS names of a network
Finding DNS host information
Finding DNS resource records
Making DNS zone transfer
Querying NTP servers
Connecting to an LDAP server
Making LDAP bind
Reading and writing LDAP
Authenticating REST APIs with Eve
Throttling requests with RequestsThrottler
Chapter 12: Open and Proprietary Networking Solutions
Introduction
Configuring Red PNDA
Configuring VMware NSX for vSphere 6.3.2
Configuring Juniper Contrail Server Manager
Configuring OpenContrail controller
Configuring OpenContrail cluster
Interacting with devices running Cisco IOS XR
Collaborating with Cisco Spark API
Chapter 13: NFV and Orchestration – A Larger Ecosystem
Introduction
Building VNFs with OPNFV
Packet processing with DPDK
Parsing BMP messages with SNAS.io
Controlling drones with a wireless network
Creating PNDA clusters
Chapter 14: Programming the Internet
Introduction
Checking a website status
Benchmarking BGP implementations with bgperf
BGP with ExaBGP
Looking glass implementations with Python
Understanding the internet ecosystem with Python
Establishing BGP connections with yabgp

What You Will Learn

  • Develop TCP/IP networking client/server applications
  • Administer local machines' IPv4/IPv6 network interfaces
  • Write multi-purpose efficient web clients for HTTP and HTTPS protocols
  • Perform remote system administration tasks over Telnet and SSH connections
  • Interact with popular websites via web services such as XML-RPC, SOAP, and REST APIs
  • Monitor and analyze major common network security vulnerabilities
  • Develop Software-Defined Networks with Ryu, OpenDaylight, Floodlight, ONOS, and POX Controllers
  • Emulate simple and complex networks with Mininet and its extensions for network and systems emulations
  • Learn to configure and build network systems and Virtual Network Functions (VNF) in heterogeneous deployment environments
  • Explore various Python modules to program the Internet

Authors

Table of Contents

Chapter 1: Sockets, IPv4, and Simple Client/Server Programming
Introduction
Printing your machine's name and IPv4 address
Retrieving a remote machine's IP address
Converting an IPv4 address to different formats
Finding a service name, given the port and protocol
Converting integers to and from host to network byte order
Setting and getting the default socket timeout
Handling socket errors gracefully
Modifying a socket's send/receive buffer sizes
Changing a socket to the blocking/non-blocking mode
Reusing socket addresses
Printing the current time from the internet time server
Writing an SNTP client
Writing a simple TCP echo client/server application
Writing a simple UDP echo client/server application
Chapter 2: Multiplexing Socket I/O for Better Performance
Introduction
Using ForkingMixIn in your socket server applications
Using ThreadingMixIn in your socket server applications
Writing a chat server using select.select
Multiplexing a web server using select.epoll
Multiplexing an echo server using Diesel concurrent library
Chapter 3: IPv6, Unix Domain Sockets, and Network Interfaces
Introduction
Forwarding a local port to a remote host
Pinging hosts on the network with ICMP
Waiting for a remote network service
Enumerating interfaces on your machine
Finding the IP address for a specific interface on your machine
Finding whether an interface is up on your machine
Detecting inactive machines on your network
Performing a basic IPC using connected sockets (socketpair)
Performing IPC using Unix domain sockets
Finding out if your Python supports IPv6 sockets
Extracting an IPv6 prefix from an IPv6 address
Writing an IPv6 echo client/server
Chapter 4: Programming with HTTP for the Internet
Introduction
Downloading data from an HTTP server
Serving HTTP requests from your machine
Extracting cookie information after visiting a website
Submitting web forms
Sending web requests through a proxy server
Checking whether a web page exists with the HEAD request
Spoofing Mozilla Firefox in your client code
Saving bandwidth in web requests with the HTTP compression
Writing an HTTP fail-over client with resume and partial downloading
Writing a simple HTTPS server code with Python and OpenSSL
Building asynchronous network applications with Twisted
Building asynchronous network applications with Tornado
Building concurrent applications with Tornado Future
Chapter 5: Email Protocols, FTP, and CGI Programming
Introduction
Listing the files in a remote FTP server
Uploading a local file to a remote FTP server
Emailing your current working directory as a compressed ZIP file
Downloading your Google email with POP3
Checking your remote email with IMAP
Sending an email with an attachment via Gmail SMTP server
Writing a guestbook for your (Python-based) web server with CGI
Finding the mail server from an email address
Writing a simple SMTP server
Writing a secure SMTP client using TLS
Writing an email client with POP3
Chapter 6: Programming Across Machine Boundaries
Introduction
Executing a remote shell command using telnet
Copying a file to a remote machine by SFTP
Printing a remote machine's CPU information
Installing a Python package remotely
Running a MySQL command remotely
Transferring files to a remote machine over SSH
Configuring Apache remotely to host a website
Chapter 7: Working with Web Services – XML-RPC, SOAP, and REST
Introduction
Querying a local XML-RPC server
Writing a multithreaded, multicall XML-RPC server
Running an XML-RPC server with a basic HTTP authentication
Collecting some photo information from Flickr using REST
Searching for SOAP methods from an Amazon S3 web service
Searching Amazon for books through the product search API
Creating RESTful web applications with Flask
Chapter 8: Network Monitoring and Security
Introduction
Sniffing packets on your network
Saving packets in the pcap format using the pcap dumper
Adding an extra header in HTTP packets
Scanning the ports of a remote host
Customizing the IP address of a packet
Replaying traffic by reading from a saved pcap file
Scanning the broadcast of packets
Chapter 9: Network Modeling
Introduction
Simulating networks with ns-3
Emulating networks with Mininet
Distributed network emulation with MaxiNet
Emulating wireless networks with Mininet-WiFi
Extending Mininet to emulate containers
Chapter 10: Getting Started with SDN
Introduction
SDN emulation with Mininet
Developing Software-Defined Networks with OpenDaylight controller
Developing Software-Defined Networks with ONOS controller
Developing Software-Defined Networks with Floodlight controller
Developing Software-Defined Networks with Ryu controller
Developing Software-Defined Networks with POX controller
Developing Software-Defined Networks visually with MiniEdit
Chapter 11: Authentication, Authorization, and Accounting (AAA)
Introduction
Finding DNS names of a network
Finding DNS host information
Finding DNS resource records
Making DNS zone transfer
Querying NTP servers
Connecting to an LDAP server
Making LDAP bind
Reading and writing LDAP
Authenticating REST APIs with Eve
Throttling requests with RequestsThrottler
Chapter 12: Open and Proprietary Networking Solutions
Introduction
Configuring Red PNDA
Configuring VMware NSX for vSphere 6.3.2
Configuring Juniper Contrail Server Manager
Configuring OpenContrail controller
Configuring OpenContrail cluster
Interacting with devices running Cisco IOS XR
Collaborating with Cisco Spark API
Chapter 13: NFV and Orchestration – A Larger Ecosystem
Introduction
Building VNFs with OPNFV
Packet processing with DPDK
Parsing BMP messages with SNAS.io
Controlling drones with a wireless network
Creating PNDA clusters
Chapter 14: Programming the Internet
Introduction
Checking a website status
Benchmarking BGP implementations with bgperf
BGP with ExaBGP
Looking glass implementations with Python
Understanding the internet ecosystem with Python
Establishing BGP connections with yabgp

Book Details

ISBN 139781786463999
Paperback450 pages
Read More
From 2 reviews

Read More Reviews

Recommended for You

Python GUI Programming Cookbook - Second Edition Book Cover
Python GUI Programming Cookbook - Second Edition
$ 39.99
$ 28.00
QGIS Python Programming Cookbook - Second Edition Book Cover
QGIS Python Programming Cookbook - Second Edition
$ 39.99
$ 28.00
Programming ArcGIS with Python Cookbook - Second Edition Book Cover
Programming ArcGIS with Python Cookbook - Second Edition
$ 35.99
$ 25.20
Network Analysis using Wireshark 2 Cookbook - Second Edition Book Cover
Network Analysis using Wireshark 2 Cookbook - Second Edition
$ 43.99
$ 30.80
Nmap: Network Exploration and Security Auditing Cookbook - Second Edition Book Cover
Nmap: Network Exploration and Security Auditing Cookbook - Second Edition
$ 39.99
$ 28.00
Kali Linux Network Scanning Cookbook - Second Edition Book Cover
Kali Linux Network Scanning Cookbook - Second Edition
$ 39.99
$ 28.00