Traffic Generators for NS2

PART 1
Simulation of Networks
Traffic generation in ns
Traffic generation is described in Chapter 32 of the ns Manual.

Some extracts:

32.5 Applications objects
An application object may be of two types, a traffic generator or a simulated application. Traffic generator objects generate traffic and can be of four types, namely, exponential, pareto, CBR and traffic trace.

Application/Traffic/Exponential objects
Exponential traffic objects generate On/Off traffic. During "on" periods, packets are generated at a constant burst rate. During "off" periods, no traffic is generated. Burst times and idle times are taken from exponential distributions. Configuration parameters are:

PacketSize_
constant size of packets generated.
burst_time_
average on time for generator.
idle_time_
average off time for generator.
rate_
sending rate during on time.

Application/Traffic/Pareto
Application/Traffic/Pareto objects generate On/Off traffic with burst times and idle times taken from pareto distributions. Configuration parameters are:

PacketSize_
constant size of packets generated.
burst_time_
average on time for generator.
idle_time_
average off time for generator.
rate_
sending rate during on time.
shape_
the shape parameter used by pareto distribution.

Application/Traffic/CBR
CBR objects generate packets at a constant bit rate.

$cbr start
Causes the source to start generating packets.

$cbr stop
Causes the source to stop generating packets.

Configuration parameters are:

PacketSize_
constant size of packets generated.
rate_
sending rate.
interval_
(optional) interval between packets.
random_
whether or not to introduce random noise in the scheduled departure times. defualt is off.
maxpkts_
maximum number of packets to send.

Application/Traffic/Trace
Application/Traffic/Trace objects are used to generate traffic from a trace file. $trace attach-tracefile tfile
Attach the Tracefile object tfile to this trace. The Tracefile object specifies the trace file from which the traffic data is to be read. Multiple Application/Traffic/Trace objects can be attached to the same Tracefile object. A random starting place within the Tracefile is chosen for each Application/Traffic/Trace object.

There are no configuration parameters for this object.

TRACEFILE OBJECTS Tracefile objects are used to specify the trace file that is to be used for generating traffic (see Application/Traffic/Trace objects described earlier in this section). $tracefile is an instance of the Tracefile Object.
$tracefile filename trace-input
Set the filename from which the traffic trace data is to be read to trace-input.

There are no configuration parameters for this object. A trace file consists of any number of fixed length records. Each record consists of 2 32 bit fields. The first indicates the interval until the next packet is generated in microseconds. The second indicates the length of the next packet in bytes.


======================================
Link: I found this article at the following Location:
http://www.it.usyd.edu.au/~deveritt/networksimulation/trafficgeneration.html
======================================




PART 2

=============================
Code
=============================
## tg.tcl
## simple example to demonstrate use of traffic generation modules
##
## topology consists of 6 nodes. 4 traffic sources are attached
## to each of 4 'access' nodes. These nodes have links to a single
## 'concentrator' node, which is connected by the bottleneck link
## to the destination node.
##
## there are 4 source agents that generate packets
## 1 generates traffic based on an Exponential On/Off distribution
## 1 generates traffic based on a Pareto On/Off distribution
## 2 generate traffic using the trace file 'example-trace'.
##
set stoptime 10.0
set plottime 11.0

set ns [new Simulator]

set n0 [$ns node]
set n1 [$ns node]

set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]
set n5 [$ns node]

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

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

$ns duplex-link $n0 $n2 10Mb 5ms DropTail
$ns duplex-link $n0 $n3 10Mb 5ms DropTail
$ns duplex-link $n0 $n4 10Mb 5ms DropTail
$ns duplex-link $n0 $n5 10Mb 5ms DropTail

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

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

#$ns trace-queue $n0 $n1 $f

## set up the exponential on/off source, parameterized by packet size,
## ave on time, ave off time and peak rate

set s1 [new Agent/UDP]
$ns attach-agent $n2 $s1

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

$ns connect $s1 $null1

set exp1 [new Application/Traffic/Exponential]
$exp1 set packetSize_ 210
$exp1 set burst_time_ 500ms
$exp1 set idle_time_ 500ms
$exp1 set rate_ 100k

$exp1 attach-agent $s1

