LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 08-24-2013, 02:25 PM   #46
zadi
LQ Newbie
 
Registered: Aug 2013
Posts: 21

Rep: Reputation: Disabled
Lightbulb


Quote:
Originally Posted by knudfl View Post
# 44 .

bt_flashcrowd_star.tcl : Please run from ns-allinone-2.29/ns-2.29/.

Works OK here :
Code:
$ cd ns-allinone-2.29/ns-2.29/
$ ./ns-bittorrent bt_flashcrowd_flow.tcl 4 44 4
bittorrent/results_flash_flow_100MB_N_P_4_C_500.0Bps_seed_44_1377322065
Received piece without request
.
.
Note : There are three tcl files in the package "p2p.rar" (f09ba8b90d6b.rar)
http://www.codeforge.com/dlpre/15764...d6b.rar__.html
bt_flashcrowd_flow.tcl, bt_flashcrowd_star.tcl,
and the "Traffic source generator" file 'cbrgen_star.tcl'.

-
hi; plz what is the purpose of each( bt_flashcrowd_flow.tcl, bt_flashcrowd_star.tcl,
and the "Traffic source generator" file 'cbrgen_star.tcl'.)because my goal is to simulate peer to peer traffic information system .
i installed sumo;ns 2.29 patch bittorent ;and TRANs ,now i need a soulution to integrate these exemples 'bittorrent file" in an exemple of trans ..is it possible ! thank u for all
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 08-24-2013, 05:10 PM   #47
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2014.08, Slack14.1 DebWheezy, +50+ other Linux OS, for test only.
Posts: 14,278

Rep: Reputation: 2664Reputation: 2664Reputation: 2664Reputation: 2664Reputation: 2664Reputation: 2664Reputation: 2664Reputation: 2664Reputation: 2664Reputation: 2664Reputation: 2664
# 46 .

Peer to peer : Something is sent from sender to receiver :
Isn't that what the output from $ 'bt_flashcrowd_flow.tcl 4 44 4' shows ?

Sumo / traffic / vehicles :
Please try with Google .. ns2 peer to peer vehicle simulation ..
https://www.google.com/webhp?hl=all#...cle+simulation

P.S. : Peer to peer https://www.google.com/webhp?hl=all#...s+peer+to+peer

PPS :
Quote:
my goal is to simulate peer to peer traffic information system .
I installed sumo, ns 2.29 patch bittorent and TraNS ,
now I need a soulution to integrate these exemples 'bittorrent file"
in an exemple of trans ..is it possible
If you can put it in a convincing way, you may be lucky getting an answer
from an expert at the "ns2 headquarters" :
http://network-simulator-ns-2.7690.n7.nabble.com/

-

Last edited by knudfl; 08-24-2013 at 05:21 PM.
 
Old 08-24-2013, 09:11 PM   #48
zadi
LQ Newbie
 
Registered: Aug 2013
Posts: 21

Rep: Reputation: Disabled
Quote:
Originally Posted by zadi View Post
hi; plz what is the purpose of each( bt_flashcrowd_flow.tcl, bt_flashcrowd_star.tcl,
and the "Traffic source generator" file 'cbrgen_star.tcl'.)because my goal is to simulate peer to peer traffic information system .
i installed sumo;ns 2.29 patch bittorent ;and TRANs ,now i need a soulution to integrate these exemples 'bittorrent file" in an exemple of trans ..is it possible ! thank u for all
root@peertis-laptop:~/ns-allinone-2.29/ns-2.29# ./ns bt_flashcrowd_star.tcl 10 1 1000
bittorrent/results_flash_packet_star_100MB_N_P_10_C_125000.0Bps_seed_1_1377392318
cp: impossible d'évaluer «bittorrent/scripts/bt_flashcrowd_star.tcl»: Aucun fichier ou dossier de ce type
while executing
"exec cp bittorrent/scripts/bt_flashcrowd_star.tcl $p2ptrace2"
(file "bt_flashcrowd_star.tcl" line 103)
root@peertis-laptop:~/ns-allinone-2.29/ns-2.29
where is the problem
 
Old 08-25-2013, 03:13 AM   #49
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2014.08, Slack14.1 DebWheezy, +50+ other Linux OS, for test only.
Posts: 14,278

Rep: Reputation: 2664Reputation: 2664Reputation: 2664Reputation: 2664Reputation: 2664Reputation: 2664Reputation: 2664Reputation: 2664Reputation: 2664Reputation: 2664Reputation: 2664
# 48 .

Not quite clear what you are doing. I'd guess you are trying to run this :
$ ./ns bt_flashcrowd_star.tcl 10 1 1000

The output from the above command wih my "ns-2.29_bittorrent" is :
bittorrent/results_flash_packet_star_100MB_N_P_10_C_125000.0Bps_seed_1_1377413870
907.15774629796567
... which is a folder by name ..
"results_flash_packet_star_100MB_N_P_10_C_125000.0Bps_seed_1_1377413870/"
... containing { bittorrent_default.tcl, log }.

The puzzling issue is the "No file or folder of this type" reply that you get.
* There is no need for «bittorrent/scripts/bt_flashcrowd_star.tcl»,
unless you edited something.
But then again, it's very easy to do $ 'mkdir bittorrent/scripts' ,
.. and then copy the required scripts to the new folder "scripts/".


Quote:
root@peertis-laptop:~/ns-allinone-2.29/ns-2.29#
* ! No ns2 command is supposed to be done as root !
( The only exception is 'make install'.)

-

Last edited by knudfl; 08-25-2013 at 03:17 AM.
 
Old 08-28-2013, 06:39 PM   #50
zadi
LQ Newbie
 
Registered: Aug 2013
Posts: 21

Rep: Reputation: Disabled
Quote:
Originally Posted by knudfl View Post
# 48 .

Not quite clear what you are doing. I'd guess you are trying to run this :
$ ./ns bt_flashcrowd_star.tcl 10 1 1000

The output from the above command wih my "ns-2.29_bittorrent" is :
bittorrent/results_flash_packet_star_100MB_N_P_10_C_125000.0Bps_seed_1_1377413870
907.15774629796567
... which is a folder by name ..
"results_flash_packet_star_100MB_N_P_10_C_125000.0Bps_seed_1_1377413870/"
... containing { bittorrent_default.tcl, log }.

The puzzling issue is the "No file or folder of this type" reply that you get.
* There is no need for «bittorrent/scripts/bt_flashcrowd_star.tcl»,
unless you edited something.
But then again, it's very easy to do $ 'mkdir bittorrent/scripts' ,
.. and then copy the required scripts to the new folder "scripts/".



* ! No ns2 command is supposed to be done as root !
( The only exception is 'make install'.)

-
1-hi i want to install sumo 0.10 for the good work of TRANS.
TRANS Generates me dump.xml file but and I want a tcl file
3- the problem is in the sumo 0.12 sure thanks for all
4-i use ubuntu 10.04
 
Old 09-09-2013, 10:20 AM   #51
zadi
LQ Newbie
 
Registered: Aug 2013
Posts: 21

Rep: Reputation: Disabled
Quote:
Originally Posted by knudfl View Post
# 44 .

bt_flashcrowd_star.tcl : Please run from ns-allinone-2.29/ns-2.29/.

Works OK here :
Code:
$ cd ns-allinone-2.29/ns-2.29/
$ ./ns-bittorrent bt_flashcrowd_flow.tcl 4 44 4
bittorrent/results_flash_flow_100MB_N_P_4_C_500.0Bps_seed_44_1377322065
Received piece without request
.
.
Note : There are three tcl files in the package "p2p.rar" (f09ba8b90d6b.rar)
http://www.codeforge.com/dlpre/15764...d6b.rar__.html
bt_flashcrowd_flow.tcl, bt_flashcrowd_star.tcl,
and the "Traffic source generator" file 'cbrgen_star.tcl'.

-
hi knudfl I want to add bittorrent ns 2 v 2.29 and I found problems in the applicaton of its steps


### How to build a program (Makefile setting)
1. Makefile

In order to simulate our BitTorrent implementation, you should add a define "BITTO" to your Makefile of ns-2 and add lists of files about our BitTorrent implementation (that will be listed below section). Also, there is an additional define variables called "BIT_DOWNLOADING". If you turn on this variables, the BitTorrent node will handle the DOWNLOADING state of a block; If a block is downloading from a neighbor, a node will not request to offer that block to any other BitTorrent nodes only if there exists an imcomplete block of a piece which are not in the DOWNLOADING state. This helps to minimize the number of packets in the network, but it can make that node taken a little bit more to finish to download.

2. Modified files of the existing NS-2

In order to implement our BitTorrent, I modified some existing ns-2 implementations. Here are the lists of modified files.
- $NS/Makefile
- $NS/tcl/lib/ns-default.tcl
- $NS/common/packet.h
- $NS/ns-process.h
- $NS/dsdv/dsdv.h
- $NS/dsdv/dsdv.cc


