Вы находитесь на странице: 1из 32

Networking Laboratory Experiments

1. Preparation Of Network Cables

2. Point To Point Connection

3. Establishing Console Session

4. Establishing Telnet Session

5. Basic Configurations For Switch

6. Basic Configurations For Router

7.Configure SSH Access On Switch

8.Password Recovery Procedure For Cisco Devices

9.Configuration Of Application Servers

10. Rip Protocol Configuration , Verification Commands


1. PREPARATION OF NETWORK CABLES

Objective

To prepare straight through, cross over cable using twisted pair cable and to check continuity.

Materials Required

Twisted pair cable - 1 Mt., RJ-45 Connectors 4No. Crimping Tool- 1No. Cable Tester- 1No.

Procedure: Straight Trough Cable

Take the Twisted Pair cable remove the plastic sheath over both ends of the cable.
Untwist the 4 pairs, remove the crimps straighten it assemble it as per color code for Straight
through cable. Trim the edges of the assembled pairs insert into the RJ 45 connector then insert
into the crimping tool at the 8P provision apply sufficient pressure to ensure proper crimping.

Cross Over Cable

Remove the plastic sheath over the cable at the both ends. Untwist the pairs, remove the
crimps straighten the individual wires and assemble as per color code for cross over cable. Trim
the edges insert the assembled wires into the RJ 45 connector then insert the connector along
with the wire in the 8P provision given in the crimping tool. Crimp the wire with the connector
using proper pressure on the tool.

Testing

Check both the cables for continuity, open or short using the cable tester. Insert one end
of the cable to the master side, other end to the remote side, press the test button. For straight
through cable LED indicator at both master, remote side glow parallel from pin 1 to pin 8 which
indicates proper crimping. For cross over cable when LED 1 glows other end LED 3 should
glow, for LED 2 other end LED 6 should glow, pin 4,5,6,7,8 show glow on both the ends
parallel.

Data Terminal Equipement (Dte)

It is an end instrument converts information into signal and vice versa. Also called as tail
instrument. Communicates with Data Circuit- terminating equipment. Any deice that is a source
or destination for digital data is called as DTE.
Examples are Hosts (pc, servers & printers, fax.), routers and wireless routers.

DATA CIRCUIT-TERMINATING EQUIPEMENT


(OR)
DATA COMMUNICATION EQUIPEMENT
(OR)
DATA CARRIER EQUIPEMENT

DCE devices are Switches, Hubs and Modems.

DCE + transmission circuit + DTE.


Result:

Straight through, cross over cable prepared. Connectivity tested.


2. POINT TO POINT CONNECTION

Objective

To establish peer-to-peer connection, Monitor the Network using Wireshark.

Basic Requirement

1.Two systems with Windows 7 O/S.


2.Cross over cable.
3.Wireshark software.

Operation

1.Start Wireshark and run it.


2. Connect two systems through the cross over cable .
3.Start-> Control panel->Network and Internet >Network and sharing center-> left hand side find
Change adapter setting.
4.Local Area Connection->Right click->Properties-> Choose Internet protocol
version4(TCP/IPv4)->click properties.
5.Select use the following IP address Ex:IP address 10.0.0.1, Subnet mask 255.0.0.0. Default
gateway : 10.0.0.2.
6.Follow same procedure on the other PC with next IP Ex:IP address as 10.0.0.2 and Subnet
mask 255.0.0.0. Default Gateway 10.0.0.1.
7..Start->Control Panel->Network and sharing center.
8.Choose home group and sharing options->Click what is network location.
9.Select Home network->Select what you want to share->click next->Finish.

To Check

10.Start->Type cmd->Type the command at prompt->Ping next PC IP address you should get
ping results at the screen.

File Sharing

11.Start ->choose computer->click network icon on the left hand side->Right hand icon of
systems on home group will be displayed . Click Neighbor PC to see the sharing files.
To Share Files In The System

12.Start->Computer->Select the drive from which you want to share the file and right click the
drive (or) the file you want to share->Choose share with if you want to share the drive ->Right
click->Share with->Advanced sharing->Select the share the folder->Apply->OK->Close.

To Access This Shared File From Another System

13.Start->Computer->Network->click the neighbor PC see the shared folder copy paste to where
you want to keep.

Revert To Original State

1.Start->Computer->Select the drive(or) the file shared-Right click->Sharing with Advanced


sharing->Advanced sharing->Uncheck the share this folder option->OK.
2.Start->Control panel->Network and sharing center->Change Adapter settings ->Select Local
Area Connection->Right click->Properties->Select IPv4->Choose properties->Choose obtain IP
address automatically->Choose obtain DNS server address automatically.
3.Unplug the cross over cable .
4.Plug the Internet cable.

Result:

Peer-to-peer Network established. Network monitored using Wireshark.


3. ESTABLISHING CONSOLE SESSION
Objective

1. To establish console session using Cisco packet tracer.


2. To establish console session in real time.
Requirement:
Cisco Packet Tracer, Desktop, Switch. Console Cable.