## set up the pareto on/off source, parameterized by packet size,
## ave on time, ave off time, peak rate and pareto shape parameter

set s2 [new Agent/UDP]
$ns attach-agent $n3 $s2

set null2 [new Agent/Null]
$ns attach-agent $n1 $null2

$ns connect $s2 $null2

set pareto2 [new Application/Traffic/Pareto]
$pareto2 set packetSize_ 210
$pareto2 set burst_time_ 500ms
$pareto2 set idle_time_ 500ms
$pareto2 set rate_ 200k
$pareto2 set shape_ 1.5

$pareto2 attach-agent $s2

## initialize a trace file
set tfile [new Tracefile]
$tfile filename example-trace

## set up a source that uses the trace file

set s3 [new Agent/UDP]
$ns attach-agent $n4 $s3

set null3 [new Agent/Null]
$ns attach-agent $n1 $null3

$ns connect $s3 $null3

set tfile [new Tracefile]
#$tfile filename /tmp/example-trace
$tfile filename example-trace

set trace3 [new Application/Traffic/Trace]
$trace3 attach-tracefile $tfile

$trace3 attach-agent $s3

## attach a 2nd source to the same trace file

set s4 [new Agent/UDP]
$ns attach-agent $n5 $s4

set null4 [new Agent/Null]
$ns attach-agent $n1 $null4

$ns connect $s4 $null4

set trace4 [new Application/Traffic/Trace]
$trace4 attach-tracefile $tfile

$trace4 attach-agent $s4

$ns at 1.0 "$exp1 start"
$ns at 1.0 "$pareto2 start"
$ns at 1.0 "$trace3 start"
$ns at 1.0 "$trace4 start"

$ns at $stoptime "$exp1 stop"
$ns at $stoptime "$pareto2 stop"
$ns at $stoptime "$trace3 stop"
$ns at $stoptime "$trace4 stop"

$ns at $plottime "close $f"
$ns at $plottime "finish tg"

proc finish file {

set f [open temp.rands w]
puts $f "TitleText: $file"
puts $f "Device: Postscript"

exec rm -f temp.p1 temp.p2 temp.p3 temp.p4
exec touch temp.p1 temp.p2 temp.p3 temp.p4
#
#
exec awk {
{
if (($1 == "+") && ($3 != 0) && ($9 == 2.0)) \
print $2, 2
}
} out.tr > temp.p1
exec awk {
{
if (($1 == "+") && ($3 != 0) && ($9 == 3.0)) \
print $2, 3
}
} out.tr > temp.p2
exec awk {
{
if (($1 == "+") && ($3 != 0) && ($9 == 4.0)) \
print $2, 4
}
} out.tr > temp.p3
exec awk {
{
if (($1 == "+") && ($3 != 0) && ($9 == 5.0)) \
print $2, 5
}
} out.tr > temp.p4

puts $f [format "\n\"ExpOnOff"]
flush $f
exec cat temp.p1 >@ $f
flush $f
puts $f [format "\n\"ParetoOnOff"]
flush $f
exec cat temp.p2 >@ $f
flush $f
puts $f [format "\n\"Trace1"]
flush $f
exec cat temp.p3 >@ $f
flush $f
puts $f [format "\n\"Trace2"]
flush $f
exec cat temp.p4 >@ $f
flush $f

close $f
exec rm -f temp.p1 temp.p2 temp.p3 temp.p4
exec xgraph -bb -tk -nl -m -x time -y "source node" temp.rands &

puts "running nam..."
exec nam out.nam &

exec rm -f out.tr

}

$ns run


exit 0


====================================
Link: Found the above code at the following link:
http://www.it.usyd.edu.au/~deveritt/networksimulation/tg.tcl
====================================

(ZZ)那些出境率极高但是你绝对想不到怎么说的单词。。。

Learn something interesting ~

