Sei sulla pagina 1di 44

Kingdom of Saudi Arabia Council of Higher Education

Salman Bin Abdulaziz University

CS 422 ComputersNetworks LabManual

Preparedby

MujthabaGulamMuqeeth M.Mustaq

ComputersNetworkLab manual
1.1. Purposeof the laboratory The main goal of this laboratory is to give you an overview of the computer network and data transmission. You will have to plan the IP address scheme, congure and test the equipment, as well as con gure several applications and servers typical of any network You will also learn the socket programming to build a network application. After you have completed the laboratory exercises, you should be familiar with the practical issues of the different concepts explained in the course, as well as with the real equipment used nowadays in computer networks. 1.2. Objective : The objectives of this lab is to make the student to implement To understand the concepts of data communication, computer networks and information security. Understand the student the basic network devises like repeater, hub, switch, and router & Making him to configure. Make the student to connect the systems in various topologies and implement networking commands. Implementing to configure and assigning of IP addresses by using clientserver technology. Programming the various issues data link layer like error control and flow control. Finally make the student to develop few encryption and decryption algorithms for network security 1.3. Assessmentcriteria A. InternalAssessment : 10 Marks In continuous evaluation system of the university, a student is evaluated throughout semester. His/her performance in the lab, attendance, practical knowledge, problem solving skill, written work in practical file and behavior are main criteria to evaluate student performance. Apart from that a lab quiz will be organize to see program programming skill and knowledge about the proposed at last we keep one test. Subject. B. ExternalAssessment 10 Marks At the end of the semester a lab examination will be scheduled to check overall programming skill,

in which student will need to solve 2 programming problems in time span of 2 hours. C. Total Marks A+B= 20 Marks

1.4. Toolsusedin lab 1. Router: CISCO router 2. Programming Language: C Programming 3. Operating System: Windows 7 4. Network Simulator: Opnet IT Academic Edition 9.1 1.4 Formatfor Experiment Aim: Name of the Experiment. Objective: In this section write complete objective of the program you are going to make in the lab. This section specifies the complete description of the including problem analysis, input description, method used, fundamental concept and desired output format. Softwareused : In this section write what types of software will be used by the Student to develop source code of the given problem. Tool : Operating System: Hardware : SourceCode /experimentdescription : In this section write the complete errorless procedure/program and if any simulator. Input: Write input test data that are used to test program objective to see whether Output : Write complete output produced by the program, at run time Conclusion : Write complete conclusion that comprises what student learned from this

1.5. List of Experiments 1. Demonstration and use of various network devices like repeater, hub switch, and Bridge, router, & transmission cables.

2. Assigning IP address 3. Implementation Networking commands PING ARP TELNET TRACERT NETSTAT

4. Implementation of Data Link layer issues for Error Control Bit stuffing Character stuffing

5. Building Ethernet using simulator

6. Designing and implementation encryption and Decryption algorithms using RSA.

7. Developing CASE Study

1.6 Plan of Coveragesyallabus Sl.No. 1 Exp.No. Exp.No.1 WeekNo. ExperimentName Week 1 Demonstration and use of various network & Week devices like repeater, hub switch, and Bridge, 2 router, & transmission cables. Week 3 Week 4 & Week 5 Week 6 & Week 7 Assigning IP address Implementation Networking commands

2 3

Exp.No.2 Exp.No.3

Exp.No.4

Implementation of Data Link layer issues for Error Control Bit stuffing Character stuffing

Exp.No.5

Exp.No.6

Week 8 , 9& Week 10 Week 11 & Week 12 Week 13

Building Ethernet using simulator

Designing and implementation encryption and Decryption algorithms using Developing CASE Study RSA.

Exp.No.7