Procedure:
1. Establishing Console Session Using Cisco Packet Tracer
Start cisco packet tracer. Click end devices icon in the device type selection box
window, drag and drop generic PC-PT (desktop) (from device specific selection box) in to the
logical workspace. Click switches icon in the device type selection window and click 2960
switch drag and drop into the logical workspace from the device specific selection box.
Click connections icon in the device type selection box, choose console cable light blue
bend symbol. (mouse icon will change to cable shape) Keep your mouse over PC click it
interface options will be displayed choose RS232 and move the cursor to the switch click it
interface options will be displayed click console option. Click on PC Physical, Config, Desktop
options will be displayed select Desktop option under which choose Terminal option, Terminal
Configuration window will be open ensure the settings for port configurations as follows: 1. Bits
per Second: 9600; Data Bits: 8; Parity : None; Stop bits: 1; Flow Control : None; Then Click
OK icon.
Terminal Window will display the booting and prompt messages. Press enter key when prompt
for Press RETURN to get started.
2. Establishing Console Session Using Switch (Realtime)
The console cable consist of DB 9 end (RS232, serial) other side RJ 45 connector end. Connect
the DB 9 connector side to the CPU serial port (behind the CPU). RJ 45 side to switch console
port. Power on the switch. In the desktop start search type putty click putty.exe and run it. Right
hand side connection type option will be displayed choose click serial option click open option.
COM1-putty window will be open it will show the booting process of the switch followed by the
switch prompt.
Result:
1. Console session established. 2. Console session in realtime mode established.
4. ESTABLISHING TELNET SESSION
Objective

1. To establish telnet session using Cisco packet tracer.


2. To establish telnet session in real time.

Requirement:
Cisco Packet Tracer, Desktop, Switch. Console Cable.
Procedure:
1. Establishing Telnet Session Using Cisco Packet Tracer
Using the console session configure the line vty password, enable password, and assign
IP address to the PC for example (192.168.108.2) switch vlan1 (192.168.108.1). Connect a
FastEthernet cable from the PC to the switch port. From the PC command window type Telnet
192.168.108.1 . Connection will be established. You will be prompted to enter line VTY
password, enter the password. Switch prompt will be displayed. To switch over to privileged
mode enable password will required.
2. Establishing Telnet Session Using Switch (Realtime)
Start and run wireshark then procede to carry out following steps:
The console cable consist of DB 9 end (RS232, serial) other side RJ 45 connector end. Connect
the DB 9 connector side to the CPU serial port (behind the CPU). RJ 45 side to switch console
port. Power on the switch. In the desktop start search type putty click putty.exe and run it. Right
hand side connection type option will be displayed choose click serial option click open option.
COM1-putty window will be open it will show the booting process of the switch followed by the
switch prompt.
Establish the console session configure IP address for the switch, enable password, line vty
password save the configuration.
Connect RJ45 cable to PC NIC card and other end to the switch port.
Open command prompt in the system use the command :
c:\> telnet IP address of the switch.
System will prompt for login password enter the line vty password.

If connection is not established enable telnet service in the Windows OS 7, start the Telent
service and add telnet clients to the group. The steps are as follows:
1.Start -> Control panel-> Programs-> Turn windows features on or off
2. Windows features-> To select the Telnet Client and server-> ok.
3.Computer-> Right click -> Manage->Services and Applications-> Services->Double
click-> Telnet->Right click ->Properties->Startup type as automatic->Apply-
>Start ->ok.
4.Computer->Right click-> Manage-> Local users and Groups->select ->Group->Double
click->Telnet clients-> Properties->Add->Advanced ->Find Now-> Everyone->ok.

Once logged in to the switch.


Stop the wireshark capture filter the telnet activates. Select any one of the packet follow TCP
stream you can visuvalize the telnet password you have entered.

This proves that telnet is vulnerable.

Result:

1. Telnet session established. 2. Telnet session in real-time mode established.


5. BASIC CONFIGURATIONS FOR SWITCH
Objective:

To learn Internetworking Operating System commands to confiure a Network Switch.

Establish console session

Configuration commands can be stored in a file by enabling logging in the terminal software for
example putty. Option available at the left hand corner of the putty window. Under Session->
logging. Right hand side window show the options Controlling Session logging . Under session
logging select all session output. Name the file to be saved in the browse option space.

Switch> enable
Switch# show flash
Switch# delete vlan.dat
Switch# erase startup-config
Switch# reload
Switch>enable
Switch# configure terminal
Switch(config)#hostname S1
S1(config)# Service password- encryption
S1(config)# enable secret (CISCO)
S1(config)# no ip domain-lookup
S1(config)# banner motd # message # (C) OR " "
S1#copy running-configuration startup-configuration
S1(config)# exit

S1(config)#line console 0
S1(config-line)# password password
S1(config)# exec time out value in minutes
S1(config-line)# login
S1(config-line)# logging synchronous
S1(config-line)#exit

S1(config)# line vty 0 15


S1(config-line)# password password
S1(config-line)# exec_time out value in minutes
S1(config-line)# login
S1(config-line)# end

S1(config)# ip default- gateway ip address


S1#copy running-configuration startup-configuration

S1(config)# interface vlan 1


S1(config –if)# ip address ip addrss subnetmask
S1(config-if)# no shutdown
S1(config-if )# exit

Important Show Commands

Switch# Show running-config


