当前位置: 首页>>代码示例>>Python>>正文


Python Transmitter.transmit方法代码示例

本文整理汇总了Python中transmitter.Transmitter.transmit方法的典型用法代码示例。如果您正苦于以下问题:Python Transmitter.transmit方法的具体用法?Python Transmitter.transmit怎么用?Python Transmitter.transmit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在transmitter.Transmitter的用法示例。


在下文中一共展示了Transmitter.transmit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: start

# 需要导入模块: from transmitter import Transmitter [as 别名]
# 或者: from transmitter.Transmitter import transmit [as 别名]
def start():
    get_arguments()

    # Transmitter.transmit returns the new size of a block
    new_block_size = Transmitter.transmit(parameter_dict[K],
                                          parameter_dict[F])

    # for T trials, repeat the simulation
    for i in range(parameter_dict[T]):
        # clear this trial's variables
        trials_time = 0
        trials_received_frames = 0
        trials_failed_frames = 0

        # Set the first seed for the simulation
        Simulator.set_seed(parameter_dict[TSeeds][i])

        while (trials_time <= parameter_dict[R]):
            trials_received_blocks = 0  # new frame
            trials_failed_blocks = 0    # new frame

            # set the number of blocks to be transmitted in this frame
            transmissions = parameter_dict[K]

            if (parameter_dict[K] == 0):
                transmissions = 1

            # For K blocks (or 1 if K == 0), simulate the transmission
            for j in range(transmissions):  # range starts at 0
                # frame_failure = 0 if block was transmitted successfully
                block_failure = handle_block(new_block_size,
                                             parameter_dict[E],
                                             parameter_dict[K])

                # record block success or failure
                if (block_failure > 0):
                    trials_failed_blocks += 1
                else:
                    trials_received_blocks += 1

            # set trials_time to number of bits and response overhead
            trials_time += (parameter_dict[F] +
                            (parameter_dict[K] * Transmitter.r)
                            + parameter_dict[A])
            # update number of transmitted frames
            Statistics.update(Statistics.total_frames)
            # frame failed, resend the frame
            if(trials_failed_blocks >= 1):
                trials_failed_frames += 1
            # the last frame being sent (no longer needed) see forums
            #elif(trials_time > parameter_dict[R]):
            #    pass
            # successful transmition
            else:
                Statistics.update(Statistics.correctly_received_frames)
                trials_received_frames += 1

        #a print("Trial number:", i)
        #a print("Received Frames", trials_received_frames)
        #a print("Failed Frames", trials_failed_frames)

        # Assume: Take all K*(F+r) trials_time units into account
        # even if in last frame
        Statistics.append(Statistics.throughput_averages,
                          ((parameter_dict[F] * trials_received_frames)
                           / trials_time))

        if(trials_received_frames != 0):
            # Assume: Take all frames into account, even last frame
            Statistics.append(Statistics.frame_averages,
                              (trials_received_frames + trials_failed_frames) /
                              trials_received_frames)
        else:
            Statistics.append(Statistics.frame_averages, 0)

        # Add to total time
        Statistics.statistics_dict[Statistics.total_time] += trials_time

    # Call Print Statements
    #a print()
    #a print("----------------------------------------------")
    print_input(sys.argv)
    Statistics.set_final_values(parameter_dict[F], parameter_dict[R])
    Statistics.print_frame_ci()
    Statistics.print_throughput_ci()
开发者ID:Solanar,项目名称:CMPUT313_Asn1,代码行数:87,代码来源:main.py


注:本文中的transmitter.Transmitter.transmit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。