ExperimentNo. 1 Aim : Demonstrationand use of variousnetworkdeviceslike repeater, hubswitch,Bridge, router, & transmissioncables Objective: You will work with different pieces of network equipment such as cables, switches and routers during this lab. You should know what their functions and capabilities are in general terms. This section shows the actual models that you will nd in the lab. It also contains some guidelines to identify the equipment and its interfaces. All the equipment is classier into four groups: cables, switches, routers and terminals. Below there is one subsection dedicated to each group. Toolsused : OperatingSystem : Windows 7 or windows (any version) Network devices : Hub, switch, Router, Ethernet, serial line, Rj45 plug, Roll over cable Description: Network diagrams show the relationship between the elements of communication networks such as computers, peripheral devices and network equipment. A diagram is the main documentation of a network and its importance cannot be overemphasized. Often, it is the key resource when troubleshooting the network. The network diagram shows how the network operates, so the main task of the network administrator is to maintain the network functioning as its diagram species. As a general rule, any modication to the network must rst be made to the network diagram, the side Effects analyzed and then, if everything works properly, the network equipment will be recongured following the new diagram.

Switches The switch you will use in the lab is a Cisco Catalyst 3512 XL. In the front it has twelve 10/100 Ethernet switched RJ45 ports plus two additional Gigabit Ethernet slots. The Ethernet ports will be used to connect the equipment of the area network. The Gigabit slots will not be used in this lab. In the back it has the RJ45 console port for its Conguration and the three-pin power supply socket. It does not have a power switch; the equipment is turned on when connected to the power supply. Each port is labeled on the box with a name, which it is also used to identify the port in the conguration menus. Figure 2.12 shows the front and Figure 2.13 shows a closer view of the Ethernet ports in the front. Note that each port is given a number, with number one in the top left corner. The number allows identi cation of the ports in the conguration le, but there is no difference in the behavior of the ports. Any of them can be used to connect equipment to the switch. More information about this model can be found at http: //www.cisco.com/univercd/cc/td/doc/product/lan/c2900xl/29_35xu/index.htm There are additional switches inside the cabling rack. You will use them to connect your router to the departmental backbone, but you do not have to change their conguration. Routers The router you will use in the lab is a Cisco 2621. All its ports are situated in the back. It has two 10/100 Ethernet RJ45 ports, a RJ45 console port for its conguration, a three-pin power socket and a power switch. Each port is labeled in the box with a name, which it is also used to identify the port in the conguration le. Since the router forwards packets between its ports, it is very important to connect each network to the proper port. Figure 2.14 shows the front and Figure 2.15 shows the ports in the back. More information about this equipment can be found at http://www.cisco.com/ en/US/products/hw/routers/ps259/index.html

10

Ciscosoftware In this section we will review the conguration process of the Cisco equipment in the lab. The best way to prepare yourself for this task, it is to read the manufacturers documentation. This is available on line, so we will not copy it here but we will give you some references. Read these references in advance. You will not have time during the lab. Since there is a huge amount of published documentation, the next paragraphs contain some guides on what are the parts that you must study for this lab. The software con guration guide for the Cisco 2600 router is available on line at http://www.cisco.com/ univercd/cc/td/doc/product/access/acs_mod/cis2600/sw_conf/26_swcg/index.htm . Start reading from the section "About this guide" on the objectives, organization and conventions of the document. Then go to the chapter 1, "First-time con guration", which explains how to congure the router initially. This chapter describes both the 3600 and 2600 model series, read only the part related to the Cisco 2600 series. It is important to review the "Cisco 2600 Series Interface Numbering". While reading this part, recall that the routers in the lab have two Fast Ethernet ports in slot 0. Then read the following sections to overview the initial conguration process of the router: "Using the Setup Command Facility", "Conguring Global Parameters" and "Conguring Interface Parameters". This last section describes several interface types, read only the "Fast Ethernet Interface Conguration" section. Cablesand connectors All the cables used in the lab are terminated with adequate connectors on both ends. Two major types of cables will be used in the lab, power supply and data cables. The power supply cable is necessary for the equipment to be powered, but it does not participate in the transmission of data signals. Figure 2.4 shows the power supply cable for PCs, routers And switches. Conclusion: The conclusion of this experiment that the student able to achieve the objective of knowing different network devices.

11

