aDTN.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:aDTN-python 作者: megfault 项目源码 文件源码
def __init__(self, batch_size, sending_interval, wireless_interface, data_store):
        """
        Initialize an aDTN instance and its respective key manager and message store, as well as a sending message pool
        from which the next sending batch gets generated.

        Define aDTNInnerPacket to be the payload of aDTNPacket. Define aDTNPacket to be the payload of Ethernet frames
        of type 0xcafe.

        Set up a scheduler to handle message sending.
        Define a thread to handle received messages.

        The wireless interface should be previously set to ad-hoc mode and its ESSID should be the same in other devices
        running aDTN.
        :param batch_size: number of packets to transmit at each sending operation
        :param sending_interval: number of seconds between two sending operations
        :param wireless_interface: wireless interface to send and receive packets
        """
        self._batch_size = batch_size
        self._sending_freq = sending_interval
        self._wireless_interface = wireless_interface
        self._km = KeyManager()
        self.data_store = DataStore(data_store)
        self._sending_pool = []
        self._scheduler = sched.scheduler(time, sleep)
        self._sending = None
        self._sniffing = None
        self._thread_send = None
        self._thread_receive = None
        self._sent_pkt_counter = None
        self._received_pkt_counter = None
        self._decrypted_pkt_counter = None
        self._start_time = None
        self._mac_address = macget(getcard(wireless_interface))
        self._sending_socket = L2Socket(iface=self._wireless_interface)
        bind_layers(aDTNPacket, aDTNInnerPacket)
        bind_layers(Ether, aDTNPacket, type=ETHERTYPE)
        log_debug("MAC address in use: {}".format(self._mac_address))
        self._stats_file_name = '{}_{}.stats'.format(batch_size, sending_interval)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号