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

PRACTICAL NO-1

OBJECT:-
To study various network commands such as ping, ipconfig, tracert with its options.

NETWORK:-
A network consists of several computers connected together. The network can be as
simple as a few computers connected in our home or office, or complicated or even the
entire Internet. When our computer is part of a network, we have access to those systems
either directly or through services like mail and the web.

NETWORK COMMANDS
1.) PING:-

PING refers to Packet Internet Gropher. It helps in determining TCP/IP Networks IP


address as well as determine issues with the network and assists in resolving them. This
command is used to check the destination ip address or domain name. The ping command
displays whether the destination responded and how long it took to receive a reply. If the
destination is unreachable the ping command returns an error.

Ping is basically an internet program that allow user to verify that particular IP address
exists and can accept requests. The verb ping means the act of using ping utility or
command. This is used to ensure that a host computer we are trying to reach is actually
operating. Eg- If user can’t ping a host-then user is unable to use a File transfer
Protocol(FTP) to send files to host. Ping is also use with a host to see how long it will
take to get a reply back.

Ping operates by sending a packet to a designated address and waiting for a response.
Ping can also refer to the process of sending a message to all the members of a mailing
list requesting an ACK (acknowledgement code). This is done before sending e-mail in
order to confirm that all of the addresses are reachable.
It uses a series of Internet Control Message Protocol (ICMP) Echo messages to
determine:
• Whether a remote host is active or inactive.
• The round-trip delay in communicating with the host.
• Packet loss.
The ping command first sends an echo request packet to an address, and then waits for a
reply. The ping is successful only if:
• The echo request gets to the destination.
• The destination is able to get an echo reply back to the source within a predetermined
time called a timeout.The default value of this time out is two seconds on Cisco routers.
How to start and go to command prompt:-
START->RUN

Syntax:-

Ping [-t] [-a] [-n count] [-l size] [-f] [-i TTL] [-v TOS]
[-r count] [-s count] [[-j host-list] | [-k host-list]]
[-w timeout] destination-list

OUTPUT:-
Output of ping is-

Time-to-live (TTL) is a value in an Internet Protocol (IP) packet that tells a network
router whether or not the packet has been in the network too long and should be
discarded.
Options:-

-t Pings the specified host until stopped.


Continues sending echo request messages to destination until interrupted by
CTRL-C or CTRL-BREAK.

-a Resolve addresses to hostnames.


Specifies that reverse name resolution is performed on destination IP address. If
successful, displays corresponding host name.

-n count Number of echo requests to send.

-l size Send buffer size.


Specifies the length, in bytes, of data field in the Echo Request messages sent.

-f Set Don't Fragment flag in packet.


Echo request messages cannot be fragmented by routers in path to destination.

-I TTL Time To Live.


Specifies value of TTL field in the IP header for Echo Request messages sent.

-v TOS Type Of Service.

-r count Record route for count hops.

-s count Timestamp for count hops.

-j host-list loose source route along host-list.

-k host-list strict source route along host-list.

-w Specifies timeout in milliseconds to wait for each reply.


OUTPUT:-
Output of ping –t .

2.) IPCONFIG:-

It is used to check IP address, Physical address, and other details of the system. It is run
from MS_DOS shell to display the network settings currently assigned to a system.
It can verify network settings and network connectivity.

Syntax
ipconfig [/all][/renew [Adapter]] [/release [Adapter]] [/flushdns] [/displaydns]
[/registerdns] [/showclassid Adapter] [/setclassid Adapter [ClassID]]
OUTPUT:-
Output of ipconfig/all

Options:

/all Displays full configuration information.


Displays the full TCP/IP configuration for all adapters.

/release Release the IP address for the specific adapter.

/renew Renew the IP address for the specific adapter.


Renews the DHCP configuration for all adapters or for a specific adapter.

/flushdns Purges the DNS resolver cache.


Flushes and resets the contents of DNS client resolver cache.

/displaydns Displays the contents of DNS resolver cache.

/registerdns Refreshes all DHCP leases and re-registers DNS names.

/showclassid Displays all the DHCP class IDs allowed for adapter.

/setclassid Modifies the DHCP class ID.


OUTPUT:-
Output of ipconfig /?

3.) TRACERT:-

