Free Most Trusted List of Faucets to Earn Extra Income from Home

Earn Some Free Cryptocurrencies with these most trusted faucets.

If you are looking for an absolutely legitimate way to collect some FREE cryptocurrencies start off with Faucets which are absolutely trustworthy and reliable with proven record of payments. No eed to research because this list is meticulously made to save all the hard work. JUST REGISTER AND START EARNING RIGHT AWAY !!!

The biggest and most popular faucets for BTC and Dogecoin are the following. Easy registration using these links.

1. Freebitcoin https://freebitco.in/?r=3942043
2. Dogecoin http://freedoge.co.in/?r=817576

Register on coinpot as it supports many faucets for many currencies in an absolutely stunning integrated dashboard format.

https://coinpot.co

Register on coinpot and then register on the following faucets with the same email address that you used on coinpot.
Click on the links to easily register with faucets.

1. Moonbitcoin http://moonbit.co.in/?ref=050aea3c12db
2. Moondoge http://moondoge.co.in/?ref=de98dc2a5d20
3. MoonLitecoin http://moonliteco.in/?ref=d337f7e216ae
4. Moondash  http://moondash.co.in/?ref=42C35F83A16D
5. Mooncash http://moonbitcoin.cash/?ref=E422C8AA7828
6. Bitfun         http://bitfun.co/?ref=097365833670
7. Bonusbitcoin http://bonusbitcoin.co/?ref=4A6E78B7BB47

[Free Script] NS-2 Multicast Scenario with Web Traffic | Wired MANETs


# Create scheduler

#Create an event scheduler wit multicast turned on

set ns [new Simulator -multicast on]

#$ns multicast

#Turn on Tracing

set tf [open output.tr w]

$ns trace-all $tf

# Turn on nam Tracing

set fd [open mcast.nam w]

$ns namtrace-all $fd

# Create nodes

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 n6 [$ns node]

set n7 [$ns node]

# Create links

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

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

$ns duplex-link $n2 $n3 1.5Mb 10ms DropTail

$ns duplex-link $n3 $n4 1.5Mb 10ms DropTail

$ns duplex-link $n3 $n7 1.5Mb 10ms DropTail

$ns duplex-link $n4 $n5 1.5Mb 10ms DropTail

$ns duplex-link $n4 $n6 1.5Mb 10ms DropTail


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



# Routing protocol: say distance vector

#Protocols: CtrMcast, DM, ST, BST

set mproto DM

set mrthandle [$ns mrtproto $mproto {}]

# Allocate cluster addresses

set cluster1 [Node allocaddr]

set cluster2 [Node allocaddr]

# UDP Transport agent for the traffic source

set www_UDP_agent [new Agent/UDP]

$ns attach-agent $n0 $www_UDP_agent

$www_UDP_agent set dst_addr_ $cluster1

$www_UDP_agent set dst_port_ 0

set www_CBR_source [new Application/Traffic/CBR]

$www_CBR_source attach-agent $www_UDP_agent
$www_CBR_source set packetSize_ 48

$www_CBR_source set interval_ 50ms

# Transport agent for the traffic source

set udp1 [new Agent/UDP]

$ns attach-agent $n1 $udp1

$udp1 set dst_addr_ $cluster2

$udp1 set dst_port_ 0

set cbr2 [new Application/Traffic/CBR]

$cbr2 attach-agent $udp1

# Create receiver

set rcvr1 [new Agent/Null]

$ns attach-agent $n5 $rcvr1

$ns at 1.0 "$n5 join-cluster $rcvr1 $cluster1"

set rcvr2 [new Agent/Null]

$ns attach-agent $n6 $rcvr2

$ns at 1.5 "$n6 join-cluster $rcvr2 $cluster1"

set rcvr3 [new Agent/Null]

$ns attach-agent $n7 $rcvr3

$ns at 2.0 "$n7 join-cluster $rcvr3 $cluster1"

set rcvr4 [new Agent/Null]

$ns attach-agent $n5 $rcvr1

$ns at 2.5 "$n5 join-cluster $rcvr4 $cluster2"

set rcvr5 [new Agent/Null]

$ns attach-agent $n6 $rcvr2

$ns at 3.0 "$n6 join-cluster $rcvr5 $cluster2"

set rcvr6 [new Agent/Null]

$ns attach-agent $n7 $rcvr3

$ns at 3.5 "$n7 join-cluster $rcvr6 $cluster2"

$ns at 4.0 "$n5 leave-cluster $rcvr1 $cluster1"

$ns at 4.5 "$n6 leave-cluster $rcvr2 $cluster1"

$ns at 5.0 "$n7 leave-cluster $rcvr3 $cluster1"

$ns at 5.5 "$n5 leave-cluster $rcvr4 $cluster2"

$ns at 6.0 "$n6 leave-cluster $rcvr5 $cluster2"

$ns at 6.5 "$n7 leave-cluster $rcvr6 $cluster2"

# Schedule events

$ns at 0.5 "$www_CBR_source start"

$ns at 9.5 "$www_CBR_source stop"

$ns at 0.5 "$cbr2 start"

$ns at 9.5 "$cbr2 stop"

#post-processing

$ns at 10.0 "finish"

proc finish {} {

global ns tf

$ns flush-trace

close $tf

exec nam mcast.nam &

exit 0

}

# For nam

#Colors for packets from two mcast clusters

$ns color 10 red

$ns color 11 green

$ns color 30 purple

$ns color 31 green

# Manual layout: order of the link is significant!

#$ns duplex-link-op $n0 $n1 orient right

#$ns duplex-link-op $n0 $n2 orient right-up

#$ns duplex-link-op $n0 $n3 orient right-down

# Show queue on simplex link n0->n1

#$ns duplex-link-op $n2 $n3 queuePos 0.5

# Cluster 0 source

$www_UDP_agent set fid_ 10

$n0 color red

$n0 label "Source 1"

# Cluster 1 source

$udp1 set fid_ 11

$n1 color green

$n1 label "Source 2"

$n5 label "Receiver 1"

$n5 color blue

$n6 label "Receiver 2"

$n6 color blue

$n7 label "Receiver 3"

$n7 color blue

#$n2 add-mark m0 red

#$n2 delete-mark m0"

# Animation rate

$ns set-animation-rate 3.0ms

$ns run

Barre Chords - A Primer

Barre Chord is a technique where one can use any one finger to press all the strings  on any given fret at the same time. Most of the guitarists prefer their first finger or the index finger for playing barre chords. While playing barre chords the index finger acts like a capo and one can play riffs from that particular fret onwards using the remaining four fingers. Barre chords are used and played in a number of popular and melodious compositions. Barre chords requires a lot of strumming practice until you are able to perfectly  barre the chords. But once you are able to achieve that level of expertise, there's no stopping and no looking back and you are the master of Barre Chords.

So, Go on and give yourself a handful of rigorous practice sessions on this technique and master the art of playing barre chords !!

10 COMMANDMENTS OF GUITAR DOUCHEBAGGERY

Just for laughs.An exclusive guitarkart.com poster featuring 10 commandments of guitar douchebaggery. Free to download, Like share and subscribe if its hillarious.


Music Mends _ Acoustic healing

Music Mends. Yes this phrase means, matters and does a lot.