### The list of C++ source code
1. bitagent.[cc/h]
- These files contain the implementation of BitAgent class and struct hdr_bitAgent
- BitAgent is the Agent class which will transmits the control message by using UDP protocol
- hdr_bitAgent is the packet header of control message of BitTorrent
- To use, "flooding_ttl_" bind variables with Tcl script should be set

2. bittable.[cc/h]
- These files contain the implementation of several data structure classes (BitPeer, BitNeighbor, PeerTable, NeighborTable, Piece, PiecePool)
- BitPeer represents the peer object of the BitTorrent node
- BitNeighbor represents the neighbor object of the BitTorrent node
- PeerTable contains the peer lists of the BitTorrent node by using Tcl_HashTable whose key is the id_ of the peer object
- NeighborTable contains the neighbor lists of the BitTorrent node by using Tcl_HashTable whose key is the id_ of the neighbor object
- PeerTable / NeighborTable should be initiated with the maximum number of object which it can contain
- Piece represents the piece object of the file which will be shared by BitTorrent nodes
--> The file is consisted with several pieces and a piece is consisted with several blocks
- PiecePool contains all the pieces of the file by using Tcl_HashTable whose key is the id_ of the piece object, and maintains the status of the piece (COMPLETE, DOWNLOADING, INCOMPLETE)

3. bittcpapp.[cc/h]
- These files contain the implementation of BitTcpApp class and BitTorrentControl class, and BItTorrentPayload class
- BitTcpApp is inherited from the TcpApp which is the famous application to use FullTcp in NS-2
- In order to establish the TCP connection between two BitTorrent nodes, BitTcpApp object should be attached to each of the wireless nodes. Because we establish the TCP connections between every BitTorrent nodes dynamically, this TCP connection is maintained by BitConnection object.
- BitTorrentControl represents the control packet of BitTorrent
- BitTorrentPayload represents the packet header and the payload of data transmission
- Because NS-2 doesn't support the transmission of application payload, we use CBuf and CBufList of TcpApp in order to capsulize the data transmission to BitTcpApp or BitTorrent object.

4. bittorrent.[cc/h]
- These files are the main source files of BitTorrent program. These files contain the implementation of BitTorrent, BitConnection, GlobalBitTorrentList, GlobalBitConnectionList.
- BitTorrent represents the BitTorrent application and implements the protocol of BitTorrent
- BitConnection maintains the dynamic TCP connection between two BitTorrent (BitTcpApp) nodes
- GlobalBitTorrentList maintains the global list of BitTorrent nodes in the simulation. It is only for implementation details, it is never concerned with BitTorrent protocol.
- GlobalBitConnectionList maintains the global list of BitConnection objects in the simulation. It is also only for implementation details, never related with the BitTorrent protocol.


### Configurable parameters of Tcl script
These are the parameters which can be configured at tcl scripts. All the default values are written at NS/tcl/lib/ns-default.tcl.

Application/BitTorrent set max_peer_num_ 10
-> The maximum number of peers that node can have

Application/BitTorrent set max_neighbor_num_ 10
-> The maximum number of neighbors that node can have

Application/BitTorrent set max_upload_num_ 4
-> The maximum number of upload connections that node can have
-> When this value set as 1, the BitTorrent performs a serial transmission. When this value set over 1, it performs a parallel transmission.

Application/BitTorrent set max_download_num_ 4
-> The maximum number of download connections that node can have

Application/BitTorrent set local_rarest_select_flag_ 1
-> The flag from where the BitTorrent calculate the local rarest piece
-> If is 1, it will calculate from the PeerTable.
-> If is 2, it will calculate from the NeighborTable.

Application/BitTorrent set control_tcp_flag_ 1
-> The flag about how its control message to transmit
-> If 0, use UDP. If 1, use TCP.

Application/BitTorrent set use_bidirection_tcp_flag_ 1
-> The flag about whether to use its TCP connection for uni-direction or bi-direction
-> If 0, it uses uni-direction. If 1, bi-direction.

Application/BitTorrent set peerTable_flag_ 1
-> The flag about whether the node removes its peer which became a Seed when the node itself became a Seed.
-> Recommended to use 1 always.

Application/BitTorrent set selectNodeToUpload_flag_ 2
-> The flag about how to select node to upload
-> If 0, it selects nodes based on a choking algorithm of original BitTorrent (named basic)
-> If 1, it selects only physical 1-hop nodes (named 1HOP)
-> If 2. it selects based the closest node first strategy
-> If 3. a node selects nodes like basic and only the seed selects nodes randomly

Application/BitTorrent set selectNeighbor_flag_ 0
-> The flag about how to select neighbors from the peerTable
-> If 0, it selects the closest peers first
-> If 1, it selects randomly

Application/BitTorrent set try_upload_interval_ [expr 10* [Application/BitTorrent set max_upload_num_]]
-> The interval to try to offer the piece to its neighbors
-> The unit is sec (simulation time)

Application/BitTorrent set printCPL_flag_ 1
-> The flag about whether to generate result files of the current having Piece ID list or not
-> If 0, do not generate, and if 1, generate the result files.

Application/BitTorrent set choking_best_slot_num_ 3
-> The number of best slot for choking algorithm

Application/BitTorrent set choking_optimistic_slot_num_ 1
-> The number of optimistic slot for choking algorithm

Application/BitTorrent set into_steady_state_time_ 1000
-> There are two kinds of phase in our BitTorrent. The nodes should transmit HELLO messages more frequently at the first time, because in order to share the file fastly it needs to know about the node in the network.
-> Therefore, we separate the startUp phase and steady phase. This value indicates when the BitTorrent node goes into the steady phase.
-> The unit is the simulation time.

Application/BitTorrent set peer_update_interval1_ 100
-> The "peer_update_interval" is the interval to flood the HELLO message into the network
-> This value is the peer_update_interval for startUp phase. So, we strongly recommend to set this value smaller than the value of peer_update_interval2 which is the peer_update interval for steady phase.
-> When the timer for peer update is expred, the node starts to flood HELLO message. Whenever it receives the HELLO_REPLY from a node, it adds the sender of HELLO_REPLY to its peerTable.
-> The peerTable is maintained based on update manner not re-creation manner. The remove procedure performed only when the node itself became a seed and at that time it removes only the seed peers from its peerTable.

Application/BitTorrent set peer_update_interval2_ 500
-> The interval to update its peerList by flooding HELLO message at the steady phase

Application/BitTorrent set neighbor_select_interval1_ [expr 2*[Application/BitTorrent set try_upload_interval_]]
-> The interval to select neighbor from the peerTable at startUp phase
-> We also strongly recommend to set this value smaller than the neighbor_select_interval2_
-> Unlike peerTable, neighborTable is maintained based on re-creation manner not update manner
-> In the current version of our BitTorrent implementation, we select neighbors based on its hopcount (Closest one first), but it can be changed based on the performance results.

Application/BitTorrent set neighbor_select_interval2_ [expr 2*[Application/BitTorrent set try_upload_interval_]]
-> The interval to select neighbor from the peerTable at steady phase

Application/BitTorrent set received_bytes_reset_interval_ 60
-> The original BitTorrent adapts the choking algorithm to facilitate the file sharing. In choking algorithm, the BitTorrent node chooses the best unchoking nodes based on how many bytes it provide to me.
-> This value is the interval to reset the history about how many bytes it receives from a specific node.

Agent/BitAgent set flooding_ttl_ 3
-> The time-to-live value which will be used in flooding of HELLO message

PiecePool set piece_num_ 10
-> The number of pieces in the file which will be shared

PiecePool set block_num_ 10
-> The number of blocks in one piece

PiecePool set block_size_ [expr 10*1000]
-> The size of a block. The unit is bytes.
-> Therefore, the size of the file which will be shared is piece_num_ * block_num_ * block_size_.


### How to run a simulation

1. Setting of Tcl script

1.1. Other protocols or schemes used for implementation
I adapted below configuration with all experiments and implementation.

set opt(chan) Channel/WirelessChannel
set opt(prop) Propagation/TwoRayGround
set opt(netif) Phy/WirelessPhy
set opt(mac) Mac/802_11
set opt(ifq) CMUPriQueue
set opt(ll) LL
set opt(ant) Antenna/OmniAntenna
set opt(ifqlen) 50 ;# max packet in ifq
set opt(seed) 0.0
set opt(rp) DSDV ;# routing protocol script

$ns_ node-config -adhocRouting $opt(rp) \
-llType $opt(ll) \
-macType $opt(mac) \
-ifqType $opt(ifq) \
-ifqLen $opt(ifqlen) \
-antType $opt(ant) \
-propType $opt(prop) \
-phyType $opt(netif) \
-channel [new $opt(chan)] \
-topoInstance $topo \
-agentTrace OFF \
-routerTrace OFF \
-macTrace OFF \
-MovementTrace OFF

1.2. Parameter setting of protocols except BitTorrent
And belows are the used parameters' setting for every protocols except BitTorrent.

set opt(initEnergy) 99999999
set opt(rxPower) 100
set opt(txPower) 100

LL set mindelay_ 50us
LL set delay_ 25us
LL set bandwidth_ 0 ;# not used

Queue/DropTail/PriQueue set Prefer_Routing_Protocols 1

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

Phy/WirelessPhy set CPThresh_ 10.0
Phy/WirelessPhy set CSThresh_ 3.92405e-08 ;#Carrier Sensing Range = 70
Phy/WirelessPhy set RXThresh_ 7.69113e-08 ;#Transmission Range = 50
Phy/WirelessPhy set Rb_ 2*1e6
Phy/WirelessPhy set Pt_ 0.2818
Phy/WirelessPhy set freq_ 914e+6
Phy/WirelessPhy set L_ 1.0

Agent/DSDV set perup_ 30

1.3. BitTorrent Setting for Tcl script
Belows are about how to create and intialize the BitTorrent node at Tcl scripts.

set node_($i) [$ns_ node $i]
set id [$node_($i) id]
set bitAgent_($i) [new Agent/BitAgent]
set bit_($i) [new Application/BitTorrent $id $node_($i) $opt(nn)]

set addr [$node_($i) node-addr]

$ns_ attach-agent $node_($i) $bitAgent_($i)
$bit_($i) attach-agent $bitAgent_($i)

set piecePool [new PiecePool $file_name_]
$bit_($i) setPiecePool $piecePool

$ns_ at $opt(measureStart) "$bit_($i) start"

As you can see, you should pass the ID of node, the instance of NS-2 wireless node which the BitTorrent layer will be attached, and the number of node in the network topology to a BitTorrent node at creation. If you want to know the reasons the pass these information, please refer the constructor function of BitTorrent class (bittorrent.cc).

Also, in order to use a BitTorrent node in your simulation, you should add BitAgent class to every node whcih will be deployed in the network. Unless, a BitTorrent node cannot receive a UDP control message correctly. And, you should attach a BitAgent instance to the NS-2 wireless node, and a BitAgent instance to a BitTorrent node.

After that, you should create a PiecePool (file) and attach it to a BitTorrent node. A PiecePool instance should be initialized by passing the name of file, and every PiecePool of BitTorrent nodes which you want to share the file each other should be initialized by the same name. You can indicate the seed node with setting one of the PiecePool as complete by using the command of PiecePool "setAsComplete".

At last, you should call the command "start" to a BitTorrent node which you want to start the functionalities of our BitTorrent protocol. The "start" command should be called during simulation time.
 
Old 09-09-2013, 10:25 AM   #52
zadi
LQ Newbie
 
Registered: Aug 2013
Posts: 21

Rep: Reputation: Disabled
Quote:
Originally Posted by zadi View Post
hi knudfl I want to add bittorrent ns 2 v 2.29 and I found problems in the applicaton of its steps


### How to build a program (Makefile setting)
1. Makefile

In order to simulate our BitTorrent implementation, you should add a define "BITTO" to your Makefile of ns-2 and add lists of files about our BitTorrent implementation (that will be listed below section). Also, there is an additional define variables called "BIT_DOWNLOADING". If you turn on this variables, the BitTorrent node will handle the DOWNLOADING state of a block; If a block is downloading from a neighbor, a node will not request to offer that block to any other BitTorrent nodes only if there exists an imcomplete block of a piece which are not in the DOWNLOADING state. This helps to minimize the number of packets in the network, but it can make that node taken a little bit more to finish to download.

2. Modified files of the existing NS-2

In order to implement our BitTorrent, I modified some existing ns-2 implementations. Here are the lists of modified files.
- $NS/Makefile
- $NS/tcl/lib/ns-default.tcl
- $NS/common/packet.h
- $NS/ns-process.h
- $NS/dsdv/dsdv.h
- $NS/dsdv/dsdv.cc


### The list of C++ source code
1. bitagent.[cc/h]
- These files contain the implementation of BitAgent class and struct hdr_bitAgent
- BitAgent is the Agent class which will transmits the control message by using UDP protocol
- hdr_bitAgent is the packet header of control message of BitTorrent
- To use, "flooding_ttl_" bind variables with Tcl script should be set

2. bittable.[cc/h]
- These files contain the implementation of several data structure classes (BitPeer, BitNeighbor, PeerTable, NeighborTable, Piece, PiecePool)
- BitPeer represents the peer object of the BitTorrent node
- BitNeighbor represents the neighbor object of the BitTorrent node
- PeerTable contains the peer lists of the BitTorrent node by using Tcl_HashTable whose key is the id_ of the peer object
- NeighborTable contains the neighbor lists of the BitTorrent node by using Tcl_HashTable whose key is the id_ of the neighbor object
- PeerTable / NeighborTable should be initiated with the maximum number of object which it can contain
- Piece represents the piece object of the file which will be shared by BitTorrent nodes
--> The file is consisted with several pieces and a piece is consisted with several blocks
- PiecePool contains all the pieces of the file by using Tcl_HashTable whose key is the id_ of the piece object, and maintains the status of the piece (COMPLETE, DOWNLOADING, INCOMPLETE)

3. bittcpapp.[cc/h]
- These files contain the implementation of BitTcpApp class and BitTorrentControl class, and BItTorrentPayload class
- BitTcpApp is inherited from the TcpApp which is the famous application to use FullTcp in NS-2
- In order to establish the TCP connection between two BitTorrent nodes, BitTcpApp object should be attached to each of the wireless nodes. Because we establish the TCP connections between every BitTorrent nodes dynamically, this TCP connection is maintained by BitConnection object.
- BitTorrentControl represents the control packet of BitTorrent
- BitTorrentPayload represents the packet header and the payload of data transmission
- Because NS-2 doesn't support the transmission of application payload, we use CBuf and CBufList of TcpApp in order to capsulize the data transmission to BitTcpApp or BitTorrent object.

4. bittorrent.[cc/h]
- These files are the main source files of BitTorrent program. These files contain the implementation of BitTorrent, BitConnection, GlobalBitTorrentList, GlobalBitConnectionList.
- BitTorrent represents the BitTorrent application and implements the protocol of BitTorrent
- BitConnection maintains the dynamic TCP connection between two BitTorrent (BitTcpApp) nodes
- GlobalBitTorrentList maintains the global list of BitTorrent nodes in the simulation. It is only for implementation details, it is never concerned with BitTorrent protocol.
- GlobalBitConnectionList maintains the global list of BitConnection objects in the simulation. It is also only for implementation details, never related with the BitTorrent protocol.


### Configurable parameters of Tcl script
These are the parameters which can be configured at tcl scripts. All the default values are written at NS/tcl/lib/ns-default.tcl.

Application/BitTorrent set max_peer_num_ 10
-> The maximum number of peers that node can have

Application/BitTorrent set max_neighbor_num_ 10
-> The maximum number of neighbors that node can have

Application/BitTorrent set max_upload_num_ 4
-> The maximum number of upload connections that node can have
-> When this value set as 1, the BitTorrent performs a serial transmission. When this value set over 1, it performs a parallel transmission.

Application/BitTorrent set max_download_num_ 4
-> The maximum number of download connections that node can have

Application/BitTorrent set local_rarest_select_flag_ 1
-> The flag from where the BitTorrent calculate the local rarest piece
-> If is 1, it will calculate from the PeerTable.
-> If is 2, it will calculate from the NeighborTable.

Application/BitTorrent set control_tcp_flag_ 1
-> The flag about how its control message to transmit
-> If 0, use UDP. If 1, use TCP.

Application/BitTorrent set use_bidirection_tcp_flag_ 1
-> The flag about whether to use its TCP connection for uni-direction or bi-direction
-> If 0, it uses uni-direction. If 1, bi-direction.

Application/BitTorrent set peerTable_flag_ 1
-> The flag about whether the node removes its peer which became a Seed when the node itself became a Seed.
-> Recommended to use 1 always.

Application/BitTorrent set selectNodeToUpload_flag_ 2
-> The flag about how to select node to upload
-> If 0, it selects nodes based on a choking algorithm of original BitTorrent (named basic)
-> If 1, it selects only physical 1-hop nodes (named 1HOP)
-> If 2. it selects based the closest node first strategy
-> If 3. a node selects nodes like basic and only the seed selects nodes randomly

Application/BitTorrent set selectNeighbor_flag_ 0
-> The flag about how to select neighbors from the peerTable
-> If 0, it selects the closest peers first
-> If 1, it selects randomly