It is used to trace the route for domain name and IP address. It gives the number of
packets through which the packets goes to reach the domain name. It is used for trouble
shooting in the case of large network. Tracert uses the IP TTL field and ICMP error
message to determine the route from one host to another through a network.

Syntax

Tracert [-d][-h maximum_hops] [-j host-list] [-w timeout] target_name

Options:
-d Avoids dissolving addresses to hostname (avoids performing a DNS lookup)
This can speed up the display of tracert results.
-h Specifies maximum number of hops in path to search for target.

-j Traces hot-list along the route.

-w Wait time out millisecond for reply.

OUTPUT:-
Output of tracert and tracert –d
PRACTICAL NO-2
OBJECT:-
To study network simulator and understanding of object tool command language .

NETWORK SIMULATOR:-
The increasing demand for cyber network knowledge has introduced a new solution for
network simulation known as “Network Simulation”.This function offers a simulated
networking environment among devices to reduce problems in the development of real
devices(pc,hubs,router…) environment for a networking experiment.It simulates both
wired and wireless networks.
NS-2 is a discrete event simulator targeted at networking research.NS-2 development is
supported through DARPA with SAMAN and through NSF with CONSER both in
collaboration with other researchers.NS-2 has provided substantial contribution from
other researchers including wireless UCB daedelus,Sun Microsystems.
Network protocol stack are written in C++ language. The NS-2 simulation utilizes the
TCL to build simulation scenarios.We use OTcl (Object Tool Command Language) for
specifying scenarios and events and constructing commands and configuring interfaces. It
is a Open Source, that means it allows the users to modify, rebuilt their own design of
complements, and build own components.Along with this features the nam (Network
Animator )was provided for user friendly visualization of the flow of NS-2 messages as
well as the simulation of entire networking system..NS-2 can only developed in a
environment of UNIX(SunOS,Linux,Solaris).Cygwin is a LINUX like environment for
windows.

A package of tools that simulates behavior of networks


 Create Network Topologies
 Log events that happen under any load
 Analyze events to understand the network behavior
It helps to create a number of interconnections and topologies. It helps to study the effects
of routing, packet size, delay etc.
Motivation for Simulations
● Cheap and does not require any costly equipment. It is a open source program.
● Complex scenarios can be easily tested.
● Results can be quickly obtained – more ideas can be tested in a smaller timeframe.
● The real thing is not yet available.
● Controlled experimental conditions – Repeatability helps aid debugging.
● Disadvantages: Real systems are too complex to model.
NS COMMANDS:-
1 set and puts command:-
NS-2 script starts with creating simulator object.
set ns [new Simulator] : It generates an NS simulator object instance, and assigns it to
variable ns.This line can be understood in a following ways:-
a. Initialize the packet format.
b. Create a scheduler (default is calendar scheduler). Set command is also used to
place the second argument in the memory space referenced by first argument.

Eg- 1.set Y “string”


This line sets the value of y as string.
2. Set label “The value in y is”
puts “$label $y”
This line gives the string with its value in the output.
3.puts “this is a command”
This line prints the string .
4. puts “sum of two numbers is $sum “
This line prints the string substituting the current value of sum.
5. set numb(0) 0;set numb(1) 1;
This is an example of array.This line sets the first element of array to 0 and second
element to1.
6. for { set i 1 } {$i <count } { incr i 1}
This line runs a loop from i=1 to i is less than count with a increment of one each time.
7.Set numb(1) [expr $numb(0) +$numb(1)]
This line set the second element of array to the sum of first and second element.

2. Defining color for data flow:

$ns color fid color: is used to set color of the packets for a flow specified by the flow
id(fid) . This member function of "Simulator" object is for the NAM display, and has no
effect on the actual simulation.eg-$ns color 1 Blue.

3.Open a namtrace file:

Set nf [open out.nam w]:-This line sets out.nam opened as nf .Along with this open a
nam file for recording.

3. $ns namtrace-all file-descriptor: This member function tells the simulator to


record simulation traces in NAM input format. It also gives the file name that the trace
will be written to later by the $ns flush-trace command. Similarly, the member function
trace-all is for recording the simulation trace in a general format and the process of
packet transmission eg-$ns namtrace-all $nf.
4. Creating finish procedure