Beat generation 垮掉的一代
Tea-ceremony 茶道
Badger game 美人计
Scene stealer 抢镜头的人
Hooligan 阿飞,足球流氓
Repeated offender 惯犯
Double agent 双重间谍
Mr. Big 黑社会老大
Love child 私生子
Hand-to-hand fighting 肉搏
Box news 花边新闻
Screen agers 整天看电视玩电脑的孩子
June-December wedding 双方年龄悬殊的婚姻
King’s English 标准英语
Leap day/year 闰日2.29/年366
Maid of Orleans 圣女贞德
Narrow squeak(口)九死一生的脱险
Ninja turtle 忍者神龟
Poet laureate 桂冠诗人
Ponytail 马尾辫
Protestant 新教徒
Pulitzer Prize 普利策奖
Rat race 激烈的竞争
Red-light district 红灯区
Reader’s Digest 读者文摘
Russian roulette 俄罗斯轮盘赌
Sexual harassment 性骚扰
Short fuse 易怒的脾气
Soft-soap 奉承讨好
Silent contribution 隐名捐款
Silly money 来路不明的钱
Silver screen 银幕,电影界
Summer complaint 夏季病,拉肚子
Tenth-rate 最低等的,劣等的
Vertical/lateral thinking 纵向,横向思维
Wide-body 大部头的作品
Wheel of life (佛教)轮回
Xenomania 媚外
Yearbook 年鉴年刊
Zen 禅
Paparazzi 狗仔队
Show people 娱乐界人士
Exotic dance 脱衣舞
Bearish 行情下跌的
Bullish 行情上涨的
State prisoner 政治犯
Stowaway 偷渡者,逃票的乘客
Plainclothesman 便衣警察
Police dog 警犬
Police post 派出所
Negligent homicide 过失杀人
Impostor 江湖骗子
ICJ International Court of Justice 国际法院
Espionage 间谍 间谍活动
Lifer 职业军人
Mine 地雷 水雷
Panzer 装甲车 坦克
Off limits 军事禁区
Q-boat 伪装成商船或渔船的武装船只
Riot corps 防暴部队
Standing army 常规军
Sniper 狙击手
Bermuda Triangle 百慕大三角洲
Brain drain 脑力人才外流
Brawn drain 劳力外流
Break- dancing 霹雳舞
French windows 落地窗
Funeral home 殡仪馆
Taillight 车尾灯
Visiting team 客队
Runner-up 亚军
Black referee 黑哨
Foul play 犯规动作
Standing broad jump 立定跳远
Underachiever 差等生
Hothouse 对儿童进行学前教育
Whiz kid 神童 优等生
Newsbreak 重要新闻
Needle trade 成衣业
Massage parlour 挂按摩牌子的妓院
Moonlight 作动词,干第二职业
Mixed marriage 异族通婚
Moon roof 汽车的顶窗
Egghead 对知识分子的蔑称
Dog days 七八月份的酷暑期,伏天
Connoisseur 鉴赏家
Box office 票房
Bridesmaid 女傧相
Bee (美)为互助友好而举行的聚会
Bigtime 红极一时的,赫赫有名的
Bank of issue 发行银行
Cater ∏ 美国总统克林顿 (卡特二世。。。)
Big stick大棒政策
Oxbridge 牛津和剑桥大学
Multiversity 综合大学
CDV compact video disc 激光光碟
Beeper BP机
Exclusive 独家新闻
Divorcee 离了婚的人
disposable worker 临时工
Eden 伊甸园
Bandwagon 见风使舵
Sapphire 蓝宝石
Scrappage 报废物
Shangri-la 香格里拉
Obituary 补告
Hangover 宿醉
Full scholarship 全额奖学金
Stone-cold fox 冰山美人
Brain trust 政府的智囊团
A-list 名流群,精英
all-expense tour 自费游
Bard-of-Avon 埃文河诗人,莎士比亚的别称
Beau monde 上流社会
Beautiful people 上流社会的时髦阶层
Bagstuffer 街头广告传单
Antichoice 反堕胎
Backwater 死水,死气沉沉的地方
Intercom 对讲机,闭路通讯装置
In vitro fertilization 体外受精,试管受精
Cottonmouth snake 百步蛇
Laser surgery 激光外科手术
Intercept 截球
Unscrupulous bombing 狂轰滥炸
Tommy gun (美)冲锋枪
Strafe 扫射,猛烈炮击
Superbomb 氢弹
Unconditional surrender 无条件投降
Losing battle 必败之战
Military operation 作战
Missile equipped destroyer 导弹驱逐舰
Mess 军用食堂
Rock-bottom 最低的
Seed money 本钱
Principal 本金,可生息
Securities 证券,有价证券
Sag 萧条,下跌
Profiteer 投机商,奸商
Prime 银行贷款的最低利率
Red ink 赤字,亏损
Ready money 现钞
Bell-bottom trousers 喇叭裤
Julibee 五十周年大庆
Jim Crow 对黑人的蔑称
Iron lady 指铁娘子撒切尔夫人
Itinerant 巡回的
Intelligentsia知识分子的总称,知识界,知识阶层
Jack 千斤顶
Blue moon 千载难逢的时机
Benefit 义卖,义演,义赛
Brainwave 灵感,突然想到的主意
Honor man (美)优等生
Full professor 正教授
Doctorate博士学位
Alma Mater 母校
Academician 院士
Pony report 每日要闻报道
Peter Funk (美俚)拍卖中冒充卖家抬高价格的冒牌出价人
Pep rally 动员大会
Pipe dream 白日梦,空想
Pay TV 收费电视
Plastic operation 整形手术
Made man 成功的人
Manicure 修指甲
Mad money (美俚)私房钱
Lotusland 逍遥乡
Jolly Roger 海盗旗
Invalid 病号,伤残者
Informed sources 消息灵通的人士
Hot air 吹牛,空话
Idiot box (口)电视机
Ins and outs 迂回曲折,底细
In-flight meal 航空餐

