예제 #1
0
 def reset(self,
           trace_path: str = "",
           report_interval_ms: int = 60,
           duration_time_ms: int = 3000):
     if self.gym_conn:
         del self.gym_conn
     if self.gym_process:
         del self.gym_process
     self.gym_process = gym_process.GymProcess(self.gym_id, trace_path,
                                               report_interval_ms,
                                               duration_time_ms)
     self.gym_conn = gym_connect.GymConnector(self.gym_id)
예제 #2
0
def test_base():
    proc = gym_process.GymProcess(gym_id="test_gym",
                                  report_interval_ms=60,
                                  duration_time_ms=1000)
    conn = gym_connect.GymConnector(gym_id="test_gym")
    all_stats = []
    while True:
        stats = conn.step(1e9)
        if stats == None:
            break
        all_stats += stats
    # stats shouldn't be empty
    assert (all_stats)
    assert (proc.wait() == 0)
예제 #3
0
def test_trace():
    trace_path = os.path.join(os.path.dirname(__file__), "data",
                              "trace_example.json")
    proc = gym_process.GymProcess(gym_id="test_gym",
                                  trace_path=trace_path,
                                  report_interval_ms=60,
                                  duration_time_ms=0)
    conn = gym_connect.GymConnector(gym_id="test_gym")
    all_stats = []
    while True:
        stats = conn.step(1e9)
        if stats == None:
            break
        all_stats += stats
    # stats shouldn't be empty
    assert (all_stats)
    assert (proc.wait() == 0)
예제 #4
0
    def reset(self,
              trace_path: str = "",
              report_interval_ms: int = 60,
              duration_time_ms: int = 3000):
        """ Reset gym environment, this function will destroy the old context
            and create a new one for next step.

            Parameters
            trace_path: a path to indicate a trace file with json format.
                The following is an exmaple of trace file
                {
                    "type": "video",
                    "downlink": {},
                    "uplink": {
                        "trace_pattern": [
                            {
                                "duration": 60000, # duration time
                                "capacity": 300,   # link bandwidth(kbps)
                                "loss": 0,         # not used in current version
                                "jitter": 0,       # not used in current version
                                "time": 0.0        # not used in current version
                            },
                            ...
                        ]
                    }
                }
            report_interfal_ms: to indicate the report interval. It indicates
                the a step's duration, the unit is Millisecond.
            duration_time_ms: to indicate the duration for an epoch.
                If this value is None or 0, the duration will be caculated
                according to the trace file.
        """
        if self.gym_conn:
            del self.gym_conn
        if self.gym_process:
            del self.gym_process
        self.gym_process = gym_process.GymProcess(self.gym_id, trace_path,
                                                  report_interval_ms,
                                                  duration_time_ms)
        self.gym_conn = gym_connect.GymConnector(self.gym_id)