Proc finish {} is called after this simulation is over by the command $ns at 5.0 "finish".
In this function, post-simulation processes are specified.

Eg-proc finish {} {
global ns nf
$ns flush-trace
Close $nf
#execute nam trace file
exec nam out.nam &
exit 0
}
5. Creating nodes

Set n0 [$ns node] The member function node creates a node. A node in NS is compound
object made of address and port classifiers. Users can create a node by separately creating
an address and a port classifier objects and connecting them together. However, this
member function of Simulator object makes the job easier.

set n0 [$ns node]


set n1 [$ns node]
set n2 [$ns node]

N N N
0 1 2

6. Creating link

$ns duplex-link node1 node2 bandwidth delay queue-type: creates two simplex links
of specified bandwidth and delay, and connects the two specified nodes. In NS, the output
queue of a node is implemented as a part of a link, therefore users should specify the
queue-type when creating links.

$ns duplex-link $n0 $n1 1Mb 10ms DropTail

This line tells the simulator object to connect the nodes n0 and n1 with a duplex link with
the bandwidth.1Megabit, a delay of 10ms and a DropTail queue.

7. $ns queue-limit node1 node2 number: This line sets the queue limit of the two
simplex links that connect node1 and node2 to the number specified.

8. $ns duplex-link-op node1 node2 queue_pos number: this is used to monitor


queue between node1 and node2.

9. UDP communication
In UDP communication, data is flows from UDP agent to Null agent.
#Create a UDP agent and attach it to node n0
set udp0 [new Agent/UDP]
$ns attach-agent $n0 $udp0
# create a null agent which act as traffic sink and attach it to node n1
set null0 [new Agent/Null]
$ns attach-agent $n1 $null0
# connect two agents with each other
$ns connect $udp0 $null0

10. TCP Communication


In TCP communication, data is flows from TCP agent to TCP sink agent.

# create Tcp agent and attach it to node no


set tcp0 [new Agent/TCP]
$ns attach-agent $n0 $tcp0
# create a tcpsink agent which act as traffic sink and attach it to node n1
set tcpsink0 [new Agent/TCPSink]
$ns attach-agent $n1 $tcpsink0
# connect two agents with each other
$ns connect $tcp0 $tcpsink0

11. Traffic generator(CBR)


For actual data to flow, we need traffic generators. They simulate some application
traffic. # creating CBR agent
set cbr0 [new Application/Traffic/CBR]
# Attach the CBR agent to some udp/tcp agent
$cbr0 attach-agent $udp0

12. Scheduling the events

$ns at time “string”: This member function of a Simulator object makes the scheduler to
schedule the execution of the specified string at given simulation time.

For example, $ns at 1.0 “$cbr0 start” will make the scheduler call a start member
function of the CBR traffic source object, which starts the CBR to transmit data. In NS,
usually a traffic source does not transmit actual data, but it notifies the underlying agent
that it has some amount of data to transmit, and the agent, just knowing how much of the
data to transfer, creates packets and sends them.
$ns at 1.0 “$cbr0 start”
$ns at 5.0 “finish"
13. Run simulator

In the end, to run the simulator we use $ns run


PRACTICAL NO-3
OBJECT: Set up a Local Area Network by taking Class C private address.

Network Terminology:

1) IP Address : Internet Address, the identifying number that enables any computer on
the Internet to find any other computer on the network. It consists of four sets of numbers
separated by periods—for example, 123.456.78.90. The Internet is the interconnection of
many individual networks. So the IP is basically the set of rules for one network
communicating with any other. Each network must know its own address on the Internet
and that of any other networks with which it communicates. The four numbers in an IP
address are called octets.

2) Subnet mask : A sub network, or subnet, describes networked computers and devices
that have a common, designated IP address routing prefix. Subnetting is used to break the
network into smaller more efficient subnets to prevent excessive rates of Ethernet packet
collision in a large network. A subnet mask allows you to identify which part of an IP
address is reserved for the network, and which part is available for host use. Knowing the
subnet mask can allow you to easily calculate whether IP addresses are on the same
subnet, or not.

3) Default Gateway: It is a network setting on a computer that specifies the IP address of


the computer or router that network traffic should be sent to when the traffic is not on the
same subnet as the sending computer. The subnet that the computer is on is determined
by the netmask and IP address of the computer.