Experiment:2 Aim : Assigning IP address Objective: When organizing your home network its easier to assign each computer its own IP address statically and than using DHCP. Here we will take a look at doing it in XP, Vista, and Windows 7. If you have a home network with several computes and devices, its a good idea to assign each of them a specific address. If you use DHCP (Dynamic Host Configuration Protocol), each computer will request and be assigned an address every time its booted up. When you have to do troubleshooting on your network, its annoying going to each machine to figure out what IP they have. Using Static IPs prevents address conflicts between devices and allows you to manage them more easily. Assigning IPs to Windows is essentially the same process, but getting to where you need to be varies between each version. Tools : Operating system: windows Network: LAN ExperimentDescription: There are several steps: 1. See your current IP address 2. Choose a static IP address 3. Assign the static IP address Current IP Address Find your current IP address and whether it is static or dynamic : 1. Open Windows Start menu. 2. Select Run . Type: commandand click OK. 3. At the blinking cursor, type: ipconfig/all and press Enter. 4. Look for these entries near the end of the list: - DhcpEnabled . No means your IP address is static. Yes means it is dynamic. - IP Address . This is your current IP address. 5. To exit, at the blinking cursor, type: exit and press Enter.

12

If your current IP address is:

Static , then make note of the IP address. You need the IP address when you open ports in your router or firewall. Dynamic , then assign a static IP address instead.

Choose an IP address Choose an IP address, and collect other information needed in order to assign a static IP address to your computer. 1. In your router administration program, find and remember this information: Router (Gateway) IP address Subnet Mask IP addresses of your DNS servers 2. In your router administration program, find an IP address that can be assigned as a static IP. The address: Must not be one that might be assigned to someone as a dynamic address. Must not be one that has been assigned to another device (often these are the low numbers). Must be lower than the range of dynamic addresses .

13

Assign the IP address To set a static IP address: 1. Open Windows Start menu. 2. Open ControlPanel . 3. Classic view: Open NetworkConnections Category view: Select Networkand InternetConnections , and then Network Connections . 4. Double-click on your active LANor Internetconnection . 5. Click Properties . This opens the Local Area Connections Properties window. 6. In the General tab, highlight the InternetProtocol(TCP/IP) item, and click Properties .

This opens the Internet Protocol (TCP/IP) Properties window. 7. In the General tab, click Usethe followingIP address , and enter: - IP address. The static IP address you want to assign to this computer. - Subnet mask. Subnet mask used by your router. - Default gateway. IP address of your router's default gateway.

14

8. In Use the followingDNSserveraddresses , enter all the IP addressses for the DNS servers your router uses.
9. Click OK.

Then: 10. Click OK to close each window. 11. Restart your computer. 12. Then, check your IP address again, to make sure that the changes were applied. Input: Assigning the IP statically Output:Changed IP address Conclusion : The objective of this experiment is to assigning the IP can be achieved.

Experiment3 15

Aim : Implementation Networking commands PING ARP TELNET TRACERT NETSTAT Ping: Sends ICMP ECHO_REQUEST packets to network hosts SYNTAX ping -s [-d] [-l] [-L] [-n] [-r] [-R] [-v] [ -i interface_address ] [-I interval] [-t ttl] host [packetsize] [count] -d -l Set the SO_DEBUG socket option. Loose source route. Use this option in the IP header to send the packet to the given host and back again. Usually specified with the -R option. Turn off loopback of multicast packets. Normally, if there are members in the host group on the out- going interface, a copy of the multicast packets will be delivered to the local machine. Show network addresses as numbers. ping normally displays addresses as host names. Bypass the normal routing tables and send directly to a host on an attached network. If the host is not on a directly-attached network, an error is returned. This option can be used to ping a local host through an interface that has been dropped by the router daemon. Record route. Sets the IP record route option, which will store the route of the packet inside the IP header. The contents of the record

-L

-n -r

-R

ping computerhope.com - Would ping the host computerhope.com to see if it is alive ARP : AddressResolutionProtocol Displays and modifies entries in the Address Resolution Protocol (ARP) cache, which contains one or more tables that are used to store IP addresses and their resolved Ethernet or Token Ring physical addresses. There is a separate table for each Ethernet or Token Ring network adapter installed on your computer. Used without parameters, arp displays help.