Let us see how. Music has always been known for its healing abilities, especially mostly in untowardly conditions of mental health of Human beings. Here in this article I,m going to quickly list 3 super wonderful effects of Music in Mending Souls.

       What’s more interesting and revealing is that practicing music has even better healing effects than just listening to music. Results reveal that those who have practiced music have not only found and regained self-confidence but have a risen self esteem, during their phase of recovery.
        It helps in improved co-ordination; results reveal that practicing acoustic music helps in channelizing the nervous system co-ordination with the body.
        It helps in better communication with people and helps in becoming a people’s person. Discussing music is one of the healthiest discussions around. Finding music is one of the most precious findings around.Hope you find these recommendations a boon in enjoying your musical journey. Good Luck and Happy strumming.

The Guitar Therapy
Guitar  is one such musical instrument which never loses its glitz and charm. Right from the age of 5 to an 80 year old, playing guitar always soothes the heart and soul. This is one such instrument which can even cure depression and eliminates stress. The vibes produced by Guitar strumming can eliminate tension and stress. Moreover, music is known for its healing and soothing qualities since ages.  It is beneficial for any individual, both physically and mentally, through improved heart rate, reduced anxiety, stimulation of the brain, and improved learning. Music therapists use their techniques to help their patients in many areas.

The therapeutic effects of guitar are proven and well accepted over the globe. It sharpens the mind body coordination and makes the person more smarter. 

ZEN STORIES FOR GOOD LIFE

Zen Stories are stories for life and stories for keep sake. Some of the stories are easy straight forward, but some of the stories are witty, twisted and have a touch of sarcasm. But all the stories will sure stir your soul. Here is a collection of short stories in the form of images. (how cool is that !!). I started off this project quite sometime ago, hope you like it and i continue making it.














100 Commandments of Photography

100 Commandments of Photography is a comprehensive guide to understanding do’s and don’ts of photography on a lighter note. A must Read, a must laugh.

1. Just because someone has an expensive camera doesn’t mean that they’re a good photographer.
2. Always shoot in RAW. Always.
3. Prime lenses help you learn to be a better photographer.
4. Photo editing is an art in itself.
5. The rule of thirds works 99% of the time.
6. Macro photography isn’t for everybody.
7. UV filters work just as well as lens caps.
8. Go outside and shoot photos rather than spending hours a day on photography forums.
9. Capture the beauty in the mundane and you have a winning photograph.
10. Film isn’t better than digital.
11. Digital isn’t better than film.
12. There is no “magic” camera or lens.
13. Better lenses don’t give you better photos.
14. Spend less time looking at other people’s work and more time shooting your own.
15. Don’t take your DSLR to parties.
16. Girls dig photographers.
17. Making your photos b/w doesn’t automatically make them “artsy”.
18. People will always discredit your work if you tell them you “photoshop” your images. Rather,            tell them that you process them in the “digital darkroom”.
19. You don’t need to take a photo of everything.
20. Have at least 2 backups of all your images. Like they say in war, two is one, one is none.
21. Ditch the neck strap and get a handstrap.
22. Get closer when taking your photos, they often turn out better.
23. Be a part of a scene while taking a photo; not a voyeur.
24. Taking a photo crouched often make your photos look more interesting.
25. Worry less about technical aspects and focus more on compositional aspects of photography.
26. Tape up any logos on your camera with black gaffers tape- it brings a lot less attention to you.
27. Always underexpose by 2/3rds of a stop when shooting in broad daylight.
28. The more photos you take, the better you get.
29. Don’t be afraid to take several photos of the same scene at different exposures, angles, or                    apertures.
30. Only show your best photos.
31. A point-and-shoot is still a camera.
32. Join an online photography forum.
33. Critique the works of others.
34. Think before you shoot.
35. A good photo shouldn’t require explanation (although background information often adds to an          image).
*36. Alcohol and photography do not mix well.
37. Draw inspiration from other photographers but never worship them.
38. Grain is beautiful.
39. Ditch the photo backpack and get a messenger bag. It makes getting your lenses and camera a              whole lot easier.
40. Simplicity is key.
41. The definition of photography is: “painting with light.” Use light in your favor.
42. Find your style of photography and stick with it.
43. Having a second monitor is the best thing ever for photo processing.
44. Silver EFEX pro is the best b/w converter.
45. Carry your camera with you everywhere. Everywhere.
46. Never let photography get in the way of enjoying life.
47. Don’t pamper your camera. Use and abuse it.
48. Take straight photos.
49. Shoot with confidence.
50. Photography and juxtaposition are best friends.
51. Print out your photos big. They will make you happy.
52. Give your photos to friends.
53. Give them to strangers.
54. Don’t forget to frame them.
55. Costco prints are cheap and look great.
56. Go out and take photos with (a) friend(s).
57. Join a photo club or start one for yourself.
58. Photos make great presents.
59. Taking photos of strangers is thrilling.
60. Candid>Posed.
61. Natural light is the best light.
62. 35mm (on full frame) is the best “walk-around” focal length.
63. Don’t be afraid to bump up your ISO when necessary.
64. You don’t need to always bring a tripod with you everywhere you go (hell, I don’t even own one).
65. It is always better to underexpose than overexpose.
66. Shooting photos of homeless people in an attempt to be “artsy” is exploitation.
67. You will find the best photo opportunities in the least likely situations.
68. Photos are always more interesting with the human element included.
69. You can’t “photoshop” bad images into good ones.
70. Nowadays everybody is a photographer.
71. You don’t need to fly to Paris to get good photos; the best photo opportunities are in your                    backyard.
72. People with DSLRS who shoot portraits with their grip pointed downwards look like morons.
73. Cameras as tools, not toys.
74. In terms of composition, photography and painting aren’t much different.
75. Photography isn’t a hobby- it’s a lifestyle.
76. Make photos, not excuses.
77. Be original in your photography. Don’t try to copy the style of others.
78. The best photographs tell stories that begs the viewer for more.
79. Any cameras but black ones draw too much attention.
80. The more gear you carry around with you the less you will enjoy photography.
81. Good self-portraits are harder to take than they seem.
82. Laughter always draws out peoples’ true character in a photograph.
83. Don’t look suspicious when taking photos- blend in with the environment.
84. Landscape photography can become dull after a while.
85. Have fun while taking photos.
86. Never delete any of your photos.
87. Be respectful when taking photos of people or places.
88. When taking candid photos of people in the street, it is easier to use a wide-angle than a                       telephoto        lens.
89. Travel and photography are the perfect pair.
90. Learn how to read a histogram.
91. A noisy photo is better than a blurry one.
92. Don’t be afraid to take photos in the rain.
93. Learn how to enjoy the moment, rather than relentlessly trying to capture the perfect picture of it.
94. Never take photos on an empty stomach.
95. You will discover a lot about yourself through your photography.
96. Never hoard your photographic insight- share it with the world.
97. Never stop taking photos.
98. Photography is more than simply taking photos, it is a philosophy of life.
99. Capture the decisive moment.
100. Write your own list.

4B5B ENCODING TABLE

4B5B ENCODING