4) DNS Server: (Domain Name System) This is a server that translates domain names
into IP addresses. Because domain names are alphabetic, they're easier to remember. The
Internet however, is really based on IP addresses. Every time you use a domain name,
therefore, a DNS service must translate the name into the corresponding IP address. For
example, the domain name http://www.example.com/ might translate to 198.105.232.4.
The DNS system is, in fact, its own network. If one DNS server doesn't know how to
translate a particular domain name, it asks another one, and so on, until the correct IP
address is returned.

Class C IP addresses

Since networks vary in size, there are four different address formats or classes to consider
when applying for a network number:
• Class A addresses are for large networks with many devices.
• Class B addresses are for medium-sized networks.
• Class C addresses are for small networks (fewer than 256 devices).
• Class D addresses are multicast addresses.
Class C addresses are commonly used for small to mid-size businesses. IP addresses with
a first octet from 192 to 223 are part of this class. Class C addresses also include the
second and third octets as part of the Net identifier. The last octet is used to identify each
host. This means that there are 2,097,152 (221) Class C networks each with 254 (28 -2)
possible hosts for a total of 536,870,912 (229) unique IP addresses. All Class C
addresses, for example, have the leftmost three bits set to '110', but each of the remaining
29 bits may be set to either '0' or '1' independently (as represented by an x in these bit
positions):

110xxxxx xxxxxxxx xxxxxxxx xxxxxxxx .

Hardware required for LAN

1. NIC (Network interface card)


2. Optical fiber cable
3. RJ 45 connector
4. Switch which may be 8 ports or 16 ports according to your requirements.
5. Modem

Setting up local area network

Step1:

• Right click on My Network Places.

• Select Properties
Step-II

Window appears.

 Right click on Local Area Connection and go to Properties.

.Step-III

Select Internet Protocol (TCP/IP) and then select properties.


Step-IV:

Select Internet Protocol (TCP/IP) and then select properties.

Enter the following

IP address:-192.168.11.15, Subnet mask:-255.255.255.0, Default gateway:-

192.168.11.1, Preferred DNS server:-202.41.97.134, Alternate DNS server:-

202.41.97.135

And then click on ok.

PRACTICAL
NO-4

OBJECT: To prepare a
script file for NS
application by creating
four nodes and to
establish link between the
nodes.

PROGRAM CODE:
# create a new simulator
set ns [new Simulator]

#open name trace file


set nf [open out.nam w]
$ns namtrace-all $nf

# create a finish procedure with definition


proc finish {} {
global ns nf
$ns flush-trace
close $nf
#execute name trace file
exec nam out.nam &
#exit
exit 0
}
#create four nodes

set n0 [$ns node]


set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]

# give colours to data flows


$ns color 1 Green
$ns color 2 Red

#create four duplex link between diff nodes of 1Mb bandwidth


$ns duplex-link $n0 $n1 1Mb 50ms DropTail
$ns duplex-link $n1 $n2 1Mb 50ms DropTail
$ns duplex-link $n2 $n3 1Mb 20ms DropTail
$ns duplex-link $n3 $n0 1Mb 20ms DropTail

#provide orientation to different nodes and path


$ns duplex-link-op $n0 $n1 orient right
$ns duplex-link-op $n1 $n2 orient down
$ns duplex-link-op $n2 $n3 orient left
$ns duplex-link-op $n3 $n0 orient up

#call finish procedure


$ns at 5.0 "finish"

#run the simulation


$ns run

PRACTICAL NO-5

OBJECT: To create four nodes ,UDP agent,CBR traffic ,duplex link and attach these to
sources.
PROGRAM CODE:
# create a new simulator
set ns [new Simulator]
#open name trace file
set nf [open out.nam w]
$ns namtrace-all $nf
# create afinish procedure with defination
proc finish {} {
global ns nf
$ns flush-trace
close $nf
#execute name trace file
exec nam out.nam &
#exit
exit 0
}
#create four nodes

set n0 [$ns node]


set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]

# give colours to data flows


$ns color 1 Green
$ns color 2 Red

#create four duplex link between diff nodes of 1Mb bandwidth


