Ftp in Ns2

           File transfer protocol is abbreviated as FTP and it is considered as the standard network protocol that is deployed to transfer the files among the computers through the TCP and IP networks. The client server architecture is created and mainly it is functioning in the application layer.

             In addition, the clients are used to control the conversation and various servers are transmitting the file content. On the other hand, the browsers are functioning as the client to start the conversation through the creation of various requests in the server. The client is capable to remove, download, delete and upload the files based on server using the FTP process. The automatic process of traffic controlling is considered as the functions of FTP for the throttle mechanism in TCP.

Application FTP

  • Attaching the application to agnet
  • Causes to attach the TCP object to stop data sending process
  • FTP object is to produce the packets
  • Source to produce maxpkts_packets
  • FTP objects create the bulk data for TCP object to send the data

Data Transfer between Nodes Using FTP

          The nodes are communicating with the wired network through the utilization of communication model and that includes the file transfer protocol application, TCP sink agent and transport control protocol. The sender nodes are attached to the TCP agent while the receiver nodes are attached with the TCP sink agent. The application and transport agent is connected through the utilization of keyword namely “attach agent”.

#————Data Transfer between Nodes—————-#
# Defining a transport agent for sending
set tcp [new Agent/TCP]
# Attaching transport agent to sender node
$ns attach-agent $node_($server) $tcp
# Defining a transport agent for receiving
set sink [new Agent/TCPSink]
# Attaching transport agent to receiver node
$ns attach-agent $node_($client) $sink
#Connecting sending and receiving transport agents
$ns connect $tcp $sink
#Defining Application instance
set ftp [new Application/FTP]
# Attaching transport agent to application agent
$ftp attach-agent $tcp
# Setting flow color
$tcp set fid_ 4
# data packet generation starting time
$ns at 1.0 "$ftp start"
# data packet generation ending time
$ns at 6.0 "$ftp stop"

TCL Script to Create FTP Traffic over TCP

        TCP is considered as the connection oriented protocol and the retransmission of lost data packets is possible along with TCP. TCL script is deployed to create the FTP traffic through TCP.

Step: 1 – We have to create the network simulator object and initialize the routing protocol as distance vector routing protocol (DV).

set ns [new Simulator]
$ns rtproto DV

Step: 2 – Two nodes are created such as node 0 and node 1 through the utilization of node instance in network simulator.

set node0 [$ns node]
set node1 [$ns node]

Step: 3 – The creation of nam file and trace file is implemented, the named as out.tr and out.nam.

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

Step: 4 – The duplex link are created among the nodes through the utilization of duplex link instance. Then, the particular three parameters are included in this process such as,

  • Kind of queue (Droptail)
  • Delay (10ms)
  • Data rate (1Mb)
$ns duplex-link $node0 $node1 1Mb 10ms DropTail

Step: 5 – The agents are carried information among the nodes in network with the required TCP agents for the accomplishment task. The agents are initialized to connect.

set tcp2 [new Agent/TCP]
$ns attach-agent $node0 $tcp2
set sink2 [new Agent/TCPSink]
$ns attach-agent $node1 $sink2
$ns connect $tcp2 $sink2

Step: 6 – Initialization of FTP traffic to attach the source tcp2 and it is capable to create the FTP object to attach the traffic to TCP2

set traffic_ftp2 [new Application/FTP]
$traffic_ftp2 attach-agent $tcp2

Step: 7 – The data are flushed to trace file and then run to nam file

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

Step: 8 – The events are scheduled for the FTP agents and the TCL file is running with the command. The traffic is initiated with time 1.0 and stopped at 3.0.

$ns at 1.0 "traffic_ftp2 start"
$ns at 3.0 "traffic_ftp2 stop"
$ns at 5.0 "finish"
$ns run

The research scholars can reach us at any time to enquire about the required data and we are providing the 24/7 customer service. So, be in touch with and aid more.