4B5B ENCODING was purposely invented to produce at least two transitions per 5 bits of output code regardless of input data. When it is NRZI-encoded, the transitions give necessary clock transitions for the receiver to be able to comprehend input data correctly. For example, a run of 4 bits such as 00002 contains no transitions and that causes clocking problems for the receiver. 4B5B comes to rescue this problem by assigning the 4-bit block a 5-bit code, in this particular example 111102.

Data 4B5B code
(Hex) (Binary)
0 0 11110
1 1 1001
2 10 10100
3 11 10101
4 100 1010
5 101 1011
6 110 1110
7 111 1111
8 1000 10010
9 1001 10011
A 1010 10110
B 1011 10111
C 1100 11010
D 1101 11011
E 1110 11100
F 1111 11101



Check out the youtube video for more.
https://youtu.be/97nmHK4DRoA

Photography Studio Equipment for Rent in Chandigarh (Mohali, Panchkula)



Studio Equipment for Urgent Photoshoot Available on Rent at affordable Price in Chandigarh (Tricity)


Studio Equipment on Rent

1. Backdrops All Colours
2. Backdrop Stands
3. Light stands
3. Strobe lights
4. Umbrellas
5. Flash Lights
6. Triggers
7. Softboxes - Square
8. Softboxes - Octa - Big Size
9. Static Light Sources
 

Call : 8699007766
Email: nipunharitash@gmail.com

[Free] Photography Cheat Sheet

THE MOST COMPREHENSIVE PHOTOGRAPHY CHEAT-SHEET

So you have graduated yourself to a photographer who uses the MANUAL mode. But those technical jargons are still not fitting into the muscle memory. Dont worry a bit, cause Nipun Haritash Photography brings you the most condensed and comprehensive Photography Cheat sheet that you can download free of cost.

You have just landed on the perfect page of photography cheat-sheet that will help you keep the basics on our tips until they sink in completely. In this comprehensive cheat sheet, I have tried to cover the most essential elements in a super easy visual demonstration. I have covered the basics of understanding exposure, aperture, shutter-speed, ISO and composition.

The most interesting and important thing about this photography cheat-sheet is that it is going to sharpen your learning curve of not only operating your DSLR in the manual mode but also the other modes. If you understand the basics of each element then understanding different modes become easier. For example, if you understand what Aperture is, then in aperture priority mode you are going to change the aperture of the lens (having a full manual control over aperture only )and rest everything will be adjusted automatically by the DSLR. This makes experimenting a lot easier and finding the best results quicker.

This exclusive Cheat-Sheet is provided by Nipun Haritash Photography.


Sample NS-2 TCL Script Files [Free]

1. Create a Wired Loop Network (Kind of Ring Network)

The network link breaks somewhere in between and the link becomes up after some time.

#Create a simulator object
set ns [new Simulator]

#Tell the simulator to use dynamic routing
$ns rtproto DV

#Open the nam trace file
set nf [open out.nam w]
$ns namtrace-all $nf


#Define a 'finish' procedure
proc finish {} {
        global ns nf
        $ns flush-trace
#Close the trace file
        close $nf
#Execute nam on the trace file
        exec nam out.nam &
        exit 0
}

#Create seven nodes
for {set i 0} {$i < 7} {incr i} {
        set n($i) [$ns node]
}


#Create links between the nodes
for {set i 0} {$i < 7} {incr i} {
        $ns duplex-link $n($i) $n([expr ($i+1)%7]) 1Mb 10ms DropTail
}

#Create a UDP agent and attach it to node n(0)
set udp0 [new Agent/UDP]
$ns attach-agent $n(0) $udp0

# Create a CBR traffic source and attach it to udp0
set cbr0 [new Application/Traffic/CBR]
$cbr0 set packetSize_ 500
$cbr0 set interval_ 0.005
$cbr0 attach-agent $udp0

#Create a Null agent (a traffic sink) and attach it to node n(3)
set null0 [new Agent/Null]
$ns attach-agent $n(3) $null0

#Connect the traffic source with the traffic sink
$ns connect $udp0 $null0 

#Schedule events for the CBR agent and the network dynamics
$ns at 0.5 "$cbr0 start"
$ns rtmodel-at 1.0 down $n(1) $n(2)
$ns rtmodel-at 2.0 up $n(1) $n(2)
$ns at 4.5 "$cbr0 stop"
#Call the finish procedure after 5 seconds of simulation time
$ns at 5.0 "finish"

#Run the simulation
$ns run

2. Code to insert Channel Error rate to a wired network


#Set error model on link n2 to n3.

set loss_module [new ErrorModel]
$loss_module set rate_ 0.2
$loss_module ranvar [new RandomVariable/Uniform]
$loss_module drop-target [new Agent/Null]
$ns lossmodel $loss_module $n2 $n3


3. Wireless Sensor Network


# ======================================================================
# Define options
# ======================================================================
set val(chan)           Channel/WirelessChannel    ;# Channel Type
set val(prop)           Propagation/TwoRayGround   ;# radio-propagation model
set val(netif)          Phy/WirelessPhy/802_15_4
set val(mac)            Mac/802_15_4
set val(ifq)            Queue/DropTail/PriQueue    ;# interface queue type
set val(ll)             LL                         ;# link layer type
set val(ant)            Antenna/OmniAntenna        ;# antenna model
set val(ifqlen)         150                         ;# max packet in ifq
set val(nn)             4                         ;# number of mobilenodes
set val(rp)             AODV                       ;# routing protocol
set val(x)  50
set val(y)  50
#Queue/DropTail/PriQueue set Prefer_Routing_Protocols    1
#LL set mindelay_                50us
#LL set delay_                   25us
#LL set bandwidth_               0       ;# not used
#LL set-limit 1000000




# =================================
# Antenna Settings
# =================================
Antenna/OmniAntenna set X_ 0
Antenna/OmniAntenna set Y_ 0
Antenna/OmniAntenna set Z_ 1.5
Antenna/OmniAntenna set Gt_ 1.0 
Antenna/OmniAntenna set Gr_ 1.0
#======================
#Physica layer setting
#======================
Phy/WirelessPhy set freq_ 2.4e+9 ;# The working band is 2.4GHz
Phy/WirelessPhy set L_ 0.5   ;#Define teh system loss in TwoRayGround
Phy/WirelessPhy set  bandwidth_  28.8*10e3   ;#28.8 kbps
# For model 'TwoRayGround'
# Thereceived signals strenghts  in different distances
set dist(5m)  7.69113e-06
set dist(9m)  2.37381e-06
set dist(10m) 1.92278e-06
set dist(11m) 1.58908e-06
set dist(12m) 1.33527e-06
set dist(13m) 1.13774e-06
set dist(14m) 9.81011e-07
set dist(15m) 8.54570e-07
set dist(16m) 7.51087e-07
set dist(20m) 4.80696e-07
set dist(25m) 3.07645e-07
set dist(30m) 2.13643e-07
set dist(35m) 1.56962e-07
set dist(40m) 1.20174e-07
Phy/WirelessPhy set CSThresh_  ;#$dist(40m)
Phy/WirelessPhy set RXThresh_  ;#$dist(40m)
#Phy/WirelessPhy set CPThresh_ 10
# According to the Two-Ray Ground propagation model
#Pr(d) = Pt*Gt*Gr*ht*ht*hr*hr/(d*d*d*d*L)
# thus the transmitted signal power
#average Pt= d*d*d*d*L*Pr(d)/(Gt*Gr*ht*ht*hr*hr) = 1mW   
Phy/WirelessPhy set  pt_ 0.001
#Specified Parameters for 802.15.4 MAC
Mac/802_15_4 wpanCmd verbose on   ;# to work in verbose mode
Mac/802_15_4 wpanNam namStatus on  ;# default = off (should be turned on before other 'wpanNam' commands can work)

