IP address. Subnetting. Ping command in detail. Threads in Python. Sub process in Python

Similar documents
McGraw-Hill The McGraw-Hill Companies, Inc., 2000

The identifier used in the IP layer of the TCP/IP protocol suite to identify each device connected to the Internet is called the Internet address or

Objectives. Note: An IP address is a 32-bit address. The IP addresses are unique. The address space of IPv4 is 2 32 or 4,294,967,296.

IP Addresses McGraw-Hill The McGraw-Hill Companies, Inc., 2000

Lecture 8 Network Layer: Logical addressing

Internet Protocol. Outline Introduction to Internet Protocol Header and address formats ICMP Tools CS 640 1

IP Addressing and Subnetting

Addressing the Network IPv4

ROUTING INTRODUCTION TO IP, IP ROUTING PROTOCOLS AND PROXY ARP

Chapter 6 Addressing the Network- IPv4

Table of Contents Chapter 1 IP Addressing Configuration

Communication at the network layer is host-to-host Length of address. Total number of addresses used by the protocol. IPv4 & IPv6

The Internet Protocol. IP Addresses Address Resolution Protocol: IP datagram format and forwarding: IP fragmentation and reassembly

CCNA Exploration Network Fundamentals. Chapter 06 Addressing the Network IPv4

Computer Networks Lecture -5- IPv4 Addresses. Dr. Abbas Abdulazeez

Module 4. Planning the Addressing Structure

Table of Contents 1 Static Routing Configuration 1-1

Subnetting Questions with Detailed Answers: Subnetting Questions with Detailed Answers:

Table of Contents 1 Static Routing Configuration 1-1

Chapter 06 IP Address

NETWORK LAYER: IP Addressing

Network Layer/IP Protocols

TCP/IP and the OSI Model

Chapter 5 TCP/IP SUITE

Figure 11 Two-level addressing in classful addressing

TSIN02 - Internetworking

Otasuke Pro-ServerEX! Introduction. What is Pro-Server EX? - Introduction-0 -

Chapter 4 Network Layer

Lab 6.7.1: Ping and Traceroute

Table of Contents 1 Static Routing Configuration 1-1

OSI Network Layer. Chapter 5

Ping, tracert and system debugging commands

Configuring IP addressing

Router Architecture Overview

Just enough TCP/IP. Protocol Overview. Connection Types in TCP/IP. Control Mechanisms. Borrowed from my ITS475/575 class the ITL

Internet Addresses (You should read Chapter 4 in Forouzan)

Chapter 18 and 22. IPv4 Address. Data Communications and Networking

Module 7 Internet And Internet Protocol Suite

TCP /IP Fundamentals Mr. Cantu

Table of Contents 1 System Maintaining and Debugging Commands 1-1

Manipal Institute of Technology

TSIN02 - Internetworking

Lab 4.2.5a Connectivity Tests Ping

Department of Computer Science and Engineering. COSC 4213: Computer Networks II (Fall 2005) Instructor: N. Vlajic Date: November 3, 2005

Shell Scripting. Todd Kelley CST8207 Todd Kelley 1

Lab Troubleshooting Using traceroute Instructor Version 2500

APPLICATION NOTE AN0004 CHANGING THE IP ADDRESS ON AN EWSi PORTAL PLUS CONTROLLER WITH WINDOWS 7

Subnetting/Supernetting and Classless Addressing

Network Layer. The Network Layer. Contents Connection-Oriented and Connectionless Service. Recall:

Network Layer. Recall: The network layer is responsible for the routing of packets The network layer is responsible for congestion control

Subnetting. This Hour. Subnetting. Hour 5

Introduction to Internetworking

Brocade 5600 vrouter Basic Routing Configuration Guide

ETSF10 Internet Protocols Network Layer Protocols

IP: Addressing, ARP, Routing

Brocade 5600 vrouter Basic Routing

The Internet. The Internet is an interconnected collection of netw orks.

Each ICMP message contains three fields that define its purpose and provide a checksum. They are TYPE, CODE, and CHECKSUM fields.

EITF25 Internet Techniques and Applications L7: Internet. Stefan Höst

Network Layer (4): ICMP

Vorlesung Kommunikationsnetze

Network+ Guide to Networks 5 th Edition. Chapter 10 In-Depth TCP/IP Networking

Homework 2 TCP/IP Network Monitoring and Management

LECTURE -4 IP ADDRESSES. IP Addresses: Classful Addressing

Homework 2: Lab Activity TCP/IP Network Monitoring and Management

Configuring Routes on the ACE

Lab Configuring Static Routes Instructor Version 2500

Chapter 4: Network Layer

Lecture (03) Internet Protocol tcp/ip> OSI>

Configure IP SLA Tracking for IPv4 Static Routes on an SG550XG Switch

Table of Contents 1 System Maintenance and Debugging Commands 1-1

SEN366 (SEN374) (Introduction to) Computer Networks

CIS 632 / EEC 687 Mobile Computing

Chapter 18. Introduction to Network Layer

Lab 9.8.1: Address Resolution Protocol (ARP)

CHAPTER-2 IP CONCEPTS

IP - The Internet Protocol. Based on the slides of Dr. Jorg Liebeherr, University of Virginia

Data Communication & Computer Networks Week # 13

ffmpy3 Documentation Release Eric Ahn

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files. Compiler vs.

On Distributed Communications, Rand Report RM-3420-PR, Paul Baran, August 1964

CIS 551 / TCOM 401 Computer and Network Security

Operation Manual IP Addressing and IP Performance H3C S5500-SI Series Ethernet Switches. Table of Contents

Lecture 10: Addressing

CC231 Introduction to Networks Dr. Ayman A. Abdel-Hamid. Internet Protocol Suite

Configuring IP addressing 1

The Network Layer. Internet solutions. Nixu Oy PL 21. (Mäkelänkatu 91) Helsinki, Finland. tel fax.

1/18/13. Network+ Guide to Networks 5 th Edition. Objectives. Chapter 10 In-Depth TCP/IP Networking

Cisco Interconnecting Cisco Networking Devices Part 2

A shell can be used in one of two ways:

Cross-platform daemonization tools.

Chapter Motivation For Internetworking

RMIT University. Data Communication and Net-Centric Computing COSC 1111/2061. Lecture 2. Internetworking IPv4, IPv6

Guide to Networking Essentials, 6 th Edition. Chapter 5: Network Protocols

5/20/2007. Touring Essential Programs

Subnetting And Supernetting

5.7 K E Y TE R M S 5.8 SUM M A R Y

HP 5120 EI Switch Series

Department of Computer Science and Engineering. CSE 3214: Computer Network Protocols and Applications Instructor: N. Vlajic Date: Feb 23, 2016

Transcription:

IP address Subnetting Ping command in detail Threads in Python Sub process in Python

IPv4 Addressing- Introduction An IP address is a 32-bit address that uniquely and universally defines the connection of a host or a router to the Internet. IP addresses are unique. 3

Note: An IP address is a 32-bit address. 4

Note: The IP addresses are unique. 5

Note: The address space of IPv4 is 2 32 or 4,294,967,296. 6

Dotted-decimal and Binary equivalent notation 7

Example 1 Change the following IP addresses from binary notation to dotteddecimal notation. a. 10000001 00001011 00001011 11101111 b. 11000001 10000011 00011011 11111111 c. 11100111 11011011 10001011 01101111 d. 11111001 10011011 11111011 00001111 Solution We replace each group of 8 bits with its equivalent decimal number and add dots for separation: a. 129.11.11.239 b. 193.131.27.255 c. 231.219.139.111 d. 249.155.251.15 8

Example 2 Change the following IP addresses from dotted-decimal notation to binary notation. a. 111.56.45.78 b. 221.34.7.82 c. 241.8.56.12 d. 75.45.34.78 Solution We replace each decimal number with its binary equivalent: a. 01101111 00111000 00101101 01001110 b. 11011101 00100010 00000111 01010010 c. 11110001 00001000 00111000 00001100 d. 01001011 00101101 00100010 01001110 TCP/IP Protocol Suite 9

Finding the class in binary notation TCP/IP Protocol Suite 11

Example Find the class of each address: a. 00000001 00001011 00001011 11101111 b. 11000001 10000011 00011011 11111111 c. 10100111 11011011 10001011 01101111 d. 11110011 10011011 11111011 00001111 Solution a. The first bit is 0. This is a class A address. b. The first 2 bits are 1; the third bit is 0. This is a class C address. c. The first bit is 0; the second bit is 1. This is a class B address. d. The first 4 bits are 1s. This is a class E address.. TCP/IP Protocol Suite 12

Finding the class in decimal notation TCP/IP Protocol Suite 13

Example Find the class of each address: a. 227.12.14.87 b.193.14.56.22 c.14.23.120.8 d. 252.5.15.111e.134.11.78.56 Solution a. The first byte is 227 (between 224 and 239); the class is D. b. The first byte is 193 (between 192 and 223); the class is C. c. The first byte is 14 (between 0 and 127); the class is A. d. The first byte is 252 (between 240 and 255); the class is E. e. The first byte is 134 (between 128 and 191); the class is B. TCP/IP Protocol Suite 14

Netid and hostid TCP/IP Protocol Suite 15

Example Given the network address 17.0.0.0, find the class, the block, and the range of the addresses. Solution The class is A because the first byte is between 0 and 127. The block has a netid of 17. The addresses range from 17.0.0.0 to 17.255.255.255. TCP/IP Protocol Suite 16

Example Given the network address 132.21.0.0, find the class, the block, and the range of the addresses. Solution The class is B because the first byte is between 128 and 191. The block has a netid of 132.21. The addresses range from 132.21.0.0 to 132.21.255.255. TCP/IP Protocol Suite 17

Example Given the network address 220.34.76.0, find the class, the block, and the range of the addresses. Solution The class is C because the first byte is between 192 and 223. The block has a netid of 220.34.76. The addresses range from 220.34.76.0 to 220.34.76.255. TCP/IP Protocol Suite 18

Masking concept TCP/IP Protocol Suite 19

AND operation TCP/IP Protocol Suite 20

TCP/IP Protocol Suite 21

Note: The network address is the beginning address of each block. It can be found by applying the default mask to any of the addresses in the block (including itself). It retains the netid of the block and sets the hostid to zero. TCP/IP Protocol Suite 22

Example Given the address 23.56.7.91, find the beginning address (network address). Solution The default mask is 255.0.0.0, which means that only the first byte is preserved and the other 3 bytes are set to 0s. The network address is 23.0.0.0. TCP/IP Protocol Suite 23

Example Given the address 132.6.17.85, find the beginning address (network address). Solution The default mask is 255.255.0.0, which means that the first 2 bytes are preserved and the other 2 bytes are set to 0s. The network address is 132.6.0.0. TCP/IP Protocol Suite 24

Example Given the address 201.180.56.5, find the beginning address (network address). Solution The default mask is 255.255.255.0, which means that the first 3 bytes are preserved and the last byte is set to 0. The network address is 201.180.56.0. TCP/IP Protocol Suite 25

.

IPv4 Addressing- Subnetting The problems associated with classful addressing is that the network addresses available for assignment to organizations are close to depletion. This is coupled with the ever-increasing demand for addresses from organizations that want connection to the Internet. In this section we briefly discuss two solutions: subnetting and supernetting. TCP/IP Protocol Suite 27

Note: IP addresses are designed with two levels of hierarchy. TCP/IP Protocol Suite 28

A network with two levels of hierarchy (not subnetted) TCP/IP Protocol Suite 29

Addresses in a network with and without subnetting TCP/IP Protocol Suite 30

Default mask and subnet mask TCP/IP Protocol Suite 31

Comparison of a default mask and a subnet mask TCP/IP Protocol Suite 32

Example What is the subnetwork address if the destination address is 200.45.34.56 and the subnet mask is 255.255.240.0? Solution We apply the AND operation on the address and the subnet mask. Address 11001000 00101101 00100010 00111000 Subnet Mask 11111111 11111111 11110000 00000000 Subnetwork Address 11001000 00101101 00100000 00000000. TCP/IP Protocol Suite 33

Style -1 Subnetting when given a required number of networks Example 1: A service provider has given you the Class C network range 209.50.1.0. Your company must break the network into 20 separate subnets. Solution Step 1) Determine the number of subnets and convert to binary -In this example, the binary representation of 20 = 00010100. Step 2) Reserve required bits in subnet mask and find incremental value - The binary value of 20 subnets tells us that we need at least 5 network bits to satisfy this requirement TCP/IP Protocol Suite 34

Example 1 continued - Our original subnet mask is 255.255.255.0 (Class C subnet) - The full binary representation of the subnet mask is as follows: 255.255.255.0 = 11111111.11111111.11111111.00000000 - We must convert 5 of the client bits (0) to network bits (1) in order to satisfy the requirements: New Mask = 11111111.11111111.11111111.11111000 -If we convert the mask back to decimal, we now have the subnet mask that will be used on all the new networks 255.255.255.248 TCP/IP Protocol Suite 35

Example 1 continued New subnet mask 255.255.255.248 Our increment bit is the last possible network bit, converted back to a binary number: New Mask = 11111111.11111111.11111111.1111(1)000 bit with the parenthesis is your increment bit. If you convert this bit to a decimal number, it becomes the number 8 that is every subnet is having 8 addresses allotted to it (from 0 to 7, then 8 to 15 etc) TCP/IP Protocol Suite 36

Example 1 continued Step 3) Use increment to find network ranges You can now fill in your end ranges, which is the last possible IP address before you start the next range 209.50.1.0 209.50.1.7 209.50.1.8 209.50.1.15 209.50.1.16 209.50.1.23 etc You can then assign these ranges to your networks! Remember the first and last address from each range (network / broadcast IP) are unusable TCP/IP Protocol Suite 37

ping - may be used to test basic 2-way connectivity Syntax Ping [-c count] [-i wait] [-l preload] [-p pattern] [-s packetsize] hostname/ipaddress DESCRIPTION Ping uses the ICMP protocol s mandatory ECHO_REQUEST datagram to elicit an ICMP ECHO_RESPONSE from a host or gateway. ECHO_REQUEST datagrams ( pings ) have an IP and ICMP header, followed by a struct timeval and then an arbitrary number of pad bytes used to fill out the packet.

ping 10.1.32.124 response from 10.1.32.124 Reply from 74.125.224.82: bytes=32 time=6ms TTL=64 Reply from 74.125.224.82: bytes=32 time=6ms TTL=64 Reply from 74.125.224.82: bytes=32 time=5ms TTL=64 Reply from 74.125.224.82: bytes=32 time=6ms TTL=64 Ping statistics for 74.125.224.82: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 5ms, Maximum =6ms, Average = 6ms

from threading import Thread import subprocess from Queue import Queue num_threads = 4 queue = Queue() ips = ["11.11.3.230", "11.11.3.229", "11.11.3.228", "10.0.1.51"]

#wraps system ping command def pinger(i, q): """Pings subnet""" while True: ip = q.get() print "Thread %s: Pinging %s" % (i, ip) ret = subprocess.call("ping -c 1 %s" % ip, shell=true, stdout=open('/dev/null', 'w'), stderr=subprocess.stdout)

# ToDo: take the return value and check if computer is alive or dead if ret == 0: print"%s Alive"% ip else: print"%snot Alive"% ip q.task_done()

#Spawn thread pool for i in range(num_threads): worker = Thread(target=pinger, args=(i, queue)) worker.setdaemon(true) worker.start() #Place work in queue for ip in ips: queue.put(ip) #Wait until worker threads are done to exit queue.join()

subprocess.call(args, *, stdin=none, stdout= args: should be a sequence of program arguments or else a single string. By default, the program to execute is the first item in args if args is a sequence. If args is a string, the interpretation is platform-dependent. It is recommended to pass args as a sequence. shell: shell argument (which defaults to False) specifies whether to use the shell as the program to execute. If shell is True, it is recommended to pass args as a string rather than as a sequence. On Unix with shell=true, the shell defaults to /bin/sh. If args is a string, the string specifies the command to execute through the shell. This means that the string must be formatted exactly as it would be when typed at the shell prompt. This includes, for example, quoting or backslash escaping filenames with spaces in them. If args is a sequence, the first item specifies the command string, and any additional items will be treated as additional arguments to the shell itself. None, stderr=none, shell=false)

stdin, stdout and stderr: specify the executed program's standard input, standard output and standard error file handles, respectively. Valid values are PIPE, an existing file descriptor (a positive integer), an existing file object, and None. PIPE indicates that a new pipe to the child should be created. With the default settings of None, no redirection will occur; the child's file handles will be inherited from the parent. Additionally, stderr can be STDOUT, which indicates that the stderr data from the child process should be captured into the same file handle as for stdout.

# Import the module import subprocess # Ask the user for input host = raw_input("enter a host to ping: ") # Set up the echo command and direct the output to a pipe host = subprocess.popen(['ping', '-c 2', host], stdout=subprocess.pipe) print host