$ns duplex-link $n0 $n1 1Mb 50ms DropTail
$ns duplex-link $n1 $n2 1Mb 50ms DropTail
$ns duplex-link $n2 $n3 1Mb 20ms DropTail
$ns duplex-link $n3 $n0 1Mb 20ms DropTail

#provide orientation to different nodes and path


$ns duplex-link-op $n0 $n1 orient right
$ns duplex-link-op $n1 $n2 orient down
$ns duplex-link-op $n2 $n3 orient left
$ns duplex-link-op $n3 $n0 orient up

#create two udp agent and attach to node zero ,node one
set udp0 [new Agent/UDP]
$udp0 set class_ 1
$ns attach-agent $n0 $udp0
set udp1 [new Agent/UDP]
$udp1 set class_ 2
$ns attach-agent $n1 $udp1

#create two traffic source(cbr)

set cbr0 [new Application/Traffic/CBR]


$cbr0 set packetSize_ 550
$cbr0 set interval_ 0.005
$cbr0 attach-agent $udp0

set cbr1 [new Application/Traffic/CBR]


$cbr1 set packetSize_ 500
$cbr1 set interval_ 0.005
$cbr1 attach-agent $udp1

#create two traffic sink

set null0 [new Agent/Null]


$ns attach-agent $n2 $null0
set null1 [new Agent/Null]
$ns attach-agent $n3 $null1

#connect traffic source with sink


$ns connect $udp0 $null0
$ns connect $udp1 $null1

#shedule different events

$ns at 0.5 "$cbr0 start"


$ns at 3.5 "$cbr0 stop"

$ns at 1.5 "$cbr1 start"


$ns at 4.5 "$cbr1 stop"
#call finish procedure

$ns at 5.0 "finish"


#run the simulation
$ns run

PRACTICAL NO-6
OBJECT: Monitor the queue for different scheduling event and queuing management
system.

PROGRAM CODE:
# create a new simulator
set ns [new Simulator]
#open name trace file
set nf [open out.nam w]
$ns namtrace-all $nf
# create afinish procedure with defination
proc finish {} {
global ns nf
$ns flush-trace
close $nf
#execute name trace file
exec nam out.nam &
#exit
exit 0
}
#create four nodes

set n0 [$ns node]


set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]

# give colours to data flows


$ns color 1 Green
$ns color 2 Red

#create four duplex link between diff nodes of 1Mb bandwidth


$ns duplex-link $n0 $n1 1Mb 50ms DropTail
$ns duplex-link $n1 $n2 1Mb 50ms DropTail
$ns duplex-link $n2 $n3 1Mb 20ms DropTail
$ns duplex-link $n3 $n0 1Mb 20ms DropTail

#provide orientation to different nodes and path


$ns duplex-link-op $n0 $n1 orient right
$ns duplex-link-op $n1 $n2 orient down
$ns duplex-link-op $n2 $n3 orient left
$ns duplex-link-op $n3 $n0 orient up

#check queue monitoring

$ns duplex-link-op $n0 $n1 queuePos 1.5


$ns duplex-link-op $n0 $n3 queuePos 2.0

#create two udp agent and attach to node zero


set udp0 [new Agent/UDP]
$udp0 set class_ 1
$ns attach-agent $n0 $udp0
set udp1 [new Agent/UDP]
$udp1 set class_ 2
$ns attach-agent $n1 $udp1

#create two traffic source(cbr)

set cbr0 [new Application/Traffic/CBR]


$cbr0 set packetSize_ 550
$cbr0 set interval_ 0.005
$cbr0 attach-agent $udp0

set cbr1 [new Application/Traffic/CBR]


$cbr1 set packetSize_ 500
$cbr1 set interval_ 0.005
$cbr1 attach-agent $udp1

#create two traffic sink

set null0 [new Agent/Null]


$ns attach-agent $n2 $null0
set null1 [new Agent/Null]
$ns attach-agent $n3 $null1

#connect traffic source with sink


$ns connect $udp0 $null0

$ns connect $udp1 $null1

#shedule different events

$ns at 0.5 "$cbr0 start"


$ns at 3.5 "$cbr0 stop"

$ns at 1.5 "$cbr1 start"


$ns at 4.5 "$cbr1 stop"
#call finish procedure

$ns at 5.0 "finish"