Materials for 802.11 Simulation in NS2

Network Troubleshooting using Command-line

To troubleshoot a TCP/IP networking problem, utilize the following command step be step.


1. ipconfig

ipconfig /all : view TCP/IP configuration of the computer.

ipconfig /renew : force network adapter to contact a DHCP server and renew the existing configuration or obtain a new configuration.

Also, ipconfig command can be used to deal with DNS. (might be useful) /displaydns : displays the contents of the DNS Resolver Cache; /flushdns : purges the DNS cache; /registerdns : refreshes all DHCP leases and re-registers DNS names.

2. ping

The ping command helps to verify IP-level connectivity by sending an ICMP echo request to a target host name or IP address.

Perform the following steps when using ping:

1). Ping the loopback address to verify that TCP/IP is installed and configured correctly on the local computer.

ping 127.0.0.1

2). Ping the IP address of the local computer to verify that it was added to the network correctly.

ping IP_address_of_local_host

3). Ping the IP address of the default gateway to verify that default gateway is functioning and you can communicate with a local host on the local network.

ping IP_address_of_default_gateway

4). Ping the IP address of a remote host to verify that you can communicate through a router.

ping IP_address_of_remote_host

The ping command uses Windows Sockets - style name resolution to resolve a computer name to an IP address, so if pinging by address succeeds, but pinging by name failes, then the problem lies in address or name resolution, not network connectivity.

3. arp

The arp command is used to view and modify the ARP table entires on the local computer so as to resolve address resolution problems.

4. nbtstat

The nbtstat command is used for troubleshooting NetBIOS name resolution problems (basically for netBIOS services in local area networks).

NetBIOS (Network Basic Input/Output System) provides services related to the session layer of the OSI model allowing applications on seperate computers to commnicate over a local area network. NetBIOS over TCP/IP is a network protocol that allows legacy computer applications relying on NetBIOS API to be used on modern TCP/IP networks. NetBIOS provides three distinct services: name service, session service and datagram distribution service.

5. netstat

The netstat command can be used to display protocol stastics and current TCP/IP connections.

netstat -a : displays all connections.

netstat -r : displays the route table plus active connections.

netstat -e : displays Ethernet statistics.

netstat -s : displays per-protocol statistics.

netstat -n : addresses and port numbers are not converted to names.

6. tracert

Trace Route is a route-tracing utility that is used to determine the path that an IP datagram takes to reach a destination. The tracert command uses the IP time-to-live field and ICMP error messages to determine the route.

tracert [-d](specifies that IP address are not resolved to host name) [-h maximum_hops] [-j host-list] [-w timeout] target_name

7. pathping

The pathping command is a route tracing tool that combines features of the ping and tracert commands with additional information that neither of those tools provides.

The pathping command sends packets to each router on the way to a final destination over a period of time, and then computes results based on the packets returned from each hop. Since the command shows the degree of packet loss at any given router or link, it is easy to determine which routers or links might be causing network problems.