Switch# Show startup-config
Switch# show ip interface vlan 1
Switch# show ip interface brief
Switch# show vlan brief
Switch# show flash
Switch# dir flash

Result

Learned and configured IOS commands for a Network Switch.


6. BASIC CONFIGURATIONS FOR ROUTER
Objective

To learn Internetworking operating System Commands (IOS) to configure a Router.

Establish Console Session To Configure The Router

Router> enable
Router# show flash
Router# delete vlan.dat
Router# erase startup-config
Router# reload
Router>enable
Router# configure terminal
Router(config)#hostname R1
R1(config)# Service password encryption
R1(config)# enable secret password
R1(config)# no ip domain-lookup
R1(config)# banner motd # message #
R1(config)# exit

Configure console port , other line ports as the method used in switch configuration.

Configuration Of Gigabit Enthernet Interface

R1(config)# interface gigabitethernet 0/0


R1(config-if)# description ____________
R1(config-if) # ip address ip address subnetmask
R1(config-if)# no shutdown
R1(config-if)# exit
R1(config)# exit
r1# copy running-configuration startup-configuration

Configuration Of Serial Interface

R1(config)# interface serial 0/0/0


R1(config-if)# description link to __________
R1(config-if)# ip address IPV4ADDRESS SUBNETMASK
R1(config-if)# clock rate _______________
(In laboratory environment the serial interface connecting to the serial cable end labelled DCE
must be configured with the clock rate command).

R1(config-if)# no shutdown
R1(config-if)# exit.

Assigining Ipv6 Address

R1(config-if)#ipv6 enable
R1(config-if)# ipv6 address ipv6address / prefix length
R1(config-if)# ipv6 address ipv6address / prefix length eui-64
R1(config-if)# ipv6 address ipv6address / prefix length link-local

Enabling Loopback Interface

R1(config)# interface loopback 0


R1(config-if)# ip address ipaddress subnetmask
R1(config-if)# exit

Interface Settings Verification Commands

show ip interface brief


show ip route
show running-configuration interface ____________
show ip interface
show ipv6 routers

Filtering Commands

R1# show running-configuration | section line vty

R1# show ip interface brief | include up


R1# show ip interface brief | exclude unassigned
R1# show ip route | begin gateway

R1# show history


R1# terminal history size ______
7.CONFIGURE SSH ACCESS ON SWITCH
Objective:

To Configure a switch to access it remotely using Sechure Shell protocol.

S1(config)# ip domain-name cisco.com


S1(config)# username admin privilege 15 secret password
S1(config)# line vty 0 15
S1(config-line)# password cisco
S1(config-line)# transport input ssh
S1(config-line)# login local
S1(config-line)# exit
S1(config)# crypto key generate rsa

How many bits in the modulus[512] 1024


Command from PC to check ssh is working.
PC> ssh –l username ip address
password : password

S1# show ip ssh


S1# show ssh
8.Password recovery procedure for Cisco Devices

Objective

To learn password recovery procedure for Switch, Router.

Switch:

1.Establish console session


2. press mode button, power on the switch.
hold it till the SYST LED toggle from green to orange and orange to blinking green .
3. Switch Prompt will be switch:
4.Type
flash_init
load_helper
dir flash:
delete flash: /vlan.dat
Will be prompted to say [Yes/No ] choose YES.
5.Check the presence of config.text file.
6.Type delete flash: /config.text ->enter
Will be prompted to say [Yes/No ] choose YES.
7.Type boot.

Router:

1..Putty ->select serial ->open


2. Press Break on the terminal keyboard within 60 seconds of power up in
order to put the router into ROMMON.

. 3.If required rommon 1 > confreg 0x2142


4. rommon 2 > reset

Result:
Learned the password recovery procedure for Switch, Router.
9.CONFIGURATION OF APPLICATION SERVERS

Objective:

To configure and setup application layer services/servers DHCP, DNS, MAIL, WEB, FTP.

Connect as per scenario. Add serial interface card to gateway router connect the cable to the
cloud. Up the interface s0/1/0 by issuing the no shutdown command. Assign the IP address to
G0/0 192.168.1.1 255.255.255.0.

Server (DHCP, DNS 192.168.1.254)

Assign IP address 192.168.1.254, SNM: 255.255.255.0. Default Gateway: 192.168.1.1, DNS


Server: 192.168.1.1.

Server (mail 192.168.1.252)

Assign IP address 192.168.1.252, SNM: 255.255.255.0. Default Gateway: 192.168.1.1, DNS


Server: 192.168.1.254.
Server (Web, FTP)

Assign IP address 192.168.1.253, SNM: 255.255.255.0 . Default Gateway: 192.168.1.1, DNS


Server: 192.168.1.254.

To configure DHCP service in DHCP Server

Click on the DHCP server - click services- DHCP - off the service. Assign the Pool name :
DONOT CHANGE THE POOL NAME LEAVE IT AS ServerPool Assign Default Gateway
address : 192.168.1.1. DNS Server address: 192.168.1.254. Start IP address: 192.168.1.50,
Subnetmask : 255.255.255.0 . Maximum No. of Users : 50 . Save the settings by clicking the
Save icon. ON the DHCP service.

