Search is not available for this dataset
text stringlengths 75 104k |
|---|
def parse_innotop_mode_b(self):
""" Generic parsing method for all other modes """
with open(self.infile, 'r') as infh:
# Pre processing to figure out different headers
max_row_quot = 0
valrow = -1
thisrowcolumns = {}
data = {}
while True:
line1 = infh.readline()
... |
def parse_innotop_mode_m(self):
""" Special parsing method for Innotop "Replication Status" results (innotop --mode M)"""
with open(self.infile, 'r') as infh:
# Pre processing to figure out different headers
max_row_quot = 0
valrow = -1
thisrowcolumns = {}
data = {}
last_ts =... |
def highlight_region(plt, start_x, end_x):
"""
Highlight a region on the chart between the specified start and end x-co-ordinates.
param pyplot plt: matplotlibk pyplot which contains the charts to be highlighted
param string start_x : epoch time millis
param string end_x : epoch time millis
"""
start_x = ... |
def graph_data_on_the_same_graph(list_of_plots, output_directory, resource_path, output_filename):
"""
graph_data_on_the_same_graph: put a list of plots on the same graph: currently it supports CDF
"""
maximum_yvalue = -float('inf')
minimum_yvalue = float('inf')
plots = curate_plot_list(list_of_plots)
plo... |
def _set_scores(self):
"""
Compute anomaly scores for the time series.
"""
anom_scores = {}
self._compute_derivatives()
derivatives_ema = utils.compute_ema(self.smoothing_factor, self.derivatives)
for i, (timestamp, value) in enumerate(self.time_series_items):
anom_scores[timestamp] = ... |
def extract_metric_name(self, metric_name):
"""
Method to extract SAR metric names from the section given in the config. The SARMetric class assumes that
the section name will contain the SAR types listed in self.supported_sar_types tuple
:param str metric_name: Section name from the config
:return... |
def _find_allowed_shift(self, timestamps):
"""
Find the maximum allowed shift steps based on max_shift_milliseconds.
param list timestamps: timestamps of a time series.
"""
init_ts = timestamps[0]
residual_timestamps = map(lambda ts: ts - init_ts, timestamps)
n = len(residual_timestamps)
... |
def _find_first_bigger(self, timestamps, target, lower_bound, upper_bound):
"""
Find the first element in timestamps whose value is bigger than target.
param list values: list of timestamps(epoch number).
param target: target value.
param lower_bound: lower bound for binary search.
param upper_b... |
def create_analysis(self, config):
"""
Create Analysis and save in Naarad from config
:param config:
:return:
"""
self._default_test_id += 1
self._analyses[self._default_test_id] = _Analysis(ts_start=None, config=config, test_id=self._default_test_id) |
def signal_start(self, config, test_id=None, **kwargs):
"""
Initialize an analysis object and set ts_start for the analysis represented by test_id
:param test_id: integer that represents the analysis
:param config: config can be a ConfigParser.ConfigParser object or a string specifying local or http(s) ... |
def signal_stop(self, test_id=None):
"""
Set ts_end for the analysis represented by test_id
:param test_id: integer that represents the analysis
:return: test_id
"""
if test_id is None:
test_id = self._default_test_id
if self._analyses[test_id].ts_end:
return CONSTANTS.OK
sel... |
def get_failed_analyses(self):
"""
Returns a list of test_id for which naarad analysis failed
:return: list of test_ids
"""
failed_analyses = []
for test_id in self._analyses.keys():
if self._analyses[test_id].status != CONSTANTS.OK:
failed_analyses.append(test_id)
return faile... |
def _set_sla_data(self, test_id, metrics):
"""
Get sla data from each metric and set it in the _Analysis object specified by test_id to make it available
for retrieval
:return: currently always returns CONSTANTS.OK. Maybe enhanced in future to return additional status
"""
for metric in metrics:
... |
def _set_stats_data(self, test_id, metrics):
"""
Get summary stats data from each metric and set it in the _Analysis object specified by test_id to make it available
for retrieval
:return: currently always returns CONSTANTS.OK. Maybe enhanced in future to return additional status
"""
for metric ... |
def _create_output_directories(self, analysis):
"""
Create the necessary output and resource directories for the specified analysis
:param: analysis: analysis associated with a given test_id
"""
try:
os.makedirs(analysis.output_directory)
except OSError as exception:
if exception.err... |
def _run_pre(self, analysis, run_steps):
"""
If Naarad is run in CLI mode, execute any pre run steps specified in the config. ts_start/ts_end are set based on
workload run steps if any.
:param: analysis: The analysis object being processed
:param: run_steps: list of post run steps
"""
worklo... |
def _run_post(self, run_steps):
"""
If Naarad is run in CLI mode, execute any post run steps specified in the config
:param: run_steps: list of post run steps
"""
for run_step in sorted(run_steps, key=lambda step: step.run_rank):
run_step.run()
return CONSTANTS.OK |
def _process_args(self, analysis, args):
"""
When Naarad is run in CLI mode, get the CL arguments and update the analysis
:param: analysis: The analysis being processed
:param: args: Command Line Arguments received by naarad
"""
if args.exit_code:
self.return_exit_code = args.exit_code
... |
def analyze(self, input_directory, output_directory, **kwargs):
"""
Run all the analysis saved in self._analyses, sorted by test_id.
This is useful when Naarad() is used by other programs and multiple analyses are run
In naarad CLI mode, len(_analyses) == 1
:param: input_directory: location of log f... |
def run(self, analysis, is_api_call, **kwargs):
"""
:param analysis: Run naarad analysis for the specified analysis object
:param **kwargs: Additional keyword args can be passed in here for future enhancements
:return:
"""
threads = []
crossplots = []
report_args = {}
metrics = defau... |
def diff(self, test_id_1, test_id_2, config=None, **kwargs):
"""
Create a diff report using test_id_1 as a baseline
:param: test_id_1: test id to be used as baseline
:param: test_id_2: test id to compare against baseline
:param: config file for diff (optional)
:param: **kwargs: keyword arguments... |
def diff_reports_by_location(self, report1_location, report2_location, output_directory, config=None, **kwargs):
"""
Create a diff report using report1 as a baseline
:param: report1_location: report to be used as baseline
:param: report2_location: report to compare against baseline
:param: config fi... |
def _process_naarad_config(self, config, analysis):
"""
Process the config file associated with a particular analysis and return metrics, run_steps and crossplots.
Also sets output directory and resource_path for an anlaysis
"""
graph_timezone = None
output_directory = analysis.output_directory
... |
def parse(self):
"""
Parse the vmstat file
:return: status of the metric parse
"""
file_status = True
for input_file in self.infile_list:
file_status = file_status and naarad.utils.is_valid_file(input_file)
if not file_status:
return False
status = True
cur_zone = No... |
def collect(self):
"""
Take a list of metrics, filter all metrics based on hostname, and metric_type
For each metric, merge the corresponding csv files into one,update corresponding properties such as csv_column_map.
Users can specify functions: raw, count (qps), sum (aggregated value), avg (averaged va... |
def get_times(self, native):
"""
get start time stamp, launch time duration, and nus update time duration from JSON object native
:param JSON OBJECT native
:return: LONG event time stamp, LONG launch time, and LONG nus update time
"""
start_time = 0
end_time = 0
launch_time = 0
nus_u... |
def run(self):
"""Perform the Oct2Py speed analysis.
Uses timeit to test the raw execution of an Octave command,
Then tests progressively larger array passing.
"""
print('Oct2Py speed test')
print('*' * 20)
time.sleep(1)
print('Raw speed: ')
... |
def exit(self):
"""Quits this octave session and cleans up.
"""
if self._engine:
self._engine.repl.terminate()
self._engine = None |
def push(self, name, var, timeout=None, verbose=True):
"""
Put a variable or variables into the Octave session.
Parameters
----------
name : str or list
Name of the variable(s).
var : object or list
The value(s) to pass.
timeout ... |
def pull(self, var, timeout=None, verbose=True):
"""
Retrieve a value or values from the Octave session.
Parameters
----------
var : str or list
Name of the variable(s) to retrieve.
timeout : float, optional.
Time to wait for response fro... |
def get_pointer(self, name, timeout=None):
"""Get a pointer to a named object in the Octave workspace.
Parameters
----------
name: str
The name of the object in the Octave workspace.
timemout: float, optional.
Time to wait for response from Octave... |
def extract_figures(self, plot_dir, remove=False):
"""Extract the figures in the directory to IPython display objects.
Parameters
----------
plot_dir: str
The plot dir where the figures were created.
remove: bool, optional.
Whether to remove the p... |
def feval(self, func_path, *func_args, **kwargs):
"""Run a function in Octave and return the result.
Parameters
----------
func_path: str
Name of function to run or a path to an m-file.
func_args: object, optional
Args to send to the function.
... |
def eval(self, cmds, verbose=True, timeout=None, stream_handler=None,
temp_dir=None, plot_dir=None, plot_name='plot', plot_format='svg',
plot_width=None, plot_height=None, plot_res=None,
nout=0, **kwargs):
"""
Evaluate an Octave command or commands.
... |
def restart(self):
"""Restart an Octave session in a clean state
"""
if self._engine:
self._engine.repl.terminate()
executable = self._executable
if executable:
os.environ['OCTAVE_EXECUTABLE'] = executable
if 'OCTAVE_EXECUTABLE' not in os... |
def _feval(self, func_name, func_args=(), dname='', nout=0,
timeout=None, stream_handler=None, store_as='', plot_dir=None):
"""Run the given function with the given args.
"""
engine = self._engine
if engine is None:
raise Oct2PyError('Session is closed')
... |
def _parse_error(self, err):
"""Create a traceback for an Octave evaluation error.
"""
self.logger.debug(err)
stack = err.get('stack', [])
if not err['message'].startswith('parse error:'):
err['message'] = 'error: ' + err['message']
errmsg = 'Octave eva... |
def _get_doc(self, name):
"""
Get the documentation of an Octave procedure or object.
Parameters
----------
name : str
Function name to search for.
Returns
-------
out : str
Documentation string.
Raises
... |
def _exist(self, name):
"""Test whether a name exists and return the name code.
Raises an error when the name does not exist.
"""
cmd = 'exist("%s")' % name
resp = self._engine.eval(cmd, silent=True).strip()
exist = int(resp.split()[-1])
if exist == 0:
... |
def _isobject(self, name, exist):
"""Test whether the name is an object."""
if exist in [2, 5]:
return False
cmd = 'isobject(%s)' % name
resp = self._engine.eval(cmd, silent=True).strip()
return resp == 'ans = 1' |
def _get_function_ptr(self, name):
"""Get or create a function pointer of the given name."""
func = _make_function_ptr_instance
self._function_ptrs.setdefault(name, func(self, name))
return self._function_ptrs[name] |
def _get_user_class(self, name):
"""Get or create a user class of the given type."""
self._user_classes.setdefault(name, _make_user_class(self, name))
return self._user_classes[name] |
def _cleanup(self):
"""Clean up resources used by the session.
"""
self.exit()
workspace = osp.join(os.getcwd(), 'octave-workspace')
if osp.exists(workspace):
os.remove(workspace) |
def demo(delay=1, interactive=True):
"""
Play a demo script showing most of the oct2py api features.
Parameters
==========
delay : float
Time between each command in seconds.
"""
script = """
#########################
# Oct2Py demo
#########################... |
def kill_octave():
"""Kill all octave instances (cross-platform).
This will restart the "octave" instance. If you have instantiated
Any other Oct2Py objects, you must restart them.
"""
import os
if os.name == 'nt':
os.system('taskkill /im octave /f')
else:
os.syst... |
def thread_check(nthreads=3):
"""
Start a number of threads and verify each has a unique Octave session.
Parameters
==========
nthreads : int
Number of threads to use.
Raises
======
Oct2PyError
If the thread does not sucessfully demonstrate independence.
... |
def run(self):
"""
Create a unique instance of Octave and verify namespace uniqueness.
Raises
======
Oct2PyError
If the thread does not sucessfully demonstrate independence
"""
octave = Oct2Py()
# write the same variable name in ea... |
def read_file(path, session=None):
"""Read the data from the given file path.
"""
try:
data = loadmat(path, struct_as_record=True)
except UnicodeDecodeError as e:
raise Oct2PyError(str(e))
out = dict()
for (key, value) in data.items():
out[key] = _extract(value, ... |
def write_file(obj, path, oned_as='row', convert_to_float=True):
"""Save a Python object to an Octave file on the given path.
"""
data = _encode(obj, convert_to_float)
try:
# scipy.io.savemat is not thread-save.
# See https://github.com/scipy/scipy/issues/7260
with _WRITE_... |
def _extract(data, session=None):
"""Convert the Octave values to values suitable for Python.
"""
# Extract each item of a list.
if isinstance(data, list):
return [_extract(d, session) for d in data]
# Ignore leaf objects.
if not isinstance(data, np.ndarray):
return dat... |
def _create_struct(data, session):
"""Create a struct from session data.
"""
out = Struct()
for name in data.dtype.names:
item = data[name]
# Extract values that are cells (they are doubly wrapped).
if isinstance(item, np.ndarray) and item.dtype.kind == 'O':
i... |
def _encode(data, convert_to_float):
"""Convert the Python values to values suitable to send to Octave.
"""
ctf = convert_to_float
# Handle variable pointer.
if isinstance(data, (OctaveVariablePtr)):
return _encode(data.value, ctf)
# Handle a user defined object.
if isins... |
def _is_simple_numeric(data):
"""Test if a list contains simple numeric data."""
for item in data:
if isinstance(item, set):
item = list(item)
if isinstance(item, list):
if not _is_simple_numeric(item):
return False
elif not isinstance(item... |
def get_log(name=None):
"""Return a console logger.
Output may be sent to the logger using the `debug`, `info`, `warning`,
`error` and `critical` methods.
Parameters
----------
name : str
Name of the log.
References
----------
.. [1] Logging facility for Pytho... |
def _setup_log():
"""Configure root logger.
"""
try:
handler = logging.StreamHandler(stream=sys.stdout)
except TypeError: # pragma: no cover
handler = logging.StreamHandler(strm=sys.stdout)
log = get_log()
log.addHandler(handler)
log.setLevel(logging.INFO)
lo... |
def _make_user_class(session, name):
"""Make an Octave class for a given class name"""
attrs = session.eval('fieldnames(%s);' % name, nout=1).ravel().tolist()
methods = session.eval('methods(%s);' % name, nout=1).ravel().tolist()
ref = weakref.ref(session)
doc = _DocDescriptor(ref, name)
values... |
def from_value(cls, value):
"""This is how an instance is created when we read a
MatlabObject from a MAT file.
"""
instance = OctaveUserClass.__new__(cls)
instance._address = '%s_%s' % (instance._name, id(instance))
instance._ref().push(instance._address, value)
... |
def to_value(cls, instance):
"""Convert to a value to send to Octave."""
if not isinstance(instance, OctaveUserClass) or not instance._attrs:
return dict()
# Bootstrap a MatlabObject from scipy.io
# From https://github.com/scipy/scipy/blob/93a0ea9e5d4aba1f661b6bb0e18f9c2d1fce... |
def to_pointer(cls, instance):
"""Get a pointer to the private object.
"""
return OctavePtr(instance._ref, instance._name, instance._address) |
def document_func_view(serializer_class=None,
response_serializer_class=None,
filter_backends=None,
permission_classes=None,
authentication_classes=None,
doc_format_args=list(),
doc_... |
def format_docstring(*args, **kwargs):
"""
Decorator for clean docstring formatting
"""
def decorator(func):
func.__doc__ = getdoc(func).format(*args, **kwargs)
return func
return decorator |
def is_rarfile(filename):
"""Return true if file is a valid RAR file."""
mode = constants.RAR_OM_LIST_INCSPLIT
archive = unrarlib.RAROpenArchiveDataEx(filename, mode=mode)
try:
handle = unrarlib.RAROpenArchiveEx(ctypes.byref(archive))
except unrarlib.UnrarException:
return False
... |
def _read_header(self, handle):
"""Read current member header into a RarInfo object."""
header_data = unrarlib.RARHeaderDataEx()
try:
res = unrarlib.RARReadHeaderEx(handle, ctypes.byref(header_data))
rarinfo = RarInfo(header=header_data)
except unrarlib.ArchiveEnd... |
def _process_current(self, handle, op, dest_path=None, dest_name=None):
"""Process current member with 'op' operation."""
unrarlib.RARProcessFileW(handle, op, dest_path, dest_name) |
def _load_metadata(self, handle):
"""Load archive members metadata."""
rarinfo = self._read_header(handle)
while rarinfo:
self.filelist.append(rarinfo)
self.NameToInfo[rarinfo.filename] = rarinfo
self._process_current(handle, constants.RAR_SKIP)
ra... |
def _open(self, archive):
"""Open RAR archive file."""
try:
handle = unrarlib.RAROpenArchiveEx(ctypes.byref(archive))
except unrarlib.UnrarException:
raise BadRarFile("Invalid RAR file.")
return handle |
def open(self, member, pwd=None):
"""Return file-like object for 'member'.
'member' may be a filename or a RarInfo object.
"""
if isinstance(member, RarInfo):
member = member.filename
archive = unrarlib.RAROpenArchiveDataEx(
self.filename, mode=consta... |
def namelist(self):
"""Return a list of file names in the archive."""
names = []
for member in self.filelist:
names.append(member.filename)
return names |
def getinfo(self, name):
"""Return the instance of RarInfo given 'name'."""
rarinfo = self.NameToInfo.get(name)
if rarinfo is None:
raise KeyError('There is no item named %r in the archive' % name)
return rarinfo |
def printdir(self):
"""Print a table of contents for the RAR file."""
print("%-46s %19s %12s" % ("File Name", "Modified ", "Size"))
for rarinfo in self.filelist:
date = "%d-%02d-%02d %02d:%02d:%02d" % rarinfo.date_time[:6]
print("%-46s %s %12d" % (
rari... |
def extract(self, member, path=None, pwd=None):
"""Extract a member from the archive to the current working directory,
using its full name. Its file information is extracted as accurately
as possible. `member' may be a filename or a RarInfo object. You can
specify a different di... |
def extractall(self, path=None, members=None, pwd=None):
"""Extract all members from the archive to the current working
directory. `path' specifies a different directory to extract to.
`members' is optional and must be a subset of the list returned
by namelist().
"""
... |
def _extract_members(self, members, targetpath, pwd):
"""Extract the RarInfo objects 'members' to a physical
file on the path targetpath.
"""
archive = unrarlib.RAROpenArchiveDataEx(
self.filename, mode=constants.RAR_OM_EXTRACT)
handle = self._open(archive)
... |
def dostime_to_timetuple(dostime):
"""Convert a RAR archive member DOS time to a Python time tuple."""
dostime = dostime >> 16
dostime = dostime & 0xffff
day = dostime & 0x1f
month = (dostime >> 5) & 0xf
year = 1980 + (dostime >> 9)
second = 2 * (dostime & 0x1f)
minute = (dostime >> 5) &... |
def _c_func(func, restype, argtypes, errcheck=None):
"""Wrap c function setting prototype."""
func.restype = restype
func.argtypes = argtypes
if errcheck is not None:
func.errcheck = errcheck
return func |
def _load_savefile_header(file_h):
"""
Load and validate the header of a pcap file.
"""
try:
raw_savefile_header = file_h.read(24)
except UnicodeDecodeError:
print("\nMake sure the input file is opened in read binary, 'rb'\n")
raise InvalidEncoding("Could not read file; it mi... |
def load_savefile(input_file, layers=0, verbose=False, lazy=False):
"""
Parse a savefile as a pcap_savefile instance. Returns the savefile
on success and None on failure. Verbose mode prints additional information
about the file's processing. layers defines how many layers to descend and
decode the ... |
def _load_packets(file_h, header, layers=0):
"""
Read packets from the capture file. Expects the file handle to point to
the location immediately after the header (24 bytes).
"""
pkts = []
hdrp = ctypes.pointer(header)
while True:
pkt = _read_a_packet(file_h, hdrp, layers)
i... |
def _generate_packets(file_h, header, layers=0):
"""
Read packets one by one from the capture file. Expects the file
handle to point to the location immediately after the header (24
bytes).
"""
hdrp = ctypes.pointer(header)
while True:
pkt = _read_a_packet(file_h, hdrp, layers)
... |
def _read_a_packet(file_h, hdrp, layers=0):
"""
Reads the next individual packet from the capture file. Expects
the file handle to be somewhere after the header, on the next
per-packet header.
"""
raw_packet_header = file_h.read(16)
if not raw_packet_header or len(raw_packet_header) != 16:
... |
def parse_ipv4(address):
"""
Given a raw IPv4 address (i.e. as an unsigned integer), return it in
dotted quad notation.
"""
raw = struct.pack('I', address)
octets = struct.unpack('BBBB', raw)[::-1]
ipv4 = b'.'.join([('%d' % o).encode('ascii') for o in bytearray(octets)])
return ipv4 |
def strip_ip(packet):
"""
Remove the IP packet layer, yielding the transport layer.
"""
if not isinstance(packet, IP):
packet = IP(packet)
payload = packet.payload
return payload |
def strip_ethernet(packet):
"""
Strip the Ethernet frame from a packet.
"""
if not isinstance(packet, Ethernet):
packet = Ethernet(packet)
payload = packet.payload
return payload |
def load_network(self, layers=1):
"""
Given an Ethernet frame, determine the appropriate sub-protocol;
If layers is greater than zerol determine the type of the payload
and load the appropriate type of network packet. It is expected
that the payload be a hexified string. The laye... |
def WIFI(frame, no_rtap=False):
"""calls wifi packet discriminator and constructor.
:frame: ctypes.Structure
:no_rtap: Bool
:return: packet object in success
:return: int
-1 on known error
:return: int
-2 on unknown error
"""
pack = None
try:
pack = WiHelper.g... |
def get_wifi_packet(frame, no_rtap=False):
"""Discriminates Wi-Fi packet and creates
packet object.
:frame: ctypes.Structure
:no_rtap: Bool
:return: obj
Wi-Fi packet
"""
_, packet = WiHelper._strip_rtap(frame)
frame_control = struct.unpack('BB'... |
def _strip_rtap(frame):
"""strip injected radiotap header.
:return: ctypes.Structure
radiotap header
:return: ctypes.Structure
actual layer 2 Wi-Fi payload
"""
rtap_len = WiHelper.__get_rtap_len(frame)
rtap = frame[:rtap_len]
packet = frame... |
def strip_present(payload):
"""strip(4 byte) radiotap.present. Those are flags that
identify existence of incoming radiotap meta-data.
:idx: int
:return: str
:return: namedtuple
"""
present = collections.namedtuple(
'present', ['tsft', 'flags', 'rate',... |
def strip_tsft(self, idx):
"""strip(8 byte) radiotap.mactime
:idx: int
:return: int
idx
:return: int
mactime
"""
idx = Radiotap.align(idx, 8)
mactime, = struct.unpack_from('<Q', self._rtap, idx)
return idx + 8, mactime |
def strip_flags(self, idx):
"""strip(1 byte) radiotap.flags
:idx: int
:return: int
idx
:return: collections.namedtuple
"""
flags = collections.namedtuple(
'flags', ['cfp', 'preamble', 'wep', 'fragmentation', 'fcs',
'datapad', ... |
def strip_rate(self, idx):
"""strip(1 byte) radiotap.datarate
note that, unit of this field is originally 0.5 Mbps
:idx: int
:return: int
idx
:return: double
rate in terms of Mbps
"""
val, = struct.unpack_from('<B', self._rtap, idx)
... |
def strip_chan(self, idx):
"""strip(2 byte) radiotap.channel.flags
:idx: int
:return: int
idx
:return: collections.namedtuple
"""
chan = collections.namedtuple(
'chan', ['freq', 'turbo', 'cck', 'ofdm', 'two_g', 'five_g',
'passi... |
def strip_fhss(self, idx):
"""strip (2 byte) radiotap.fhss.hopset(1 byte) and
radiotap.fhss.pattern(1 byte)
:idx: int
:return: int
idx
:return: collections.namedtuple
"""
fhss = collections.namedtuple('fhss', ['hopset', 'pattern'])
fhss.hopset,... |
def strip_dbm_antsignal(self, idx):
"""strip(1 byte) radiotap.dbm.ant_signal
:idx: int
:return: int
idx
:return: int
"""
dbm_antsignal, = struct.unpack_from('<b', self._rtap, idx)
return idx + 1, dbm_antsignal |
def strip_dbm_antnoise(self, idx):
"""strip(1 byte) radiotap.dbm_antnoise
:idx: int
:return: int
idx
:return: int
"""
dbm_antnoise, = struct.unpack_from('<b', self._rtap, idx)
return idx + 1, dbm_antnoise |
def strip_lock_quality(self, idx):
"""strip(2 byte) lock quality
:idx: int
:return: int
idx
:return: int
"""
idx = Radiotap.align(idx, 2)
lock_quality, = struct.unpack_from('<H', self._rtap, idx)
return idx + 2, lock_quality |
def strip_tx_attenuation(self, idx):
"""strip(1 byte) tx_attenuation
:idx: int
:return: int
idx
:return: int
"""
idx = Radiotap.align(idx, 2)
tx_attenuation, = struct.unpack_from('<H', self._rtap, idx)
return idx + 2, tx_attenuation |
def strip_db_tx_attenuation(self, idx):
"""strip(1 byte) db_tx_attenuation
:return: int
idx
:return: int
"""
idx = Radiotap.align(idx, 2)
db_tx_attenuation, = struct.unpack_from('<H', self._rtap, idx)
return idx + 2, db_tx_attenuation |
def strip_dbm_tx_power(self, idx):
"""strip(1 byte) dbm_tx_power
:return: int
idx
:return: int
"""
idx = Radiotap.align(idx, 1)
dbm_tx_power, = struct.unpack_from('<b', self._rtap, idx)
return idx + 1, dbm_tx_power |
def strip_antenna(self, idx):
"""strip(1 byte) radiotap.antenna
:return: int
idx
:return: int
"""
antenna, = struct.unpack_from('<B', self._rtap, idx)
return idx + 1, antenna |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.