Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Full Duplex Chat Implementation with TCP and Ethernet LAN Simulation, Exercises of Computer Networks

Computer Networks lab record for cse

Typology: Exercises

2018/2019

Uploaded on 07/31/2019

PvnsHemanth
PvnsHemanth 🇮🇳

5

(1)

4 documents

1 / 9

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Exp No:9 IMPLEMENTATION FULL DUPLEX CHAT USING TCP
Date-
Aim: To write a program for implementing Full Duplex using TCP.
Algorithm:
1. Start the program.
2. Create the required number of nodes and establish the connection between Server and
Client using Router.
3. Give various transfer rates to nodes of data between each other.
4. Create the agent, which is used to check the connection between the nodes and process
FTP over TCP using connection agent.
5. Run the procedures and call the appropriate functions.
6. Run the simulation and nam file for getting the result.
7. Check the output and stop the program.
Program:
set ns [new Simulator]
setnt [open test2.tr w]
$ns trace-all $nt
setnf [open test2.nam w]
$ns namtrace-all $nf
$ns color 1 darkmagenta
$ns color 2 yellow
$ns color 3 blue
$ns color 4 green
$ns color 5 black
settotalNodes 3
for {set i 0} {$i< $totalNodes} {incri} {
set node_($i) [$ns node]
}
set server 0
Exp No:10 SIMULATE THE PACKET TRANSMISSION OVER ETHERNET LAN
AND ITS CSMA/CD PROTOCOL
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download Full Duplex Chat Implementation with TCP and Ethernet LAN Simulation and more Exercises Computer Networks in PDF only on Docsity!

Exp No:9 IMPLEMENTATION FULL DUPLEX CHAT USING TCP

Date-

Aim: To write a program for implementing Full Duplex using TCP.

Algorithm:

  1. Start the program.
  2. Create the required number of nodes and establish the connection between Server and Client using Router.
  3. Give various transfer rates to nodes of data between each other.
  4. Create the agent, which is used to check the connection between the nodes and process FTP over TCP using connection agent.
  5. (^) Run the procedures and call the appropriate functions.
  6. Run the simulation and nam file for getting the result.
  7. Check the output and stop the program.

Program:

set ns [new Simulator] setnt [open test2.tr w] $ns trace-all $nt setnf [open test2.nam w] $ns namtrace-all $nf $ns color 1 darkmagenta $ns color 2 yellow $ns color 3 blue $ns color 4 green $ns color 5 black settotalNodes 3 for {set i 0} {$i< $totalNodes} {incri} { set node_($i) [$ns node] } set server 0

Exp No:10 SIMULATE THE PACKET TRANSMISSION OVER ETHERNET LAN AND ITS CSMA/CD PROTOCOL

DATE-

Aim: To simulate the packet transmission over Ethernet LAN and its CSMA/CD protocol using NS2.

Algorithm:

  1. To analyze the given problem you have to write a Tcl script and simulate with ns
  2. Begin by specifying the trace files and the nam files to be created
  3. Determine and create the nodes that will be used to create the topology. Here in our experiment we are selecting 6 nodes namely 0, 1, 2, 3, 4, 5
  4. (^) Create the links to connect the nodes
  5. Set up the LAN by specifying the nodes, and assign values for bandwidth, delay, queue type and channel to it
  6. Optionally you can position and orient the nodes and links to view a nice video output with Nam
  7. Set up the TCP and/or UDP connection(s) and the FTP/CBR (or any other application) that will run over it
  8. Schedule the different events like simulation start and stop, data transmission start and stop
  9. Call the finish procedure and mention the time at what time your simulation will end
  10. (^) Execute the script with ns

Program: set ns [new Simulator] #define color for data flows $ns color 1 Blue $ns color 2 Red #open tracefiles set tracefile1 [open out.tr w] setwinfile [open winfile w] $ns trace-all $tracefile #open nam file setnamfile [open outter.nam w] $ns namtrace-all $namfile #define the finish procedure

$ns simplex-link-op $n3 $n2 orient left #set queue size of link(n2-n3) to 20 $ns queue-limit $n2 $n3 20 #setup TCP connection settcp [new Agent/TCP/Newreno] $ns attach-agent $n0 $tcp set sink [new Agent/TCPSink/DelAck] $ns attach-agent $n4 $sink $ns connect $tcp $sink $tcp set fid_ 1 $tcp set packet_size_ 552 #set ftp over tcp connection set ftp [new Application/FTP] $ftp attach-agent $tcp #setup a UDP connection setudp [new Agent/UDP] $ns attach-agent $n1 $udp set null [new Agent/Null] $ns attach-agent $n5 $null $ns connect $udp $null $udp set fid_ 2 #setup a CBR over UDP connection setcbr [new Application/Traffic/CBR] $cbr attach-agent $udp $cbr set type_ CBR $cbr set packet_size_ 1000 $cbr set rate_ 0.01Mb $cbr set random_ false

#scheduling the events $ns at 0.1 "$cbr start" $ns at 1.0 "$ftp start" $ns at 124.0 "$ftp stop" $ns at 125.5 "$cbr stop" procplotWindow {tcpSource file} { global ns set time 0. set now [$ns now] setcwnd [$tcpSource set cwnd_] puts $file "$now $cwnd" $ns at [expr $now+$time] "plotWindow $tcpSource $file" } $ns at 0.1 "plotWindow $tcp $winfile" $ns at 125.0 "finish" $ns run

OUTPUT

RESULT: