title: How to set the TCP parameters in NS2 for packet generation
body: <p>I am working in NS2 and trying to mix the tcp and udp packets, by using MD1 queue type. I want to split the arrival rate between each udp and tcp packets. I have managed to set the udp as Poisson traffic and found out how to control the generation of packets, but in tcp I haven't figured out how I can control the generation of packets meaning how to set the arrival rate in tcp source traffic, (I will be using ftp and cbr traffic). I have tried many ways but I haven't managed to solve it. Which parameter in the .tcl file for tcp should I use to do that?</p>
  
  <p>My .tcl file:</p>
  
  <pre><code>    set ns [new Simulator]
  
      set tf [open output.tr w]
      set nf [open nam.nam w]
  
      $ns trace-all $tf
      $ns namtrace-all $nf
  
      proc finish {} {
              global ns nf tf
              $ns flush-trace
              close $tf
          close $nf
          exec nam nam.nam &amp;
              exit 0
      }
  
          set n0 [$ns node]
          set n1 [$ns node]
          set n2 [$ns node]
          set n3 [$ns node]
  
          $ns duplex-link $n0 $n2 1Mb 10ms DropTail
          $ns simplex-link $n1 $n2 1Mb 10ms DropTail
          $ns duplex-link $n2 $n3 0.04Mb 10ms DropTail
  
          $ns queue-limit $n0 $n2 100
          $ns queue-limit $n1 $n2 100
          $ns queue-limit $n2 $n3 100
  
      $ns duplex-link-op $n0 $n2 orient right-down
      $ns simplex-link-op $n1 $n2 orient right-up
      $ns duplex-link-op $n2 $n3 orient right
  
      $ns duplex-link-op $n0 $n2 queuePos 0.5
      $ns simplex-link-op $n1 $n2 queuePos 0.5
      $ns duplex-link-op $n2 $n3 queuePos 0.5
  
      set udp [new Agent/UDP]
      $ns attach-agent $n1 $udp
      set null [new Agent/Null]
      $ns attach-agent $n3 $null
      $ns connect $udp $null
  
      set exp  [new Application/Traffic/Exponential]
      $exp  attach-agent $udp
      $exp  set burst_time_ 0
      $exp  set idle_time_ 400ms
      $exp  set rate_ 1mb
      $exp  set packetSize_ 1000
  
      set tcp [new Agent/TCP]
      $tcp set class_ 2
      $ns attach-agent $n0 $tcp
  
      set sink [new Agent/TCPSink]
      $ns attach-agent $n3 $sink
      $ns connect $tcp $sink
      $tcp set window_ 20
      $tcp set packetSize_ 555
  
      set ftp [new Application/FTP]
      $ftp attach-agent $tcp
      $ftp set type_ FTP
  
      $ns at 0.2 "$exp start"
      $ns at 0.3 "$ftp start"
      $ns at 30000 "$exp stop"
      $ns at 30000 "$ftp stop"
      $ns at 30000 "finish"
          $ns run
  </code></pre>