Configure Web Service In Web Server

Click on web server - click services - HTTP - select index.html file in the right hand side modify
and save it. Ensure HTTP service is ON. Click one of the PC click Desktop option click web
browser type the web server IP address 192.168.1.253 in the URL. Web page will be open. Try
with the name of web page, it will not display the web page instead it will say DNS not
configured.

Configure Dns Server

Record Type: A Record

Click the DNS Server . ON the DNS services. Under resource records select the Type as A
Record. In the name option type vimal.com. At the address bar type 192.168.1.253. Click Add
icon.

Record Type : CNAME

Type www.vimal.com in the Record Name. Hostname : vimal.com. Click Add icon.

Record Type: NS

Type ns1.vimal.com in the Name. Server Name Type the name of the Server click the Add icon.

Record Type: SOA

On the DNS service. Resource Record Name vimal.com Type SOA. Primary Server Name :
ns1.vimal.com. Mail Box: Webadmin.vimal.com. Minimum TTL 3600. Referesh Time 3600
Retry Time : 600. Expiry Time: 86400. Click the ADD icon .
Testing:

From the command prompt in the PC type nslookup at the prompt > type vimal.com check the
DNS details as Server: [192.168.1.254], Address: 192.168.1.254. non-authoritative answer:
name: vimal.com, Address: 192.168.1.253.

Configuration For Ftp

Click FTP server. Click services- FTP. ON the service. UserName: vimal, Password: Vimal.
Check the options for write, Read, Delete, Rename, List.

Testing:

From PC go to command prompt type ftp 192.168.1.253. Connected prompt will be displayed. It
will check the username, password. Username: Vimal; Password: Vimal.
ftp> help (To see ftp commands)

ftp> get filename (Once the file is transferred type exit command at the ftp prompt).

ftp>exit

ftp>quit

Create any document in the PC using text editor for example hello world save in the PC .

Login to the server.

PC> ftp vimal.com , username: vimal. Password : vimal.

ftp> put hello.txt (file name) .

Check the file is present in the ftp server.

Mail Server

Click on Mail Server - Services - Email - ON the SMTP, POP3 services. Domain Name :
mail.vimal . Create users user vimal, Password : vimal click the + icon. Create next user. User:
Cisco; Password: Cisco. Click the + icon.

Configuration on DNS server for mail details

Click DNS server ON the DNS service . Under Resource Records: Type the details for Name,
Address, Type o f Record . Type: A Record. Name: mail.vimal.com. Address: 192.168.1.252.
Click the icon ADD.
Configuration for email in the PC

Click PC - Desktop - Email - Configure Email - Under User Information username: vimal;
email address: vimal@mail.vimal.com. I

Under Server Information

Incoming mail server: mail.vimal.com. Outgoing mail Server: mail.vimal.com.

Under logon Information

User Name: vimal

Password: vimal

click Save icon.

Under Mail Browser Compose - send.

To check click the Receive icon under mail Browser.

Result:

Configured and setup application layer services/servers DHCP, DNS, MAIL, WEB, FTP
10. RIP PROTOCOL CONFIGURATION , VERIFICATION COMMANDS

Objective:

To configure Routing Information Prtotocol and verify the router.

R1(config)#router rip

R1(config-router)#network 192.168.1.0

Verifying Rip Settings

R1#show ip protocols
R1#show ip route
R1#show ip route |begin gateway
Ripv2 Enable And Verify

R1(config )# router rip


R1(config-router)#version 2
R1#show ip route |section default
R1#show ip route |begin gateway
Disabling Auto Summary

R1(config)#router rip
R1(config-router)# no auto-summary
R1(config-router)# end
Passive-Interface Configuration

R1(config)# router rip


R1(config-router)# passive-interface g0/0
R1(config-router)# end
R1# show ip protocols | begin Default
R2# show ip protocols

Result:
Configured router for Routing Information Protocol (RIP).
11.To create scenario and study the performance of CSMA/CD protocol simulation

Objective:

To study and simulate the CSMA/CD protocol.

Algorithm :
• Create a simulator object.
• Define different colors for data flows (for NAM) and nodes
• Label the nodes
• Open a nam trace file and define finish procedure then close the trace file, and
execute nam on trace file.
• Create six nodes that forms a network numbered from 0 to 5
• Create duplex links between the nodes and add Orientation to the nodes for
setting a LAN topology
• Setup TCP Connection between n(0) and n(2) , n(1) and n(2) , n(1) and n(0) , n(0)
and n(1) and apply FTP Application over TCP
• Schedule events to achieve CSMA/CD scenario

Program:
#send packets one by one
set ns [new Simulator]
$ns color 1 Green
foreach i " 0 1 2 3 4 5 " {
set n$i [$ns node]
}
$n0 color "purple"
$n1 color "purple"
$n2 color "violet"
$n3 color "violet"
$n4 color "chocolate"
$n5 color "chocolate"
$n0 shape box ;
$n1 shape box ;
$n2 shape box ;
$n3 shape box ;
$n4 shape box ;
$n5 shape box ;
$ns at 0.0 "$n0 label SYS1"
$ns at 0.0 "$n1 label SYS2"
$ns at 0.0 "$n2 label SYS3"
$ns at 0.0 "$n3 label SYS4"
$ns at 0.0 "$n4 label SYS5"
$ns at 0.0 "$n5 label SYS6"
set nf [open csma.nam w]
$ns namtrace-all $nf
set f [open csma.tr w]
$ns trace-all $f
$ns duplex-link $n0 $n2 0.1Mb 20ms DropTail
$ns duplex-link-op $n0 $n2 orient right-down
$ns queue-limit $n0 $n2 5
$ns duplex-link $n1 $n2 0.1Mb 20ms DropTail
$ns duplex-link-op $n1 $n2 orient right-up
$ns duplex-link $n2 $n3 0.1Mb 20ms DropTail
$ns duplex-link-op $n2 $n3 orient right
$ns duplex-link $n3 $n4 0.1Mb 20ms DropTail
$ns duplex-link-op $n3 $n4 orient right-up
$ns duplex-link $n3 $n5 0.1Mb 20ms DropTail
$ns duplex-link-op $n3 $n5 orient right-down
Agent/TCP set nam_tracevar_ true
set tcp [new Agent/TCP]
$tcp set window_ 1
$tcp set maxcwnd_ 1
$tcp set fid_ 1
$ns attach-agent $n0 $tcp
set sink [new Agent/TCPSink]
$ns attach-agent $n2 $sink
$ns connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
set tcp1 [new Agent/TCP]
$tcp1 set window_ 1
$tcp1 set maxcwnd_ 1
$tcp1 set fid_ 1
$ns attach-agent $n1 $tcp1
set sink1 [new Agent/TCPSink]
$ns attach-agent $n2 $sink1
$ns connect $tcp1 $sink1
set ftp1 [new Application/FTP]
$ftp1 attach-agent $tcp1
set tcp2 [new Agent/TCP]
$tcp2 set window_ 1
$tcp2 set maxcwnd_ 1
$tcp2 set fid_ 1
$ns attach-agent $n1 $tcp2
set sink2 [new Agent/TCPSink]
$ns attach-agent $n0 $sink2
$ns connect $tcp2 $sink2
set ftp2 [new Application/FTP]
$ftp2 attach-agent $tcp2
set tcp3 [new Agent/TCP]
$tcp3 set window_ 1
$tcp3 set maxcwnd_ 1
$tcp3 set fid_ 1
$ns attach-agent $n0 $tcp3
set sink3 [new Agent/TCPSink]
$ns attach-agent $n1 $sink3
$ns connect $tcp3 $sink3
set ftp3 [new Application/FTP]
$ftp3 attach-agent $tcp3
$ns at 0.05 "$ftp start"
$ns at 0.071 "$ns queue-limit $n2 $n0 0"
$ns at 0.10 "$ns queue-limit $n2 $n0 5"
$ns at 0.09 "$ns detach-agent $n0 $tcp ; $ns detach-agent $n2 $sink"
$ns at 0.25 "finish"
$ns at 0.05 "$ftp1 start"
$ns at 0.072 "$ns queue-limit $n2 $n1 0"
$ns at 0.10 "$ns queue-limit $n2 $n1 5"
$ns at 0.09 "$ns detach-agent $n1 $tcp1 ; $ns detach-agent $n2 $sink1"
$ns at 0.25 "finish"
$ns at 0.10 "$ftp2 start"
$ns at 0.13 "$ns detach-agent $n0 $tcp2 ; $ns detach-agent $n1 $sink2"
$ns at 0.25 "finish"
$ns at 0.12 "$ftp3 start"
$ns at 0.14 "$ns detach-agent $n1 $tcp1 ; $ns detach-agent $n0 $sink3"
$ns at 0.25 "finish"
$ns at 0.0 "$ns trace-annotate \"CSMA/CA\""
$ns at 0.05 "$ns trace-annotate \"FTP starts at 0.01\""
$ns at 0.05 "$ns trace-annotate \"Send Packet_1 from SYS1 to SYS0 and Packet_2 from SYS0 to
SYS1 \""
$ns at 0.073 "$ns trace-annotate \"Collision Occurs so 2 Packets are lossed\""
$ns at 0.10 "$ns trace-annotate \"Retransmit Packet_1 from SYS1 to SYS0 \""
$ns at 0.12 "$ns trace-annotate \"Retransmit Packet_2 from SYS0 to SYS1 \""
$ns at 0.20 "$ns trace-annotate \"FTP stops\""
proc finish {} {
global ns nf
$ns flush-trace
close $nf
puts "filtering..."
#exec tclsh ../bin/namfilter.tcl csma.nam
#puts "running nam..."
exec nam csma.nam &
exit 0
}
$ns run
Token bus protocol: To create scenario and study the performance of token bus through
simulation

Aim :

To Study The Performance Of Token Bus Using Ns2 Simulation


Algorithm :

• Create a simulator object , set Bandwidth 0.5 MB and packet size 700
• Define different colors for data flows (for NAM)
• Create seven nodes that forms a network numbered from 0 to 6 and label the
nodes for identifying sender and receiver
• Open a nam trace file and define finish procedure then close the trace file, and
execute nam on trace file.
• Create duplex links between the nodes and add Orientation to the nodes for
setting a LAN topology
• Setup TCP Connection between some nodes and apply FTP Application over
TCP
• Setup UDP Connection between some other nodes and apply CBR Application
over UDP
• Schedule events to achieve Token bus scenario and view graph for the
throughput calculated

