Commit ba937310 authored by Andreas Schmidt's avatar Andreas Schmidt
Browse files

Add xlap timestamping code and evaluation suite.

parent ba753077
build/
dist/
xlap.egg-info/
.ipynb_checkpoints/
\ No newline at end of file
# X-Lap: A Systems Approach for Cross-Layer Profiling and Latency Analysis for Cyber-Physical Networks
## How to install X-Lap?
Enter the project directory and type `python setup.py install` to install `xlap` on your system.
## How to use X-lap?
### Step 0: Define your relevant timestamps across a packet trace.
Define time- and cyclestamps:
* Where data enters the sender app.
* Where data leaves the sender app.
* Where data enters the receiver app.
* Where data leaves the receiver app.
* Define additional cyclestamps wherever appropriate.
* Define interesting durations inside xlap.yml.
### Step 1: Instrument your code and generate traces
* Define a Sender and Receiver Application (send arbitrary data around).
* Initialize the xlap facility.
* Add stamping code where-ever appropriate.
* There are different mechanisms for adding timestamps.
### Step 2: Use the provided xlap analysis tools
* Write your `xlap.yml` file as follows:
```yml
data_files:
sender: sender.csv
receiver: receiver.csv
cycle_reference:
sender: StampA
receiver: SampB
time_reference:
sender: StampC
receiver: StampE
stamps:
StampA:
Source: receiver
Type: time
StampB:
Source: receiver
Type: time
StampC:
Source: receiver
Type: time
StampD:
Source: receiver
Type: cycle
StampE:
Source: receiver
Type: time
durations:
DurationA:
Start: StampA
Stop: StampB
Source: sender
DurationB:
Start: StampC
Stop: StampD
Source: receiver
packet_types:
Data: 0
Ack: 1
```
* You can run a jitter analysis via `xlap jitter`. The parameter `-e` exports the diagrams as `pdf`.
* The best way to interact with `xlap` is through a [Jupyter Python 3 Notebook](http://jupyter.org/). An example can be found in `notebook.ipynb`.
* `xlap.analyse.trace.traces()` can be used to investigate individual packet traces.
## Conventions
* Suffixes (indicate type):
* `_T`: Timestamp (us precision)
* `_C`: Clockstamp
* `_D`: Duration (us precision)
* Reserved Names (including suffixes as mentioned before):
* `Channel`
* `Sender`
* `SenderCycle`
* `Receiver`
* `ReceiverCycle`
* `EndToEnd`
* Note that expressions with other suffixes such as `SenderQueueing_T` would be allowed.
%% Cell type:markdown id: tags:
# X-Lap in Action
%% Cell type:markdown id: tags:
## Imports
%% Cell type:code id: tags:
``` python
from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgets
from xlap.parse import evaluate, parse_config
import xlap.analyse.jitter as jitter
from xlap.analyse.regress import linear as linear_regression
from xlap.analyse.trace import traces
from xlap.analyse.correlation import correlation
```
%% Cell type:markdown id: tags:
## Data Retrieval
%% Cell type:code id: tags:
``` python
config = parse_config()
data_files = config["data_files"]
original = evaluate(data_files["sender"], data_files["receiver"], config=config, kind=0)
```
%% Cell type:markdown id: tags:
## Traces
%% Cell type:code id: tags:
``` python
traces(original, config)
```
%% Output
%% Cell type:markdown id: tags:
## Jitter Analysis
%% Cell type:code id: tags:
``` python
df = jitter.prep(original, config=config)
jitter.trace_jitter(df)
```
%% Output
4018 / 4095 are no outliers.
%% Cell type:markdown id: tags:
## Correlation
%% Cell type:code id: tags:
``` python
correlation(df[df["EndToEnd_D"] < 150], config)
```
%% Output
%% Cell type:code id: tags:
``` python
```
/*
* pp.h
*
* This file contains some useful preprocessor macros.
*
* Warning: This file is auto-generated. Do not edit.
*/
#ifndef __PP_H__
#define __PP_H__ 1
/*
* PP__cmn_* macros
*
* PP common macros
*/
#define PP__cmn_id(...) __VA_ARGS__
#define PP__cmn_call(m,...) m(__VA_ARGS__)
/*
* PP__arg_* macros
*
* PP macros that operate on argument lists.
*/
#define PP_arg_count(...) PP__arg_cnt(__VA_ARGS__)
#define PP__arg_cnt(...) PP__arg_cnt_2(__VA_ARGS__,128,127,126,125,124,123,122,121,120,119,118,117,116,115,114,113,112,111,110,109,108,107,106,105,104,103,102,101,100,99,98,97,96,95,94,93,92,91,90,89,88,87,86,85,84,83,82,81,80,79,78,77,76,75,74,73,72,71,70,69,68,67,66,65,64,63,62,61,60,59,58,57,56,55,54,53,52,51,50,49,48,47,46,45,44,43,42,41,40,39,38,37,36,35,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)
#define PP__arg_cnt_2(_a1,_a2,_a3,_a4,_a5,_a6,_a7,_a8,_a9,_a10,_a11,_a12,_a13,_a14,_a15,_a16,_a17,_a18,_a19,_a20,_a21,_a22,_a23,_a24,_a25,_a26,_a27,_a28,_a29,_a30,_a31,_a32,_a33,_a34,_a35,_a36,_a37,_a38,_a39,_a40,_a41,_a42,_a43,_a44,_a45,_a46,_a47,_a48,_a49,_a50,_a51,_a52,_a53,_a54,_a55,_a56,_a57,_a58,_a59,_a60,_a61,_a62,_a63,_a64,_a65,_a66,_a67,_a68,_a69,_a70,_a71,_a72,_a73,_a74,_a75,_a76,_a77,_a78,_a79,_a80,_a81,_a82,_a83,_a84,_a85,_a86,_a87,_a88,_a89,_a90,_a91,_a92,_a93,_a94,_a95,_a96,_a97,_a98,_a99,_a100,_a101,_a102,_a103,_a104,_a105,_a106,_a107,_a108,_a109,_a110,_a111,_a112,_a113,_a114,_a115,_a116,_a117,_a118,_a119,_a120,_a121,_a122,_a123,_a124,_a125,_a126,_a127,_a128,_x,...) _x
/*
* argument list map-reduce macros
*/
#define PP__mapreduce_1(reduce,eol,map,a) eol(map(a))
#define PP__mapreduce_2(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_1(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_3(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_2(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_4(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_3(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_5(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_4(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_6(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_5(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_7(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_6(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_8(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_7(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_9(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_8(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_10(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_9(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_11(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_10(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_12(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_11(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_13(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_12(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_14(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_13(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_15(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_14(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_16(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_15(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_17(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_16(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_18(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_17(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_19(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_18(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_20(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_19(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_21(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_20(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_22(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_21(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_23(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_22(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_24(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_23(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_25(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_24(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_26(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_25(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_27(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_26(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_28(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_27(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_29(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_28(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_30(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_29(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_31(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_30(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_32(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_31(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_33(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_32(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_34(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_33(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_35(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_34(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_36(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_35(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_37(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_36(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_38(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_37(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_39(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_38(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_40(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_39(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_41(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_40(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_42(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_41(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_43(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_42(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_44(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_43(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_45(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_44(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_46(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_45(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_47(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_46(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_48(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_47(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_49(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_48(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_50(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_49(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_51(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_50(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_52(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_51(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_53(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_52(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_54(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_53(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_55(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_54(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_56(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_55(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_57(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_56(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_58(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_57(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_59(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_58(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_60(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_59(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_61(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_60(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_62(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_61(reduce,eol,map,__VA_ARGS__))
#define PP__mapreduce_63(reduce,eol,map,head,...) reduce(map(head),PP__mapreduce_62(reduce,eol,map,__VA_ARGS