SlideShare a Scribd company logo
1 of 22
ATHLONE INSTITUTE OF TECHNOLOGY
SubNetwork Calculator
Scripting 3.1 Project
Dmitrijus Ponomarenko
2013-2014
Athlone Institute of Technology Computer Network Management 3 Scripting 3.1 Project
SubNetwork Calculator
2013-2014
Page 1
Introduction
This document gives a brief description of how my project was designed
and developed. The idea of my project was to create a fully working
SubNetwork Calculator. To implement that project I was using Python
programing language.
This project is a part of the final exam in Scripting 3.1 subject.
Purpose ofProject
The purpose of this project is to develop an easy-to-use IP subnetwork
calculator that lets individuals using it to calculate every aspect of subnet
configuration.
Description
The program will work with three classes of IP address, such as: A, B and
C. The program will calculate and shows you the network address,
subnetmask, available subnets per network, available number of hosts
per subnet, subnet host address range, subnet broadcast address and IP
addresses of all possible subnets per network.
PythonModules
This program was created by using Python tkinterGUI module and
Python functions;
Tkinter
It is the standard Python GUI (Graphical User Interface) toolkit, which
helps to create more advanced interface than when using easy GUI
module.
SubNetwork Calculator
2013-2014
Page 2
In this program I use “Grid” manager to design user interface. The grid
manager is the most flexible of the geometry managers in Tkinter which
allows very easy management of the widgets. To achieve easy
management the "Grid" manager uses 2-dimensional system table. The
master widget is split into a number of rows and columns. Each “cell” in
the table can hold a single widget.
Functions
A function is a piece of code that is called by name. It is like a
subprogram which is like a small program inside of another program.
The function plays a role of performing a specific task. The advantages
of using functions are to:
 Reduce duplication of code
 Decompose complex problems into simpler pieces
 Improve clarity of the code
 Reuse of code
