在inet下写一个“HelloWorld”程序

本文介绍如何在Omnet++中搭建一个简单的TCP测试环境。通过新建项目、配置网络模型及参数设置,实现了不同场景下的TCP数据传输测试。文中详细记录了网络组件定义、配置文件设置等步骤。

写在最前

由于要用别人的项目代码来进行仿真,却不知道如何新建一个项目来跑自己的网络,故写下这篇文章。在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

搞定

水了篇博客,跟自己做人一样

课程设计报告:总体方案设计说明 一、软件开发环境配置 本系统采用C++作为核心编程语言,结合Qt 5.12.7框架进行图形用户界面开发。数据库管理系统选用MySQL,用于存储用户数据与小精灵信息。集成开发环境为Qt Creator,操作系统平台为Windows 10。 二、窗口界面架构设计 系统界面由多个功能模块构成,各模块职责明确,具体如下: 1. 起始界面模块(Widget) 作为应用程序的入口界面,提供初始导航功能。 2. 身份验证模块(Login) 负责处理用户登录与账户注册流程,实现身份认证机制。 3. 游戏主大厅模块(Lobby) 作为用户登录后的核心交互区域,集成各项功能入口。 4. 资源管理模块(BagWidget) 展示用户持有的全部小精灵资产,提供可视化资源管理界面。 5. 精灵详情模块(SpiritInfo) 呈现选定小精灵的完整属性数据与状态信息。 6. 用户名录模块(UserList) 系统内所有注册用户的基本信息列表展示界面。 7. 个人资料模块(UserInfo) 显示当前用户的详细账户资料与历史数据统计。 8. 服务器精灵选择模块(Choose) 对战准备阶段,从服务器可用精灵池中选取参战单位的专用界面。 9. 玩家精灵选择模块(Choose2) 对战准备阶段,从玩家自有精灵库中筛选参战单位的操作界面。 10. 对战演算模块(FightWidget) 实时模拟精灵对战过程,动态呈现战斗动画与状态变化。 11. 对战结算模块(ResultWidget) 对战结束后,系统生成并展示战斗结果报告与数据统计。 各模块通过统一的事件驱动机制实现数据通信与状态同步,确保系统功能的连贯性与数据一致性。界面布局遵循模块化设计原则,采用响应式视觉方案适配不同显示环境。 资源来源于网络分享,仅用于学习交流使用,请勿用于商业,如有侵权请联系我删除!
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值