Simple Module TelnetApp

Package: inet.applications.tcpapp
File: src/inet/applications/tcpapp/TelnetApp.ned

C++ definition

Models Telnet sessions with a specific user behaviour. The server app should be TCPGenericSrvApp. Compatible with both IPv4 and IPv6.

NOTE: This module emulates a very specific user behaviour, and as such, it should be viewed as an example rather than a generic Telnet model. If you want to model realistic Telnet traffic, you are encouraged to gather statistics from packet traces on a real network, and write your model accordingly.

Configuring App

The module parameter dataTransferMode should be set the transfer mode in TCP layer. Currently you have three choices:

  1. set them to "bytecount". This mode manages "virtual bytes", that is, only byte counts are transmitted over the TCP connection and no actual data. cMessage contents, and even message boundaries are not preserved with these classes: for example, if the client sends a single cMessage with length = 1 megabyte over TCP, the receiver-side client will see a sequence of MSS-sized messages.
  2. use "object", which transmits cMessage objects (and subclasses) over a TCP connection. The same message object sequence that was sent by the client to the sender-side TCP entity will be reproduced on the receiver side. If a client sends a cMessage with length = 1 megabyte, the receiver-side client will receive the same message object (or a clone) after the TCP entities have completed simulating the transmission of 1 megabyte over the connection. This is a different behaviour from TCPVirtualDataSendQueue/RcvQueue. This mode is not implemented in TCP_NSC yet.
  3. use "bytestream", which transmits real bytes of messages.
TelnetApp

Usage diagram:

The following diagram shows usage relationships between types. Unresolved types are missing from the diagram.

Inheritance diagram:

The following diagram shows inheritance relationships for this type. Unresolved types are missing from the diagram.

Parameters:

Name Type Default value Description
localAddress string ""

local address or empty ("")

localPort int

local port number

connectAddress string

server address (may be symbolic)

connectPort int 1000

port number to connect to

dataTransferMode string "bytecount"
startTime double 1s

time first session begins

stopTime double -1s

time of finishing sending, negative values mean forever

numCommands int exponential(10)

user types this many commands in a session

commandLength int 10B

commands are this many characters (plus Enter)

keyPressDelay double exponential(0.1s)

delay between keypresses

commandOutputLength int exponential(1000B)

commands produce this much output

thinkTime double exponential(10s)

user waits this much before starting to type new command

idleInterval double exponential(300s)

time gap between sessions

reconnectInterval double 30s

if connection breaks, user waits this much before trying to reconnect

Properties:

Name Value Description
display i=block/telnet

Gates:

Name Direction Size Description
tcpIn input
tcpOut output

Signals:

Name Type Unit
sentPk cPacket
rcvdPk cPacket
connect long

Statistics:

Name Title Source Record Unit Interpolation Mode
numSessions total number of sessions sum(connect+1)/2 last
sentPk packets sent sentPk count, sum(packetBytes), vector(packetBytes) none
rcvdPk packets received rcvdPk count, sum(packetBytes), vector(packetBytes) none
numActiveSessions number of active sessions sum(connect) max, timeavg, vector sample-hold
endToEndDelay end-to-end delay messageAge(rcvdPk) histogram, vector s none

Source code:

//
// Models Telnet sessions with a specific user behaviour.
// The server app should be ~TCPGenericSrvApp.
// Compatible with both ~IPv4 and ~IPv6.
//
// NOTE: This module emulates a very specific user behaviour, and as such,
// it should be viewed as an example rather than a generic Telnet model.
// If you want to model realistic Telnet traffic, you are encouraged
// to gather statistics from packet traces on a real network, and
// write your model accordingly.
//
// <b>Configuring App</b>
//
// The module parameter dataTransferMode should be set the transfer mode in TCP layer.
// Currently you have three choices:
//
//   -# set them to "bytecount".
//      This mode manages "virtual bytes", that is, only byte counts are
//      transmitted over the TCP connection and no actual data. cMessage
//      contents, and even message boundaries are not preserved with these
//      classes: for example, if the client sends a single cMessage with
//      length = 1 megabyte over TCP, the receiver-side client will see a
//      sequence of MSS-sized messages.
//
//   -# use "object", which transmits
//      cMessage objects (and subclasses) over a TCP connection. The same
//      message object sequence that was sent by the client to the
//      sender-side TCP entity will be reproduced on the receiver side.
//      If a client sends a cMessage with length = 1 megabyte, the
//      receiver-side client will receive the same message object (or a clone)
//      after the TCP entities have completed simulating the transmission
//      of 1 megabyte over the connection. This is a different behaviour
//      from TCPVirtualDataSendQueue/RcvQueue.
//      This mode is not implemented in ~TCP_NSC yet.
//
//   -# use "bytestream", which transmits real bytes of messages.
//
simple TelnetApp like ITCPApp
{
    parameters:
        string localAddress = default(""); // local address or empty ("")
        int localPort; // local port number
        string connectAddress;  // server address (may be symbolic)
        int connectPort = default(1000); // port number to connect to
        string dataTransferMode = default("bytecount");
        double startTime @unit(s) = default(1s); // time first session begins
        double stopTime @unit(s) = default(-1s);  // time of finishing sending, negative values mean forever
        volatile int numCommands = default(exponential(10)); // user types this many commands in a session
        volatile int commandLength @unit(B) = default(10B); // commands are this many characters (plus Enter)
        volatile double keyPressDelay @unit(s) = default(exponential(0.1s)); // delay between keypresses
        volatile int commandOutputLength @unit(B) = default(exponential(1000B)); // commands produce this much output
        volatile double thinkTime @unit(s) = default(exponential(10s)); // user waits this much before starting to type new command
        volatile double idleInterval @unit(s) = default(exponential(300s)); // time gap between sessions
        volatile double reconnectInterval @unit(s) = default(30s);  // if connection breaks, user waits this much before trying to reconnect
        @display("i=block/telnet");
        @signal[sentPk](type=cPacket);
        @signal[rcvdPk](type=cPacket);
        @signal[connect](type=long);  // 1 for open, -1 for close
        @statistic[rcvdPk](title="packets received"; source=rcvdPk; record=count,"sum(packetBytes)","vector(packetBytes)"; interpolationmode=none);
        @statistic[sentPk](title="packets sent"; source=sentPk; record=count,"sum(packetBytes)","vector(packetBytes)"; interpolationmode=none);
        @statistic[endToEndDelay](title="end-to-end delay"; source="messageAge(rcvdPk)"; unit=s; record=histogram,vector; interpolationmode=none);
        @statistic[numActiveSessions](title="number of active sessions"; source="sum(connect)"; record=max,timeavg,vector; interpolationmode=sample-hold; );
        @statistic[numSessions](title="total number of sessions"; source="sum(connect+1)/2"; record=last);

    gates:
        input tcpIn @labels(TCPCommand/up);
        output tcpOut @labels(TCPCommand/down);
}