# Initialize Global Variables
set ns_  [new Simulator]
# Tell teh simulator to use teh new type trace data
$ns_ use-newtrace
set scenario1   [open scenario1.tr w]
$ns_ trace-all $scenario1
#Define the NAM output file
set scenario1nam     [open scenario1.nam w]
$ns_ namtrace-all-wireless $scenario1nam $val(x) $val(y)
$ns_ puts-nam-traceall {# nam4wpan #}  ;# inform nam that this is a trace file for wpan (special handling needed)

# set up topography object
set topo       [new Topography]
$topo load_flatgrid $val(x) $val(y)

# Create God
set god_ [create-god $val(nn)]
set chan_1_ [new $val(chan)]

# configure node
$ns_ node-config -adhocRouting $val(rp) \
  -llType $val(ll) \
  -macType $val(mac) \
  -ifqType $val(ifq) \
  -ifqLen $val(ifqlen) \
  -antType $val(ant) \
  -propType $val(prop) \
  -phyType $val(netif) \
  -topoInstance $topo \
  -agentTrace OFF \
  -routerTrace OFF \
  -macTrace ON \
  #-movementTrace OFF \
                -energyModel "EnergyModel"\
                -initialEnergy 100\
                -rxPower 0.3\
                -txPower 0.3\
  -channel $chan_1_

for {set i 0} {$i < $val(nn) } {incr i} {
 set node_($i) [$ns_ node]
 $node_($i) random-motion 0  ;# disable random motion
 $god_ new_node $node_($i)
}
#Lable the sink node
$ns_ at 0.0 "$node_(3) NodeLabel Sink"
# Define the nodes positions
$node_(0) set X_ 15.0
$node_(0) set Y_ 20.0
$node_(0) set Z_ 0.000000000000
$node_(1) set X_ 25.0
$node_(1) set Y_ 20.0
$node_(1) set Z_ 0.000000000000
$node_(2) set X_ 35.0
$node_(2) set Y_ 20.0
$node_(2) set Z_ 0.000000000000
$node_(3) set X_ 5.0
$node_(3) set Y_ 5.0
$node_(3) set Z_ 0.000000000000
#set null [new Agent/Null]
#$ns_ attach-agent $node_(3) $null
# Define the cbr traffic
proc cbrtraffic { src dst interval starttime stoptime packetsize stage } {
   global ns_ node_
   set udp([expr $src + $stage]) [new Agent/UDP]
   eval $ns_ attach-agent \$node_($src) \$udp([expr $src + $stage])
   set null([expr $src + $stage]) [new Agent/Null]
   eval $ns_ attach-agent \$node_($dst) \$null([expr $src + $stage])
   set cbr([expr $src + $stage]) [new Application/Traffic/CBR]
   eval \$cbr([expr $src + $stage]) set packetSize_ $packetsize
   eval \$cbr([expr $src + $stage]) set interval_ $interval
   eval \$cbr([expr $src + $stage]) set random_ 0
   #eval \$cbr($src) set maxpkts_ 10000
   eval \$cbr([expr $src + $stage]) attach-agent \$udp([expr $src + $stage])
   eval $ns_ connect \$udp([expr $src + $stage]) \$null([expr $src + $stage])
   $ns_ at $starttime "$cbr([expr $src + $stage]) start"
   $ns_ at $stoptime "$cbr([expr $src + $stage]) stop"
# $ns_ at $stoptime "$node_($src) reset"
#$ns_ at $stoptime "$node_($dst) reset"
}

## Establish traffic between nodes
 puts "\nTraffic: cbr"
   Mac/802_15_4 wpanCmd ack4data off
   puts [format "Acknowledgement for data: %s" [Mac/802_15_4 wpanCmd ack4data]]
#src dest interval start stop packetsize stage
#the first sensor activity
cbrtraffic 0 3 0.2 0.1 0.9 5 1;# target is in the range from 15 to 10 meters from the first sensor (sensed signal=5 bytes)
cbrtraffic 0 3 0.2 1.0 1.9 8 2;# target is in the range from 10 to 5 meters from the first sensor (sensed signal=8 bytes)
cbrtraffic 0 3 0.2 2.0 3.9 10 3;#target is in the range from 5 to 0 meters from the first sensor (sensed signal=10 bytes)
cbrtraffic 0 3 0.2 4.0 4.9 8 4;# target is in the range from 5 to 10 meters from the first sensor (sensed signal=8 bytes)
cbrtraffic 0 3 0.2 5.0 5.9 5 5;# target is in the range from 10 to 15 meters from the first sensor (sensed signal=5 bytes)
cbrtraffic 0 3 0.2 6.0 6.9 3 6;# target is in the range from 15 to 20 meters from the first sensor (sensed signal=5 bytes)
cbrtraffic 0 3 0.2 7 7.9 1 7;# target is in the range from 20 to 25 meters from the first sensor (sensed signal=5 bytes)
#the second sensor activity
cbrtraffic 1 3 0.2 0.2 0.9 1 1; # target is the range of 25 to 20 meters far from the sensor(sensed signal=1 bytes)
cbrtraffic 1 3 0.2 1 1.9 3 2; # target is the range of 20 to 15 meters far from the sensor(sensed signal=3 bytes)
cbrtraffic 1 3 0.2 2 2.9 5 3; # target is the range of 15 to 10 meters far from the sensor(sensed signal=5 bytes)
cbrtraffic 1 3 0.2 3 3.9 8 4; # target is the range of 10 to 5 meters far from the sensor(sensed signal=8 bytes)
cbrtraffic 1 3 0.2 4 5.9 10 5; # target is the range of 0 to 5 meters far from the sensor(sensed signal=10 bytes)
cbrtraffic 1 3 0.2 6 6.9 8 6; # target is the range of 5 to 10 meters far from the sensor(sensed signal=8 bytes)
cbrtraffic 1 3 0.2 7 7.9 5 7; # target is the range of 25 to 20 meters far from the sensor(sensed signal=5 bytes)
cbrtraffic 1 3 0.2 8 8.9 3 8; # target is the range of 25 to 20 meters far from the sensor(sensed signal=3 bytes)
cbrtraffic 1 3 0.2 9 9.9 1 9; # target is the range of 25 to 20 meters far from the sensor(sensed signal=1 bytes)
#the third sensor activity
cbrtraffic 2 3 0.2 2 2.9 1 1; # target is the range of 25 to 20 meters far from the sensor(sensed signal=1 bytes)
cbrtraffic 2 3 0.2 3 3.9 3 2; # target is the range of 20 to 15 meters far from the sensor(sensed signal=3 bytes)
cbrtraffic 2 3 0.2 4 4.9 5 3; # target is the range of 15 to 10 meters far from the sensor(sensed signal=5 bytes)
cbrtraffic 2 3 0.2 5 5.9 8 4; # target is the range of 10 to 5 meters far from the sensor(sensed signal=8 bytes)
cbrtraffic 2 3 0.2 6 7.9 10 5; # target is the range of 0 to 5 meters far from the sensor(sensed signal=10 bytes)
cbrtraffic 2 3 0.2 8 8.9 8 6; # target is the range of 5 to 10 meters far from the sensor(sensed signal=8 bytes)
cbrtraffic 2 3 0.2 9 10 5 7; # target is the range of 25 to 20 meters far from the sensor(sensed signal=5 bytes)

# defines the node size in nam
for {set i 0} {$i < $val(nn)} {incr i} {
 $ns_ initial_node_pos $node_($i) 5
}

# Tell nodes simulation ends at 10.0
for {set i 0} {$i < $val(nn) } {incr i} {
   $ns_ at 10 "$node_($i) reset";
}
$ns_ at 10 "stop"
$ns_ at 10 "puts \"\nNS EXITING...\""
$ns_ at 10 "$ns_ halt"

proc stop {} {
    global ns_ scenario1 scenario1nam
    $ns_ flush-trace
    close $scenario1
    #set hasDISPLAY 0
    exec nam scenario1.nam &

}
puts "\nStarting Simulation..."
$ns_ run

4. Sample Code for a Simple Wired Network


#Create a simulator object
set ns [new Simulator]

#Define different colors for data flows
$ns color 1 Blue
$ns color 2 Red

#Open the nam trace file
set nf [open out.nam w]
$ns namtrace-all $nf

#Define a 'finish' procedure
proc finish {} {
        global ns nf
        $ns flush-trace
#Close the trace file
        close $nf
#Execute nam on the trace file
        exec nam out.nam &
        exit 0
}

#Create four nodes
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]