16

Syntax
arp [-a [InetAddr] [-N IfaceAddr]] [-g [InetAddr] [-N IfaceAddr]] [-d InetAddr [IfaceAddr]] [-s InetAddr EtherAddr [IfaceAddr]]

Parameters
-a [InetAddr] [-N IfaceAddr] : Displays current ARP cache tables for all interfaces. To display the ARP cache entry for a specific IP address, use arp -a with the InetAddr parameter, where InetAddr is an IP address. To display the ARP cache table for a specific interface, use the -N IfaceAddr parameter where IfaceAddr is the IP address assigned to the interface. The -N parameter is case-sensitive. -g [InetAddr] [-N IfaceAddr] : Identical to -a. -d InetAddr [IfaceAddr] : Deletes an entry with a specific IP address, where InetAddr is the IP address. To delete an entry in a table for a specific interface, use the IfaceAddr parameter where IfaceAddr is the IP address assigned to the interface. To delete all entries, use the asterisk (*) wildcard character in place of InetAddr. -s InetAddr EtherAddr [IfaceAddr] : Adds a static entry to the ARP cache that resolves the IP address InetAddr to the physical address EtherAddr. To add a static ARP cache entry to the table for a specific interface, use the IfaceAddr parameter where IfaceAddr is an IP address assigned to the interface. /? : Displays help at the command prompt.

Examples
To display the ARP cache tables for all interfaces, type: arp -a To display the ARP cache table for the interface that is assigned the IP address 10.0.0.99, type: arp -a -N 10.0.0.99

17

To add a static ARP cache entry that resolves the IP address 10.0.0.80 to the physical address 00-AA-00-4F-2A-9C, type: arp -s 10.0.0.8000-AA-00-4F-2A-9C Telnet: Telnet is a simple, text-based program that allows you to connect to another computer by using the Internet. If you've been granted the right to connect to that computer by that computer's owner or administrator, Telnet will allow you to enter commands used to access programs and services that are on the remote computer, as if you were sitting right in front of it. Telnet can be used for many things, including accessing e-mail, databases, or files.

To install Telnet Client


1. Click the Start button , click Control Panel, click Programs, and then click Turn Windows features on or off. If you are prompted for an administrator password or confirmation, type the password or provide confirmation. 2. In the Windows Features dialog box, select the Telnet Client check box. 3. Click OK. The installation might take several minutes.

To open Telnet Client

Open Telnet by clicking the Start button box, and then clicking OK.

, typing Telnet in the Search

TracerouteCommand

18