Additionally, in this program I use some extra modules as "os" module
and "math" module for specific tasks such as a checking file sizes and
mathematic calculations.
More detailed information about above mentioned modules will be
discussed in the topic "Problems and Solutions" .
Sample Design and Implementation
Input Processing Output
SubNetwork Calculator
2013-2014
Page 3
IP address
Number of
subnets/hosts
Router/switch name
Port name
Inputs
Calculations
Display output
Network class
Network IP address
Subnet Mask
Subnets per Network
Hosts per Network
IP Range
Broadcast address
List networks
Pseudo-code:
Function get ip address
entry()
get first oct of ip address and assign it to the variable (oct_1)
get second oct of ip address and assign it to the variable (oct_2)
get third oct of ip address and assign it to the variable (oct_3)
get fourth oct of ip address and assign it to the variable (oct_4)
add variables and assign to the variable (address)
return variable (address)
Function for checking ip address (valid or not)
if_ip_valid(oct_1,oct_2,oct_3,oct_4)
get four parts of ip address
if each oct between 1 and 255
add octs and assign to variable (ip_address)
if not
display warning message
Function to calculate subnetwork addresses in class C
class_c_subnets_list(ip_address,num_hosts)
split ip address
assign ost 4 to the zero
count loop start from zero
create firs network ip address
insert first network ip in listbox
calculate number of subnetworks
start count loop until it reach number of subnets
add number of hosts to the oct 4
SubNetwork Calculator
2013-2014
Page 4
create subnetwork ip address
add ip address to the listbox
add one to the count loop
Function to calculate subnetwork addresses in class B
class_b_subnets_list(ip_address, num_hosts)
split ip address in four octs
if number of hosts less or equal 255
assign oct 3 to the zero
start count loop1 from zero
run count loop1 until it reach 256
assign oct 4 to the zero
count loop2 start from zero
create first subnet ip address
add ip to the listbox
calculate subnets
run count loop2 until it reach number of subnets
add number of hosts to the oct 4
create subnet ip
add ip to the lisbox
add one to the count loop2
add one to the oct 3
add one to the count loop1
if the number of hosts between 256 and 65536
assign oct 4 to the zero
assign oct 3 to the zero
start count loop from zero
create first subnet ip
add ip to the listbox
calculate number of subnets, formula (65536/num_hosts-1)
run count loop until it reach number of subnets
calculate x, formula( x=256/(65536/num_hosts))
add x to the oct 3
create subnet ip
add ip to the listbox
count plus one
else
assign oct 4 to the zero
assign oct 3 to the zero
create subnet ip
add ip to the listbox
SubNetwork Calculator
2013-2014
Page 5
Function to calculate subnetwork addresses in class A
class_a_subnets_list(ip_address,num_hosts)
split ip address into four octets
if number of host less or equals 255
assign oct 2 to the zero
count loop1 start from zero
run count loop1 until it reach 256
assign oct 4 to the zero
assign oct 3 to the zero
count loop2 start from zero
run loop2 until it reach 256
assign oct 4 to the zero
count loop3 start from zero
create first subnet ip
insert ip to the listbox
calculate subnets per network
run count loop3 until it reach number of subnets
add number of hosts to the oct 4
create network ip
insert ip to the listbox
add one to the loop3
add one to the oct 3
add one to the loop2
add one to the oct 2
add one to loop1
if number of hosts between 256 and 65536
assign oct 2 to the zero
loop1 start from zero
loop not finished until it reach 256
assign oct 4 to the zero
assign oct 3 to the zero
loop2 start from zero
create first subnet ip
add ip to the listbox
calculate number of subnets
run loop2 until it reach number of subnets
calculate x, formula (256/(65536/num_hosts))
add x to the oct 3
create subnet ip
insert ip to the listbox
add one to the loop2
add one to the oct 2
add one to the loop1
if number of hosts between 65536 and 16777216
assign oct4 to the zero
assign oct3 to the zero
SubNetwork Calculator
2013-2014
Page 6
assign oct2 to the zero
count loop start from zero
create first network ip
add ip to the listbox
calculate number of subnetworks
run count loop until it reach number of subnets
calculate x, formula (256/(16777216/num_hosts))
add x to the oct2
create network ip
add ip to the litbox
add one to the count loop
else
assign oct4 to the zero
assign oct3 to the zero
assign oct2 to the zero
create network ip
add ip to the listbox
Function net_class(ip_address,num_hosts) : define network class,
calculate subnets per network, all possible networks address and insert to
the listbox
net_class(ip_address,num_hosts)
split ip address into four octets
convert oct 1 to the integer
convert number of hosts to the integer
if oct1 between 192 and 223
function subnets_c(num_hosts)
clear listbox
create heading
add heading to the lictbox
function class_c_subnets_list(ip_address,num_hosts)
if else oct1 between 128 and 191
function subnets_b(num_hosts)
clear listbox
create heading
add heading to the lictbox
function class_b_subnets_list(ip_address,num_hosts)
else
display warning message
Functions to define ip class and calculate number of subnetworks
SubNetwork Calculator
2013-2014
Page 7
subnets_c(num_hosts)
if number of hosts less or equal 255
display suitable message
calculate number of subnets per network, formula(256/num_hosts)
display subnets
else
display suitable message
set number of subnets (1) and display it
subnets_b(num_hosts)
if number of hosts less or equal 65536
display suitable message
calculate number of subnets per network, formula(65536/num_hosts)
display subnets
else
display suitable message
set number of subnets (1) and display it
subnets_a(num_hosts)
if number of hosts less or equal 16777216
display suitable message
calculate number of subnets per network, formula(16777216/num_hosts)
display subnets
else
display suitable message
set number of subnets (1) and display it
Function to calculate network ip address, ip range, subnet mask and
broadcast address for class C ip address
f1(num_hosts,ip_address)
split ip address by dots
convert oct1 to integer
convert oct2 to ineger
convert oct3 to integer
convert oct4 to integer
calculate host bits in ip address, formula(math.log(num_hosts)/math.log(2))
calculate network bits in ip address,formula(32-host bits)
create variable (m1) and assign to it 255
create variable (m2) and assign to it 255
create variable (m3) and assign to it 255
SubNetwork Calculator
2013-2014
Page 8
create variable (m4) and assign to it (256-number of hosts)
use bin() to calculate first oct of network ip and assign it to variable (f1)
use bin() to calculate second oct of network ip and assign it to variable (f2)
use bin() to calculate third oct of network ip and assign it to variable (f3)
use bin() to calculate fourt oct of network ip and assign it to variable (f4)
convert f1 to the integer and assign it to the variable oct1
convert f2 to the integer and assign it to the variable oct2
convert f3 to the integer and assign it to the variable oct3
convert f4 to the integer and assign it to the variable oct4
display network ip address
display subnet mask
display ip range
display broadcast ip
create variable (sub_net_mask)
create variable (ip range)
create variable (net ip address)
create variable (broadcast)
return net_ip_address,ip_range, sub_net_mask,broadcast
Function to calculate network ip address, ip range, subnet mask and
broadcast address for class B ip address
f2(num_hosts,ip_address)
split ip address by dots
convert oct1 to integer
convert oct2 to ineger
convert oct3 to integer
convert oct4 to integer
calculate host bits in ip address, formula(math.log(num_hosts)/math.log(2))
calculate network bits in ip address,formula(32-host bits)
calculate variable (x),formula (number of hosts/256) and assign it to the variable (num bits)
create variable (m1) and assign to it 255
create variable (m2) and assign to it 255
create variable (m3) and assign to it (256-num bits)
create variable (m4) and assign to it 0
use bin() to calculate first oct of network ip and assign it to variable (f1)
use bin() to calculate second oct of network ip and assign it to variable (f2)
use bin() to calculate third oct of network ip and assign it to variable (f3)
use bin() to calculate fourt oct of network ip and assign it to variable (f4)
convert f1 to the integer and assign it to the variable oct1
convert f2 to the integer and assign it to the variable oct2
convert f3 to the integer and assign it to the variable oct3
convert f4 to the integer and assign it to the variable oct4
display network ip address
display subnet mask
SubNetwork Calculator
2013-2014
Page 9
display ip range
display broadcast ip
create variable (sub_net_mask)
create variable (ip range)
create variable (net ip address)
create variable (broadcast)
return net_ip_address,ip_range, sub_net_mask,broadcast
Function to calculate network ip address, ip range, subnet mask and
broadcast address for class A ip address
f3(num_hosts,ip_address)
split ip address by dots
convert oct1 to integer
convert oct2 to ineger
convert oct3 to integer
convert oct4 to integer
calculate host bits in ip address, formula(math.log(num_hosts)/math.log(2))
calculate network bits in ip address,formula(32-host bits)
calculate variable (x),formula (number of hosts/256^2) and assign it to the variable (num bits)
create variable (m1) and assign to it 255
create variable (m2) and assign to it (256-num bits)
create variable (m3) and assign to it 0
create variable (m4) and assign to it 0
use bin() to calculate first oct of network ip and assign it to variable (f1)
use bin() to calculate second oct of network ip and assign it to variable (f2)
use bin() to calculate third oct of network ip and assign it to variable (f3)
use bin() to calculate fourt oct of network ip and assign it to variable (f4)
convert f1 to the integer and assign it to the variable oct1
convert f2 to the integer and assign it to the variable oct2
convert f3 to the integer and assign it to the variable oct3
convert f4 to the integer and assign it to the variable oct4
display network ip address
display subnet mask
display ip range
display broadcast ip
create variable (sub_net_mask)
create variable (ip range)
create variable (net ip address)
create variable (broadcast)
return net_ip_address,ip_range, sub_net_mask,broadcast
Functio to clear entry sels
SubNetwork Calculator
2013-2014
Page
10
clear_all()
delete ip entry
delete hardware entry
delete port name entry
Function save to a file
open_file(net_ip_address, ip_range, sub_net_mask, broadcast,num_hosts)
assign net_ip_address to the variable (ipaddress)
assign ip range to the variable (iprange)
assign sub_net_mask to the variable (subnet)
assign broadcast to the variable (broadcast)
open file assign it to the variable (data file)
get file size
if file size equal 0
write headings to the file
get hardware name
get port name
from number of hosts extract two assign to variable
write data to file
else
get hardware name
get port name
write data to file
Function in which I add all function in a logical chain
calculation()
run function entry() assign output to the variable (ip_address)
split ip address by dots
run function if_ip_valid(oct_1,oct_2,oct_3,oct_4) assign output to the variable
if choice number of host
get choice from listbox and assign it to variable (num hosts)
run function net_class(ip_address,num_hosts)
if number of hosts between 0 and 256
run function f1 (num_hosts,ip address) assign output to the variables
if number of hosts between 256 and 65536
run function f2 (num_hosts,ip adress) assign output to the variables
if number of hosts between 65536 and 16777216
run function f3 (num_hosts, ip address) assign output to the variables
else
run function f4 (num_hosts,ip address) assign output to the variables
SubNetwork Calculator
2013-2014
Page
11
else
get choice of number of subnets
if oct1 between 192 and 223
calculate hosts 256/num_subnets
if number of subnets less or equal 64
run function net_class(ip_address,num_hosts)
run function f1 (num_hosts,ip address) assign output to the variables
else
clear networks listbox and all outputs
display warning message
if else oct1 between 128 and 191
calculate hosts 65536/num_subnets
if number of subnets less or equal 16384
run function net_class(ip_address,num_hosts)
if number of hosts between 0 and 256
run function f1 (num_hosts,ip address) assign output to the variables
if number of hosts between 256 and 65536
run function f2 (num_hosts,ip adress) assign output to the variables
else
clear networks listbox and all outputs
display warning message
if else oct1 between 1 and 126
calculate hosts 16777216/num_subnets
if number of subnets less or equal 4194304
run function net_class(ip_address,num_hosts)
if number of hosts between 0 and 256
run function f1 (num_hosts,ip address) assign output to the variables
if number of hosts between 256 and 65536
run function f2 (num_hosts,ip adress) assign output to the variables
if number of hosts between 65536 and 16777216
run function f3 (num_hosts, ip address) assign output to the variables
get choice save or not
if choice yes
run fuction open_file(net_ip_address, ip_range,sub_net_mask,broadcast, num_hosts)
Program BreakDownStructure
SubNetwork Calculator
2013-2014
Page
12
User Manual
SubNetwork Calculator User Interface
SubNetwork
Calculator
Functions
Exit Clearall Calculate
Get IP
address
CheckIP
address
Check network class
Find all networks ip
add to listbox
If network
classC
Calculate
networks ip
add to
listbox
If network
classB
Calculate
networks ip
add to
listbox
If network
classA
Calculate
networks
ip add to
listbox
Calculate network ip
address
ip range
mask
broadcast ip
Create file
Save to file
GUI Tkinter
SubNetwork Calculator
2013-2014
Page
13
Step 1
Enter ip address, split ip address into four parts by dots (192.100.100.0)
and enter each part to windows.
SubNetwork Calculator
2013-2014
Page
14
Step 2
Select subnet numbers which you need to divide or select number of
hosts that you require per subnet.
Step 3
SubNetwork Calculator
2013-2014
Page
15
If you need to save your calculation, enter hardware name (Athlone-
Router) and port name (serial0/1/0). Alternatively, you can skip this step
if you want to run calculation without saving.
Step 4
To save data into a file tick the box or alternatively skip this step if you
don't need to save data.
Step 5
Click "Calculate" button to run calculations process.
SubNetwork Calculator
2013-2014
Page
16
Output of calculation:
1. Network class A(1-126),B(128-191)or C(192-223)
2. Network IP address
3. Subnet Mask
4. Subnets per Network
5. Hosts per Network
6. IP Range (first usable address last usable address)
7. Broadcast IP address
8. List of all possible SubNetworks
Step 6
If you are finished your calculations press ‘exit’. However, if you would
like to repeat calculations press 'clear all' and repeat steps 1,2,3,4,5.
SubNetwork Calculator
2013-2014
Page
17
or
Problems andSolutions
In the process of implementing a program I encountered some
challenges. The main two problems include:
1. Calculating the network ip address.
2. Calculating the host bits in subnetmask.
To solve the problem of calculating network ip address, I utilised ip
address and subnet mask as thought during academic semester in the
classes. Usually, ip address and number of hosts or subnets necessary in
the network are provided.
Therefore, the first step is to identify the subnetmask of the network. To
carry out this task the individual creating the programme requires to
have knowledge in ip address structure.Fromthe knowledge gained
during the course I found the way of calculating subnet mask. This is
achieved by having ip address and number of hosts already provided.
Example:
The ip address provided is 192.168.20.0 therefore, it is required to
calculate 30 ip addresses. First of all it is important to determine the
'class' of ip address and default subnetmask belonging to it. Additionally,
SubNetwork Calculator
2013-2014
Page
18
it is required to identify maximum number of ip addresses that each
default subnetmask supports such as:
 Class A 1-126 default subnetmask 255.0.0.0 max number of ip