#Create links between the nodes
$ns duplex-link $n0 $n2 1Mb 10ms DropTail
$ns duplex-link $n1 $n2 1Mb 10ms DropTail
$ns duplex-link $n3 $n2 2Mb 10ms DropTail

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

#Monitor the queue for the link between node 2 and node 3
$ns duplex-link-op $n2 $n3 queuePos 0.5

#Create a UDP agent and attach it to node n0
set udp0 [new Agent/UDP]
$udp0 set class_ 1
$ns attach-agent $n0 $udp0

# Create a CBR traffic source and attach it to udp0
set cbr0 [new Application/Traffic/CBR]
$cbr0 set packetSize_ 500
$cbr0 set interval_ 0.005
$cbr0 attach-agent $udp0

#Create a UDP agent and attach it to node n1
set udp1 [new Agent/UDP]
$udp1 set class_ 2
$ns attach-agent $n1 $udp1

# Create a CBR traffic source and attach it to udp1
set cbr1 [new Application/Traffic/CBR]
$cbr1 set packetSize_ 500
$cbr1 set interval_ 0.005
$cbr1 attach-agent $udp1

#Create a Null agent (a traffic sink) and attach it to node n3
set null0 [new Agent/Null]
$ns attach-agent $n3 $null0

#Connect the traffic sources with the traffic sink
$ns connect $udp0 $null0 
$ns connect $udp1 $null0

#Schedule events for the CBR agents
$ns at 0.5 "$cbr0 start"
$ns at 1.0 "$cbr1 start"
$ns at 4.0 "$cbr1 stop"
$ns at 4.5 "$cbr0 stop"
#Call the finish procedure after 5 seconds of simulation time
$ns at 5.0 "finish"

#Run the simulation
$ns run

5. A sample Code of Wired Network Generated fron Network Script Generator NSG


# This script is created by NSG2 beta1
# <http://wushoupong.googlepages.com/nsg>

#===================================
#     Simulation parameters setup
#===================================
set val(stop)   10.0                         ;# time of simulation end

#===================================
#        Initialization       
#===================================
#Create a ns simulator
set ns [new Simulator]

$ns color 1 Purple
$ns color 2 Yellow

#Open the NS trace file
set tracefile [open out.tr w]
$ns trace-all $tracefile

#Open the NAM trace file
set namfile [open out.nam w]
$ns namtrace-all $namfile

#===================================
#        Nodes Definition       
#===================================
#Create 6 nodes
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]
set n5 [$ns node]

#===================================
#        Links Definition       
#===================================
#Createlinks between nodes
$ns duplex-link $n0 $n2 10.0Mb 10ms DropTail
$ns queue-limit $n0 $n2 20
$ns duplex-link $n1 $n2 10.0Mb 10ms DropTail
$ns queue-limit $n1 $n2 20
$ns duplex-link $n2 $n3 10.0Mb 10ms DropTail
$ns queue-limit $n2 $n3 20
$ns duplex-link $n3 $n4 10.0Mb 10ms DropTail
$ns queue-limit $n3 $n4 20
$ns duplex-link $n3 $n5 10.0Mb 10ms DropTail
$ns queue-limit $n3 $n5 20

#Give node position (for NAM)
$ns duplex-link-op $n0 $n2 orient right-down
$ns duplex-link-op $n1 $n2 orient right-up
$ns duplex-link-op $n2 $n3 orient right
$ns duplex-link-op $n3 $n4 orient right-up
$ns duplex-link-op $n3 $n5 orient right-down

#===================================
#        Agents Definition       
#===================================
#Setup a UDP connection
set udp0 [new Agent/UDP]
$udp0 set class_ 1
$ns attach-agent $n0 $udp0
set null2 [new Agent/Null]
$ns attach-agent $n4 $null2
$ns connect $udp0 $null2
$udp0 set packetSize_ 1000

#Setup a TCP connection
set tcp1 [new Agent/TCP]
$tcp1 set class_ 1
$ns attach-agent $n1 $tcp1
set sink3 [new Agent/TCPSink]
$ns attach-agent $n5 $sink3
$ns connect $tcp1 $sink3
$tcp1 set packetSize_ 1500


#===================================
#        Applications Definition       
#===================================
#Setup a CBR Application over UDP connection
set cbr1 [new Application/Traffic/CBR]
$cbr1 attach-agent $udp0
$cbr1 set packetSize_ 1000
$cbr1 set rate_ 1.0Mb
$cbr1 set random_
$ns at 1.0 "$cbr1 start"
$ns at 2.0 "$cbr1 stop"

#Setup a FTP Application over TCP connection
set ftp2 [new Application/FTP]
$ftp2 attach-agent $tcp1
$ns at 1.0 "$ftp2 start"
$ns at 5.0 "$ftp2 stop"


#===================================
#        Termination       
#===================================
#Define a 'finish' procedure
proc finish {} {
    global ns tracefile namfile
    $ns flush-trace
    close $tracefile
    close $namfile
    exec nam out.nam &
    exit 0
}
$ns at $val(stop) "$ns nam-end-wireless $val(stop)"
$ns at $val(stop) "finish"
$ns at $val(stop) "puts \"done\" ; $ns halt"
$ns run


6. A sample Wireless Network script