traceroute [-m #] [-q #] [-w #] [-p #] {IP_address|host_name}

Option -m

Definition Set the maximum Time To Live (TTL) for the trace, measured as the number of hosts the program will trace before ending, default of 30 Set the number of UDP packets to send for each setting, default of 3. Set the amount of seconds to wait for an answer from each host before giving up, default of 5 Specify the other host's invalid port address, default of 33434

-q

-w

-p

NETSTAT

19

netstat command netstat displays the contents of various network-related data structures in various formats, depending on the options you select. The first form of the command displays a list of active sockets for each protocol. The second form selects one from among various other network data structures. The third form shows the state of the interfaces. The fourth form displays the routing table, the fifth form displays the multicast routing table, and the sixth form displays the state of DHCP on one or all interfaces. SYNOPSIS ABOUTNETSTAT Shows network status. SYNTAX netstat [-a] [-n] [-v] netstat [-g | -m | -p | -s | -f address_family ] [-n] [-P protocol] netstat [ -i ] [ -I interface ] [ interval ] netstat -r [-a] [-n] [-v ] netstat -M [-n] [-s ] netstat -D [ -I interface ] -a Show the state of all sockets and all routing table entries; normally, sockets used by server processes are not shown and only interface, host, network, and default routes are shown. Show network addresses as numbers. netstat normally displays addresses as symbols. This option may be used with any of the display formats. Verbose. Show additional information for the sockets and the routing table. Show the multicast group memberships for all interfaces. Show the STREAMS statistics. Show the address resolution (ARP) tables. Show per-protocol statistics. When used with the -M option, show multicast routing statistics instead.

-n

-v -g -m -p -s

20

-i -r -M -d -D

Show the state of the interfaces that are used for TCP/IP traffic. Show the routing tables. Show the multicast routing tables. When used with the -s option, show multicast routing statistics instead. Show the state of all interfaces that are under Dynamic Host Configuration Protocol (DHCP) control. Show the status of DHCP configured interfaces.

-f imit statistics or address control block reports to those of the address_family specified address_family, which can be one of: inet For the AF_INET address unix For the AF_UNIX address family -P protocol - I interface family

Limit display of statistics or state of all sockets to those applicable to protocol. Show the state of a particular interface. interface can be any valid interface such as ie0 or le0.

IfConfig The "ifconfig" command allows the operating system to setup network interfaces and allow the user to view information about the configured network interfaces. SYNTAX ifconfig [-L] [-m] interface [create] [address_family] [address[/prefixlength] [dest_address]] [parameters] ifconfig interface destroy ifconfig -a [-L] [-d] [-m] [-u] [address_family] ifconfig -l [-d] [-u] [address_family] ifconfig [-L] [-d] [-m] [-u] [-C] Address For the DARPA-Internet family, the address is either a host name present in the host name data base, or a DARPA Internet address expressed in the Internet standard ``dot notation''. It is also possible to use the CIDR notation (also known as the slash notation) to include the netmask. That is, one can specify an address like 192.168.0.1/16.

21

addres_family

Specify the address family which affects interpretation of the remaining parameters. Since an interface can receive transmissions in differing protocols with different naming schemes, specifying the address family is recommended. The address or protocol families currently supported are ``inet'', ``inet6'', Specify the address of the correspondent on the other end of a point to point link. This parameter is a string of the form ``name unit'', for example, ``en0''.

dest_address Interface

Conclusion: The Networking commands will get implemented\

ExperimentNo. 4 Aim : Implementation of data link layer issues for error control Objective: The main aim of the data link layer is to provide the Services to the network layer and physical layer .It mainly deals with Framing, Error Control flow

22

Control. To implement these issues we have different algorithms like bits stuffing, character stuffing, cyclic redundancy check, reminder generator. Tools: Softwares:C programming Editor Operatingsystem: windows ExperimentDescription Provide service interface to the network layer, dealing with transmission errors Regulating data flow slow receivers not swamped by fast senders Functions of the Data Link layer

FramingBit stuffing is the insertion of one or more bits into a transmission unit as a way to provide signaling information to a receiver. The receiver knows how to detect and remove or disregard the stuffed bits.

Bit stuffing (a) The original data. (b) The data as they appear on the line. 23

(c) The data as they are stored in receivers memory after destuffing Program:Bit Stuffing int main() { int a[20],b[30],i,j,k,count,n; //clrscr(); printf("Enter frame length:"); scanf("%d",&n); printf("Enter input frame (0's & 1's only):"); for(i=0;i<n;i++) scanf("%d",&a[i]); i=0; count=1; j=0; while(i<n) { if(a[i]==1) { b[j]=a[i]; for(k=i+1;a[k]==1 && k<n && count<5;k++) { j++; b[j]=a[k]; count++; if(count==5) { j++; b[j]=0; } i=k; }} else { b[j]=a[i]; } i++; j++; } printf("After stuffing the frame is:"); for(i=0;i<j;i++) printf("%d",b[i]); getch(); }

24

Input: Enter frame length: 10 Enter input frame (0's & 1's only): 1010111111 Output After stuffing the frame is: 10101111101 CharacterStuffing Although using characters to mark the beginning and end of each frame has advantages, most Computer networks cannot afford to reserve characters for use by the network. Instead, the network permits an application to transfer arbitrary data values across the network. In particular, an application may choose to send data that contains one or more occurrences of characters that are used for framing. In general, to distinguish between data being sent and control information such as frame delimiters, network systems arrange for the sending side to change the data slightly before it is sent, and then arrange for the receiving side to restore the original data before passing it to the receiving application. Use reserved characters to indicate the start and end of a frame. For instance, use the two-character sequence DLE STX (Data-Link Escape, Start of TeXt) to signal the beginning of a frame, and the sequence DLE ETX (End of TeXt) to flag the frame's end. main() { int i=0,j=0,n,pos; char a[20],b[50],ch; clrscr(); printf("enter string\n"); scanf("%s",&a); n=strlen(a); printf("enter position\n"); scanf("%d",&pos); if(pos>n) { printf("invalid position, Enter again :"); scanf("%d",&pos); } printf("enter the character\n"); ch=getche();

25

b[0]='d'; b[1]='l'; b[2]='e'; b[3]='s'; b[4]='t'; b[5]='x'; j=6; while(i<n) { if(i==pos-1) { b[j]='d'; b[j+1]='l'; b[j+2]='e'; b[j+3]=ch; b[j+4]='d'; b[j+5]='l'; b[j+6]='e'; j=j+7; } if(a[i]=='d' && a[i+1]=='l' && a[i+2]=='e') { b[j]='d'; b[j+1]='l'; b[j+2]='e'; j=j+3; } b[j]=a[i]; i++; j++; } b[j]='d'; b[j+1]='l'; b[j+2]='e'; b[j+3]='e'; b[j+4]='t'; b[j+5]='x'; b[j+6]='\0'; printf("\nframe after stuffing:\n"); printf("%s",b); getch();

26

} INPUT: enter string: asdlefgh enter position: 8 invalid position,enter again: 3 enter the character: k

OUTPUT: frame after stuffing: dlestx as dle k dle dle dlefgh dleetx

Conclusion: The Error control transmission of frames can be achieved.

27

Experiment5 Aim:Building Ethernet using simulator Ethernet (A Direct Link Network with Media Access Control) Objective: This lab is designed to demonstrate the operation of the Ethernet network. The simulation in this lab will help you examine the performance of the Ethernet Networkunderdifferentscenarios .

Tools Softwares : Open IT 9.1 Academic Simulation Edition Hardwares: Connected LAN Operatingsystem : Any windows

ExperimentDescription: Createa NewProject To create a new project for the Ethernet network: 1. Start OPNET IT Guru Academic Edition Choose New from the File menu. 2. Select Project Click OK Name the project <your initials>_Ethernet, and the scenario Coax Click OK. 3. In the Startup Wizard: Initial Topology dialog box, make sure that Create Empty Scenario is selected Click Next Choose Ofce from the Network Scale list Click Next Assign 200 to X Span and keep Y Span as 100 Click Next twice Click OK. 28

4. Close the Object Palette dialog box. Createthe Network 1. To create our coaxial Ethernet network: 2. To create the network conguration, select Topology Rapid 3. Conguration. From the drop-down menu choose Bus and click OK. 4. Click the Select Models button in the Rapid Con guration dialog box. From 5. The Model List drop-down menu choose ethcoax and click OK. 6. In the Rapid Conguration dialog box, set the following eight values and 7. click OK

29

4. To congure the coaxial bus, right-click on the horizontal link Select Advanced Edit Attributes from the menu: a. Click on the value of the model attribute Select Edit from the drop-down menu Choose the eth_coax_adv model. b. Assign the value 0.05 to the delay attribute (propagation delay in sec/m). c. Assign 5 to the thickness attribute. d. Click OK.

5. Now you have created the network. It should look like the illustration below. 6. Make sure to save your project.

30

congurethe NetworkNodes To congure the trafc generated by the nodes: 1. Right-click on any of the 30 nodes Select Similar Nodes. Now all nodes in the network are selected. 2. Right-click on any of the 30 nodes Edit Attributes. 3. Check the Apply Changes to Selected Objects check box. This is important to avoid reconguring each node individually. 4. Expand the Trafc Generation Parameters hierarchy: a. Change the value of the ON State Time to exponential(100) Change the value of the OFF State Time to exponential(0).(Note: Packets are generated only in the ON state.) 5. Expand the Packet Generation Arguments hierarchy: a. Change the value of the Packet Size attribute to constant(1024). b. Right-click on the Interarrival Time attribute and choose Promote Attribute to Higher Level. This allows us to assign multiple values to the Interarrival Time attribute and hence to test the network performance under different loads.

31

6. ClickOKto returnbackto the ProjectEditor. 7. Makesureto saveyourproject Congurethe Simulation To examine the network performance under different loads, you need to run the simulation several times by changing the load into the network. There is an easy way to do that. Recall that we promoted the Interarrival Time attribute for package generation. Here we will assign different values to that attribute: 1. Click on the Congure/Run Simulation button: 2. Make sure that the Common tab is chosen Assign 15 seconds to the Duration.

32

3. Click on the Object Attributes tab. 4. Click on the Add button. The Add Attribute dialog box should appear lled with the promoted attributes of all nodes in the network (if you do not see the attributes in the list, close the whole project and reopen it). You need to add the Interarrival Time attribute for all nodes. To do that: a. Click on the rst attribute in the list (Ofce Network.node_0.Traf c Generation ) Click the Wildcard button Click on node_0 and choose the asterisk (*) from the drop-down menu Click OK. b. A new attribute is now generated containing the asterisk (the second one in the list), and you need to add it by clicking on the corresponding cell under the Add? column. c. The Add Attribute dialog box should look like the following. Click OK.

33

5. Now you should see the Ofce Network.*.Trafc Generation Parameter in the list of simulation object attributes. Click on that attribute to select it Click the Values button of the dialog box. 6. Add the following nine values. (Note: To add the rst value, double-click on the rst cell in the Value column Type exponential (2) into the textbox and hit enter. Repeat this for all nine values.)

34

7. Click OK. Now look at the upper-right corner of the Simulation Con guration dialog box and make sure that the Number of runs in set is 9.

8. For each simulation of the nine runs, we need the simulator to save a scalar value that represents the average load in the network and to save another scalar value that represents the average throughput of th

35

network. To save these scalars we need to congure the simulator to save them in a le. Click on the Advanced tab in the Con gure Simulation dialog box. 10. Assign <your initials>_Ethernet_Coax to the Scalar le text eld.

10. Click OK and then save your project. oose the Statistics hoose the statistics to be collected during the simulation: 1. Right-click anywhere in the project workspace (but not on one of the nodes or links) and select Choose Individual Statistics from the pop-up menu Expand the Global Statistics hierarchy. a. Expand the Trafc Sink hierarchy Click the check box next to Trafc Received (packets/sec) (make sure you select the statistic with units of packets/sec). b. Expand the Trafc Source hierarchy Click the check box next to Trafc Sent (packets/sec). c. Click OK. 2. Now to collect the average of the above statistics as a scalar value by the end of each simulation run:

36

a. Select Choose Statistics (Advanced) from the Simulation menu. b. The Trafc Sent and Trafc Received probes should appear under the Global Statistic Probes. c. Right-click on Trafc Received probe Edit Attributes. Set the scalar data attribute to enabled Set the scalar type attribute to time average Compare to the following gure and click OK. d. Repeat the previous step with the Traf c Sent probe. e. Select save from the File menu in the Probe Model window and then close that window. f. Now you are back to the Project Editor. Make sure to save your project.

Run the Simulation To run the simulation: 1. Click on the Congure/Run Simulation button: Make sure that 15 second(s) (not hours) is assigned to the Duration Click Run. Depending on the speed of your processor, this may take several minutes to complete. 37

2. Now the simulator is completing nine runs, one for each traf c generation interarrival time (representing the load into the network). Notice that each successive run takes longer to complete because the traf c intensity is increasing. 3. After the nine simulation runs complete, click Close. 4. Save your project. When you rerun the simulation, OPNET IT Guru will append the new results to the results already in the scalar le. To avoid that, delete the scalar le before you start a new run. (Note: Deleting the scalar le after a run will result in losing the collected results from that run.) Go to the File menu Select Model Files Delete Model Files Select (.os): Output Scalars Select the scalar le to be deleted; in this lab it is <your initials>_Ethernet_Coax Conrm the deletion by clicking OK Click Close. View the Results To view and analyze the results: 1. Select View Results (Advanced) from the Results menu. Now the Analysis Conguration tool is open. 2. Recall that we saved the average results in a scalar le. To load this le, select Load Output Scalar File from the File menu Select <your initials>_Ethernet-Coax from the pop-up menu. 3. Select Create Scalar Panel from the Panels menu Assign Trafc Source.Trafc Sent (packets/sec).average to Horizontal Assign Trafc Sink.Trafc Received (packets/sec).average to Vertical Click OK

38

39

Experiment7 Aim: Designing and implementation of encryption and decryption Algorithms Objective: Make the student to send the packet errorless and securely. Keeping in that intension make him todo design the encryption and decryption algorithms using RSA as it is one of the standard secured algorithm. Tools: Softwares: Any c editor Hardware : Connected LAN lab OperatingSystem: Windows Version o o o o o o o o o Public key algorithm invented in 197 by Ron Rivest, Adi Shamir and Leonard Adleman (RSA) Sup orts Encryption and Digital Signatures Most widely used public key algorithm Gets its security from integer factorization problem Relatively easy to understand and implement Patent fre (since 20 0) Program Description :\

RSAAlgorithm
/* C program for the Implementation Of RSA Algorithm */ #include< stdio.h> #include< conio.h> int phi,M,n,e,d,C,FLAG; int check() { int i; for(i=3;e%i==0 && phi%i==0;i+2) { FLAG = 1; 40

return; } FLAG = 0; } void encrypt() { int i; C = 1; for(i=0;i< e;i++) C=C*M%n; C = C%n; printf("\n\tEncrypted keyword : %d",C); } void decrypt() { int i; M = 1; for(i=0;i< d;i++) M=M*C%n; M = M%n; printf("\n\tDecrypted keyword : %d",M); } void main() { int p,q,s; clrscr(); printf("Enter Two Relatively Prime Numbers\t: "); scanf("%d%d",&p,&q); n = p*q; phi=(p-1)*(q-1); printf("\n\tF(n)\t= %d",phi); do { printf("\n\nEnter e\t: "); scanf("%d",&e); check(); }while(FLAG==1); d = 1; do {

41

s = (d*e)%phi; d++; }while(s!=1); d = d-1; printf("\n\tPublic Key\t: {%d,%d}",e,n); printf("\n\tPrivate Key\t: {%d,%d}",d,n); printf("\n\nEnter The Plain Text\t: "); scanf("%d",&M); encrypt(); printf("\n\nEnter the Cipher text\t: "); scanf("%d",&C); decrypt(); getch(); } /*************** OUTPUT ***************** Enter Two Relatively Prime Numbers : 7 17 F(n) = 96 Enter e : 5 Public Key : {5,119} Private Key : {77,119} Enter The Plain Text : 19 Encrypted keyword : 66 Enter the Cipher text : 66 Decrypted keyword : 19 */

Conclusion: The encryption and decryption can be achieved by using RSA.

42

References 1. Computer networks by s. Tanambaum, PHI, 2009 2. Data and computer communication by William stallings, 2008, pearson education 3. Computer network by sanjay sharma, S.kataria and sons , 2011, new delhi 4. Computer Networks: A Systematic Approach by Larry L. Peterson , Bruice S.Davi ,3rd Edition , Morgan Kauffman Publishers. 5. Data & computer Networks Communications, Shashi Banzal ,1 st Edition -2007 ,Firewall Media. 6. Cryptography and Network Security by willima stallings 3 rd Edition -2007 Academic Authors Association. Websites 1. 2. 3. 4. 5. www.ietf.org/rfc.html http://www.spsu.ac.in/Laboratory_details/labd/CS/IT-302-LM.pdf http://cppgm.blogspot.com/2008/01/rsa-algorithm.html http://williamstallings.com/Crypto3e.html http://technolamp.blogspot.com/p/jntu-lab-manuals-for-cse-it-ece-andeee.html

43

Potrebbero piacerti anche