Application/BitTorrent set try_upload_interval_ [expr 10* [Application/BitTorrent set max_upload_num_]]
-> The interval to try to offer the piece to its neighbors
-> The unit is sec (simulation time)

Application/BitTorrent set printCPL_flag_ 1
-> The flag about whether to generate result files of the current having Piece ID list or not
-> If 0, do not generate, and if 1, generate the result files.

Application/BitTorrent set choking_best_slot_num_ 3
-> The number of best slot for choking algorithm

Application/BitTorrent set choking_optimistic_slot_num_ 1
-> The number of optimistic slot for choking algorithm

Application/BitTorrent set into_steady_state_time_ 1000
-> There are two kinds of phase in our BitTorrent. The nodes should transmit HELLO messages more frequently at the first time, because in order to share the file fastly it needs to know about the node in the network.
-> Therefore, we separate the startUp phase and steady phase. This value indicates when the BitTorrent node goes into the steady phase.
-> The unit is the simulation time.

Application/BitTorrent set peer_update_interval1_ 100
-> The "peer_update_interval" is the interval to flood the HELLO message into the network
-> This value is the peer_update_interval for startUp phase. So, we strongly recommend to set this value smaller than the value of peer_update_interval2 which is the peer_update interval for steady phase.
-> When the timer for peer update is expred, the node starts to flood HELLO message. Whenever it receives the HELLO_REPLY from a node, it adds the sender of HELLO_REPLY to its peerTable.
-> The peerTable is maintained based on update manner not re-creation manner. The remove procedure performed only when the node itself became a seed and at that time it removes only the seed peers from its peerTable.

Application/BitTorrent set peer_update_interval2_ 500
-> The interval to update its peerList by flooding HELLO message at the steady phase

Application/BitTorrent set neighbor_select_interval1_ [expr 2*[Application/BitTorrent set try_upload_interval_]]
-> The interval to select neighbor from the peerTable at startUp phase
-> We also strongly recommend to set this value smaller than the neighbor_select_interval2_
-> Unlike peerTable, neighborTable is maintained based on re-creation manner not update manner
-> In the current version of our BitTorrent implementation, we select neighbors based on its hopcount (Closest one first), but it can be changed based on the performance results.

Application/BitTorrent set neighbor_select_interval2_ [expr 2*[Application/BitTorrent set try_upload_interval_]]
-> The interval to select neighbor from the peerTable at steady phase

Application/BitTorrent set received_bytes_reset_interval_ 60
-> The original BitTorrent adapts the choking algorithm to facilitate the file sharing. In choking algorithm, the BitTorrent node chooses the best unchoking nodes based on how many bytes it provide to me.
-> This value is the interval to reset the history about how many bytes it receives from a specific node.

Agent/BitAgent set flooding_ttl_ 3
-> The time-to-live value which will be used in flooding of HELLO message

PiecePool set piece_num_ 10
-> The number of pieces in the file which will be shared

PiecePool set block_num_ 10
-> The number of blocks in one piece

PiecePool set block_size_ [expr 10*1000]
-> The size of a block. The unit is bytes.
-> Therefore, the size of the file which will be shared is piece_num_ * block_num_ * block_size_.


### How to run a simulation

1. Setting of Tcl script

1.1. Other protocols or schemes used for implementation
I adapted below configuration with all experiments and implementation.

set opt(chan) Channel/WirelessChannel
set opt(prop) Propagation/TwoRayGround
set opt(netif) Phy/WirelessPhy
set opt(mac) Mac/802_11
set opt(ifq) CMUPriQueue
set opt(ll) LL
set opt(ant) Antenna/OmniAntenna
set opt(ifqlen) 50 ;# max packet in ifq
set opt(seed) 0.0
set opt(rp) DSDV ;# routing protocol script

$ns_ node-config -adhocRouting $opt(rp) \
-llType $opt(ll) \
-macType $opt(mac) \
-ifqType $opt(ifq) \
-ifqLen $opt(ifqlen) \
-antType $opt(ant) \
-propType $opt(prop) \
-phyType $opt(netif) \
-channel [new $opt(chan)] \
-topoInstance $topo \
-agentTrace OFF \
-routerTrace OFF \
-macTrace OFF \
-MovementTrace OFF

1.2. Parameter setting of protocols except BitTorrent
And belows are the used parameters' setting for every protocols except BitTorrent.

set opt(initEnergy) 99999999
set opt(rxPower) 100
set opt(txPower) 100

