Skip to content
Python Network Programming Cookbook – Second Edition, published by Packt
Python Shell HTML
Branch: master
Clone or download
Latest commit 7f5ebcb Dec 17, 2017
Type Name Latest commit message Commit time
Failed to load latest commit information.
Chapter01 Code files Aug 9, 2017
Chapter02 Code files Aug 9, 2017
Chapter03 Code files Aug 9, 2017
Chapter05 Code files Aug 9, 2017
Chapter06 Code files Aug 9, 2017
Chapter07 Code files Aug 9, 2017
Chapter08 Code files Aug 9, 2017
Chapter09 Code files Aug 9, 2017
Chapter10 Code files Aug 9, 2017
Chapter11 Code files Aug 9, 2017
Chapter12 Code files Aug 9, 2017
Chapter13 Code files Aug 9, 2017
Chapter14 Code files Aug 9, 2017
.gitattributes 🎪 Added .gitattributes & .gitignore files Aug 4, 2017
.gitignore 🎪 Added .gitattributes & .gitignore files Aug 4, 2017
LICENSE Create LICENSE Aug 9, 2017 Update Dec 17, 2017

Python Network Programming Cookbook – Second Edition

This is the code repository for Python Network Programming Cookbook - Second Edition, published by Packt. It contains all the supporting project files necessary to work through the book from start to finish.

About the Book

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.

Instructions and Navigations

All of the code is organized into folders. Each folder starts with a number followed by the application name. For example, Chapter02.

The code will look like the following:

import socket
import select
import argparse

SERVER_HOST = 'localhost'

EOL1 = b'\n\n'
EOL2 = b'\n\r\n'
SERVER_RESPONSE  = b"""HTTP/1.1 200 OK\r\nDate: Mon, 1 Apr 2013 01:01:01 GMT\r\nContent-Type: text/plain\r\nContent-Length: 25\r\n\r\n
Hello from Epoll Server!"""

Software and Hardware Requirements

You need a working PC or laptop, preferably with a modern Linux operating system. The installation instructions are written and tested on Ubuntu 16.04 LTS and would work on any recent Debian-based Linux operating system without modification. We developed for Python 3. However, we have maintained backward-compatibility with Python 2 in our recipes as much as we can. On the other hand, some open source projects used in this book do not yet support Python 3. So, ideally, you will need both Python 2 and Python 3 to test all the recipes in this book.

Most of the recipes in this book will run on other platforms such as Windows and Mac OS with some changes in the configuration steps. Some of the recipes require two or more computers in a cluster to test the distributed systems. You may use Amazon Web Services (AWS) to initiate a cluster inside a single placement group to test these recipes.

You also need a working internet connection to install the third-party software libraries mentioned with respective recipes. If you do not have a stable or continuous internet connection, you can download the third-party libraries and install them in one go. However, it is highly recommended to test some of these recipes with the internet connection, as it would make the configuration task minimal and more interesting, than having to download a bulk of software in bunch. Moreover, testing the application in an AWS cluster would certainly require the internet connectivity.

The following is a list of the Python third-party libraries with their download URLs:

• ntplib:

• diesel:

• nmap:

• scapy:

• netifaces:

• netaddr:

• pyopenssl:

• pygeocoder:

• pyyaml:

• requests:

• feedparser:

• paramiko:

• fabric:

• supervisor:

• xmlrpclib:

• SOAPpy:

• bottlenose:

• construct:

• libpcap:

• setup tools:

• exabgp:

• traixroute:

• dronekit:

• dronekit-sitl:

• ryu:

• Flask:

• smtpd:

• twisted:

• tornado:

• dnspython:

• ldap3:

• Eve:

• RequestsThrottler:

• PyNSXv:

• vmware-nsx:

Other software needed to run some recipes are as follows:

• postfix:

• openssh server:

• mysql server:

• apache2:

• virtualenv:

• filezilla:

• vsftpd:

• telnetd:

• curl:

• NS-3:

• Mininet:

• Ansible:

• Git:

• aptitude:

• Node-ws / wscat:

• MaxiNet:

• Mininet-WiFi:

• ContainerNet:

• Ant:

• Maven:

• OpenDaylight:


• Floodlight:

• POX:

• libnl-3-dev:

• libnl-genl-3-dev:

• libnl-route-3-dev:

• pkg-config:

• python-tz:

• libpcap-dev:

• libcap2-dev:

• wireshark:

• Juniper Contrail:

• OpenContrail Controller:

• Contrail Server Manager:

• VMWare NSX for vSphere 6.3.2:

• OPNFV Compass:


• libpcap-dev:




• bgperf:

• swig:

• yabgp:

• Virtualbox:

• Vagrant:


• Apache ZooKeeper:

• Apache Cassandra:

• RabbitMQ:

• pyIOSXR:

• Cisco Spark API:

Related Products

You can’t perform that action at this time.