/* Define here if you want to swap ports also */ #define REALPORT 23 /* port you which to communicate */ #define FAKEPORT 9000 /* port that appears on the wire */
unsigned int print_hex(char *str, unsigned int str_len) { char *curr_line; char ch; int i = 0, j = 0; unsigned int len = 0; unsigned int total_len = 0; unsigned int index = 0; unsigned int line = 0;
proc monitor {interval} { global FlowNumber tcp ns set nowtime [$ns now]
# for {set i 0} {$i < $FlowNumber} {incr i 1} { set win [open result a] # puts $win "$nowtime [$tcp($i) set cwnd_] [$tcp($i) set ack_]" puts $win "$nowtime [$tcp set cwnd_]" # [$tcp set ack_]" close $win # } $ns after $interval "monitor $interval" }
proc finish { } { puts "inner end1" global ns tf nf filename # f_cwnd $ns flush-trace close $tf # close $nf # close $f_cwnd puts "inner end" exec nam $filename.nam & exit 0; }
#Create six nodes #agent set host1 [$ns node] #puts "$ns $n0" set host2 [$ns node] #puts "$ns $n1" set host3 [$ns node] #puts "$ns $n2" set host4 [$ns node] #puts "$ns $n3" set rout1 [$ns node] #puts "$ns $n4" set rout2 [$ns node]
set sender1 [$ns node] set sender2 [$ns node] set sender3 [$ns node] set sender4 [$ns node]
set recv1 [$ns node] set recv2 [$ns node] set recv3 [$ns node] set recv4 [$ns node] #puts "$ns $n5"
set redq [[$ns link $rout1 $rout2] queue] # set traceq [open reno-queue.tr w] # $redq attach $traceq
#Create a TCP agent and attach it to node n0 set tcp [new Agent/TCP/$tcp_protocol] # set tcp [new Agent/TCP] $tcp set fid_ 1 $tcp set window_ 100 $tcp set packetSize_ $packet_size # set tcp2 [new Agent/TCP/$tcp_protocol] set tcp2 [new Agent/TCP] $tcp2 set fid_ 3 $tcp2 set window_ 100 set tcp3 [new Agent/TCP] $tcp3 set fid_ 4 $tcp3 set window_ 100 set tcp4 [new Agent/TCP] $tcp4 set fid_ 5 $tcp4 set window_ 100 #set tcp [new Agent/TCP]
#$tcp set pace_packet_ 2 # $tcp set rtt 0.01s #$tcp set rate_ 1mb #set tcp [$ns create-connection TCP $n0 TCPSink $n2 0] set snk [new Agent/TCPSink] set snk2 [new Agent/TCPSink] set snk3 [new Agent/TCPSink] set snk4 [new Agent/TCPSink]
$tcp set syn_ true $tcp2 set syn_ true $tcp3 set syn_ true $tcp4 set syn_ true $ns attach-agent $host1 $tcp
#Create a UDP agent and attach it to node n0 set udp [new Agent/UDP] $ns attach-agent $host2 $udp set null [new Agent/UDP] $ns attach-agent $host4 $null $ns connect $udp $null $udp set fid_ 2
#Setup a CBR over UDP connection set cbr [new Application/Traffic/CBR] $cbr attach-agent $udp $cbr set type_ CBR $cbr set packet_size_ 512 #5MBps # $cbr set rate_ 5000000 $cbr set rate_ $rate # [lindex $argv 0]
#proc logTCPwnd {logfile tcpSource timeInterval} { # global ns # set now [$ns now] # set cwnd [$tcpSource set cwnd_] # set awnd [$tcpSource set awnd_] # puts $logfile "$now $cwnd $awnd" # $ns at [expr $now+$timeInterval] "logTCPwnd $logfile $tcpSource $timeInterval" }
#Schedule events for the CBR agents #$ns at 0.0 "logTCPwnd $t_cwndTf $tcp 0.05" #Setup a FTP over TCP Connection set ftp [$tcp attach-source FTP] $ftp set type_ FTP # set ftp2 [new Application/FTP] # $ftp attach-agent $tcp2
set ftp2 [$tcp2 attach-source FTP] set ftp3 [$tcp3 attach-source FTP] set ftp4 [$tcp4 attach-source FTP] $ftp2 set type_ FTP # $ftp2 set packet_size_ 512 $ftp3 set type_ FTP # $ftp3 set packet_size_ 512 $ftp4 set type_ FTP # $ftp4 set packet_size_ 512
# $ns at 0 "monitor 0.5" $ns at 0.0 "$ftp start" # $ns at 0.0 "$ftp2 start" # $ns at 0.0 "$ftp3 start" # $ns at 0.0 "$ftp4 start" $ns at 10.0 "$cbr start" $ns at 110.0 "finish" # $ns at 10.0 "$ftp start" # $ns at 1.0 "$cbr start" # $ns at 10.0 "finish" #Run the simulation $ns run return 1; }
}
아래는 thoughput 스크립트
BEGIN { init=0; i=0; recv = 0 }
{ # Trace line format: normal # if ($2 != "-t") { event = $1 time = $2 if (event == "+" || event == "-") node_id = $3 if (event == "r" || event == "d") node_id = $4 flow_id = $8 pkt_id = $12 pkt_size = $6 # } # Trace line format: new # if ($2 == "-t") { # event = $1 # time = $3 # node_id = $5 # flow_id = $39 # pkt_id = $41 # pkt_size = $37 # }
# Calculate total received packets' size if(event=="+" && node_id==0 && flow_id==1) {
POTS networks almost universally use the ITU G.711 64 kb/s PCM standard. As previously noted, this type of coder outputs 8 bits every 1/8000th of a second, that is, the frame of this coder is 1/8000th of a second, and the frame size is 8 bits. Other coders exist that can reduce the generated bit rate, but usually with a slightly reduced perceived quality. Table 1 compares selected ITU coders, including their associated bit rates [2, 3]. Of these codes, G.729 has evoked considerable interest for VoIP providers as it has comparable quality to G.711, but at a greatly reduced bit rate. G.729 has a frame length of 10 msec, and its compression algorithm outputs 80 bits every 1/100th of a second, yielding an 8 kb/s bit rate. POTS TDM backbones are based around fixed-rate coders. For example, a G.711 coder outputs 64 kb/s at all times, regardless of whether or not the voice source is talking or listening. The statistical as-needed allocation of backbone bandwidth on VoIP networks offers the opportunity to deploy variable-rate coders, which output traffic at one bit rate when the voice source is talking, and a lower bit rate (possibly zero) when the voice source is quiet. For example, G.729B with silence suppression examines each 10 msec voice frame and makes a voice/no voice decision. If the coder detects voice energy, it will output the standard 80 bits of compressed, digitized voice for that frame. If the coder decides this frame does not contain voice energy, the coder will output a reduced block of bits containing comfort noise, information that the receiver will use to generate background noise so that the user does not think the connection has been lost [3]. Alternatively, the coder could output nothing at all and the receiver could generate comfort noise. Experiments have shown that in a typical two-way interactive voice conversation, voice sources are only active 40 percent of the time [4]. The 60 percent idle time includes pauses while listening to the other party talking, as well as pauses between sentences, and even pauses between some words. A G.729B coder with silence suppression will output 8 kb/s during talk spurts (40 percent of the time), and nothing or a reduced bit rate during intervening silence intervals (60 percent of the time). The use of silence suppression potentially allows a G.729 coder to reduce its average output from 8 kb/s to 3.2 kb/s (alternating 8 kb/s and 0 kb/s bursts).