addresses 16777216
 Class B 128-191 default subnetmask 255.255.0.0 max number of ip
addresses 65536
 Class C 192-223 default subnetmask 255.255.255.0 max number of
ip addresses 256
By the first byte of the ip address provided, it was determined that it
belongs to 'class C' with default subnetmask 255.255.255.0 (binary
equivalent = 11111111.11111111.11111111.00000000 or wildcard mask of
0.0.0.255). At this stage it is necessary to determine the number of host
bits in the subnetmask required to cover 30 hosts.
In order to continue with network ip address calculations, at this stage, it
is required to identify host bits of subnetmask:
In the interface programme host listbox window select the number of
hosts that cover the requirements provided in the above described
example which is 30. In this case the number selected 32 because it
covers required range.
With the use the formula : 2^x=32, the number of host bits in the
subnetmask can be calculated at this stage.
(x) – represents the number of host bits in the subnetmask. (X) can be
calculated with the use of math.log function. To make this calculation
new module “math”is being used. By doing so (x) can be expressed in the
formula showed below:
x=log(32)/log(2), so x=5.
Calculation identified that 5 bits of the subnetmask cover needed
requirements of 30 hosts. At this stage the value of subnetmask can be
identified by:
32-5=27 (binary equivalent = 11111111.11111111.11111111.11100000)or
255.255.255.224 and (wildcard binary equivalent = 0.0.0.00011111)or
SubNetwork Calculator
2013-2014
Page
19
0.0.0.31. By linking subnetmask (255.255.255.224)and wildcardmask
(0.0.0.31)together, it shows that when adding last byte from subnetmask
(224) with last byte of wildcardmask (31) the outcome is 255.
Therefore to identify subnetmask in class C ip address in this particular
programme, it is required to subtract number of hosts which was selected
from the host list box (32) from last byte of the subnetmask (255) which
was calculated above.
(255-32)+1=224 or 256-32=224 (255.255.255.224).
For higher number of hosts the same logic should be used but with more
difficult formula.
Example:
When 1000 of hots are required per network. First of all the number of
hosts to which default subnetmask belong need to be identified.
First example shows that class C default subnetmask is 255.255.255.0
which may cover the maximum of 256 ip addresses. Class B default
subnetmask is 255.255.0.0 whuch may cover the maximum of 65536 ip
addresses. At this stage select from the number hosts from hosts listbox
that cover requirements of 1000. In this case the number selected 1024
because it covers required range.
With the use the formula : 2^x=1024, the number of host bits in the
subnetmask that are required to cover 1000 hosts can be calculated.
2^x=1024, x=log(1024)/log(2), x=10. The subnetmask can be calculated
in the way showed below:
SubNetwork Calculator
2013-2014
Page
20
32-10=22 (binary equivalent = 11111111.11111111.11111100.00000000)or
255.255.252.0.
From this, it shows that to cover needed requirements two bits from third
byte can be taken.
(x) represents sum of two bits that were taken from third byte.
x=1024/256
x=4,
In next step the third byte is represented as 256.
256-4=252
The subnetmask is 255.255.252.0.
Now when the subnetmask was identified, the network address can be
calculated by using bin() function, which converts decimal number to
the binary numbers
For example:
Ip address bin(192.168.30.0)= (11000000.10101000.00011110.00000000)
Subnetmask bin(255.255.254.0)=
(11111111.11111111.11111100.00000000)
11000000.10101000.00011110.00000000
11111111.11111111.11111100.00000000
________________________________
11000000.10101000.00011100.00000000
Network ip address 192.168.28.0
SubNetwork Calculator
2013-2014
Page
21
The “os” module in this particular program works with the file or with
the size of the file if to be more exact. When the program executes for
the first time and creates new file, the “os” module checks the file size. If
the size of the file equals zero the program will create headings and add
data. If the file exists already, the “os” module will skip the step to create
headings and only add data to a file and save it.
Conclusion
This document provided a brief description of how my project of subnet
calculator was designed and developed. By doing this project I gained
valuable experience in developing Python program. I hope that the
experience gained will positively influence my future development in
the use of Python.

More Related Content

What's hot (20)

Ppl for students unit 1,2 and 3
Ppl for students unit 1,2 and 3Ppl for students unit 1,2 and 3
Ppl for students unit 1,2 and 3
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Nested loops
Nested loopsNested loops
Nested loops
 
Threads in JAVA
Threads in JAVAThreads in JAVA
Threads in JAVA
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 
Debugging
DebuggingDebugging
Debugging
 
PROLOG: Arithmetic Operations In Prolog
PROLOG: Arithmetic Operations In PrologPROLOG: Arithmetic Operations In Prolog
PROLOG: Arithmetic Operations In Prolog
 
Oop concepts in python
Oop concepts in pythonOop concepts in python
Oop concepts in python
 
N Queens problem
N Queens problemN Queens problem
N Queens problem
 
Regular expressions in Python
Regular expressions in PythonRegular expressions in Python
Regular expressions in Python
 
Object-Oriented Paradigm
Object-Oriented Paradigm Object-Oriented Paradigm
Object-Oriented Paradigm
 
Java Networking
Java NetworkingJava Networking
Java Networking
 
Imperative programming
Imperative programmingImperative programming
Imperative programming
 
Java Thread Synchronization
Java Thread SynchronizationJava Thread Synchronization
Java Thread Synchronization
 
Neural network
Neural networkNeural network
Neural network
 
Interface in java
Interface in javaInterface in java
Interface in java
 
Debugging
DebuggingDebugging
Debugging
 
Chapter 8 Inheritance
Chapter 8 InheritanceChapter 8 Inheritance
Chapter 8 Inheritance
 
Phases of Compiler
Phases of CompilerPhases of Compiler
Phases of Compiler
 
The n Queen Problem
The n Queen ProblemThe n Queen Problem
The n Queen Problem
 

Viewers also liked

Variables Creation using SAS on Longitudinal Data for Fraud Models
Variables Creation using SAS on Longitudinal Data for Fraud ModelsVariables Creation using SAS on Longitudinal Data for Fraud Models
Variables Creation using SAS on Longitudinal Data for Fraud ModelsKaitlyn Hu
 
Error Correction of Burst error
Error Correction of Burst errorError Correction of Burst error
Error Correction of Burst errorTanzila Islam
 
config_mini link
config_mini linkconfig_mini link
config_mini linkAmir Moradi
 
Powerpoint Mini Project.Pdf
Powerpoint  Mini Project.PdfPowerpoint  Mini Project.Pdf
Powerpoint Mini Project.PdfSanea
 
HOME AUTOMATION USING ANDROID PHONE OVER BLUETOOTH
HOME AUTOMATION USING ANDROID PHONE OVER BLUETOOTHHOME AUTOMATION USING ANDROID PHONE OVER BLUETOOTH
HOME AUTOMATION USING ANDROID PHONE OVER BLUETOOTHSubhash Kumar Yadav
 
Ppt of mini project.
Ppt of mini project.Ppt of mini project.
Ppt of mini project.saikiran_gone
 

Viewers also liked (10)

Variables Creation using SAS on Longitudinal Data for Fraud Models
Variables Creation using SAS on Longitudinal Data for Fraud ModelsVariables Creation using SAS on Longitudinal Data for Fraud Models
Variables Creation using SAS on Longitudinal Data for Fraud Models
 
Error Correction of Burst error
Error Correction of Burst errorError Correction of Burst error
Error Correction of Burst error
 
BIT Error Rate
BIT Error RateBIT Error Rate
BIT Error Rate
 
config_mini link
config_mini linkconfig_mini link
config_mini link
 
Powerpoint Mini Project.Pdf
Powerpoint  Mini Project.PdfPowerpoint  Mini Project.Pdf
Powerpoint Mini Project.Pdf
 
HOME AUTOMATION USING ANDROID PHONE OVER BLUETOOTH
HOME AUTOMATION USING ANDROID PHONE OVER BLUETOOTHHOME AUTOMATION USING ANDROID PHONE OVER BLUETOOTH
HOME AUTOMATION USING ANDROID PHONE OVER BLUETOOTH
 
CCNA training report
CCNA training reportCCNA training report
CCNA training report
 
Mini project ppt
Mini project pptMini project ppt
Mini project ppt
 
Ppt of mini project.
Ppt of mini project.Ppt of mini project.
Ppt of mini project.
 
Ip address
Ip addressIp address
Ip address
 

Similar to SubNetwork Calculator (Python Project)

acn-practical_manual-19-20-1 final.pdf
acn-practical_manual-19-20-1 final.pdfacn-practical_manual-19-20-1 final.pdf
acn-practical_manual-19-20-1 final.pdfQual4
 
7-Lect_7 .pptxNetwork LayerNetwork Layer
7-Lect_7 .pptxNetwork LayerNetwork Layer7-Lect_7 .pptxNetwork LayerNetwork Layer
7-Lect_7 .pptxNetwork LayerNetwork LayerZahouAmel1
 
7-Lect_7 .pptxNetwork Layer. Addressing Subnetting Mask (default and subnet) ...
7-Lect_7 .pptxNetwork Layer. Addressing Subnetting Mask (default and subnet) ...7-Lect_7 .pptxNetwork Layer. Addressing Subnetting Mask (default and subnet) ...
7-Lect_7 .pptxNetwork Layer. Addressing Subnetting Mask (default and subnet) ...ZahouAmel1
 