#run the simulation
$ns run
PRACTICAL NO-7

OBJECT:To create five nodes and perform dynamic data flow routing.

PROGRAM CODE:
#Create a simulator object ns
set ns [new Simulator]

#Tell the simulator to use dynamic routing


$ns rtproto DV

#Open the nam trace file


set nf [open out.nam w]
$ns namtrace-all $nf

#Define a 'finish' procedure


proc finish {} {
global ns nf
$ns flush-trace
#Close the trace file
close $nf
#Execute nam on the trace file
exec nam out.nam &
#exit
exit 0
}
#end of finish procedure

#Create five nodes using for loop


for {set i 0} {$i < 5} {incr i} {
set n($i) [$ns node]
}

#Create links between the nodes by using for loop


for {set i 0} {$i < 5} {incr i} {
$ns duplex-link $n($i) $n([expr ($i+1)%5]) 1Mb 10ms DropTail
}

#Create a UDP agent and attach it to node n(0)


set udp0 [new Agent/UDP]
$ns attach-agent $n(0) $udp0
# Create a CBR traffic source and attach it to udp0
set cbr0 [new Application/Traffic/CBR]
$cbr0 set packetSize_ 550
$cbr0 set interval_ 0.005
$cbr0 attach-agent $udp0

#Create a traffic sink and attach it to node n(3)


set null0 [new Agent/Null]
$ns attach-agent $n(3) $null0

#Connect the traffic source udp(0) with the traffic sink null0
$ns connect $udp0 $null0

#Schedule events for the CBR agent and the network dynamics
$ns at 0.5 "$cbr0 start"

# dissolve link between n(4) and n(3) at time 1 second


$ns rtmodel-at 1.0 down $n(4) $n(3)

# dissolve link between n(2) and n(3) at time 2 second


$ns rtmodel-at 2.0 down $n(2) $n(3)

# resolve link between n(4) and n(3) at time 2.5 second


$ns rtmodel-at 2.5 up $n(4) $n(3)

#stop the flow of data


$ns at 4.0 "$cbr0 stop"
#Call the finish procedure after 5 seconds
$ns at 4.5 "finish"

#Run the simulation


$ns run
PRACTICAL NO-8

OBJECT: WAP to create 2 routers r1, r2 . attach nodes s1, s2 to r1 and nodes rc1, rc2
to r2.

PROGRAM CODE:

# create simulator
set ns [new Simulator]

#color given to data flow


$ns color 1 Red
$ns color 2 Blue

# open name trace file


set nf [open out.nam w]
$ns namtrace-all $nf

#finish procedure defined


proc finish {} {
global ns nf
$ns flush-trace
close $nf
#execute trace file
exec nam out.nam &
exit 0
}

#create 2 routers
set r1 [$ns node]
set r2 [$ns node]

#crate 4 nodes
set s1 [$ns node]
set s2 [$ns node]
set rc1 [$ns node]
set rc2 [$ns node]

#create duplex links between nodes


$ns duplex-link $r1 $s1 10Mb 1ms DropTail
$ns duplex-link $r1 $s2 10Mb 1ms DropTail
$ns duplex-link $r1 $r2 2Mb 1ms DropTail
$ns duplex-link $r2 $rc1 10Mb 1ms DropTail
$ns duplex-link $r2 $rc2 10Mb 1ms DropTail

# orientation
$ns duplex-link-op $r1 $s1 orient left-up
$ns duplex-link-op $r1 $s2 orient left-down
$ns duplex-link-op $r1 $r2 orient right
$ns duplex-link-op $r2 $rc1 orient right-up
$ns duplex-link-op $r2 $rc2 orient right-down

#udp agent made and attached to s1


set udp0 [new Agent/UDP]
#color attach to udp0
$udp0 set class_ 1
$ns attach-agent $s1 $udp0
# udp1 agent made and attached to s2
set udp1 [new Agent/UDP]
#attached to color
$udp1 set class_ 2
$ns attach-agent $s2 $udp1

#cbr traffic source made and packet size and interval defined
set cbr0 [new Application/Traffic/CBR]
$cbr0 set packetSize_ 500
$cbr0 set interval_ 0.005
$cbr0 attach-agent $udp0

# traffic source created and attached to udp0


