sctp.README
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:36k
源码类别:

通讯编程

开发平台:

Visual C++

  1. sctp.README - README file for NS-2 SCTP module release 3.7
  2. ###############################################################################
  3. # Copyright (c) 2006-2007 by the Protocol Engineering Lab, U of Delaware      #
  4. # All rights reserved.                                                        #
  5. #                                                                             #
  6. # Protocol Engineering Lab web page : http://pel.cis.udel.edu/                #
  7. #                                                                             #
  8. # Paul D. Amer        <amer@@cis,udel,edu>                                    #
  9. # Armando L. Caro Jr. <acaro@@cis,udel,edu>                                   #
  10. # Janardhan Iyengar   <iyengar@@cis,udel,edu>                                 #
  11. # Preethi Natarajan   <nataraja@@cis,udel,edu>                                #
  12. # Nasif Ekiz          <nekiz@@cis,udel,edu>                                   #
  13. ###############################################################################
  14. Please submit bug reports to pel@@cis,udel,edu
  15. @(#) $Header: /cvsroot/nsnam/ns-2/sctp/sctp.README,v 1.2 2007/06/17 21:44:44 tom_henderson Exp $
  16. ------------------------------------------------------------------------------
  17. MODULE INFO:
  18. The SCTP module for NS-2 currently supports the features in the following
  19. sections of RFC4460 (with draft-ietf-tsvwg-sctpimpguide-04.txt):
  20.    5.1 Normal Establishment of an Association (rudimentary handshake)
  21.    5.4 Path Verification
  22.    6.1 Transmission of DATA Chunks
  23.    6.2 Acknowledgement of Reception of DATA Chunks
  24.    6.3 Management Retransmission Timer
  25.    6.4 Multi-homed SCTP Endpoints
  26.    6.5 Stream Identifier and Stream Sequence Number
  27.    6.6 Ordered and Unordered Delivery 
  28.    6.7 Report Gaps in Received DATA TSNs
  29.    7.2 SCTP Slow-Start and Congestion Avoidance
  30.    8.1 Endpoint Failure Detection
  31.    8.2 Path Failure Detection
  32.    8.3 Path Heartbeat (without upper layer control)
  33. Also, the unreliable data mode extension (U-SCTP) is supported as of
  34. draft-ietf-tsvwg-usctp-01.txt. 
  35. The SCTP module has NS-2 upper layer API support (but many features are
  36. still lacking). It supports all legacy NS-2 applications, but they
  37. obviously aren't able to exploit all SCTP's features. However, SCTP-aware
  38. application modules can be written to do so.
  39. NS-2 applications wishing to become SCTP-aware can use the sendmsg API as
  40. follows (see sctp_app1.cc and sctp_app1.h for an example). Note: this
  41. feature hasn't been tested extensively, so please report bugs!
  42.    1. create and fill an AppData_S object (see sctp.h)
  43.    
  44.       - usNumStreams
  45. The number of outgoing streams to setup during
  46. negotiation. Although this field is passed with every sendmsg
  47. call, it is only used when associating the connection.
  48.       - usNumUnreliable
  49.         The number of outgoing streams which are unreliable. The sender
  50.         simply sets the lowest outgoing stream to unreliable; the
  51.         remaining ones are reliable. This field is also only used when
  52.         associating the connection.
  53.       - usStreamId
  54. The stream ID of this message.
  55.       - usReliability
  56.         The reliability level (k-rtx value) of this message.
  57.       - eUnordered
  58.         The unordered boolean flag for this message.
  59.       - uiNumBytes
  60.         The number of bytes in this message.
  61.    2. pass this object as the second parameter in SCTP's sendmsg: 
  62.  
  63.  sctpAgent->sendmsg(numBytes, (char *)appData);
  64. The SCTP module uses several variables which can be bound from within tcl. The
  65. corresponding variables to be used in tcl are (with explanations):
  66.    debugMask_
  67.       The 32-bit mask to turn on/off debugging for particular
  68.       functions. See sctpDebug.h for the mappings of the bitmask. To set
  69.       all bits, a -1 may be used. The default is 0, which means all
  70.       debugging is off. 
  71.       Note: ns must be compiled with -DDEBUG for this option to
  72.       work. Also, if debug_ (the standard debug flag) is set to 1, then
  73.       all the bits in debugMask_ are set.
  74.    debugFileIndex_ 
  75.       Each SCTP peer can independently output debugging info to a separate
  76.       file. For example, the data sender can log debugging output to one
  77.       file, while the receiver does it to another file. The file index
  78.       specifies the file to be used for the particular peer. ie, If
  79.       debugFileIndex_ is set to 0, the file used will be named
  80.       'debug.SctpAgent.0'. If -1 is used, the debug output is sent to
  81.       stderr. Also, two peers should NOT send debug output to the same
  82.       file. The default is -1. 
  83.       Note: ns must be compiled with -DDEBUG for this option to work.
  84.    associationMaxRetrans_
  85.       Sets the parameter Association.Max.Retrans. The default is 10 attempts.
  86.    pathMaxRetrans_
  87.       Sets the parameter Path.Max.Retrans. The default is 5 attempts.
  88.    maxInitRetransmits_
  89.       Sets the parameter Max.Init.Retransmits. The default is 8 attempts.
  90.    heartbeatInterval_ 
  91.       Sets the parameters HB.interval. Setting this parameter to 0 turns
  92.       off HEARTBEATing. The default is 30 seconds.
  93.    mtu_
  94.       Sets the MTU for the path. Consequently, it sets the maximum packet
  95.       size as well, since our sender tries to fill packets up to MTU. The
  96.       actual data is MTU - SCTP/IPv4 header (32 bytes). The default is
  97.       1500.
  98.    initialRwnd_
  99.       Sets the initial rwnd value which will be advertised to the
  100.       peer. The default is 65536.
  101.    initialSsthresh_
  102.       Sets the initial ssthresh value (in bytes). The default is 65536.
  103.    initialCwnd_
  104.       Cwnd will be initialized to (initialCwnd_ * MTU). The default is 2.
  105.    numOutStreams_
  106.       Sets the number of outgoing streams from the sender. Although the
  107.       sender does transmit this value as the RFC specifies, the receiver
  108.       simply accepts without negotiation. The default is 1.
  109.    numUnrelStreams_
  110.       Sets the number of outgoing streams which are unreliable. The sender
  111.       simply sets the lowest outgoing stream to unreliable; the remaining
  112.       ones are reliable. The default is 0.
  113.    reliability_
  114.       Sets the default reliability level on all the unreliable streams. An
  115.       SCTP-aware ns-2 application can control the reliablilty level on a
  116.       per chunk basis by using the upper layer API. On the other hand,
  117.       since legacy ns-2 applications do not use this API, they do not have
  118.       individual control. The default is 0, which means zero
  119.       retransmissions on the unreliable streams.
  120.    unordered_
  121.       Sets the default unordered flag for all chunks on all streams. An
  122.       SCTP-aware ns-2 application can control the unordered flag on a per
  123.       chunk basis by using the upper layer API. On the other hand, since
  124.       legacy ns-2 applications do use this API, they do not have
  125.       individual control. The default is 0, which means all chunks are
  126.       ordered.
  127.    ipHeaderSize_
  128.       Sets the IP header size (in bytes) of each packet. The default is 20
  129.       (IPv4 without any options).
  130.    dataChunkSize_
  131.       Sets the size of each data chunk. Between this and the MTU, the
  132.       number of chunks per packet can be controlled. We do not support
  133.       variable length chunks yet. The default is 512.
  134.    useDelayedSacks_
  135.       Sets whether delayed sacks will be used or not. 0 means generate a
  136.       sack for every incoming packet. 1 means do the normal delayed ack
  137.       algorithm. The default is 1.
  138.    useMaxBurst_
  139.       Sets whether the Max.Burst restriction will be applied or not. 0
  140.       means it is off. 1 means it is on and follows the SCTP implementor's
  141.       guide. The default is 1, which means the option is on.
  142.    rtxToAlt_
  143.       RFC2960 says that retransmissions should go to an alternate
  144.       destination when available. An experimental behavior is to
  145.       retransmit to the same destination, unless it is inactive. The
  146.       default is 1, which means that retransmission go to an alternate
  147.       destination. 
  148.    cwnd_
  149.    
  150.       Used to trace the CWNDs of all paths. It can be used with both the
  151.       sampling ("print") and non-sampling ("trace") method of tracing.
  152.    rto_
  153.    
  154.       Used to trace the RTOs of all paths.  It can be used with both the
  155.       sampling ("print") and non-sampling ("trace") method of tracing.
  156.    errorCount_
  157.    
  158.       Used to trace the error counters of all paths.  It can be used with
  159.       both the sampling ("print") and non-sampling ("trace") method of
  160.       tracing.
  161.    trace_all_
  162.       Possible values are 0 and 1. This is used to determine whether all
  163.       the trace variables should be printed out any time a single traced
  164.       variable is triggered. It can be used with both the sampling
  165.       ("print") and non-sampling ("trace") method of tracing. Default is
  166.       0, which means the option is off.
  167. The SCTP module provides certain "commands" that can be used within tcl
  168. scripts. The commands are (with explanations):
  169.    print
  170.       Provides the non-sampling method of tracing. Takes 1 argument: one
  171.       of the trace variables presented above. 
  172.    set-multihome-core
  173.       Set the core node for multihomed endpoints. Takes 1 argument of type
  174.       node. Mandatory for multihomed endpoints and must not be set more
  175.       than once per endpoint. (see "interesting features" 6. below)
  176.    multihome-add-interface
  177.       Add an interface to a multihomed endpoint. Takes 2 arguments of type
  178.       node. Argument 1 is the core node of the multihomed
  179.       endpoint. Argument 2 is the interface node to be added. Mandatory
  180.       for multihomed endpoints. All interfaces must be added after
  181.       set-multihome-core is called and before multihome-attach-agent is
  182.       called. (see "interesting features" 6. below)
  183.    multihome-attach-agent
  184.       Attach an SCTP agent to a multihomed endpoint. Takes 2
  185.       arguments. Argument 1 is the core node. Argument 2 is the SCTP
  186.       agent. Mandatory for multihomed endpoints. (see "interesting
  187.       features" 6. below)
  188.    set-primary-destination
  189.       Set the interface node of the peer endpoint as the primary
  190.       destination. Takes 1 argument of type node. Optional and may be set
  191.       more than once per endpoint. If not used, a primary destination is
  192.       chosen automatically. (see "interesting features" 6. below)
  193.    force-source
  194.       Set the interface node that packets will be sent from. Takes 1
  195.       argument of type node. Optional and may be set more than once per
  196.       endpoint. If not used, routing will automatically choose the
  197.       source on a per packet basis. (see "interesting features" 6. below)
  198. The SCTP module also comes with some "interesting features" :-).
  199.    1. Since legacy ns-2 applications are unaware of SCTP and the module's
  200.       upper layer API, they lack fine level control of stream
  201.       unreliability levels and data chunks' unordered flags. Hence, only
  202.       the tcl default variables can be used for those applications.
  203.    2. There is a 4-way handshake which is used to initialize an
  204.       association, but it is done as simply as possible. Hence, there is
  205.       no actual exchange of tags, etc as detailed in RFC2960. Also, the
  206.       INIT and COOKIE-ECHO do have retransmission timers associated with
  207.       them in case of loss, but these chunks are not used to update the
  208.       RTT. RTT estimation calculations begin with the first DATA chunk.
  209.    3. While ns-2 starts numbering packets at 0, the SCTP module starts
  210.       numbering DATA chunk TSNs at 1 and assigns undefined TSN values to
  211.       non-DATA chunks (ie, INIT, SACK, HEARTBEAT, etc). In addition, the 4
  212.       packets exchanged during the association initialization are not
  213.       included in the traces and do not show up in the graphs, but they
  214.       are still counted in the packet enumeration. This information is
  215.       important when doing things like specifying a drop list for the
  216.       ErrorModel object. For example, if a List is specified for the
  217.       ErrorModel object, packet 2 actually refers to the first SCTP packet
  218.       with DATA chunk(s).
  219.    4. RTT measurements are done once per packet containing DATA chunk(s)
  220.       with no retransmissions. This is more frequent than what RFC2960
  221.       specifies (" RTT measurements SHOULD be made no more than once per
  222.       round-trip"). This may change to follow the RFC in a later release.
  223.    5. A proper shutdown is not done yet. The association is abruptly
  224.       terminated when the simulated connection ends. 
  225.    6. Due to ns-2's architecture, a node cannot actually be multihomed. We
  226.       have gotten around this limitation in the following way. Each
  227.       multihomed node is actually made up of more than one node. There is
  228.       a "core node" and multiple "interface nodes" to simulate the
  229.       interfaces. The SCTP agent resides on all the nodes, but traffic
  230.       only goes to and from the interface nodes. The core node is used for
  231.       routing and is connected to each interface node via a
  232.       uni-directional link towards the interface node. Traffic does not
  233.       traverse this link. Instead, these links are used to dynamically
  234.       determine which outgoing interface node to use for sending to a
  235.       particular destination. NAM can help better visualize the
  236.       architecture, but the diagram below gives some idea.
  237.                   +-  iface 1     O=====
  238.                   |              /
  239.       SCTP Agent  |      core   O
  240.                   |              
  241.                   +-  iface 2     O=====
  242. SCTP version 3.6 includes implementation for Concurrent Multipath
  243. Transfer (CMT)[1].
  244. CMT uses SCTP's multihoming feature to distribute data across multiple
  245. end-to-end paths in a multihomed SCTP association to increase an
  246. application's throughput. The ns-2 CMT module implements Split Fast
  247. Retransmit (SFR), Cwnd Update for CMT (CUC) and Delayed Ack for CMT
  248. (DAC) algorithms as explained in [1].
  249. SCTP version 3.7 includes implementation for CMT with Potentially
  250. Failed (CMT-PF) destination state that improves CMT performance during
  251. failures. Detailed information regarding CMT-PF can be found in [2].
  252. The SCTP module uses several variables for CMT and CMT-PF which can be
  253. bound from within tcl. The corresponding variables used in tcl are
  254. (with explanations):
  255. CMT variables:
  256.         useCmtReordering_
  257.  
  258.           Variable to turn ON/OFF CMT's Split Fast Retransmit (SFR)
  259.           algorithm which eliminates unnecessary fast retransmissions
  260.           due to reordering. Unnecessary fast retransmissions have 2
  261.           negative consequences: 1) reduced cwnd for the destination
  262.           to which the retransmitted data was outstanding.  2)
  263.           aggressive cwnd growth for the destination to which the
  264.           retransmissions are sent. Details of the algorithm can be
  265.           found in [1]. The default value is 1 (ON).
  266.         useCmtCwnd_
  267.   
  268.           Variable to turn ON/OFF CMT's Cwnd Update for CMT (CUC)
  269.           algorithm. The CUC algorithm eliminates reduced cwnd growth
  270.           due to reordering caused fewer cwnd updates. Reordering
  271.           causes many SACKs to be sent containing gaps reports but not
  272.           new cum acks. With CUC algorithm, cwnd is updated even in
  273.           the absence of new cum acks. The details of the algorithm
  274.           can be found in [1]. The default value is 1 (ON).
  275.        useCmtDelAck_
  276.          Variable to turn ON/OFF CMT's Delayed Ack for CMT (DAC)
  277.          algorithm. DAC algorithm eliminates the increased ack traffic
  278.          due to fewer delayed acks. Acks are delayed only as long as
  279.          the receiver recieves data in order. Due to reordering
  280.          introduced with CMT, an SCTP receiver does not frequently
  281.          delay acks. With DAC algorithm, a CMT receiver always delays
  282.          acks irrespective of whether or not data is received in
  283.          order. The details of the algorithm can be found in [1]. The
  284.          default value is 1 (ON).
  285.        eCmtRtxPolicy_
  286.          Variable to define retransmission policy for CMT
  287.          sender. Currently there are 5 retransmission policies for
  288.          CMT, of which two are recommended and the rest are
  289.          experimental. The retransmission policies for CMT are:
  290.          RTX_ASAP (experimental) - A retransmission of a data chunk is
  291.          sent to any destination for which the sender has cwnd space
  292.          available at the time of retransmission. If multiple
  293.          destinations have available cwnd space, one is chosen
  294.          randomly. Set value to 0 for RTX_ASAP.
  295.          RTX_SAME (experimental) - All retransmissions of the data
  296.          chunk are sent to the same destination until the destination
  297.          is deemed inacive due to failure. Set value to 1 for RTX_SAME.
  298.   
  299.  RTX_SSTHRESH (recommended) - A retransmission is sent to the
  300.          destination for which the sender has the largest ssthresh
  301.          value. A tie is broken by random selection. Set value to 2
  302.          for RTX_SSTHRESH.
  303.   
  304.          RTX_LOSSRATE (experimental) - A retransmission is sent to the
  305.          destination with the lowest loss rate path. A tie is broken
  306.          by random selection. Set value to 3 for RTX_LOSSRATE.
  307.   
  308.          RTX_CWND (recommended, default) - A retransmission is sent to
  309.          the destination for which the sender has the largest cwnd. A
  310.          tie is broken by random selection. Set value to 4 for
  311.          RTX_CWND. This policy is the default policy for CMT.
  312. CMT-PF variables:
  313.        useCmtPF_
  314.           This variable is used to turn the CMT-PF extension
  315.           ON/OFF. The default value is 0 (OFF).
  316.        cmtPFCwnd_
  317.           This variable is used to set cwnd (in MTUs) after HB-ACK is
  318.           received (PF->ACTIVE) at the sender. Two possible values for
  319.           this variable are 1 or 2. The default value is 1.
  320. ------------------------------------------------------------------------------
  321. # EXAMPLE SCRIPT 1
  322. #
  323. # Simply drops one packet and later fast rtx it.
  324. # this needs to be set for tracing SCTP packets
  325. Trace set show_sctphdr_ 1
  326. set ns [new Simulator]
  327. set nf [open sctp.nam w]
  328. $ns namtrace-all $nf
  329. set allchan [open all.tr w]
  330. $ns trace-all $allchan
  331. proc finish {} {
  332.     global ns nf allchan
  333.     set PERL "/usr/bin/perl"
  334.     set USERHOME [exec env | grep "^HOME" | sed /^HOME=/s/^HOME=//]
  335.     set NSHOME "$USERHOME/proj/ns-allinone-2.1b8.sctp"
  336.     set XGRAPH "$NSHOME/bin/xgraph"
  337.     set SETFID "$NSHOME/ns-2.1b8/bin/set_flow_id"
  338.     set RAW2XG_SCTP "$NSHOME/ns-2.1b8/bin/raw2xg-sctp"
  339.     $ns flush-trace
  340.     close $nf
  341.     close $allchan
  342.     exec $PERL $SETFID -s all.tr | 
  343.     $PERL $RAW2XG_SCTP -A -q > temp.rands
  344.     exec $XGRAPH -bb -tk -nl -m -x time -y packets temp.rands &
  345.     exec nam sctp.nam &
  346.     exit 0
  347. }
  348. set false      0
  349. set true       1
  350. set n0 [$ns node]
  351. set n1 [$ns node]
  352. $ns duplex-link $n0 $n1 .5Mb 200ms DropTail
  353. $ns duplex-link-op $n0 $n1 orient right
  354. #$ns queue-limit $n0 $n1 93000
  355. set err [new ErrorModel/List]
  356. $err droplist {15}
  357. $ns lossmodel $err $n0 $n1
  358. # NOTE: The debug files (in this example, they would be debug.SctpAgent.0
  359. #       and debug.SctpAgent.1) contain a lot of useful info. They can be 
  360. #       used to trace every packet sent/rcvd/processed.
  361. #
  362. set sctp0 [new Agent/SCTP]
  363. $ns attach-agent $n0 $sctp0
  364. $sctp0 set fid_ 0 
  365. $sctp0 set debugMask_ 0x00303000   # u can use -1 to turn on everything
  366. $sctp0 set debugFileIndex_ 0
  367. $sctp0 set mtu_ 1500
  368. $sctp0 set dataChunkSize_ 1468
  369. $sctp0 set numOutStreams_ 1
  370. $sctp0 set initialCwndMultiplier_ 2
  371. $sctp0 set useMaxBurst_ $true
  372. set trace_ch [open trace.sctp w]
  373. $sctp0 set trace_all_ 0 # do not trace all variables on one line
  374. $sctp0 trace cwnd_
  375. $sctp0 attach $trace_ch
  376. set sctp1 [new Agent/SCTP]
  377. $ns attach-agent $n1 $sctp1
  378. $sctp1 set debugMask_ -1 
  379. $sctp1 set debugFileIndex_ 1
  380. $sctp1 set mtu_ 1500
  381. $sctp1 set initialRwnd_ 131072 
  382. $sctp1 set useDelayedSacks_ $true
  383. $ns color 0 Red
  384. $ns color 1 Blue
  385. $ns connect $sctp0 $sctp1
  386. set ftp0 [new Application/FTP]
  387. $ftp0 attach-agent $sctp0
  388. $ns at 0.5 "$ftp0 start"
  389. $ns at 5.0 "finish"
  390. $ns run
  391. ------------------------------------------------------------------------------
  392. # EXAMPLE SCRIPT 2
  393. #
  394. # Demonstrates multihoming. Two endpoints with 2 interfaces with direct
  395. # connections between each pair. There is a single HEARTBEAT timer for all
  396. # the destinations (similar to the reference implementation). In the
  397. # middle of the association, a change primary is done.
  398. #
  399. #       host0_if0      O===========O    host1_if0
  400. #                     /             
  401. #       host0_core   O               O  host1_core
  402. #                                  /
  403. #       host0_if1      O===========O    host1_if1
  404. Trace set show_sctphdr_ 1
  405. set ns [new Simulator]
  406. set nf [open sctp.nam w]
  407. $ns namtrace-all $nf
  408. set allchan [open all.tr w]
  409. $ns trace-all $allchan
  410. proc finish {} {
  411.     global ns nf allchan
  412.     set PERL "/usr/bin/perl"
  413.     set USERHOME [exec env | grep "^HOME" | sed /^HOME=/s/^HOME=//]
  414.     set NSHOME "$USERHOME/proj/ns-allinone-2.1b8.sctp"
  415.     set XGRAPH "$NSHOME/bin/xgraph"
  416.     set SETFID "$NSHOME/ns-2.1b8/bin/set_flow_id"
  417.     set RAW2XG_SCTP "$NSHOME/ns-2.1b8/bin/raw2xg-sctp"
  418.     set GETRC "$NSHOME/ns-2.1b8/bin/getrc"
  419.     $ns flush-trace
  420.     close $nf
  421.     close $allchan
  422.     # Graph the host0_if0 <-> host1_if0
  423.     exec $PERL $GETRC -s 1 -d 4 all.tr > all.tr.if0 
  424.     exec $PERL $GETRC -s 4 -d 1 all.tr >> all.tr.if0 
  425.     exec $PERL $SETFID -s all.tr.if0 | 
  426.       $PERL $RAW2XG_SCTP -A -q -t if0 > temp.rands.if0
  427.     exec $XGRAPH -bb -tk -nl -m -x time -y packets temp.rands.if0 &
  428.     
  429.     # Graph the host0_if1 <-> host1_if1
  430.     exec $PERL $GETRC -s 2 -d 5 all.tr > all.tr.if1 
  431.     exec $PERL $GETRC -s 5 -d 2 all.tr >> all.tr.if1 
  432.     exec $PERL $SETFID -s all.tr.if1 | 
  433.     $PERL $RAW2XG_SCTP -A -q -t if1 > temp.rands.if1
  434.     exec $XGRAPH -bb -tk -nl -m -x time -y packets temp.rands.if1 &
  435.     
  436.     # Graph the entire association on one graph
  437.     exec $PERL $SETFID -s all.tr | 
  438.     $PERL $RAW2XG_SCTP -A -q -t all > temp.rands
  439.     exec $XGRAPH -bb -tk -nl -m -x time -y packets temp.rands &
  440.     
  441.     exec nam sctp.nam &
  442.     exit 0
  443. }
  444. set host0_core [$ns node]
  445. set host0_if0 [$ns node]
  446. set host0_if1 [$ns node]
  447. $host0_core color Red
  448. $host0_if0 color Red
  449. $host0_if1 color Red
  450. $ns multihome-add-interface $host0_core $host0_if0
  451. $ns multihome-add-interface $host0_core $host0_if1
  452. set host1_core [$ns node]
  453. set host1_if0 [$ns node]
  454. set host1_if1 [$ns node]
  455. $host1_core color Blue
  456. $host1_if0 color Blue
  457. $host1_if1 color Blue
  458. $ns multihome-add-interface $host1_core $host1_if0
  459. $ns multihome-add-interface $host1_core $host1_if1
  460. $ns duplex-link $host0_if0 $host1_if0 .5Mb 200ms DropTail
  461. $ns duplex-link $host0_if1 $host1_if1 .5Mb 200ms DropTail
  462. set sctp0 [new Agent/SCTP]
  463. $ns multihome-attach-agent $host0_core $sctp0
  464. $sctp0 set fid_ 0 
  465. $sctp0 set debugMask_ -1
  466. $sctp0 set debugFileIndex_ 0
  467. $sctp0 set mtu_ 1500
  468. $sctp0 set dataChunkSize_ 1468
  469. $sctp0 set numOutStreams_ 1
  470. $sctp0 set oneHeartbeatTimer_ 1   # one heartbeat timer shared for all dests
  471. set trace_ch [open trace.sctp w]
  472. $sctp0 set trace_all_ 1           # trace them all on oneline
  473. $sctp0 trace cwnd_
  474. $sctp0 trace rto_
  475. $sctp0 trace errorCount_
  476. $sctp0 attach $trace_ch
  477. set sctp1 [new Agent/SCTP]
  478. $ns multihome-attach-agent $host1_core $sctp1
  479. $sctp1 set debugMask_ -1
  480. $sctp1 set debugFileIndex_ 1
  481. $sctp1 set mtu_ 1500
  482. $sctp1 set initialRwnd_ 131072 
  483. $sctp1 set useDelayedSacks_ 1
  484. $ns color 0 Red
  485. $ns color 1 Blue
  486. $ns connect $sctp0 $sctp1
  487. set ftp0 [new Application/FTP]
  488. $ftp0 attach-agent $sctp0
  489. # set primary before association starts
  490. $sctp0 set-primary-destination $host1_if0
  491. # do a change primary in the middle of the association
  492. $ns at 7.5 "$sctp0 set-primary-destination $host1_if1"
  493. $ns at 7.5 "$sctp0 print cwnd_"
  494. $ns at 0.5 "$ftp0 start"
  495. $ns at 10.0 "finish"
  496. $ns run
  497. ------------------------------------------------------------------------------
  498. # EXAMPLE SCRIPT 3
  499. #
  500. # Demonstrates multihoming. One endpoint is single homed while the other
  501. # is multihomed. They are connected through a router. Shows that the they
  502. # can be combined. The sender is multihomed. The sender has the HEARTBEAT
  503. # mechanism turned off. In the middle of the association, the sender does
  504. # a "force-source", which means that the sender forces the source
  505. # interface used for outgoing traffic.
  506. #
  507. #       host0_if0      O===
  508. #                     /    \
  509. #       host0_core   O       O=======O  host1
  510. #                         //
  511. #       host0_if1      O===  
  512. Trace set show_sctphdr_ 1
  513. set ns [new Simulator]
  514. set nf [open sctp.nam w]
  515. $ns namtrace-all $nf
  516. set allchan [open all.tr w]
  517. $ns trace-all $allchan
  518. proc finish {} {
  519.     global ns nf allchan
  520.     set PERL "/usr/bin/perl"
  521.     set USERHOME [exec env | grep "^HOME" | sed /^HOME=/s/^HOME=//]
  522.     set NSHOME "$USERHOME/proj/ns-allinone-2.1b8.sctp"
  523.     set XGRAPH "$NSHOME/bin/xgraph"
  524.     set SETFID "$NSHOME/ns-2.1b8/bin/set_flow_id"
  525.     set RAW2XG_SCTP "$NSHOME/ns-2.1b8/bin/raw2xg-sctp"
  526.     set GETRC "$NSHOME/ns-2.1b8/bin/getrc"
  527.     $ns flush-trace
  528.     close $nf
  529.     close $allchan
  530.     exec nam sctp.nam &
  531.     exit 0
  532. }
  533. set host0_core [$ns node]
  534. set host0_if0 [$ns node]
  535. set host0_if1 [$ns node]
  536. $host0_core color Red
  537. $host0_if0 color Red
  538. $host0_if1 color Red
  539. $ns multihome-add-interface $host0_core $host0_if0
  540. $ns multihome-add-interface $host0_core $host0_if1
  541. set host1 [$ns node]
  542. $host1 color Blue
  543. set router [$ns node]
  544. $ns duplex-link $host0_if0 $router .5Mb 200ms DropTail
  545. $ns duplex-link $host0_if1 $router .5Mb 200ms DropTail
  546. $ns duplex-link $host1 $router .5Mb 200ms DropTail
  547. set sctp0 [new Agent/SCTP]
  548. $ns multihome-attach-agent $host0_core $sctp0
  549. $sctp0 set fid_ 0 
  550. $sctp0 set debugMask_ -1
  551. $sctp0 set debugFileIndex_ 0
  552. $sctp0 set mtu_ 1500
  553. $sctp0 set dataChunkSize_ 1468
  554. $sctp0 set numOutStreams_ 1
  555. $sctp0 set oneHeartbeatTimer_ 0   # turns off heartbeating
  556. set sctp1 [new Agent/SCTP]
  557. $ns attach-agent $host1 $sctp1
  558. $sctp1 set debugMask_ -1
  559. $sctp1 set debugFileIndex_ 1
  560. $sctp1 set mtu_ 1500
  561. $sctp1 set initialRwnd_ 131072 
  562. $sctp1 set useDelayedSacks_ 1
  563. $ns color 0 Red
  564. $ns color 1 Blue
  565. $ns connect $sctp0 $sctp1
  566. set ftp0 [new Application/FTP]
  567. $ftp0 attach-agent $sctp0
  568. # force the source interface
  569. $ns at 6.0 "$sctp0 force-source $host0_if1"
  570. $ns at 0.5 "$ftp0 start"
  571. $ns at 8.0 "finish"
  572. $ns run
  573. ------------------------------------------------------------------------------
  574. # EXAMPLE SCRIPT 4
  575. #
  576. # Demonstrates multihoming. Two endpoints with 2 interfaces each all
  577. # connected via a router. The sender has a HEARTBEAT timer for each
  578. # destination. In the middle of the association, a change primary is done.
  579. #
  580. #       host0_if0      O===     ===O    host1_if0
  581. #                     /    \ //    
  582. #       host0_core   O       O       O  host1_core
  583. #                         // \    /
  584. #       host0_if1      O===     ===O    host1_if1
  585. Trace set show_sctphdr_ 1
  586. set ns [new Simulator]
  587. set nf [open sctp.nam w]
  588. $ns namtrace-all $nf
  589. set allchan [open all.tr w]
  590. $ns trace-all $allchan
  591. proc finish {} {
  592.     global ns nf allchan
  593.     set PERL "/usr/bin/perl"
  594.     set USERHOME [exec env | grep "^HOME" | sed /^HOME=/s/^HOME=//]
  595.     set NSHOME "$USERHOME/proj/ns-allinone-2.1b8.sctp"
  596.     set XGRAPH "$NSHOME/bin/xgraph"
  597.     set SETFID "$NSHOME/ns-2.1b8/bin/set_flow_id"
  598.     set RAW2XG_SCTP "$NSHOME/ns-2.1b8/bin/raw2xg-sctp"
  599.     $ns flush-trace
  600.     close $nf
  601.     close $allchan
  602.     exec nam sctp.nam &
  603.     exit 0
  604. }
  605. set host0_core [$ns node]
  606. set host0_if0 [$ns node]
  607. set host0_if1 [$ns node]
  608. $host0_core color Red
  609. $host0_if0 color Red
  610. $host0_if1 color Red
  611. $ns multihome-add-interface $host0_core $host0_if0
  612. $ns multihome-add-interface $host0_core $host0_if1
  613. set host1_core [$ns node]
  614. set host1_if0 [$ns node]
  615. set host1_if1 [$ns node]
  616. $host1_core color Blue
  617. $host1_if0 color Blue
  618. $host1_if1 color Blue
  619. $ns multihome-add-interface $host1_core $host1_if0
  620. $ns multihome-add-interface $host1_core $host1_if1
  621. set router [$ns node]
  622. $ns duplex-link $host0_if0 $router .5Mb 200ms DropTail
  623. $ns duplex-link $host0_if1 $router .5Mb 200ms DropTail
  624. $ns duplex-link $host1_if0 $router .5Mb 200ms DropTail
  625. $ns duplex-link $host1_if1 $router .5Mb 200ms DropTail
  626. set sctp0 [new Agent/SCTP]
  627. $ns multihome-attach-agent $host0_core $sctp0
  628. $sctp0 set fid_ 0 
  629. $sctp0 set debugMask_ -1
  630. $sctp0 set debugFileIndex_ 0
  631. $sctp0 set mtu_ 1500
  632. $sctp0 set dataChunkSize_ 1468 
  633. $sctp0 set numOutStreams_ 1
  634. $sctp0 set oneHeartbeatTimer_ 0  # each dest has its own heartbeat timer
  635. set trace_ch [open trace.sctp w]
  636. $sctp0 set trace_all_ 1           # trace them all on oneline
  637. $sctp0 trace cwnd_
  638. $sctp0 trace rto_
  639. $sctp0 trace errorCount_
  640. $sctp0 attach $trace_ch
  641. set sctp1 [new Agent/SCTP]
  642. $ns multihome-attach-agent $host1_core $sctp1
  643. $sctp1 set debugMask_ -1
  644. $sctp1 set debugFileIndex_ 1
  645. $sctp1 set mtu_ 1500
  646. $sctp1 set initialRwnd_ 131072 
  647. $sctp1 set useDelayedSacks_ 1
  648. $ns color 0 Red
  649. $ns color 1 Blue
  650. $ns connect $sctp0 $sctp1
  651. set ftp0 [new Application/FTP]
  652. $ftp0 attach-agent $sctp0
  653. $sctp0 set-primary-destination $host1_if0
  654. # change primary
  655. $ns at 7.5 "$sctp0 set-primary-destination $host1_if1"
  656. $ns at 7.5 "$sctp0 print cwnd_"
  657. $ns at 0.5 "$ftp0 start"
  658. $ns at 12.0 "finish"
  659. $ns run
  660. -------------------------------------------------------------------------------
  661. # EXAMPLE SCRIPT 5
  662. #
  663. # Demonstrates Concurrent Multipath Transfer (CMT). Two endpoints with
  664. # 2 interfaces with direct connections between each pair. Data is
  665. # transfered using both paths concurrently.
  666. #
  667. #       host0_if0      O===========O    host1_if0
  668. #                     /             
  669. #       host0_core   O               O  host1_core
  670. #                                  /
  671. #       host0_if1      O===========O    host1_if1
  672. Trace set show_sctphdr_ 1
  673. set ns [new Simulator]
  674. set nf [open sctp.nam w]
  675. $ns namtrace-all $nf
  676. set allchan [open all.tr w]
  677. $ns trace-all $allchan
  678. proc finish {} {
  679.     global ns nf allchan
  680.     set PERL "/usr/bin/perl"
  681.     set NSHOME "/home/userA/ns-allinone-2.31"
  682.     set XGRAPH "$NSHOME/bin/xgraph"
  683.     set SETFID "$NSHOME/ns-2.31/bin/set_flow_id"
  684.     set RAW2XG_SCTP "$NSHOME/ns-2.31/bin/raw2xg-sctp"
  685.     set GETRC "$NSHOME/ns-2.31/bin/getrc"
  686.     $ns flush-trace
  687.     close $nf
  688.     close $allchan
  689.     # Graph the host0_if0 <-> host1_if0
  690.     exec $PERL $GETRC -s 1 -d 4 all.tr > all.tr.if0 
  691.     exec $PERL $GETRC -s 4 -d 1 all.tr >> all.tr.if0 
  692.     exec $PERL $SETFID -s all.tr.if0 | 
  693.       $PERL $RAW2XG_SCTP -A -q -t if0 > temp.rands.if0
  694.     exec $XGRAPH -bb -tk -nl -m -x time -y packets temp.rands.if0 &
  695.     
  696.     # Graph the host0_if1 <-> host1_if1
  697.     exec $PERL $GETRC -s 2 -d 5 all.tr > all.tr.if1 
  698.     exec $PERL $GETRC -s 5 -d 2 all.tr >> all.tr.if1 
  699.     exec $PERL $SETFID -s all.tr.if1 | 
  700.     $PERL $RAW2XG_SCTP -A -q -t if1 > temp.rands.if1
  701.     exec $XGRAPH -bb -tk -nl -m -x time -y packets temp.rands.if1 &
  702.     
  703.     # Graph the entire association on one graph
  704.     exec $PERL $SETFID -s all.tr | 
  705.     $PERL $RAW2XG_SCTP -A -q -t all > temp.rands
  706.     exec $XGRAPH -bb -tk -nl -m -x time -y packets temp.rands &
  707.     
  708.     exec nam sctp.nam &
  709.     exit 0
  710. }
  711. set host0_core [$ns node]
  712. set host0_if0 [$ns node]
  713. set host0_if1 [$ns node]
  714. $host0_core color Red
  715. $host0_if0 color Red
  716. $host0_if1 color Red
  717. $ns multihome-add-interface $host0_core $host0_if0
  718. $ns multihome-add-interface $host0_core $host0_if1
  719. set host1_core [$ns node]
  720. set host1_if0 [$ns node]
  721. set host1_if1 [$ns node]
  722. $host1_core color Blue
  723. $host1_if0 color Blue
  724. $host1_if1 color Blue
  725. $ns multihome-add-interface $host1_core $host1_if0
  726. $ns multihome-add-interface $host1_core $host1_if1
  727. $ns duplex-link $host0_if0 $host1_if0 10Mb 45ms DropTail
  728. [[$ns link $host0_if0 $host1_if0] queue] set limit_ 50
  729. $ns duplex-link $host0_if1 $host1_if1 10Mb 45ms DropTail
  730. [[$ns link $host0_if1 $host1_if1] queue] set limit_ 50
  731. set sctp0 [new Agent/SCTP/CMT]
  732. $ns multihome-attach-agent $host0_core $sctp0
  733. $sctp0 set fid_ 0 
  734. $sctp0 set debugMask_ -1
  735. $sctp0 set debugFileIndex_ 0
  736. $sctp0 set mtu_ 1500
  737. $sctp0 set dataChunkSize_ 1468
  738. $sctp0 set numOutStreams_ 1
  739. $sctp0 set useCmtReordering_ 1   # turn on Reordering algo.
  740. $sctp0 set useCmtCwnd_ 1         # turn on CUC algo.
  741. $sctp0 set useCmtDelAck_ 1       # turn on DAC algo.
  742. $sctp0 set eCmtRtxPolicy_ 4      # rtx. policy : RTX_CWND
  743. set trace_ch [open trace.sctp w]
  744. $sctp0 set trace_all_ 1          # trace them all on one line
  745. $sctp0 trace cwnd_
  746. $sctp0 trace rto_
  747. $sctp0 trace errorCount_
  748. $sctp0 attach $trace_ch
  749. set sctp1 [new Agent/SCTP/CMT]
  750. $ns multihome-attach-agent $host1_core $sctp1
  751. $sctp1 set debugMask_ -1
  752. $sctp1 set debugFileIndex_ 1
  753. $sctp1 set mtu_ 1500
  754. $sctp1 set initialRwnd_ 65536 
  755. $sctp1 set useDelayedSacks_ 1
  756. $sctp1 set useCmtDelAck_ 1
  757. $ns color 0 Red
  758. $ns color 1 Blue
  759. $ns connect $sctp0 $sctp1
  760. set ftp0 [new Application/FTP]
  761. $ftp0 attach-agent $sctp0
  762. # set primary before association starts
  763. $sctp0 set-primary-destination $host1_if0
  764. $ns at 0.5 "$ftp0 start"
  765. $ns at 10.0 "finish"
  766. $ns run
  767. -------------------------------------------------------------------------------
  768. # EXAMPLE SCRIPT 6
  769. #
  770. # Demonstrates Concurrent Multipath Transfer with Potentially Failed
  771. # (CMT-PF).  Two endpoints with 2 interfaces with direct connections
  772. # between each pair.  A link failure is introduced at 10.0 sec to one
  773. # of the paths. Data transfer continues with the other path.
  774. #
  775. #       host0_if0      O===========O    host1_if0
  776. #                     /             
  777. #       host0_core   O               O  host1_core
  778. #                                  /
  779. #       host0_if1      O===========O    host1_if1
  780. Trace set show_sctphdr_ 1
  781. set ns [new Simulator]
  782. set nf [open sctp.nam w]
  783. $ns namtrace-all $nf
  784. set allchan [open all.tr w]
  785. $ns trace-all $allchan
  786. proc finish {} {
  787.     global ns nf allchan
  788.     set PERL "/usr/bin/perl"
  789.     set NSHOME "/home/userA/ns-allinone-2.31"
  790.     set XGRAPH "$NSHOME/bin/xgraph"
  791.     set SETFID "$NSHOME/ns-2.31/bin/set_flow_id"
  792.     set RAW2XG_SCTP "$NSHOME/ns-2.31/bin/raw2xg-sctp"
  793.     set GETRC "$NSHOME/ns-2.31/bin/getrc"
  794.     $ns flush-trace
  795.     close $nf
  796.     close $allchan
  797.     # Graph the host0_if0 <-> host1_if0
  798.     exec $PERL $GETRC -s 1 -d 4 all.tr > all.tr.if0 
  799.     exec $PERL $GETRC -s 4 -d 1 all.tr >> all.tr.if0 
  800.     exec $PERL $SETFID -s all.tr.if0 | 
  801.       $PERL $RAW2XG_SCTP -A -q -t if0 > temp.rands.if0
  802.     exec $XGRAPH -bb -tk -nl -m -x time -y packets temp.rands.if0 &
  803.     
  804.     # Graph the host0_if1 <-> host1_if1
  805.     exec $PERL $GETRC -s 2 -d 5 all.tr > all.tr.if1 
  806.     exec $PERL $GETRC -s 5 -d 2 all.tr >> all.tr.if1
  807.     exec $PERL $SETFID -s all.tr.if1 | 
  808.     $PERL $RAW2XG_SCTP -A -q -t if1 > temp.rands.if1
  809.     exec $XGRAPH -bb -tk -nl -m -x time -y packets temp.rands.if1 &
  810.     
  811.     # Graph the entire association on one graph
  812.     exec $PERL $SETFID -s all.tr | 
  813.     $PERL $RAW2XG_SCTP -A -q -t all > temp.rands
  814.     exec $XGRAPH -bb -tk -nl -m -x time -y packets temp.rands &
  815.     
  816.     exec nam sctp.nam &
  817.     exit 0
  818. }
  819. set host0_core [$ns node]
  820. set host0_if0 [$ns node]
  821. set host0_if1 [$ns node]
  822. $host0_core color Red
  823. $host0_if0 color Red
  824. $host0_if1 color Red
  825. $ns multihome-add-interface $host0_core $host0_if0
  826. $ns multihome-add-interface $host0_core $host0_if1
  827. set host1_core [$ns node]
  828. set host1_if0 [$ns node]
  829. set host1_if1 [$ns node]
  830. $host1_core color Blue
  831. $host1_if0 color Blue
  832. $host1_if1 color Blue
  833. $ns multihome-add-interface $host1_core $host1_if0
  834. $ns multihome-add-interface $host1_core $host1_if1
  835. $ns duplex-link $host0_if0 $host1_if0 10Mb 45ms DropTail
  836. [[$ns link $host0_if0 $host1_if0] queue] set limit_ 50
  837. $ns duplex-link $host0_if1 $host1_if1 10Mb 45ms DropTail
  838. [[$ns link $host0_if1 $host1_if1] queue] set limit_ 50
  839. set sctp0 [new Agent/SCTP/CMT]
  840. $ns multihome-attach-agent $host0_core $sctp0
  841. $sctp0 set fid_ 0 
  842. $sctp0 set debugMask_ -1
  843. $sctp0 set debugFileIndex_ 0
  844. $sctp0 set mtu_ 1500
  845. $sctp0 set dataChunkSize_ 1468
  846. $sctp0 set numOutStreams_ 1
  847. $sctp0 set useCmtReordering_ 1    # turn on Reordering algo.
  848. $sctp0 set useCmtCwnd_ 1          # turn on CUC algo.
  849. $sctp0 set useCmtDelAck_ 1        # turn on DAC algo.
  850. $sctp0 set eCmtRtxPolicy_ 4       # rtx. policy : RTX_CWND
  851. $sctp0 set useCmtPF_ 1           # turn on CMT-PF
  852. $sctp0 set cmtPFCwnd_ 2           # cwnd=2*MTU after HB-ACK
  853. set trace_ch [open trace.sctp w]
  854. $sctp0 set trace_all_ 1           # trace them all on one line
  855. $sctp0 trace cwnd_
  856. $sctp0 trace rto_
  857. $sctp0 trace errorCount_
  858. $sctp0 attach $trace_ch
  859. set sctp1 [new Agent/SCTP/CMT]
  860. $ns multihome-attach-agent $host1_core $sctp1
  861. $sctp1 set debugMask_ -1
  862. $sctp1 set debugFileIndex_ 1
  863. $sctp1 set mtu_ 1500
  864. $sctp1 set initialRwnd_ 65536 
  865. $sctp1 set useDelayedSacks_ 1
  866. $sctp1 set useCmtDelAck_ 1
  867. $ns color 0 Red
  868. $ns color 1 Blue
  869. $ns connect $sctp0 $sctp1
  870. set ftp0 [new Application/FTP]
  871. $ftp0 attach-agent $sctp0
  872. # set primary before association starts
  873. $sctp0 set-primary-destination $host1_if0
  874. $ns rtmodel-at 10.0 down $host0_if1 $host1_if1
  875. $ns at 0.5 "$ftp0 start"
  876. $ns at 75.0 "finish"
  877. $ns run
  878. References :
  879. [1] J. Iyengar, P. Amer, R. Stewart, "Concurrent Multipath Transfer
  880. Using SCTP Multihoming Over Independent End-to-End Paths", IEEE/ACM
  881. Transactions on Networking, 14(5), 10/06.
  882. [2] Preethi Natarajan, Nasif Ekiz, Paul D. Amer and Randall Stewart,
  883. "Concurrent Multipath Transfer Using SCTP Multihoming: Transmission
  884. Policies using Potentially-failed Destination State", Technical
  885. Report: #2007-338, CIS Department, University of Delaware, February
  886. 2007.