Program:

set ns [new Simulator]


set Bandwidth "0.5Mb"
set packetsize 700
set intval 0.004
$ns color 1 magenta
$ns color 2 seagreen
$ns color 3 deepskyblue
$ns color 4 brown
$ns color 5 salmon
foreach i "0 1 2 3 4 5 6" {
set n$i [$ns node]
}
$n0 color "navy"
$n1 color "salmon"
$n2 color "seagreen"
$n3 color "deepskyblue"
$n4 color "steel blue"
$n5 color "steel blue"
$n6 color "steel blue"
$ns at 0.0 "$n0 label Sender"
$ns at 0.0 "$n1 label Receiver1"
$ns at 0.0 "$n2 label Receiver2"
$ns at 0.0 "$n3 label Receiver3"
set nf [open tokenbus.nam w]
$ns namtrace-all $nf
set f [open tokenbus.tr w]
$ns trace-all $f
$ns duplex-link $n0 $n5 $Bandwidth 30ms DropTail
$ns duplex-link $n5 $n2 $Bandwidth 30ms DropTail
$ns duplex-link $n4 $n1 $Bandwidth 30ms DropTail
$ns duplex-link $n4 $n5 $Bandwidth 30ms DropTail
$ns duplex-link $n5 $n6 $Bandwidth 30ms DropTail
$ns duplex-link $n6 $n3 $Bandwidth 30ms DropTail
$ns duplex-link-op $n0 $n5 orient down
$ns duplex-link-op $n5 $n2 orient down
$ns duplex-link-op $n4 $n1 orient down
$ns duplex-link-op $n4 $n5 orient right
$ns duplex-link-op $n5 $n6 orient right
$ns duplex-link-op $n6 $n3 orient down
$ns queue-limit $n4 $n5 10
set tcp1 [new Agent/TCP]
$ns attach-agent $n0 $tcp1
$tcp1 set fid_ 1 ;
set tcp2 [new Agent/TCP]
$ns attach-agent $n1 $tcp2
$tcp2 set fid_ 1 ;
set tcp3 [new Agent/TCP]
$ns attach-agent $n2 $tcp3
$tcp3 set fid_ 1 ;
set tcp4 [new Agent/TCP]
$ns attach-agent $n3 $tcp4
$tcp4 set fid_ 1 ;
set tcp5 [new Agent/TCP]
$ns attach-agent $n0 $tcp5
$tcp5 set fid_ 1 ;
set tcp6 [new Agent/TCP]
$ns attach-agent $n1 $tcp6
$tcp6 set fid_ 1 ;
set tcp7 [new Agent/TCP]
$ns attach-agent $n2 $tcp7
$tcp7 set fid_ 1 ;
set tcp8 [new Agent/TCP]
$ns attach-agent $n3 $tcp8
$tcp8 set fid_ 1 ;
set tcp9 [new Agent/TCP]
$ns attach-agent $n0 $tcp9
$tcp9 set fid_ 1 ;
set tcp10 [new Agent/TCP]
$ns attach-agent $n1 $tcp10
$tcp10 set fid_ 1 ;
set tcp11 [new Agent/TCP]
$ns attach-agent $n2 $tcp11
$tcp11 set fid_ 1 ;
set tcp12 [new Agent/TCP]
$ns attach-agent $n3 $tcp12
$tcp12 set fid_ 1 ;
set sink1 [new Agent/TCPSink]
$ns attach-agent $n1 $sink1
set sink2 [new Agent/TCPSink]
$ns attach-agent $n2 $sink2
set sink3 [new Agent/TCPSink]
$ns attach-agent $n3 $sink3
set sink4 [new Agent/TCPSink]
$ns attach-agent $n0 $sink4
set sink5 [new Agent/TCPSink]
$ns attach-agent $n1 $sink5
set sink6 [new Agent/TCPSink]
$ns attach-agent $n2 $sink6
set sink7 [new Agent/TCPSink]
$ns attach-agent $n3 $sink7
set sink8 [new Agent/TCPSink]
$ns attach-agent $n0 $sink8
set sink9 [new Agent/TCPSink]
$ns attach-agent $n1 $sink9
set sink10 [new Agent/TCPSink]
$ns attach-agent $n2 $sink10
set sink11 [new Agent/TCPSink]
$ns attach-agent $n3 $sink11
set sink12 [new Agent/TCPSink]
$ns attach-agent $n0 $sink12
$ns connect $tcp1 $sink1 $ns connect $tcp2 $sink2 $ns connect $tcp3 $sink3 $ns connect $tcp4
$sink4
$ns connect $tcp5 $sink5 $ns connect $tcp6 $sink6 $ns connect $tcp7 $sink7 $ns connect $tcp8
$sink8
$ns connect $tcp9 $sink9 $ns connect $tcp10 $sink10 $ns connect $tcp11 $sink11
$ns connect $tcp12 $sink12
set ftp1 [new Application/FTP]
$ftp1 attach-agent $tcp1
set ftp2 [new Application/FTP]
$ftp2 attach-agent $tcp2
set ftp3 [new Application/FTP]
$ftp3 attach-agent $tcp3
set ftp4 [new Application/FTP]
$ftp4 attach-agent $tcp4
set ftp5 [new Application/FTP]
$ftp5 attach-agent $tcp5
set ftp6 [new Application/FTP]
$ftp6 attach-agent $tcp6
set ftp7 [new Application/FTP]
$ftp7 attach-agent $tcp7
set ftp8 [new Application/FTP]
$ftp8 attach-agent $tcp8
set ftp9 [new Application/FTP]
$ftp9 attach-agent $tcp9
set ftp10 [new Application/FTP]
$ftp10 attach-agent $tcp10
set ftp11 [new Application/FTP]
$ftp11 attach-agent $tcp11
set ftp12 [new Application/FTP]
$ftp12 attach-agent $tcp12
set udp0 [new Agent/UDP]
$ns attach-agent $n1 $udp0
$udp0 set fid_ 2 ;
$tcp7 set fid_ 4 ;
set cbr0 [new Application/Traffic/CBR]
$cbr0 attach-agent $udp0
set null0 [new Agent/Null]
$ns attach-agent $n3 $null0
$ns connect $udp0 $null0
$cbr0 set packetSize_ $packetsize
$cbr0 set interval_ $intval
set udp1 [new Agent/UDP]
$ns attach-agent $n3 $udp1
$udp1 set fid_ 2 ;
$tcp8 set fid_ 4 ;
set cbr1 [new Application/Traffic/CBR]
$cbr1 attach-agent $udp1
set null1 [new Agent/Null]
$ns attach-agent $n0 $null1
$ns connect $udp1 $null1
$cbr1 set packetSize_ $packetsize
$cbr1 set interval_ $intval
set udp2 [new Agent/UDP]
$ns attach-agent $n3 $udp2
$udp2 set fid_ 3 ;
$tcp12 set fid_ 4;
set cbr2 [new Application/Traffic/CBR]
$cbr2 attach-agent $udp2
set null2 [new Agent/Null]
$ns attach-agent $n0 $null2
$ns connect $udp2 $null2
$cbr2 set packetSize_ $packetsize
$cbr2 set interval_ $intval
$ns at 0.05 "$ftp1 start"
$ns at 0.13 "$ns detach-agent $n0 $tcp1;$ns detach-agent $n1 $sink1"
$ns at 3.0 "finish"
$ns at 0.14 "$ftp2 start"
$ns at 0.20 "$ns detach-agent $n1 $tcp2;$ns detach-agent $n2 $sink2"
$ns at 3.0 "finish"
$ns at 0.23 "$ftp3 start"
$ns at 0.30 "$ns detach-agent $n2 $tcp3;$ns detach-agent $n3 $sink3"
$ns at 3.0 "finish"
$ns at 0.33 "$ftp4 start"
$ns at 0.40 "$ns detach-agent $n3 $tcp4;$ns detach-agent $n0 $sink4"
$ns at 3.0 "finish"
$ns at 0.42 "$ftp5 start"
$ns at 0.50 "$ns detach-agent $n0 $tcp5;$ns detach-agent $n1 $sink5"
$ns at 3.0 "finish"
$ns at 0.51 "$ftp6 start"
$ns at 0.60 "$ns detach-agent $n1 $tcp6;$ns detach-agent $n2 $sink6"
$ns at 3.0 "finish"
$ns at 0.62 "$ftp7 start"
$ns at 0.69 "$ns detach-agent $n2 $tcp7;$ns detach-agent $n3 $sink7"
$ns at 3.0 "finish"
$ns at 0.725 "$ftp8 start"
$ns at 0.78 "$ns detach-agent $n3 $tcp8;$ns detach-agent $n0 $sink8"
$ns at 3.0 "finish"
$ns at 0.83 "$ftp9 start"
$ns at 0.90 "$ns detach-agent $n0 $tcp9;$ns detach-agent $n1 $sink9"
$ns at 3.0 "finish"
$ns at 0.93 "$ftp10 start"
$ns at 1.0 "$ns detach-agent $n1 $tcp10;$ns detach-agent $n2 $sink10"
$ns at 3.0 "finish"
$ns at 1.03 "$ftp11 start"
$ns at 1.1 "$ns detach-agent $n2 $tcp11;$ns detach-agent $n3 $sink11"
$ns at 3.0 "finish"
$ns at 1.13 "$ftp12 start"
$ns at 1.2 "$ns detach-agent $n3 $tcp12;$ns detach-agent $n0 $sink12"
$ns at 3.0 "finish"
$ns at 0.621 "$cbr0 start"
$ns at 0.69 "$cbr0 stop"
$ns at 0.726 "$cbr1 start"
$ns at 0.78 "$cbr1 stop"
$ns at 1.131 "$cbr2 start"
$ns at 1.2 "$cbr2 stop"
proc finish {} {
global ns nf
$ns flush-trace
close $nf
exec awk {
{
if(($1=="-" && $5=="tcp") || ($1=="-" && $5=="cbr")) {
print $2 "\t" $11
}
}
} tokenbus.tr > throughput.data
puts "filtering..."
exec nam tokenbus.nam &
exec xgraph throughput.data &
exit 0
}
$ns run

Token ring protocol


Aim:

To study and simulate the TOKEN RING protocol.

Algorithm :

• Create a simulator object , set Bandwidth 1 MB and packet size 700


• Define different colors for data flows (for NAM)
• Create seven nodes that forms a network numbered from 0 to 6 and label the
nodes for identifying sender and receiver
• Open a nam trace file and define finish procedure then close the trace file, and
execute nam on trace file.
• Create duplex links between the nodes and add Orientation to the nodes for
setting a LAN topology
• Setup TCP Connection between some nodes and apply FTP Application over
TCP
• Setup UDP Connection between some other nodes and apply CBR Application
over UDP
• Schedule events to achieve Token ring scenario and view graph for the
throughput calculated

Program :
set ns [new Simulator]
set Bandwidth "1Mb"
set paketsize 700
set intval 0.004
set nf [open out.nam w]
$ns namtrace-all $nf
set f [open out.tr w]
$ns trace-all $f
set old_data 0
proc finish {} {
global ns nf
$ns flush-trace
close $nf
exec awk {
{
if($1=="-"&& $5=="cbr") {
print $2"\t"$11
}
}
} out.tr > throughput.data
exec nam out.nam &
exec xgraph throughput.data &
exit 0
}
for {set i 0} {$i < 6} {incr i} {
set n($i) [$ns node]
}
$ns color 1 purple
$ns color 2 green
$ns color 3 darkgreen
for {set i 0} {$i < 6} {incr i} {
$ns duplex-link $n($i) $n([expr ($i+1)%6]) $Bandwidth 10ms DropTail
}
set tcp1 [new Agent/TCP]
$ns attach-agent $n(0) $tcp1
$tcp1 set fid_ 1 ;
set sink1 [new Agent/TCPSink]
$ns attach-agent $n(3) $sink1
$ns connect $tcp1 $sink1
set ftp1 [new Application/FTP]
$ftp1 attach-agent $tcp1
set tcp2 [new Agent/TCP]
$ns attach-agent $n(3) $tcp2
$tcp2 set fid_ 1 ;
set sink2 [new Agent/TCPSink]
$ns attach-agent $n(5) $sink2
$ns connect $tcp2 $sink2
set ftp2 [new Application/FTP]
$ftp2 attach-agent $tcp2
set tcp3 [new Agent/TCP]
$ns attach-agent $n(5) $tcp3
$tcp3 set fid_ 1 ;
set sink3 [new Agent/TCPSink]
$ns attach-agent $n(2) $sink3
$ns connect $tcp3 $sink3
set ftp3 [new Application/FTP]
$ftp3 attach-agent $tcp3
set tcp4 [new Agent/TCP]
$ns attach-agent $n(2) $tcp4
$tcp4 set fid_ 1 ;
set sink4 [new Agent/TCPSink]
$ns attach-agent $n(4) $sink4
$ns connect $tcp4 $sink4
set ftp4 [new Application/FTP]
$ftp4 attach-agent $tcp4
set tcp5 [new Agent/TCP]
$ns attach-agent $n(4) $tcp5
$tcp5 set fid_ 1 ;
set sink5 [new Agent/TCPSink]
$ns attach-agent $n(0) $sink5
$ns connect $tcp5 $sink5
set ftp5 [new Application/FTP]
$ftp5 attach-agent $tcp5
set udp0 [new Agent/UDP]
$ns attach-agent $n(5) $udp0
$udp0 set fid_ 3 ;
$tcp3 set fid_ 2 ;
set cbr0 [new Application/Traffic/CBR]
$cbr0 set interval_ $intval
$cbr0 attach-agent $udp0
set null0 [new Agent/Null]
$ns attach-agent $n(2) $null0
$ns connect $udp0 $null0
$ns at 0.1 "$ftp1 start"
$ns at 0.125 "$ns detach-agent $n(0) $tcp1; $ns detach-agent $n(3) $sink1"
$ns at 1.0 "finish"
$ns at 0.131 "$ftp2 start"
$ns at 0.14 "$ns detach-agent $n(3) $tcp2; $ns detach-agent $n(5) $sink2"
$ns at 1.0 "finish"
$ns at 0.157 "$ftp3 start"
$ns at 0.185 "$ns detach-agent $n(5) $tcp3; $ns detach-agent $n(2) $sink3"
$ns at 1.0 "finish"
$ns at 0.19 "$ftp4 start"
$ns at 0.21 "$ns detach-agent $n(2) $tcp4; $ns detach-agent $n(4) $sink4"
$ns at 1.0 "finish"
$ns at 0.211 "$ftp5 start"
$ns at 0.22 "$ns detach-agent $n(4) $tcp5; $ns detach-agent $n(0) $sink5"
$ns at 1.0 "finish"
$ns at 0.157 "$cbr0 start"
#$ns rtmodel-at 1.0 down $n(1) $n(2)
#$ns rtmodel-at 2.0 up $n(1) $n(2)
$ns at 0.185 "$cbr0 stop"
$ns at 1.0 "finish"
$ns run

Вам также может понравиться