set cbr1 [new Application/Traffic/CBR]
$cbr1 set packetSize_ 300
$cbr1 set interval_ 0.005
$cbr1 attach-agent $udp1

#null agent (traffic sink) created and attached to node rc1


set null0 [new Agent/Null]
$ns attach-agent $rc1 $null0

#null agent1 created


set null1 [new Agent/Null]
$ns attach-agent $rc2 $null1

#connect source and sink


$ns connect $udp0 $null0
$ns connect $udp1 $null1

#shedule events start and stop


$ns at 0.5 "$cbr0 start"
$ns at 4.5 "$cbr0 stop"
$ns at 1.5 "$cbr1 start"
$ns at 5.0 "$cbr1 stop"

#call finish procedure after 5 sec


$ns at 5.0 "finish"

#run the simulation


$ns run
PRACTICAL NO-9

write a program to create six nodes with 2 source and 1 sink.


study the flow of packets between these links.
# creating new simulator agent
set ns [new Simulator]

# opening nam trace file


set nf [open out.nam w]
$ns namtrace-all $nf

# defining different colors


$ns color 1 Blue
$ns color 2 Red

# finish procedure created


proc finish {} {
global ns nf
$ns flush-trace
close $nf
#execute
exec nam out.nam &
exit 0
}

# crating 6 nodes
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]
set n5 [$ns node]

# creating duplex links between nodes


$ns duplex-link $n0 $n2 1Mb 10ms DropTail
$ns duplex-link $n1 $n2 1Mb 10ms DropTail
$ns duplex-link $n2 $n3 1Mb 10ms DropTail
$ns duplex-link $n3 $n4 1Mb 10ms DropTail
$ns duplex-link $n4 $n5 1Mb 10ms DropTail
# orient the link
$ns duplex-link-op $n0 $n2 orient right-down
$ns duplex-link-op $n1 $n2 orient right-up
$ns duplex-link-op $n2 $n3 orient right
$ns duplex-link-op $n3 $n4 orient right
$ns duplex-link-op $n4 $n5 orient right-up

# source created (udp agents)


set udp0 [new Agent/UDP]
$udp0 set class_ 1
$ns attach-agent $n0 $udp0

set udp1 [new Agent/UDP]


$udp1 set class_ 2
$ns attach-agent $n1 $udp1

# cbr traffic source created


set cbr0 [new Application/Traffic/CBR]
$cbr0 set packetSize_ 500
$cbr0 set interval_ 0.005
$cbr0 attach-agent $udp0

set cbr1 [new Application/Traffic/CBR]


$cbr1 set packetSize_ 500
$cbr1 set interval_ 0.005
$cbr1 attach-agent $udp1

# sink created ( null agent)


set null0 [new Agent/Null]
$ns attach-agent $n5 $null0

# connect source with sink


$ns connect $udp0 $null0
$ns connect $udp1 $null0

# scheduling the cbr agents and events


$ns at 0.5 "$cbr0 start"
$ns at 3.5 "$cbr0 stop"
$ns at 1.5 "$cbr1 start"
$ns at 2.5 "$cbr1 stop"

# calling finish procedure at time 5.0


$ns at 5.0 "finish"

# run the file


$ns run
PRACTICAL NO-10

OBJECT: Study of Rj-45 connector .Make a straight through cable, crossover cable.

Connectors and cables:-


10/100 ports

The 10/100 Ethernet ports use standard Rj-45 connectors and Ethernet pinouts with
internal crossovers, as indicated by an x in the port name.These ports have their
transmit(TD) and receive(RD) signals internally crossed so that a straight-through cable
and adapter can be attached to the port.

When connecting the 10/100 ports to compatible servers and workstations, we must use a
straight-through cable wired for 10BaseT and 100BaseTX.when connecting to other
switches or repeaters,ensure that we use a crossover cable.

10/100 pinout
Pin Label
1 RD+
2 RD-
3 TD+
4 NC
5 NC
6 TD-
7 NC
8 NC

Straight-through cable schematic:

Crossover cable schematic:


Color coding:
Straight cable Crossover cable

White orange White green


Orange Green
White green White orange
Blue Blue
Blue white Blue white
Green Orange
Brown white Brown white
Brown Brown

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