您的位置:首页 > 其它

在inet下写一个“HelloWorld”程序

2018-04-10 06:38 274 查看

写在最前

由于要用别人的项目代码来进行仿真,却不知道如何新建一个项目来跑自己的网络,故写下这篇文章。在inet的基础上,运行一个example上的例子。

新建omnet++项目





新建test项目,empty project,之后直接按finish即可。

引用inet项目

对project 右键,properties。



新建ned

package tcptest;
import inet.networklayer.configurator.ipv4.IPv4NetworkConfigurator;
import inet.node.inet.Router;
import inet.node.inet.StandardHost;
import ned.DatarateChannel;

network net1
{
parameters:
@display("bgb=400,200");
submodules:
router: Router {
parameters:
@display("p=200,100;i=abstract/router");
gates:
pppg[2];
}
client: StandardHost {
parameters:
@display("p=50,100");
gates:
pppg[1];
}
server: StandardHost {
parameters:
@display("p=350,100;i=device/server");
gates:
pppg[1];
}
configurator: IPv4NetworkConfigurator;
connections:
router.pppg[0] <--> NormalPath <--> client.pppg[0];
router.pppg[1] <--> NormalPath <--> server.pppg[0];
}

channel NormalPath extends DatarateChannel
{
parameters:
datarate = 100Mbps;
delay = 0.0565us; // 10m
per = 0;
ber = 0;
}


新建.ini配置文件

[General]
network = net1

warnings = true
sim-time-limit = 2.1s

cmdenv-module-messages = true # for normal (non-express) mode only
cmdenv-event-banners = true   # for normal (non-express) mode only

tkenv-plugin-path = ../../../etc/plugins

#
# Network specific settings
#

# set inet_addr, Mask, MTU ( = 1500), default route (=router)
#**.client.routingTable.routingFile = "client.mrt"
#**.router.routingTable.routingFile = "router.mrt"
#**.server.routingTable.routingFile = "server.mrt"

# ip settings
**.ip.procDelay = 0s
**.forwarding = false

# hookType settings
**.ppp[*].numOutputHooks = 1
**.ppp[*].outputHook[0].typename = "OrdinalBasedDropper" # Nop | ThruputMeter | OrdinalBasedDropper | OrdinalBasedDuplicator

# ARP settings
**.arp.retryTimeout = 1s
**.arp.retryCount = 3
**.arp.cacheTimeout = 100s

# NIC settings
**.ppp[*].queueType = "DropTailQueue"
**.ppp[*].queue.frameCapacity = 100    # packets

# tcp apps - client
**.client.numTcpApps = 1
**.client.tcpApp[*].typename = "TCPSessionApp"  # FTP
**.client.tcpApp[*].sendBytes = 100MiB
**.client.tcpApp[*].active = true
#**.client.tcpApp[*].localAddress = "172.0.0.1"
**.client.tcpApp[*].localPort = 10020
**.client.tcpApp[*].connectAddress = "server"
**.client.tcpApp[*].connectPort = 10021
**.client.tcpApp[*].tOpen = 0s
**.client.tcpApp[*].tSend = 0s
**.client.tcpApp[*].tClose = 0s
**.client.tcpApp[*].sendScript = ""

# tcp apps - server
**.server.numTcpApps = 1
**.server.tcpApp[*].typename = "TCPSinkApp"
#**.server.tcpApp[*].localAddress = "172.0.1.111"
**.server.tcpApp[*].localPort = 10021

# tcp settings
**.tcp.advertisedWindow = 65535                      # in bytes, corresponds with the maximal receiver buffer capacity (Note: normally, NIC queues should be at least this size)
**.tcp.delayedAcksEnabled = false                    # delayed ACK algorithm (RFC 1122) enabled/disabled
**.tcp.nagleEnabled = true                           # Nagle's algorithm (RFC 896) enabled/disabled
**.tcp.limitedTransmitEnabled = false                # Limited Transmit algorithm (RFC 3042) enabled/disabled (can be used for TCPReno/TCPTahoe/TCPNewReno/TCPNoCongestionControl)
**.tcp.increasedIWEnabled = false                    # Increased Initial Window (RFC 3390) enabled/disabled
**.tcp.sackSupport = true                            # Selective Acknowledgment (RFC 2018, 2883, 3517) support (header option) (SACK will be enabled for a connection if both endpoints support it)
**.tcp.windowScalingSupport = false                  # Window Scale (RFC 1323) support (header option) (WS will be enabled for a connection if both endpoints support it)
**.tcp.timestampSupport = false                      # Timestamps (RFC 1323) support (header option) (TS will be enabled for a connection if both endpoints support it)
**.tcp.mss = 500                                     # Maximum Segment Size (RFC 793) (header option)
**.tcp.tcpAlgorithmClass = "TCPReno"                 # TCPReno/TCPTahoe/TCPNewReno/TCPNoCongestionControl/DumbTCP
**.tcp.recordStats = true                            # recording of seqNum etc. into output vectors enabled/disabled