Chapter 8 - IP Subnetting, Troubleshooting and Introduction to NAT 9e
Chapter 8 - IP Subnetting, Troubleshooting and Introduction to NAT 9eChapter 8 - IP Subnetting, Troubleshooting and Introduction to NAT 9e
Chapter 8 - IP Subnetting, Troubleshooting and Introduction to NAT 9eadpeer
 
IP_ADDRESSING_AND_SUBNETTING.pptx
IP_ADDRESSING_AND_SUBNETTING.pptxIP_ADDRESSING_AND_SUBNETTING.pptx
IP_ADDRESSING_AND_SUBNETTING.pptxgamerchan1
 
Ecet 465 Success Begins / snaptutorial.com
Ecet 465   Success Begins / snaptutorial.comEcet 465   Success Begins / snaptutorial.com
Ecet 465 Success Begins / snaptutorial.comWilliamsTaylorzo
 
Ecet 465  Enthusiastic Study / snaptutorial.com
Ecet 465  Enthusiastic Study / snaptutorial.comEcet 465  Enthusiastic Study / snaptutorial.com
Ecet 465  Enthusiastic Study / snaptutorial.comStephenson39
 
ECET 465 Technology levels--snaptutorial.com
ECET 465 Technology levels--snaptutorial.comECET 465 Technology levels--snaptutorial.com
ECET 465 Technology levels--snaptutorial.comsholingarjosh104
 
Ecet 465 Massive Success / snaptutorial.com
Ecet 465  Massive Success / snaptutorial.comEcet 465  Massive Success / snaptutorial.com
Ecet 465 Massive Success / snaptutorial.comHarrisGeorgz
 
Subnetting in network layer in computer networks
Subnetting in network layer in computer networksSubnetting in network layer in computer networks
Subnetting in network layer in computer networkskarthiktyagi2
 
IPv4 addressing and subnetting
IPv4 addressing and subnettingIPv4 addressing and subnetting
IPv4 addressing and subnettingShashank Asthana
 
Subnetting Network administrators are usually granted wi.docx
Subnetting Network administrators are usually granted wi.docxSubnetting Network administrators are usually granted wi.docx
Subnetting Network administrators are usually granted wi.docxpicklesvalery
 

Similar to SubNetwork Calculator (Python Project) (20)

Subnetting
SubnettingSubnetting
Subnetting
 
15 3
15 315 3
15 3
 
CCNA 200-120 Exam Quick Notes
CCNA 200-120 Exam Quick NotesCCNA 200-120 Exam Quick Notes
CCNA 200-120 Exam Quick Notes
 
acn-practical_manual-19-20-1 final.pdf
acn-practical_manual-19-20-1 final.pdfacn-practical_manual-19-20-1 final.pdf
acn-practical_manual-19-20-1 final.pdf
 
IP-Subnetworking
IP-SubnetworkingIP-Subnetworking
IP-Subnetworking
 
7-Lect_7 .pptxNetwork LayerNetwork Layer
7-Lect_7 .pptxNetwork LayerNetwork Layer7-Lect_7 .pptxNetwork LayerNetwork Layer
7-Lect_7 .pptxNetwork LayerNetwork Layer
 
7-Lect_7 .pptxNetwork Layer. Addressing Subnetting Mask (default and subnet) ...
7-Lect_7 .pptxNetwork Layer. Addressing Subnetting Mask (default and subnet) ...7-Lect_7 .pptxNetwork Layer. Addressing Subnetting Mask (default and subnet) ...
7-Lect_7 .pptxNetwork Layer. Addressing Subnetting Mask (default and subnet) ...
 
Chapter 8 - IP Subnetting, Troubleshooting and Introduction to NAT 9e
Chapter 8 - IP Subnetting, Troubleshooting and Introduction to NAT 9eChapter 8 - IP Subnetting, Troubleshooting and Introduction to NAT 9e
Chapter 8 - IP Subnetting, Troubleshooting and Introduction to NAT 9e
 
IPv4 Addressing
 IPv4 Addressing   IPv4 Addressing
IPv4 Addressing
 
IP_ADDRESSING_AND_SUBNETTING.pptx
IP_ADDRESSING_AND_SUBNETTING.pptxIP_ADDRESSING_AND_SUBNETTING.pptx
IP_ADDRESSING_AND_SUBNETTING.pptx
 
Ecet 465 Success Begins / snaptutorial.com
Ecet 465   Success Begins / snaptutorial.comEcet 465   Success Begins / snaptutorial.com
Ecet 465 Success Begins / snaptutorial.com
 
Ecet 465  Enthusiastic Study / snaptutorial.com
Ecet 465  Enthusiastic Study / snaptutorial.comEcet 465  Enthusiastic Study / snaptutorial.com
Ecet 465  Enthusiastic Study / snaptutorial.com
 
ECET 465 Technology levels--snaptutorial.com
ECET 465 Technology levels--snaptutorial.comECET 465 Technology levels--snaptutorial.com
ECET 465 Technology levels--snaptutorial.com
 
Ecet 465 Massive Success / snaptutorial.com
Ecet 465  Massive Success / snaptutorial.comEcet 465  Massive Success / snaptutorial.com
Ecet 465 Massive Success / snaptutorial.com
 
Subnetting in network layer in computer networks
Subnetting in network layer in computer networksSubnetting in network layer in computer networks
Subnetting in network layer in computer networks
 
subnetting
subnettingsubnetting
subnetting
 
IPv4 addressing and subnetting
IPv4 addressing and subnettingIPv4 addressing and subnetting
IPv4 addressing and subnetting
 
Bots.pdf
Bots.pdfBots.pdf
Bots.pdf
 
Subnetting Network administrators are usually granted wi.docx
Subnetting Network administrators are usually granted wi.docxSubnetting Network administrators are usually granted wi.docx
Subnetting Network administrators are usually granted wi.docx
 
ipv4 (internet protocol version 4)
  ipv4 (internet protocol version 4)     ipv4 (internet protocol version 4)
ipv4 (internet protocol version 4)
 

