#  tcpXnet.dml
#  2 X 2  network with TCP clients and servers, interfaces in NHI addressing
#
#   client 11(0)------1(1)                           2(1)------12(0) client
#                        \                          /
#                        [R1] 1(0)------------2(0)[R2]
#                        /                          \
#   server 21(0)------1(2)                           2(2)------22(0) server


Net [

  frequency 1000000000    # 1 nanosecond time resolution

  # "left side" client can request data from any server
  # "right side" client can request data only from "left side" server
  
  traffic [
    pattern [
      client 11
      servers [nhi 21(0) port 1600]
      servers [nhi 22(0) port 1600]
    ]
    pattern [
      client 12
      servers [nhi 21(0) port 1600]
    ]
  ]
  
  randomstream [
    generator "MersenneTwister"
    stream "seedstartingstring1234567890"
    reproducibility_level "host"
  ]
    
  # ROUTERS AND POINT-TO-POINT LINKS -----------------------------------
  
  router [ 
    idrange [from 1 to 2]
    graph [ProtocolSession [name ip use SSF.OS.IP]]
    interface [ id 0 buffer 8000 _extends .dictionary.100BaseT]
    interface [ idrange [from 1 to 2] buffersize 16000]
    route [dest default interface 0]
  ]

  link [attach 1(0) attach 2(0) delay 0.005]

  link [attach 1(1) attach 11(0) delay 0.001]
  link [attach 1(2) attach 21(0) delay 0.001]

  link [attach 2(1) attach 12(0) delay 0.001]
  link [attach 2(2) attach 22(0) delay 0.001]

 # CLIENTS AND SERVERS -------------------------------------------------

  host [ id 11
    _extends .dictionary.standardClient
  ]
  host [ id 12
    _extends .dictionary.standardClient
  ]
  host [ id 21
    _extends .dictionary.standardServer
  ]
  host [ id 22
    _extends .dictionary.standardServer
  ]
 
] # end of Net

# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
dictionary [

  # standard network interfaces
  10BaseT [
    bitrate 10000000
    latency 0.0001
  ]
  100BaseT [
    bitrate 100000000
    latency 0.0001
  ]
  
  standardClient [
    interface [id 0 _extends .dictionary.10BaseT]
    route [dest default interface 0]
    graph [
      ProtocolSession [
        name client use SSF.OS.TCP.test.tcpClient
        start_time 1.0            # earliest time to send request to server
        start_window 1.0          # send request to server at randomly chosen time
                                  # in interval [start_time, start_time+start_window]
        file_size 10000000        # requested file size (payload bytes)
        _find .dictionary.appsession.request_size
        _find .dictionary.appsession.show_report
        _find .dictionary.appsession.debug
      ]
      ProtocolSession [name socket use SSF.OS.Socket.socketMaster]
      ProtocolSession [name tcp use SSF.OS.TCP.tcpSessionMaster
                       _find .dictionary.tcpinit]
      ProtocolSession [name ip use SSF.OS.IP]
    ]
  ]
  standardServer [
    interface [id 0 _extends .dictionary.10BaseT]
    route [dest default interface 0]
    graph [
    ProtocolSession [
      name server use SSF.OS.TCP.test.tcpServer
      port 1600          # server's well known port
      client_limit  10   # max number of contemporaneously allowed clients
                         # if omitted, default is no limit
      _find .dictionary.appsession.request_size
      _find .dictionary.appsession.show_report
      _find .dictionary.appsession.debug
      ]
      ProtocolSession [name socket use SSF.OS.Socket.socketMaster]
      ProtocolSession [name tcp use SSF.OS.TCP.tcpSessionMaster
                       _find .dictionary.tcpinit]
      ProtocolSession [name ip use SSF.OS.IP]
    ]
  ]
 
  tcpinit[
    ISS 10000               # initial sequence number
    MSS 1000                # maximum segment size
    RcvWndSize  32          # receive buffer size
    SendWndSize 32          # maximum send window size
    SendBufferSize 128      # send buffer size
    MaxRexmitTimes 12       # maximum retransmission times before drop 
    TCP_SLOW_INTERVAL 0.5   # granularity of TCP slow timer
    TCP_FAST_INTERVAL 0.2   # granularity of TCP fast(delay-ack) timer
    MSL 60.0                # maximum segment lifetime
    MaxIdleTime 600.0       # maximum idle time for drop a connection
    delayed_ack false       # delayed ack option
    fast_recovery true      # implement fast recovery algorithm 
    show_report true        # print a summary connection report
  ]

  # the trivial client-server protocol
    
  appsession [
    request_size  64        # client request datagram size (in bytes)
    show_report true        # print client-server session summary report
    debug false             # print verbose client/server diagnostics
  ]
    
] # end of dictionary