NED File src/inet/applications/tcpapp/TcpSinkApp.ned¶
Name |
Type |
Description |
|---|---|---|
compound module |
Accepts any number of incoming TCP connections, and discards whatever arrives on them. Compatible with both Ipv4 and Ipv6. |
|
simple module |
Handles a single incoming TCP connection for TcpSinkApp. |
Source code¶
//
// Copyright (C) 2004 OpenSim Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later
//
package inet.applications.tcpapp;
import inet.common.SimpleModule;
//
// Accepts any number of incoming TCP connections, and discards whatever
// arrives on them. Compatible with both ~Ipv4 and ~Ipv6.
//
// Each incoming connection is handled by a separate, dynamically created module,
// which allows collecting per-connection statistics in a convenient way.
//
// By default, reading from the socket is not rate limited. To allow rate
// limiting, set autoRead=false, and use the `readSize` and `readDelay` parameters
// to set a rate limit. This will allow TCP flow control to come into effect.
//
module TcpSinkApp extends TcpServerHostApp
{
parameters:
serverThreadModuleType = default("inet.applications.tcpapp.TcpSinkAppThread");
bool autoRead = default(true); // Whether to use "autoread" or "explicit-read" mode for TCP connection
volatile int readSize @unit(B) = default(-1B); // Used only with autoRead==false
volatile double readDelay @unit(s) = default(-1s); // Used only with autoRead==false; delay for issuing a READ command after previous READ was satisfied; -1 means immediately, 0 means zero delay
@class(TcpSinkApp);
displayStringTextFormat = default("threads: {numThreads}\nrcvd: {bytesRcvd} bytes");
@display("i=block/sink");
@statistic[packetReceived](title="packets received"; source=packetReceived; record=count,"sum(packetBytes)","vector(packetBytes)"; interpolationmode=none; checkSignals=false);
@statistic[endToEndDelay](title="end-to-end delay"; source="dataAge(packetReceived)"; unit=s; record=histogram,weightedHistogram,vector; interpolationmode=none; checkSignals=false);
}
//
// Handles a single incoming TCP connection for ~TcpSinkApp.
//
simple TcpSinkAppThread extends SimpleModule
{
parameters:
@class(TcpSinkAppThread);
displayStringTextFormat = default("{socketState}\nrcvd: {bytesRcvd} bytes");
@display("i=block/sink");
@signal[packetReceived](type=inet::Packet);
@statistic[packetReceived](title="packets received"; source=packetReceived; record=count,"sum(packetBytes)","vector(packetBytes)"; interpolationmode=none);
@statistic[endToEndDelay](title="end-to-end delay"; source="dataAge(packetReceived)"; unit=s; record=histogram,weightedHistogram,vector; interpolationmode=none);
}