SubNetwork Calculator (Python Project)

  • 1. ATHLONE INSTITUTE OF TECHNOLOGY SubNetwork Calculator Scripting 3.1 Project Dmitrijus Ponomarenko 2013-2014 Athlone Institute of Technology Computer Network Management 3 Scripting 3.1 Project
  • 2. SubNetwork Calculator 2013-2014 Page 1 Introduction This document gives a brief description of how my project was designed and developed. The idea of my project was to create a fully working SubNetwork Calculator. To implement that project I was using Python programing language. This project is a part of the final exam in Scripting 3.1 subject. Purpose ofProject The purpose of this project is to develop an easy-to-use IP subnetwork calculator that lets individuals using it to calculate every aspect of subnet configuration. Description The program will work with three classes of IP address, such as: A, B and C. The program will calculate and shows you the network address, subnetmask, available subnets per network, available number of hosts per subnet, subnet host address range, subnet broadcast address and IP addresses of all possible subnets per network. PythonModules This program was created by using Python tkinterGUI module and Python functions; Tkinter It is the standard Python GUI (Graphical User Interface) toolkit, which helps to create more advanced interface than when using easy GUI module.
  • 3. SubNetwork Calculator 2013-2014 Page 2 In this program I use “Grid” manager to design user interface. The grid manager is the most flexible of the geometry managers in Tkinter which allows very easy management of the widgets. To achieve easy management the "Grid" manager uses 2-dimensional system table. The master widget is split into a number of rows and columns. Each “cell” in the table can hold a single widget. Functions A function is a piece of code that is called by name. It is like a subprogram which is like a small program inside of another program. The function plays a role of performing a specific task. The advantages of using functions are to:  Reduce duplication of code  Decompose complex problems into simpler pieces  Improve clarity of the code  Reuse of code Additionally, in this program I use some extra modules as "os" module and "math" module for specific tasks such as a checking file sizes and mathematic calculations. More detailed information about above mentioned modules will be discussed in the topic "Problems and Solutions" . Sample Design and Implementation Input Processing Output
  • 4. SubNetwork Calculator 2013-2014 Page 3 IP address Number of subnets/hosts Router/switch name Port name Inputs Calculations Display output Network class Network IP address Subnet Mask Subnets per Network Hosts per Network IP Range Broadcast address List networks Pseudo-code: Function get ip address entry() get first oct of ip address and assign it to the variable (oct_1) get second oct of ip address and assign it to the variable (oct_2) get third oct of ip address and assign it to the variable (oct_3) get fourth oct of ip address and assign it to the variable (oct_4) add variables and assign to the variable (address) return variable (address) Function for checking ip address (valid or not) if_ip_valid(oct_1,oct_2,oct_3,oct_4) get four parts of ip address if each oct between 1 and 255 add octs and assign to variable (ip_address) if not display warning message Function to calculate subnetwork addresses in class C class_c_subnets_list(ip_address,num_hosts) split ip address assign ost 4 to the zero count loop start from zero create firs network ip address insert first network ip in listbox calculate number of subnetworks start count loop until it reach number of subnets add number of hosts to the oct 4
  • 5. SubNetwork Calculator 2013-2014 Page 4 create subnetwork ip address add ip address to the listbox add one to the count loop Function to calculate subnetwork addresses in class B class_b_subnets_list(ip_address, num_hosts) split ip address in four octs if number of hosts less or equal 255 assign oct 3 to the zero start count loop1 from zero run count loop1 until it reach 256 assign oct 4 to the zero count loop2 start from zero create first subnet ip address add ip to the listbox calculate subnets run count loop2 until it reach number of subnets add number of hosts to the oct 4 create subnet ip add ip to the lisbox add one to the count loop2 add one to the oct 3 add one to the count loop1 if the number of hosts between 256 and 65536 assign oct 4 to the zero assign oct 3 to the zero start count loop from zero create first subnet ip add ip to the listbox calculate number of subnets, formula (65536/num_hosts-1) run count loop until it reach number of subnets calculate x, formula( x=256/(65536/num_hosts)) add x to the oct 3 create subnet ip add ip to the listbox count plus one else assign oct 4 to the zero assign oct 3 to the zero create subnet ip add ip to the listbox
  • 6. SubNetwork Calculator 2013-2014 Page 5 Function to calculate subnetwork addresses in class A class_a_subnets_list(ip_address,num_hosts) split ip address into four octets if number of host less or equals 255 assign oct 2 to the zero count loop1 start from zero run count loop1 until it reach 256 assign oct 4 to the zero assign oct 3 to the zero count loop2 start from zero run loop2 until it reach 256 assign oct 4 to the zero count loop3 start from zero create first subnet ip insert ip to the listbox calculate subnets per network run count loop3 until it reach number of subnets add number of hosts to the oct 4 create network ip insert ip to the listbox add one to the loop3 add one to the oct 3 add one to the loop2 add one to the oct 2 add one to loop1 if number of hosts between 256 and 65536 assign oct 2 to the zero loop1 start from zero loop not finished until it reach 256 assign oct 4 to the zero assign oct 3 to the zero loop2 start from zero create first subnet ip add ip to the listbox calculate number of subnets run loop2 until it reach number of subnets calculate x, formula (256/(65536/num_hosts)) add x to the oct 3 create subnet ip insert ip to the listbox add one to the loop2 add one to the oct 2 add one to the loop1 if number of hosts between 65536 and 16777216 assign oct4 to the zero assign oct3 to the zero
  • 7. SubNetwork Calculator 2013-2014 Page 6 assign oct2 to the zero count loop start from zero create first network ip add ip to the listbox calculate number of subnetworks run count loop until it reach number of subnets calculate x, formula (256/(16777216/num_hosts)) add x to the oct2 create network ip add ip to the litbox add one to the count loop else assign oct4 to the zero assign oct3 to the zero assign oct2 to the zero create network ip add ip to the listbox Function net_class(ip_address,num_hosts) : define network class, calculate subnets per network, all possible networks address and insert to the listbox net_class(ip_address,num_hosts) split ip address into four octets convert oct 1 to the integer convert number of hosts to the integer if oct1 between 192 and 223 function subnets_c(num_hosts) clear listbox create heading add heading to the lictbox function class_c_subnets_list(ip_address,num_hosts) if else oct1 between 128 and 191 function subnets_b(num_hosts) clear listbox create heading add heading to the lictbox function class_b_subnets_list(ip_address,num_hosts) else display warning message Functions to define ip class and calculate number of subnetworks
  • 8. SubNetwork Calculator 2013-2014 Page 7 subnets_c(num_hosts) if number of hosts less or equal 255 display suitable message calculate number of subnets per network, formula(256/num_hosts) display subnets else display suitable message set number of subnets (1) and display it subnets_b(num_hosts) if number of hosts less or equal 65536 display suitable message calculate number of subnets per network, formula(65536/num_hosts) display subnets else display suitable message set number of subnets (1) and display it subnets_a(num_hosts) if number of hosts less or equal 16777216 display suitable message calculate number of subnets per network, formula(16777216/num_hosts) display subnets else display suitable message set number of subnets (1) and display it Function to calculate network ip address, ip range, subnet mask and broadcast address for class C ip address f1(num_hosts,ip_address) split ip address by dots convert oct1 to integer convert oct2 to ineger convert oct3 to integer convert oct4 to integer calculate host bits in ip address, formula(math.log(num_hosts)/math.log(2)) calculate network bits in ip address,formula(32-host bits) create variable (m1) and assign to it 255 create variable (m2) and assign to it 255 create variable (m3) and assign to it 255
  • 9. SubNetwork Calculator 2013-2014 Page 8 create variable (m4) and assign to it (256-number of hosts) use bin() to calculate first oct of network ip and assign it to variable (f1) use bin() to calculate second oct of network ip and assign it to variable (f2) use bin() to calculate third oct of network ip and assign it to variable (f3) use bin() to calculate fourt oct of network ip and assign it to variable (f4) convert f1 to the integer and assign it to the variable oct1 convert f2 to the integer and assign it to the variable oct2 convert f3 to the integer and assign it to the variable oct3 convert f4 to the integer and assign it to the variable oct4 display network ip address display subnet mask display ip range display broadcast ip create variable (sub_net_mask) create variable (ip range) create variable (net ip address) create variable (broadcast) return net_ip_address,ip_range, sub_net_mask,broadcast Function to calculate network ip address, ip range, subnet mask and broadcast address for class B ip address f2(num_hosts,ip_address) split ip address by dots convert oct1 to integer convert oct2 to ineger convert oct3 to integer convert oct4 to integer calculate host bits in ip address, formula(math.log(num_hosts)/math.log(2)) calculate network bits in ip address,formula(32-host bits) calculate variable (x),formula (number of hosts/256) and assign it to the variable (num bits) create variable (m1) and assign to it 255 create variable (m2) and assign to it 255 create variable (m3) and assign to it (256-num bits) create variable (m4) and assign to it 0 use bin() to calculate first oct of network ip and assign it to variable (f1) use bin() to calculate second oct of network ip and assign it to variable (f2) use bin() to calculate third oct of network ip and assign it to variable (f3) use bin() to calculate fourt oct of network ip and assign it to variable (f4) convert f1 to the integer and assign it to the variable oct1 convert f2 to the integer and assign it to the variable oct2 convert f3 to the integer and assign it to the variable oct3 convert f4 to the integer and assign it to the variable oct4 display network ip address display subnet mask
  • 10. SubNetwork Calculator 2013-2014 Page 9 display ip range display broadcast ip create variable (sub_net_mask) create variable (ip range) create variable (net ip address) create variable (broadcast) return net_ip_address,ip_range, sub_net_mask,broadcast Function to calculate network ip address, ip range, subnet mask and broadcast address for class A ip address f3(num_hosts,ip_address) split ip address by dots convert oct1 to integer convert oct2 to ineger convert oct3 to integer convert oct4 to integer calculate host bits in ip address, formula(math.log(num_hosts)/math.log(2)) calculate network bits in ip address,formula(32-host bits) calculate variable (x),formula (number of hosts/256^2) and assign it to the variable (num bits) create variable (m1) and assign to it 255 create variable (m2) and assign to it (256-num bits) create variable (m3) and assign to it 0 create variable (m4) and assign to it 0 use bin() to calculate first oct of network ip and assign it to variable (f1) use bin() to calculate second oct of network ip and assign it to variable (f2) use bin() to calculate third oct of network ip and assign it to variable (f3) use bin() to calculate fourt oct of network ip and assign it to variable (f4) convert f1 to the integer and assign it to the variable oct1 convert f2 to the integer and assign it to the variable oct2 convert f3 to the integer and assign it to the variable oct3 convert f4 to the integer and assign it to the variable oct4 display network ip address display subnet mask display ip range display broadcast ip create variable (sub_net_mask) create variable (ip range) create variable (net ip address) create variable (broadcast) return net_ip_address,ip_range, sub_net_mask,broadcast Functio to clear entry sels
  • 11. SubNetwork Calculator 2013-2014 Page 10 clear_all() delete ip entry delete hardware entry delete port name entry Function save to a file open_file(net_ip_address, ip_range, sub_net_mask, broadcast,num_hosts) assign net_ip_address to the variable (ipaddress) assign ip range to the variable (iprange) assign sub_net_mask to the variable (subnet) assign broadcast to the variable (broadcast) open file assign it to the variable (data file) get file size if file size equal 0 write headings to the file get hardware name get port name from number of hosts extract two assign to variable write data to file else get hardware name get port name write data to file Function in which I add all function in a logical chain calculation() run function entry() assign output to the variable (ip_address) split ip address by dots run function if_ip_valid(oct_1,oct_2,oct_3,oct_4) assign output to the variable if choice number of host get choice from listbox and assign it to variable (num hosts) run function net_class(ip_address,num_hosts) if number of hosts between 0 and 256 run function f1 (num_hosts,ip address) assign output to the variables if number of hosts between 256 and 65536 run function f2 (num_hosts,ip adress) assign output to the variables if number of hosts between 65536 and 16777216 run function f3 (num_hosts, ip address) assign output to the variables else run function f4 (num_hosts,ip address) assign output to the variables
  • 12. SubNetwork Calculator 2013-2014 Page 11 else get choice of number of subnets if oct1 between 192 and 223 calculate hosts 256/num_subnets if number of subnets less or equal 64 run function net_class(ip_address,num_hosts) run function f1 (num_hosts,ip address) assign output to the variables else clear networks listbox and all outputs display warning message if else oct1 between 128 and 191 calculate hosts 65536/num_subnets if number of subnets less or equal 16384 run function net_class(ip_address,num_hosts) if number of hosts between 0 and 256 run function f1 (num_hosts,ip address) assign output to the variables if number of hosts between 256 and 65536 run function f2 (num_hosts,ip adress) assign output to the variables else clear networks listbox and all outputs display warning message if else oct1 between 1 and 126 calculate hosts 16777216/num_subnets if number of subnets less or equal 4194304 run function net_class(ip_address,num_hosts) if number of hosts between 0 and 256 run function f1 (num_hosts,ip address) assign output to the variables if number of hosts between 256 and 65536 run function f2 (num_hosts,ip adress) assign output to the variables if number of hosts between 65536 and 16777216 run function f3 (num_hosts, ip address) assign output to the variables get choice save or not if choice yes run fuction open_file(net_ip_address, ip_range,sub_net_mask,broadcast, num_hosts) Program BreakDownStructure
  • 13. SubNetwork Calculator 2013-2014 Page 12 User Manual SubNetwork Calculator User Interface SubNetwork Calculator Functions Exit Clearall Calculate Get IP address CheckIP address Check network class Find all networks ip add to listbox If network classC Calculate networks ip add to listbox If network classB Calculate networks ip add to listbox If network classA Calculate networks ip add to listbox Calculate network ip address ip range mask broadcast ip Create file Save to file GUI Tkinter
  • 14. SubNetwork Calculator 2013-2014 Page 13 Step 1 Enter ip address, split ip address into four parts by dots (192.100.100.0) and enter each part to windows.
  • 15. SubNetwork Calculator 2013-2014 Page 14 Step 2 Select subnet numbers which you need to divide or select number of hosts that you require per subnet. Step 3
  • 16. SubNetwork Calculator 2013-2014 Page 15 If you need to save your calculation, enter hardware name (Athlone- Router) and port name (serial0/1/0). Alternatively, you can skip this step if you want to run calculation without saving. Step 4 To save data into a file tick the box or alternatively skip this step if you don't need to save data. Step 5 Click "Calculate" button to run calculations process.
  • 17. SubNetwork Calculator 2013-2014 Page 16 Output of calculation: 1. Network class A(1-126),B(128-191)or C(192-223) 2. Network IP address 3. Subnet Mask 4. Subnets per Network 5. Hosts per Network 6. IP Range (first usable address last usable address) 7. Broadcast IP address 8. List of all possible SubNetworks Step 6 If you are finished your calculations press ‘exit’. However, if you would like to repeat calculations press 'clear all' and repeat steps 1,2,3,4,5.
  • 18. SubNetwork Calculator 2013-2014 Page 17 or Problems andSolutions In the process of implementing a program I encountered some challenges. The main two problems include: 1. Calculating the network ip address. 2. Calculating the host bits in subnetmask. To solve the problem of calculating network ip address, I utilised ip address and subnet mask as thought during academic semester in the classes. Usually, ip address and number of hosts or subnets necessary in the network are provided. Therefore, the first step is to identify the subnetmask of the network. To carry out this task the individual creating the programme requires to have knowledge in ip address structure.Fromthe knowledge gained during the course I found the way of calculating subnet mask. This is achieved by having ip address and number of hosts already provided. Example: The ip address provided is 192.168.20.0 therefore, it is required to calculate 30 ip addresses. First of all it is important to determine the 'class' of ip address and default subnetmask belonging to it. Additionally,
  • 19. SubNetwork Calculator 2013-2014 Page 18 it is required to identify maximum number of ip addresses that each default subnetmask supports such as:  Class A 1-126 default subnetmask 255.0.0.0 max number of ip addresses 16777216  Class B 128-191 default subnetmask 255.255.0.0 max number of ip addresses 65536  Class C 192-223 default subnetmask 255.255.255.0 max number of ip addresses 256 By the first byte of the ip address provided, it was determined that it belongs to 'class C' with default subnetmask 255.255.255.0 (binary equivalent = 11111111.11111111.11111111.00000000 or wildcard mask of 0.0.0.255). At this stage it is necessary to determine the number of host bits in the subnetmask required to cover 30 hosts. In order to continue with network ip address calculations, at this stage, it is required to identify host bits of subnetmask: In the interface programme host listbox window select the number of hosts that cover the requirements provided in the above described example which is 30. In this case the number selected 32 because it covers required range. With the use the formula : 2^x=32, the number of host bits in the subnetmask can be calculated at this stage. (x) – represents the number of host bits in the subnetmask. (X) can be calculated with the use of math.log function. To make this calculation new module “math”is being used. By doing so (x) can be expressed in the formula showed below: x=log(32)/log(2), so x=5. Calculation identified that 5 bits of the subnetmask cover needed requirements of 30 hosts. At this stage the value of subnetmask can be identified by: 32-5=27 (binary equivalent = 11111111.11111111.11111111.11100000)or 255.255.255.224 and (wildcard binary equivalent = 0.0.0.00011111)or
  • 20. SubNetwork Calculator 2013-2014 Page 19 0.0.0.31. By linking subnetmask (255.255.255.224)and wildcardmask (0.0.0.31)together, it shows that when adding last byte from subnetmask (224) with last byte of wildcardmask (31) the outcome is 255. Therefore to identify subnetmask in class C ip address in this particular programme, it is required to subtract number of hosts which was selected from the host list box (32) from last byte of the subnetmask (255) which was calculated above. (255-32)+1=224 or 256-32=224 (255.255.255.224). For higher number of hosts the same logic should be used but with more difficult formula. Example: When 1000 of hots are required per network. First of all the number of hosts to which default subnetmask belong need to be identified. First example shows that class C default subnetmask is 255.255.255.0 which may cover the maximum of 256 ip addresses. Class B default subnetmask is 255.255.0.0 whuch may cover the maximum of 65536 ip addresses. At this stage select from the number hosts from hosts listbox that cover requirements of 1000. In this case the number selected 1024 because it covers required range. With the use the formula : 2^x=1024, the number of host bits in the subnetmask that are required to cover 1000 hosts can be calculated. 2^x=1024, x=log(1024)/log(2), x=10. The subnetmask can be calculated in the way showed below:
  • 21. SubNetwork Calculator 2013-2014 Page 20 32-10=22 (binary equivalent = 11111111.11111111.11111100.00000000)or 255.255.252.0. From this, it shows that to cover needed requirements two bits from third byte can be taken. (x) represents sum of two bits that were taken from third byte. x=1024/256 x=4, In next step the third byte is represented as 256. 256-4=252 The subnetmask is 255.255.252.0. Now when the subnetmask was identified, the network address can be calculated by using bin() function, which converts decimal number to the binary numbers For example: Ip address bin(192.168.30.0)= (11000000.10101000.00011110.00000000) Subnetmask bin(255.255.254.0)= (11111111.11111111.11111100.00000000) 11000000.10101000.00011110.00000000 11111111.11111111.11111100.00000000 ________________________________ 11000000.10101000.00011100.00000000 Network ip address 192.168.28.0
  • 22. SubNetwork Calculator 2013-2014 Page 21 The “os” module in this particular program works with the file or with the size of the file if to be more exact. When the program executes for the first time and creates new file, the “os” module checks the file size. If the size of the file equals zero the program will create headings and add data. If the file exists already, the “os” module will skip the step to create headings and only add data to a file and save it. Conclusion This document provided a brief description of how my project of subnet calculator was designed and developed. By doing this project I gained valuable experience in developing Python program. I hope that the experience gained will positively influence my future development in the use of Python.