# pcapRecorder settings
**.numPcapRecorders = 1

#
# Config specific settings
#

# Examples from [RFC2018]:
#   "Assume the left window edge is 5000 and that the data transmitter
#   sends a burst of 8 segments, each containing 500 data bytes." [RFC2018]

[Config One]
description = "RFC_2018_Case_1"
**.client.pcapRecorder[0].pcapFile = "RFC_2018_Case_1_Client_Log.pcap"
**.server.pcapRecorder[0].pcapFile = "RFC_2018_Case_1_Server_Log.pcap"
**.client.ppp[*].outputHook[0].dropsVector = "17;18;19;20;"
#      "Case 1: The first 4 segments are received but the last 4 are
#      dropped.
#
#      The data receiver will return a normal TCP ACK segment
#      acknowledging sequence number 7000, with no SACK option." [RFC2018]

[Config Two]
description = "RFC_2018_Case_2"
**.client.pcapRecorder[0].pcapFile = "RFC_2018_Case_2_Client_Log.pcap"
**.server.pcapRecorder[0].pcapFile = "RFC_2018_Case_2_Server_Log.pcap"
**.client.ppp[*].outputHook[0].dropsVector = "13;"
#      "Case 2:  The first segment is dropped but the remaining 7 are
#      received.
#
#         Upon receiving each of the last seven packets, the data
#         receiver will return a TCP ACK segment that acknowledges
#         sequence number 5000 and contains a SACK option specifying
#         one block of queued data:
#
#             Triggering    ACK      Left Edge   Right Edge
#             Segment
#
#             5000         (lost)
#             5500         5000     5500       6000
#             6000         5000     5500       6500
#             6500         5000     5500       7000
#             7000         5000     5500       7500
#             7500         5000     5500       8000
#             8000         5000     5500       8500
#             8500         5000     5500       9000" [RFC2018]

[Config Three]
description = "RFC_2018_Case_3"
**.client.pcapRecorder[0].pcapFile = "RFC_2018_Case_3_Client_Log.pcap"
**.server.pcapRecorder[0].pcapFile = "RFC_2018_Case_3_Server_Log.pcap"
**.client.ppp[*].outputHook[0].dropsVector = "14;16;18;20;"
#      "Case 3:  The 2nd, 4th, 6th, and 8th (last) segments are
#      dropped.
#
#      The data receiver ACKs the first packet normally.  The
#      third, fifth, and seventh packets trigger SACK options as
#      follows:
#
#          Triggering  ACK    First Block   2nd Block     3rd Block
#          Segment            Left   Right  Left   Right  Left   Right
#                             Edge   Edge   Edge   Edge   Edge   Edge
#
#          5000       5500
#          5500       (lost)
#          6000       5500    6000   6500
#          6500       (lost)
#          7000       5500    7000   7500   6000   6500
#          7500       (lost)
#          8000       5500    8000   8500   7000   7500   6000   6500
#          8500       (lost)" [RFC2018]

# Examples from [RFC2883]:
#
#     "Reporting Full Duplicate Segments
#
#   We illustrate these guidelines with three examples.  In each example,
#   we assume that the data receiver has first received eight segments of
#   500 bytes each, and has sent an acknowledgement with the cumulative
#   acknowledgement field set to 4000 (assuming the first sequence number
#   is zero).  The D-SACK block is underlined in each example." [RFC2883]

[Config Four]
description = "RFC_2883_Example_1"
**.client.pcapRecorder[0].pcapFile = "RFC_2883_Example_1_Client_Log.pcap"
**.server.pcapRecorder[0].pcapFile = "RFC_2883_Example_1_Server_Log.pcap"
**.tcp.advertisedWindow = 1000
**.server.ppp[*].outputHook[0].dropsVector = "8;9;"
#    "Example 1: Reporting a duplicate segment.
#
#   Because several ACK packets are lost, the data sender retransmits
#   packet 3000-3499, and the data receiver subsequently receives a
#   duplicate segment with sequence numbers 3000-3499.  The receiver
#   sends an acknowledgement with the cumulative acknowledgement field
#   set to 4000, and the first, D-SACK block specifying sequence numbers
#   3000-3500.
#
#        Transmitted    Received    ACK Sent
#        Segment        Segment     (Including SACK Blocks)
#
#        3000-3499      3000-3499   3500 (ACK dropped)
#        3500-3999      3500-3999   4000 (ACK dropped)
#        3000-3499      3000-3499   4000, SACK=3000-3500
#                                              ---------" [RFC2883]

[Config Five]
description = "RFC_2883_Example_2"
**.client.pcapRecorder[0].pcapFile = "RFC_2883_Example_2_Client_Log.pcap"
**.server.pcapRecorder[0].pcapFile = "RFC_2883_Example_2_Server_Log.pcap"
**.tcp.advertisedWindow = 2000
**.client.ppp[*].outputHook[0].dropsVector = "11;"
**.server.ppp[*].outputHook[0].dropsVector = "8;9;10;"
#    "Example 2:  Reporting an out-of-order segment and a duplicate
#        segment.
#
#   Following a lost data packet, the receiver receives an out-of-order
#   data segment, which triggers the SACK option as specified in  RFC
#   2018.  Because of several lost ACK packets, the sender then
#   retransmits a data packet.  The receiver receives the duplicate
#   packet, and reports it in the first, D-SACK block:
#
#        Transmitted    Received    ACK Sent
#        Segment        Segment     (Including SACK Blocks)
#
#        3000-3499      3000-3499   3500 (ACK dropped)
#        3500-3999      3500-3999   4000 (ACK dropped)
#        4000-4499      (data packet dropped)
#        4500-4999      4500-4999   4000, SACK=4500-5000 (ACK dropped)
#        3000-3499      3000-3499   4000, SACK=3000-3500, 4500-5000
#                                                 ---------" [RFC2883]

[Config Six]
description = "RFC_2883_Example_3"
**.client.pcapRecorder[0].pcapFile = "RFC_2883_Example_3_Client_Log.pcap"
**.server.pcapRecorder[0].pcapFile = "RFC_2883_Example_3_Server_Log.pcap"
**.client.ppp[*].numOutputHooks = 2
**.client.ppp[*].outputHook[0].typename = "OrdinalBasedDropper" # Nop | ThruputMeter | OrdinalBasedDropper | OrdinalBasedDuplicator | ...
**.client.ppp[*].outputHook[0].dropsVector = "11;"
**.client.ppp[*].outputHook[1].typename = "OrdinalBasedDuplicator" # Nop | ThruputMeter | OrdinalBasedDropper | OrdinalBasedDuplicator | ...
**.client.ppp[*].outputHook[1].duplicatesVector = "12;"
#    "Example 3:  Reporting a duplicate of an out-of-order segment.
#
#   Because of a lost data packet, the receiver receives two out-of-order
#   segments.  The receiver next receives a duplicate segment for one of
#   these out-of-order segments:
#
#        Transmitted    Received    ACK Sent
#        Segment        Segment     (Including SACK Blocks)
#
#        3500-3999      3500-3999   4000
#        4000-4499      (data packet dropped)
#        4500-4999      4500-4999   4000, SACK=4500-5000
#        5000-5499      5000-5499   4000, SACK=4500-5500
#                       (duplicated packet)
#                       5000-5499   4000, SACK=5000-5500, 4500-5500
#                                              ---------" [RFC2883]

# References
#
#   [RFC2018]  Mathis, M., Mahdavi, J., Floyd, S. and Romanow, A., "TCP
#              Selective Acknowledgment Options", RFC 2018, October 1996.
#
#   [RFC2883]  Floyd, S., Mahdavi, J., Mathis, M. and Podolsky, M., "An
#              Extension to the Selective Acknowledgement (SACK) Option
#              for TCP", RFC 2883, July 2000.


build project

搞定

水了篇博客,跟自己做人一样
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: