Exemple #1
0
PIDFILE_PATH = "/var/run/routing_daemon.pid"
# Path to a topology configuration
## @var ABSOLUTE_PATH
# This constant is a string with an absolute path to the program's main directory.
ABSOLUTE_PATH = routing_logging.ABSOLUTE_PATH
## @var TOPOLOGY_PATH
# This constant is a string with an absolute path to the file with pre-defined network topology.
# This file will be used for incoming frames filtering if the "SET_TOPOLOGY_FLAG" in the conf.py
# configuration file will be set to True.
TOPOLOGY_PATH = ABSOLUTE_PATH + "/topology.conf"

# Set root logger
## @var ROUTING_LOG
# Contains a reference to routing_logging.LogWrapper object of the main root logger for writing
# the log messages of the main module.
ROUTING_LOG = routing_logging.create_routing_log("routing.log", "root")


## A class used for creating and managing the application daemon.
# A generic daemon class for starting the main running function by overriding the run() method.
class Daemon:
    ## Constructor
    # @param self The object pointer.
    # @param pidfile An absolute path to the pid file of the process.
    # @param stdin Path for stdin forwarding
    # @param stdout Path for stdout forwarding
    # @param stderr Path for stderr forwarding
    def __init__(self,
                 pidfile,
                 stdin="/dev/null",
                 stdout=REDIRECT_TO,
Exemple #2
0
# Import necessary python modules from the standard library
import socket
import threading
import subprocess
import os
from fcntl import ioctl
import struct

# Import the necessary modules of the program
import routing_logging
import Messages
from conf import VIRT_IFACE_NAME, SET_TOPOLOGY_FLAG, GW_MODE

## @var TRANSPORT_LOG
# Global routing_logging.LogWrapper object for logging Transport activity.
TRANSPORT_LOG = routing_logging.create_routing_log("routing.transport.log",
                                                   "transport")

# Syscall ids for managing network interfaces via ioctl.
## @var TUNSETIFF
# Set tun interface ID.
TUNSETIFF = 0x400454ca
## @var IFF_TUN
# The tun interface flag.
IFF_TUN = 0x0001
## @var SIOCSIFADDR
# Set the address of the device.
SIOCSIFADDR = 0x8916
## @var SIOCSIFNETMASK
# Set the network mask for a device.
SIOCSIFNETMASK = 0x891C
## @var SIOCSIFMTU
In the future, it can be also implemented via file I/O access, and so on.

Currently, the following command IDs are supported:
2 - get_table - returns a dictionary with current routing table;
3 - get_neighbors - returns a list L3 addresses of current neighbors of the node.
"""

# Import necessary python modules from the standard library
import threading
import socket
import pickle
import os

import routing_logging

MANAGER_LOG = routing_logging.create_routing_log("routing.manager.log",
                                                 "manager")


## A manager thread which listens for the incoming requests from the established UDS socket.
class Manager(threading.Thread):
    def __init__(self, table):
        super(Manager, self).__init__()
        ## @var running
        # Thread running state bool() flag.
        self.running = False
        ## @var table
        # Reference to RouteTable.Table object.
        self.table = table
        ## @var server_address
        # UDS file location.
        self.server_address = "/tmp/uds_socket"
Exemple #4
0
# Import necessary python modules from the standard library
import threading
import hashlib
import time

# Import the necessary modules of the program
import Messages
import routing_logging

## @var lock
# Store the global threading.Lock object.
lock = threading.Lock()

## @var ARQ_HANDLER_LOG
# Global routing_logging.LogWrapper object for logging ArqHandler activity.
ARQ_HANDLER_LOG = routing_logging.create_routing_log("routing.arq_handler.log",
                                                     "arq_handler")

## @var max_int32
# 32-bit mask constant.
max_int32 = 0xFFFFFFFF


## Main class for sending data and processing the corresponding ACKs.
class ArqHandler:
    ## Constructor.
    # @param self The object pointer.
    # @param raw_transport Reference to Transport.RawTransport object.
    # @param table Reference to RouteTable.Table object.
    # @return None
    def __init__(self, raw_transport, table):
        # Create a dictionary which will contain a map between a (msg.id + dest_address) pair and the ArqRoutine object
import Messages
import Transport
import threading
import time
from socket import inet_aton
from socket import error as sock_error

# Import the necessary modules of the program
import routing_logging

## @var PATH_TO_LOGS
# This constant stores a string with an absolute path to log files directory.
PATH_TO_LOGS = routing_logging.PATH_TO_LOGS
## @var NEIGHBOR_LOG
# Global routing_logging.LogWrapper object for logging NeighborDiscovery activity.
NEIGHBOR_LOG = routing_logging.create_routing_log("routing.neighbor_discovery.log", "neighbor_discovery")


## Class describing a neighbor and its properties.
class Neighbor:
    ## Constructor.
    # @param self The object pointer.
    # @return None
    def __init__(self):
        ## @var l3_addresses
        # List of a neighbor's L3 (both IPv4 and IPv6) addresses in a string representation.
        self.l3_addresses = list()
        ## @var mac
        # MAC address of a neighbor, in a string "xx:xx:xx:xx:xx:xx" format.
        self.mac = str()
        ## @var last_activity
Exemple #6
0
import RewardHandler
import threading
from collections import deque

# Import the necessary modules of the program
import routing_logging
from conf import MONITORING_MODE_FLAG, ENABLE_ARQ, ARQ_LIST, GW_TYPE, DEFAULT_IPS

## @var lock
# Store the global threading.Lock object.
lock = threading.Lock()

# Set up logging
## @var DATA_LOG
# Global routing_logging.LogWrapper object for logging DataHandler activity.
DATA_LOG = routing_logging.create_routing_log("routing.data_handler.log",
                                              "data_handler")


## Wrapping class for starting all auxiliary handlers and threads.
class DataHandler:
    ## Constructor.
    # @param self The object pointer.
    # @param app_transport Reference to Transport.VirtualTransport object.
    # @param raw_transport Reference to Transport.RawTransport object.
    # @param table Reference to RouteTable.Table object.
    # @return None
    def __init__(self, app_transport, raw_transport, table):
        # Creating handlers instances
        ## @var app_handler
        # Create and store the object of DataHandler.AppHandler class.
        self.app_handler = AppHandler(app_transport, raw_transport, table)
Exemple #7
0
"""

# Import necessary python modules from the standard library
import copy

# Import the necessary modules of the program
import rl_logic
import routing_logging

## @var PATH_TO_LOGS
# This constant stores a string with an absolute path to log files directory.
PATH_TO_LOGS = routing_logging.PATH_TO_LOGS

## @var TABLE_LOG
# Global routing_logging.LogWrapper object for logging RouteTable activity.
TABLE_LOG = routing_logging.create_routing_log("routing.route_table.log", "route_table")


## Class Entry represents a dictionary containing current estimated values for forwarding a packet to the given mac.
class Entry(dict):
    ## Constructor.
    # @param self The object pointer.
    # @param dst_ip Destination IP address of the route.
    # @param neighbors_list List of MAC addresses of currently accessible direct neighbors.
    # @return None
    def __init__(self, dst_ip, neighbors_list):
        super(Entry, self).__init__()
        ## @var dst_ip
        # Destination IP address of the route.
        self.dst_ip = dst_ip
        ## @var local_neighbor_list
Exemple #8
0

This module is responsible for sending out initial RREQ messages into the network, and waiting until the corresponding
RREP messages are received.
"""

# Import necessary python modules from the standard library
import time

# Import the necessary modules of the program
import Messages
import routing_logging

## @var PATH_DISCOVERY_LOG
# Global routing_logging.LogWrapper object for logging PathDiscovery activity.
PATH_DISCOVERY_LOG = routing_logging.create_routing_log(
    "routing.path_discovery.log", "path_discovery")


## Main class for dealing with sending/receiving RREQ/RREP service messages.
class PathDiscoveryHandler:
    ## Constructor.
    # @param self The object pointer.
    # @param app_transport Reference to Transport.VirtualTransport object.
    # @param arq_handler Reference to ArqHandler.ArqHandler object.
    # @return None
    def __init__(self, app_transport, arq_handler):
        ## @var delayed_packets_list
        # Dictionary of delayed packets until the RREP isn't received. Format: {dst_ip: [packet1, ..., packetN]}.
        self.delayed_packets_list = {}
        ## @var entry_deletion_timeout
        # Entry deletion timeout, in seconds, in case of the RREP hasn't been received.