# Define options
set val(chan) Channel/WirelessChannel ;# channel type
set val(prop) Propagation/TwoRayGround ;# radio-propagation model
set val(netif) Phy/WirelessPhy ;# network interface type
set val(mac) Mac/802_11 ;# MAC type
set val(ifq) Queue/DropTail/PriQueue ;# interface queue type
set val(ll) LL ;# link layer type
set val(ant) Antenna/OmniAntenna ;# antenna model
set val(ifqlen) 50 ;# max packet in ifq
set val(nn) 3 ;# number of mobilenodes
set val(rp) DSDV ;# routing protocol
set val(x) 500 ;# X dimension of topography
set val(y) 400 ;# Y dimension of topography
set val(stop) 150 ;# time of simulation end

set ns [new Simulator]
#Creating trace file and nam file
set tracefd       [open dsdv.tr w]
set windowVsTime2 [open win.tr w]
set namtrace      [open dsdv.nam w] 

$ns trace-all $tracefd
$ns namtrace-all-wireless $namtrace $val(x) $val(y)

# set up topography object
set topo       [new Topography]

$topo load_flatgrid $val(x) $val(y)

create-god $val(nn)

# configure the nodes
        $ns node-config -adhocRouting $val(rp) \
                   -llType $val(ll) \
                   -macType $val(mac) \
                   -ifqType $val(ifq) \
                   -ifqLen $val(ifqlen) \
                   -antType $val(ant) \
                   -propType $val(prop) \
                   -phyType $val(netif) \
                   -channelType $val(chan) \
                   -topoInstance $topo \
                   -agentTrace ON \
                   -routerTrace ON \
                   -macTrace OFF \
                   -movementTrace ON
                 
      for {set i 0} {$i < $val(nn) } { incr i } {
            set node_($i) [$ns node]   
      }

# Provide initial location of mobilenodes
$node_(0) set X_ 5.0
$node_(0) set Y_ 5.0
$node_(0) set Z_ 0.0

$node_(1) set X_ 490.0
$node_(1) set Y_ 285.0
$node_(1) set Z_ 0.0

$node_(2) set X_ 150.0
$node_(2) set Y_ 240.0
$node_(2) set Z_ 0.0

# Generation of movements
$ns at 10.0 "$node_(0) setdest 250.0 250.0 3.0"
$ns at 15.0 "$node_(1) setdest 45.0 285.0 5.0"
$ns at 110.0 "$node_(0) setdest 480.0 300.0 5.0"

# Set a TCP connection between node_(0) and node_(1)
set tcp [new Agent/TCP/Newreno]
$tcp set class_ 2
set sink [new Agent/TCPSink]
$ns attach-agent $node_(0) $tcp
$ns attach-agent $node_(1) $sink
$ns connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns at 10.0 "$ftp start"

# Printing the window size
proc plotWindow {tcpSource file} {
global ns
set time 0.01
set now [$ns now]
set cwnd [$tcpSource set cwnd_]
puts $file "$now $cwnd"
$ns at [expr $now+$time] "plotWindow $tcpSource $file" }
$ns at 10.1 "plotWindow $tcp $windowVsTime2"

# Define node initial position in nam
for {set i 0} {$i < $val(nn)} { incr i } {
# 30 defines the node size for nam
$ns initial_node_pos $node_($i) 30
}

# Telling nodes when the simulation ends
for {set i 0} {$i < $val(nn) } { incr i } {
    $ns at $val(stop) "$node_($i) reset";
}

# ending nam and the simulation
$ns at $val(stop) "$ns nam-end-wireless $val(stop)"
$ns at $val(stop) "stop"
$ns at 150.01 "puts \"end simulation\" ; $ns halt"
proc stop {} {
    global ns tracefd namtrace
    $ns flush-trace
    close $tracefd
    close $namtrace
exec nam dsdv.nam &
exit 0
}

$ns run


7. A Sample Wireless Script Generated from NSG2


# This script is created by NSG2 beta1
# <http://wushoupong.googlepages.com/nsg>

#===================================
#     Simulation parameters setup
#===================================
set val(chan)   Channel/WirelessChannel    ;# channel type
set val(prop)   Propagation/TwoRayGround   ;# radio-propagation model
set val(netif)  Phy/WirelessPhy            ;# network interface type
set val(mac)    Mac/802_11                 ;# MAC type
set val(ifq)    Queue/DropTail/PriQueue    ;# interface queue type
set val(ll)     LL                         ;# link layer type
set val(ant)    Antenna/OmniAntenna        ;# antenna model
set val(ifqlen) 50                         ;# max packet in ifq
set val(nn)     3                          ;# number of mobilenodes
set val(rp)     DSDV                       ;# routing protocol
set val(x)      834                      ;# X dimension of topography
set val(y)      600                      ;# Y dimension of topography
set val(stop)   10.0                         ;# time of simulation end

#===================================
#        Initialization       
#===================================
#Create a ns simulator
set ns [new Simulator]

#Setup topography object
set topo       [new Topography]
$topo load_flatgrid $val(x) $val(y)
create-god $val(nn)

#Open the NS trace file
set tracefile [open out.tr w]
$ns trace-all $tracefile

#Open the NAM trace file
set namfile [open out.nam w]
$ns namtrace-all $namfile
$ns namtrace-all-wireless $namfile $val(x) $val(y)
set chan [new $val(chan)];#Create wireless channel

#===================================
#     Mobile node parameter setup
#===================================
$ns node-config -adhocRouting  $val(rp) \
                -llType        $val(ll) \
                -macType       $val(mac) \
                -ifqType       $val(ifq) \
                -ifqLen        $val(ifqlen) \
                -antType       $val(ant) \
                -propType      $val(prop) \
                -phyType       $val(netif) \
                -channel       $chan \
                -topoInstance  $topo \
                -agentTrace    ON \
                -routerTrace   ON \
                -macTrace      ON \
                -movementTrace ON

#===================================
#        Nodes Definition       
#===================================
#Create 3 nodes
set n0 [$ns node]
$n0 set X_ 153
$n0 set Y_ 432
$n0 set Z_ 0.0
$ns initial_node_pos $n0 20
set n1 [$ns node]
$n1 set X_ 444
$n1 set Y_ 214
$n1 set Z_ 0.0
$ns initial_node_pos $n1 20
set n2 [$ns node]
$n2 set X_ 734
$n2 set Y_ 474
$n2 set Z_ 0.0
$ns initial_node_pos $n2 20

#===================================
#        Generate movement         
#===================================
$ns at 1 " $n0 setdest 500 500 20 "
$ns at 2 " $n1 setdest 600 450 20 "
$ns at 1 " $n2 setdest 200 300 30 "

#===================================
#        Agents Definition       
#===================================
#Setup a TCP connection
set tcp0 [new Agent/TCP]
$ns attach-agent $n0 $tcp0
set sink2 [new Agent/TCPSink]
$ns attach-agent $n2 $sink2
$ns connect $tcp0 $sink2
$tcp0 set packetSize_ 1500

#Setup a UDP connection
set udp1 [new Agent/UDP]
$ns attach-agent $n1 $udp1
set null3 [new Agent/Null]
$ns attach-agent $n2 $null3
$ns connect $udp1 $null3
$udp1 set packetSize_ 1500


#===================================
#        Applications Definition       
#===================================
#Setup a FTP Application over TCP connection
set ftp0 [new Application/FTP]
$ftp0 attach-agent $tcp0
$ns at 1.0 "$ftp0 start"
$ns at 5.0 "$ftp0 stop"

#Setup a CBR Application over UDP connection
set cbr1 [new Application/Traffic/CBR]
$cbr1 attach-agent $udp1
$cbr1 set packetSize_ 1000
$cbr1 set rate_ 1.0Mb
$cbr1 set random_
$ns at 1.0 "$cbr1 start"
$ns at 5.0 "$cbr1 stop"


#===================================
#        Termination       
#===================================
#Define a 'finish' procedure
proc finish {} {
    global ns tracefile namfile
    $ns flush-trace
    close $tracefile
    close $namfile
    exec nam out.nam &
    exit 0
}
for {set i 0} {$i < $val(nn) } { incr i } {
    $ns at $val(stop) "\$n$i reset"
}
$ns at $val(stop) "$ns nam-end-wireless $val(stop)"
$ns at $val(stop) "finish"
$ns at $val(stop) "puts \"done\" ; $ns halt"
$ns run

8. Sample TCL File for Xgraph Output

# [scenario]
# It consists of 8 mobile nodes: 4 source nodes and 4 destination node.
# Each source is a # CBR source over UDP. The size of a transmitted packet is 512 bytes. # Transmission rate # of a node is 600 Kbps.
# We assumed that the nodes are in transmission range at a # constant distance of 195 m. # The simulation time lasted for 80 sec.

# ====================================================================

# Define Node Configuration paramaters

#====================================================================

set val(chan)           Channel/WirelessChannel    ;# channel type

set val(prop)           Propagation/TwoRayGround   ;# radio-propagation model

set val(netif)           Phy/WirelessPhy            ;# network interface type



set val(mac)            Mac/802_11                ;# MAC type

set val(ifq)            Queue/DropTail/PriQueue   ;# interface queue type



set val(ll)             LL                         ;# link layer type

set val(ant)            Antenna/OmniAntenna        ;# antenna model

set val(ifqlen)         50                         ;# max packet in ifq

set val(nn)             8                          ;# number of mobilenodes

set val(rp)             DSDV                       ;# routing protocol

set val(x)              500                        ;# X dimension of the topography

set val(y)              500                           ;# Y dimension of the topography



Mac/802_11 set RTSThreshold_  3000

Mac/802_11 set basicRate_ 1Mb

Mac/802_11 set dataRate_  2Mb



#=====================================================================

# Initialize trace file desctiptors

#=====================================================================

# *** Throughput Trace ***

set f0 [open out02.tr w]

set f1 [open out12.tr w]

set f2 [open out22.tr w]

set f3 [open out32.tr w]



# *** Packet Loss Trace ***

set f4 [open lost02.tr w]

set f5 [open lost12.tr w]

set f6 [open lost22.tr w]

set f7 [open lost32.tr w]



# *** Packet Delay Trace ***

set f8 [open delay02.tr w]

set f9 [open delay12.tr w]

set f10 [open delay22.tr w]

set f11 [open delay32.tr w]



# *** Initialize Simulator ***

set ns_              [new Simulator]



# *** Initialize Trace file ***

set tracefd     [open trace2.tr w]

$ns_ trace-all $tracefd



# *** Initialize Network Animator ***

set namtrace [open sim12.nam w]

$ns_ namtrace-all-wireless $namtrace $val(x) $val(y)



# *** set up topography object ***

set topo       [new Topography]

$topo load_flatgrid 500 500



# Create  General Operations Director (GOD) object. It is used to store global information about the state of the environment, network, or nodes that an

# omniscent observer would have, but that should not be made known to any participant in the simulation.



create-god $val(nn)



# configure nodes

        $ns_ node-config -adhocRouting $val(rp) \
                         -llType $val(ll) \
                         -macType $val(mac) \
                         -ifqType $val(ifq) \
                         -ifqLen $val(ifqlen) \
                         -antType $val(ant) \
                         -propType $val(prop) \
                         -phyType $val(netif) \
                         -channelType $val(chan) \
                         -topoInstance $topo \
                         -agentTrace ON \
                         -routerTrace ON \
                         -macTrace OFF \
                         -movementTrace OFF                 



# Create Nodes



        for {set i 0} {$i < $val(nn) } {incr i} {

                set node_($i) [$ns_ node]

                $node_($i) random-motion 0            ;# disable random motion

        }



# Initialize Node Coordinates



$node_(0) set X_ 5.0

$node_(0) set Y_ 5.0

$node_(0) set Z_ 0.0



$node_(1) set X_ 200.0

$node_(1) set Y_ 5.0

$node_(1) set Z_ 0.0



$node_(2) set X_ 5.0

$node_(2) set Y_ 50.0

$node_(2) set Z_ 0.0



$node_(3) set X_ 200.0

$node_(3) set Y_ 50.0

$node_(3) set Z_ 0.0



$node_(4) set X_ 5.0

$node_(4) set Y_ 100.0

$node_(4) set Z_ 0.0



$node_(5) set X_ 200.0

$node_(5) set Y_ 100.0

$node_(5) set Z_ 0.0



$node_(6) set X_ 2.0

$node_(6) set Y_ 150.0

$node_(6) set Z_ 0.0



$node_(7) set X_ 200.0

$node_(7) set Y_ 150.0

$node_(7) set Z_ 0.0



# Setup traffic flow between nodes

# UDP connections between node_(0) and node_(1)



# Create Constant four Bit Rate Traffic sources



set agent1 [new Agent/UDP]             ;# Create UDP Agent

$agent1 set prio_ 0                   ;# Set Its priority to 0

set sink [new Agent/LossMonitor]  ;# Create Loss Monitor Sink in order to be able to trace the number of bytes received

$ns_ attach-agent $node_(0) $agent1     ;# Attach Agent to source node

$ns_ attach-agent $node_(1) $sink ;# Attach Agent to sink node

$ns_ connect $agent1 $sink            ;# Connect the nodes

set app1 [new Application/Traffic/CBR]  ;# Create Constant Bit Rate application

$app1 set packetSize_ 512               ;# Set Packet Size to 512 bytes

$app1 set rate_ 600Kb                    ;# Set CBR rate to 200 Kbits/sec

$app1 attach-agent $agent1             ;# Attach Application to agent



set agent2 [new Agent/UDP]             ;# Create UDP Agent

$agent2 set prio_ 1                   ;# Set Its priority to 1

set sink2 [new Agent/LossMonitor]         ;# Create Loss Monitor Sink in order to be able to trace the number obytes received

$ns_ attach-agent $node_(2) $agent2     ;# Attach Agent to source node

$ns_ attach-agent $node_(3) $sink2        ;# Attach Agent to sink node

$ns_ connect $agent2 $sink2                  ;# Connect the nodes

set app2 [new Application/Traffic/CBR]  ;# Create Constant Bit Rate application

$app2 set packetSize_ 512               ;# Set Packet Size to 512 bytes

$app2 set rate_ 600Kb                    ;# Set CBR rate to 200 Kbits/sec

$app2 attach-agent $agent2             ;# Attach Application to agent



set agent3 [new Agent/UDP]             ;# Create UDP Agent

$agent3 set prio_ 2                   ;# Set Its priority to 2

set sink3 [new Agent/LossMonitor]         ;# Create Loss Monitor Sink in order to be able to trace the number obytes received

