INSTITUTO POLITÉCNICO NACIONAL ESCUELA SUPERIOR DE CÓMPUTO
Computer Networks
“Clasification IP”
By: Romero Rubio Gerardo Daniel
Professor: M. en C. NIDIA ASUNCIÓN CORTEZ DUARTE Octubre2015 Index Contenido
Problem:......................................................................................................................1 Hypothesis:..................................................................................................................2 Software (libraries, packages, tools):..............................................................................2 Procedure:...................................................................................................................2
Results (Data):.............................................................................................................3 Conclusions:................................................................................................................3 References:................................................................................................................3 Code............................................................................................................................3
2
Problem: Make a C program receive an IP as a string and identify the breakpoints of each octet, assessing the IP as follows: INPUT: 111.111.111.111 OUTPUT: Class A Kind: HOST IP Red: 111.0.0.0 IP Broadcast: 111.255.255.255 Rank of Network: 111.0.0.1 – 111.255.255.254 Observations Short for Internet Protocol address, an IP address is an address of a computer or other network device on a network using T/IP. For example, the number "69.72.169.241" is an example of such an address. These addresses are similar to an addresses used on a house and is what allows data to reach the appropriate destination on a network and the Internet.
1st Octet Class Decimal Range
1st Octet Network/Host ID Default Number of High (N=Network, Subnet Mask Networks Order Bits H=Host)
Hosts per Network (Usable Addresses)
A
1 – 126*
0
N.H.H.H
255.0.0.0
126 (27 – 2)
16,777,214 (224 – 2)
B
128 – 191
10
N.N.H.H
255.255.0.0
16,382 (214 – 2)
65,534 (216 – 2)
C
192 – 223
110
N.N.N.H
255.255.255.0
2,097,150 (221 – 2)
254 (28 – 2)
D
224 – 239
1110
Reserved for Multicasting
E
240 – 254
1111
Experimental; used for research
1
Hypothesis: Through the proper handling of bits in C is required to assess correctly the IP entered by a displaying all right to be evaluated, for it requires the grouping of data and turn the separation of whole chain corecctamente inserted values. Considering the theory about IPs desired separated into parts chain estableciada -achieving evaluate the first most significant byte, for the class it belongs to, the type of IP and therefore the IP Network. Once completed the procedure may be used before returning to separate the string by the and evaluate others and the remaining octets results will be obtained and that achieved by bit logical operators (AND, NOR, XOR, OR, etc.).
Software (libraries, packages, tools): 1. DevC++ 5.2.0.1 2. Windows 8.1 Procedure:
* Flowchart * Add details (step-by-step) of your procedure in such a way that anyone else could repeat the experiment.
2
Results (Data):
Conclusions: Based on the results we observed different methods to which they came to the realization of the program, accepting the hypothesis generated successfully. If this were not the case it is rejected by all the hypotheses getting a different result than expected. Based on what dimensioned and realized in practice we observed acquired knowledge: 1. The correct use of handling bits. 2. Identifying each octet. 3. The complete evaluation of an IP. 4. Identification of some factors of programming. References: 1. H.M Deitel/ P.J Deitel. Como programar en C/C++, 1994 2. Francisco Javier Cevallos. Como programar en C/C++, 1999. 3. William Staling. Comunicaciones y Redes de Computadores , 2002. Code #include <stdio.h> 3
#include
#include <stdlib.h> main(){ unsigned int x; int opc=0; do{ fflush(stdin); printf("\n Introduce el Ip: "); scanf("%d",&x); if(x>255){ //Si la ip es mayor a 255 ip no existente printf("IP No existe"); } else{ if(x&128){ Analiza el primer octeto de la ip mediante compuertas if(x&64){ if(x&32){ if(x&16){ printf("\nEs Clase E\n"); }else printf("\nEs Clase D\n");//Impirme la clase de la ip segun su analisis de puerta }else printf("\nEs Clase C\n"); }else printf("\nEs Clase B\n"); }else printf("\nEs Clase A\n"); } fflush(stdin); printf("Quiere otra IP: 1.- Si 2.- No"); //mediante un while repetir el proceso fflush(stdin); printf("\n Opcion: "); scanf("&d",&opc); fflush(stdin); }while(opc!=2); system("pause"); }
4