Skip to content

Instantly share code, notes, and snippets.

View ivelin's full-sized avatar
🎯
Focusing

Ivelin Ivanov ivelin

🎯
Focusing
View GitHub Profile
@ivelin
ivelin / gist:198714ca6de46765c705
Created December 16, 2014 17:14
Phone registered to OpenBTS and placing a call to 2001. Restcomm has a 2001 virtual number tied to a simple Play prompt app.
09:11:29,206 INFO [gov.nist.javax.sip.stack.SIPTransactionStack] (Mobicents-SIP-Servlets-UDPMessageChannelThread-6) <message
from="192.168.1.22:5062"
to="192.168.1.22:5080"
time="1418749889201"
isSender="false"
transactionId="z9hg4bkobtszrbylxgxlkumsefg"
callId="001013e826c0010-67c13018b7d9f17"
firstLine="INVITE sip:2001@192.168.1.22:5080 SIP/2.0"
>
<![CDATA[INVITE sip:2001@192.168.1.22:5080 SIP/2.0
@ivelin
ivelin / gist:d2e94594e16cdf02a535
Created December 16, 2014 17:26
OpenBTS SMS flow to Restcomm
09:24:45,231 INFO [gov.nist.javax.sip.stack.SIPTransactionStack] (RestComm-akka.actor.default-dispatcher-72) <message
from="192.168.1.22:5080"
to="192.168.1.22:5062"
time="1418750685229"
isSender="true"
transactionId="z9hg4bk06b79dab-bfa9-4870-8115-c6d4fa521fb5_57a5b08a_a12fdcba-731b-44cb-9d6e-2fa8eeb7e757"
callId="86e9c4e8bdc0242e374e557b902d3f15@192.168.1.22"
firstLine="OPTIONS sip:IMSI001010000000002@192.168.1.22:5062;lr SIP/2.0"
>
<![CDATA[OPTIONS sip:IMSI001010000000002@192.168.1.22:5062;lr SIP/2.0
2014-12-18T18:50:52.859605-08:00 ubuntu openbts: NOTICE 3030383424 18:50:52.8 SIP2Interface.cpp:429:newDriveIncoming: unrecognized callid=58c2515e3a97c73c358a8998057013e2@192.168.1.22 SIP Message:=SipMessage( code=0 ReqMethod=OPTIONS CSeq=1 OPTIONS callid=58c2515e3a97c73c358a8998057013e2@192.168.1.22 ReqUri=sip:IMSI001010000000001@192.168.1.22:5062;lr To=<sip:IMSI001010000000001@192.168.1.22:5062> From=<sip:restcomm@192.168.1.22>;tag=89690810_29cfc8ef_57a5b08a_929101bb-4a48-4a3b-aa9e-d1ef02a1be27 Vias=SIP/2.0/UDP 192.168.1.22:5080;branch=z9hG4bK929101bb-4a48-4a3b-aa9e-d1ef02a1be27_57a5b08a_2fa2a5db-80bd-4386-914b-67bf72857e53 Routes=<sip:IMSI001010000000001@192.168.1.22:5062;lr> Contact=<sip:restcomm@192.168.1.22:5080> header Max-Forwards=70 header User-Agent=Mobicents Restcomm 7.2.1.581 header Content-Length=0 firstLine=)
2014-12-18T18:50:52.871833-08:00 ubuntu openbts: NOTICE 3030383424 18:50:52.8 SIP2Interface.cpp:429:newDriveIncoming: unrecognized callid=95a867fcffab72c378d341dbee5b02f4@192.168.1.22 SIP M
@ivelin
ivelin / BUILD
Last active June 18, 2019 22:23
tensorflow_io/pcap/BUILD
licenses(["notice"]) # Apache 2.0
package(default_visibility = ["//visibility:public"])
cc_binary(
name = "python/ops/_pcap_ops.so",
srcs = [
"kernels/pcap_input.cc",
"ops/pcap_ops.cc",
],
#include "tensorflow/core/framework/common_shape_fns.h"
#include "tensorflow/core/framework/op.h"
#include "tensorflow/core/framework/shape_inference.h"
namespace tensorflow {
REGISTER_OP("PcapInput")
.Input("source: string")
.Output("handle: variant")
.Attr("filters: list(string) = []")
REGISTER_UNARY_VARIANT_DECODE_FUNCTION(PcapInput, "tensorflow::data::PcapInput");
REGISTER_KERNEL_BUILDER(Name("PcapInput").Device(DEVICE_CPU),
FileInputOp<PcapInput>);
REGISTER_KERNEL_BUILDER(Name("PcapDataset").Device(DEVICE_CPU),
FileInputDatasetOp<PcapInput, PcapInputStream>);
// read packets from the file up to record_to_read or end of file
while ((*record_read) < record_to_read) {
int64 record_count = 0;
double packet_timestamp;
string packet_data_buffer;
Status status = state.get()->ReadRecord(packet_timestamp, &packet_data_buffer, record_count);
if (!(status.ok() || errors::IsOutOfRange(status))) {
return status;
}
if (record_count > 0) {
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from tensorflow.python.util.all_util import remove_undocumented
from tensorflow_io.pcap.python.ops.pcap_ops import PcapDataset
_allowed_symbols = [
"PcapDataset",
]
"""PcapDataset"""
import tensorflow as tf
from tensorflow_io.core.python.ops import data_ops as data_ops
from tensorflow_io import _load_library
pcap_ops = _load_library('_pcap_ops.so')
class PcapDataset(data_ops.Dataset):
"""A pcap Dataset. Pcap is a popular file format for capturing network packets.
"""
dataset = pcap_io.PcapDataset(url_filenames, batch=1)
packets_total = 0
for v in dataset:
(packet_timestamp, packet_data) = v
if packets_total == 0:
assert packet_timestamp.numpy()[0] == 1084443427.311224 # we know this is the correct value in the test pcap file
assert len(packet_data.numpy()[0]) == 62 # we know this is the correct packet data buffer length in the test pcap file
packets_total += 1
assert packets_total == 43 # we know this is the correct number of packets in the test pcap file