$ns_ attach-agent $node_(4) $agent3     ;# Attach Agent to source node

$ns_ attach-agent $node_(5) $sink3        ;# Attach Agent to sink node

$ns_ connect $agent3 $sink3                  ;# Connect the nodes

set app3 [new Application/Traffic/CBR]  ;# Create Constant Bit Rate application

$app3 set packetSize_ 512               ;# Set Packet Size to 512 bytes

$app3 set rate_ 600Kb                    ;# Set CBR rate to 200 Kbits/sec

$app3 attach-agent $agent3             ;# Attach Application to agent



set agent4 [new Agent/UDP]             ;# Create UDP Agent

$agent4 set prio_ 3                   ;# Set Its priority to 3

set sink4 [new Agent/LossMonitor]         ;# Create Loss Monitor Sink in order to be able to trace the number obytes received

$ns_ attach-agent $node_(6) $agent4     ;# Attach Agent to source node

$ns_ attach-agent $node_(7) $sink4        ;# Attach Agent to sink node

$ns_ connect $agent4 $sink4                  ;# Connect the nodes

set app4 [new Application/Traffic/CBR]  ;# Create Constant Bit Rate application

$app4 set packetSize_ 512               ;# Set Packet Size to 512 bytes

$app4 set rate_ 600Kb                    ;# Set CBR rate to 200 Kbits/sec

$app4 attach-agent $agent4             ;# Attach Application to agent



# defines the node size in Network Animator



for {set i 0} {$i < $val(nn)} {incr i} {

    $ns_ initial_node_pos $node_($i) 20

}



# Initialize Flags

set holdtime 0

set holdseq 0



set holdtime1 0

set holdseq1 0



set holdtime2 0

set holdseq2 0



set holdtime3 0

set holdseq3 0



set holdrate1 0

set holdrate2 0

set holdrate3 0

set holdrate4 0



# Function To record Statistcis (Bit Rate, Delay, Drop)



proc record {} {

        global sink sink2 sink3 sink4 f0 f1 f2 f3 f4 f5 f6 f7 holdtime holdseq holdtime1 holdseq1 holdtime2 holdseq2 holdtime3 holdseq3 f8 f9 f10 f11 holdrate1 holdrate2 holdrate3 holdrate4

     

        set ns [Simulator instance]

     

    set time 0.9 ;#Set Sampling Time to 0.9 Sec



        set bw0 [$sink set bytes_]

        set bw1 [$sink2 set bytes_]

        set bw2 [$sink3 set bytes_]

        set bw3 [$sink4 set bytes_]



        set bw4 [$sink set nlost_]

        set bw5 [$sink2 set nlost_]

        set bw6 [$sink3 set nlost_]

        set bw7 [$sink4 set nlost_]



        set bw8 [$sink set lastPktTime_]

        set bw9 [$sink set npkts_]



        set bw10 [$sink2 set lastPktTime_]

        set bw11 [$sink2 set npkts_]



        set bw12 [$sink3 set lastPktTime_]

        set bw13 [$sink3 set npkts_]



        set bw14 [$sink4 set lastPktTime_]

        set bw15 [$sink4 set npkts_]

     

    set now [$ns now]

     

        # Record Bit Rate in Trace Files

        puts $f0 "$now [expr (($bw0+$holdrate1)*8)/(2*$time*1000000)]"

        puts $f1 "$now [expr (($bw1+$holdrate2)*8)/(2*$time*1000000)]"

        puts $f2 "$now [expr (($bw2+$holdrate3)*8)/(2*$time*1000000)]"

        puts $f3 "$now [expr (($bw3+$holdrate4)*8)/(2*$time*1000000)]"



        # Record Packet Loss Rate in File

        puts $f4 "$now [expr $bw4/$time]"

        puts $f5 "$now [expr $bw5/$time]"

        puts $f6 "$now [expr $bw6/$time]"

        puts $f7 "$now [expr $bw7/$time]"



        # Record Packet Delay in File

        if { $bw9 > $holdseq } {

                puts $f8 "$now [expr ($bw8 - $holdtime)/($bw9 - $holdseq)]"

        } else {

                puts $f8 "$now [expr ($bw9 - $holdseq)]"

        }



        if { $bw11 > $holdseq1 } {

                puts $f9 "$now [expr ($bw10 - $holdtime1)/($bw11 - $holdseq1)]"

        } else {

                puts $f9 "$now [expr ($bw11 - $holdseq1)]"

        }



        if { $bw13 > $holdseq2 } {

                puts $f10 "$now [expr ($bw12 - $holdtime2)/($bw13 - $holdseq2)]"

        } else {

                puts $f10 "$now [expr ($bw13 - $holdseq2)]"

        }



        if { $bw15 > $holdseq3 } {

                puts $f11 "$now [expr ($bw14 - $holdtime3)/($bw15 - $holdseq3)]"

        } else {

                puts $f11 "$now [expr ($bw15 - $holdseq3)]"

        }

     

        # Reset Variables

        $sink set bytes_ 0

        $sink2 set bytes_ 0

        $sink3 set bytes_ 0

        $sink4 set bytes_ 0



        $sink set nlost_ 0

        $sink2 set nlost_ 0

        $sink3 set nlost_ 0

        $sink4 set nlost_ 0



        set holdtime $bw8

        set holdseq $bw9



        set  holdrate1 $bw0

        set  holdrate2 $bw1

        set  holdrate3 $bw2

        set  holdrate4 $bw3



    $ns at [expr $now+$time] "record"   ;# Schedule Record after $time interval sec

}





# Start Recording at Time 0

$ns_ at 0.0 "record"



$ns_ at 1.4 "$app1 start"                 ;# Start transmission at time t = 1.4 Sec



$ns_ at 10.0 "$app2 start"               ;# Start transmission at time t = 10 Sec



$ns_ at 20.0 "$app3 start"               ;# Start transmission at time t = 20 Sec



$ns_ at 30.0 "$app4 start"               ;# Start transmission at time t = 30 Sec



# Stop Simulation at Time 80 sec

$ns_ at 80.0 "stop"



# Reset Nodes at time 80 sec



for {set i 0} {$i < $val(nn) } {incr i} {

    $ns_ at 80.0 "$node_($i) reset";

}



# Exit Simulatoion at Time 80.01 sec

$ns_ at 80.01 "puts \"NS EXITING...\" ; $ns_ halt"



proc stop {} {

        global ns_ tracefd f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11



        # Close Trace Files

        close $f0

        close $f1

        close $f2

        close $f3



        close $f4

        close $f5

        close $f6

        close $f7



        close $f8

        close $f9

        close $f10

        close $f11



        # Plot Recorded Statistics

        exec xgraph out02.tr out12.tr out22.tr out32.tr -geometry 800x400 -P -bg white &

        exec xgraph lost02.tr lost12.tr lost22.tr lost32.tr -geometry 800x400 -P -bg white &

        exec xgraph delay02.tr delay12.tr delay22.tr delay32.tr -geometry 800x400 -P -bg white &

     

        # Reset Trace File

        $ns_ flush-trace

        close $tracefd

     

        exit 0

}



puts "Starting Simulation..."

$ns_ run

A Compendium of Epigrams Vol:1

Buy From Amazon  Kindle Edition Sneak Peak of Second BOOK