LL set mindelay_ 50us
LL set delay_ 25us
LL set bandwidth_ 0 ;# not used

Queue/DropTail/PriQueue set Prefer_Routing_Protocols 1

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

Phy/WirelessPhy set CPThresh_ 10.0
Phy/WirelessPhy set CSThresh_ 3.92405e-08 ;#Carrier Sensing Range = 70
Phy/WirelessPhy set RXThresh_ 7.69113e-08 ;#Transmission Range = 50
Phy/WirelessPhy set Rb_ 2*1e6
Phy/WirelessPhy set Pt_ 0.2818
Phy/WirelessPhy set freq_ 914e+6
Phy/WirelessPhy set L_ 1.0

Agent/DSDV set perup_ 30

1.3. BitTorrent Setting for Tcl script
Belows are about how to create and intialize the BitTorrent node at Tcl scripts.

set node_($i) [$ns_ node $i]
set id [$node_($i) id]
set bitAgent_($i) [new Agent/BitAgent]
set bit_($i) [new Application/BitTorrent $id $node_($i) $opt(nn)]

set addr [$node_($i) node-addr]

$ns_ attach-agent $node_($i) $bitAgent_($i)
$bit_($i) attach-agent $bitAgent_($i)

set piecePool [new PiecePool $file_name_]
$bit_($i) setPiecePool $piecePool

$ns_ at $opt(measureStart) "$bit_($i) start"

As you can see, you should pass the ID of node, the instance of NS-2 wireless node which the BitTorrent layer will be attached, and the number of node in the network topology to a BitTorrent node at creation. If you want to know the reasons the pass these information, please refer the constructor function of BitTorrent class (bittorrent.cc).

Also, in order to use a BitTorrent node in your simulation, you should add BitAgent class to every node whcih will be deployed in the network. Unless, a BitTorrent node cannot receive a UDP control message correctly. And, you should attach a BitAgent instance to the NS-2 wireless node, and a BitAgent instance to a BitTorrent node.

After that, you should create a PiecePool (file) and attach it to a BitTorrent node. A PiecePool instance should be initialized by passing the name of file, and every PiecePool of BitTorrent nodes which you want to share the file each other should be initialized by the same name. You can indicate the seed node with setting one of the PiecePool as complete by using the command of PiecePool "setAsComplete".

At last, you should call the command "start" to a BitTorrent node which you want to start the functionalities of our BitTorrent protocol. The "start" command should be called during simulation time.
the result where is the problem plz
 
Old 07-09-2014, 02:54 PM   #53
must
LQ Newbie
 
Registered: Jan 2014
Posts: 16

Rep: Reputation: Disabled
install NS2 2.29

what is the staps to install NS2 2.29.3 in ununtu 12.04 ?
 
Old 07-14-2014, 08:40 AM   #54
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2014.08, Slack14.1 DebWheezy, +50+ other Linux OS, for test only.
Posts: 14,278

Rep: Reputation: 2664Reputation: 2664Reputation: 2664Reputation: 2664Reputation: 2664Reputation: 2664Reputation: 2664Reputation: 2664Reputation: 2664Reputation: 2664Reputation: 2664
#53, @must.

The build, in /home/must/ : $ tar xvf ns-allinone-2.29.3.tar.gz
$ cd ns-allinone-2.29/
$ export CC=gcc41 CXX=g++41 && ./install

The install : $ cd ns-2.29/
$ sudo make install

Getting the gcc41/g++41 compilers for 12.04 - 32bits (i686) :
Post #18 here http://www.linuxquestions.org/questi...022/page2.html

-
 
  


Reply

Tags
bittorrent-p2p, mannasim, mannasim-ns235, ns2


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Solved Problem Second GCC-Pass(or gettext sanity check problem) hoes Linux From Scratch 0 09-04-2005 11:20 AM
Sound Card problem(every time i install linux i have diffirent hardware problem) jacka1l Linux - Newbie 7 08-11-2005 07:10 AM
Lan configuration problem - NFS boot problem - RX&TX packets errors 242VDM242 Linux - Networking 4 11-25-2004 02:35 PM
perl problem? apache problem? cgi problem? WorldBuilder Linux - Software 1 09-17-2003 08:45 PM
Not as much of a Solaris problem rether hardware Ultra 10 problem (video card) neo77777 Solaris / OpenSolaris 7 06-24-2003 09:36 PM


All times are GMT -5. The time now is 08:51 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration