How to capture packets info in Istio? - amazon-eks

I am using istio sevrice mesh for EKS services.
I would like to capture packet info of every path based request that comes to my virtual sevrices.
What is the best approach to capture this info?
-- I would like to capture packet count, packet size, payload sz and URI say like this:
packet count = x, packet sz = y, payload sz = z, URI = GET //login HTTP/1.1

Related

Adafruit IO - Can I send an object or dict or complex values to a feed?

I am new to Python and Adafruit IO.
I have created a feed in Adafruit IO and am able to periodically send a value (e.g temperature) and I can see a chart of historical values.
aio.send_data('my-feed', 123) # this works
But I am unable to send a complex value (e.g. temperature and humidity).
data = dict()
data['temperature'] = 20
data['humidity'] = 50
aio.send_data('my-feed', data) # this fails :-(
Is it possible to send a complex value to a single Adafruit IO feed?

Calculate packet size from traffic dump

I have a traffic dump in csv file containing packet arrival time, frame length and boolean values for multiple flags.
Can someone please explain how to calculate packet size from the traffic dump.
I further want to generate distribution of the packet size in python.

Java Tensorflow Serving Prediction Client Too Slow

I have created a tensorflow object detection model and served it using tensorflow serving. I have created a python client to test the serving model and that takes around 40ms time to receive all the prediction.
t1 = datetime.datetime.now()
result = stub.Predict(request, 60.0) # 60 secs timeout
t2 = datetime.datetime.now()
print ((t2 - t1).microseconds / 1000)
Now, my problem is when I do the same on java, it takes way too much time (about 10 times) of 450 to 500ms.
ManagedChannel channel = ManagedChannelBuilder.forAddress("localhost", 9000)
.usePlaintext(true)
.build();
PredictionServiceGrpc.PredictionServiceBlockingStub stub = PredictionServiceGrpc.newBlockingStub(channel);
......
Instant pre = Instant.now();
Predict.PredictResponse response = stub.predict(request);
Instant curr = Instant.now();
System.out.println("time " + ChronoUnit.MILLIS.between(pre,curr));
The actual issue was that,
I was sending all the image pixels over the network (which was a bad idea). Now, changing the input to an encoded image made it faster.

UDP over IPv4 Expected Packet Transmission

I'm not quite understanding expected total of packets sent and was wondering if i'm on the right path. I have 4 computers, A, B, C, D and they relay the message from A, so A->B->C->D and I don't count transmitting back from D. And they have a packet loss of 3%. UDP on ipv4 and message must arrive for the expected destination
Say if i was to send 1000mb along a 350 byte payload
= 1000mb = 1024*1024*1000 bytes =
1048576000 bytes / 350 = 2995931.4286 packets sent
If i also had a 3% packet loss for every 100 packets
2995931.42857 * .03/100 = 8987.7943 packet loss
Does that mean i'd compute,
2995931.42857 + 8987.7943 * 3 for each transmission by each computer for extra resubmitted packets?
-Thanks heaps

Scipy, Numpy: Audio classifier,Voice/Speech Activity Detection

I am writting a program to automatically classify recorded audio phone calls files (wav files) which contain atleast some Human Voice or not (only DTMF, Dialtones, ringtones, noise).
My first approach was implementing simple VAD (voice activity detector) using ZCR (zero crossing rate) & calculating Energy, but both of these paramters confuse DTMF, Dialtones with Voice. This techquie failed so I implemented a trivial method to calculate variance of FFT inbetween 200Hz and 300Hz. My numpy code is as follows
wavefft = np.abs(fft(frame))
n = len(frame)
fx = np.arange(0,fs,float(fs)/float(n))
stx = np.where(fx>=200)
stx = stx[0][0]
endx = np.where(fx>=300)
endx = endx[0][0]
return np.sqrt(np.var(wavefft[stx:endx]))/1000
This resulted in 60% accuracy.
Next, I tried implementing a machine learning based approach using SVM (Support Vector Machine) and MFCC (Mel-frequency cepstral coefficients). The results were totally incorrect, almost all samples were incorrectly marked. How should one train a SVM with MFCC feature vectors? My rough code using scikit-learn is as follows
[samplerate, sample] = wavfile.read ('profiles/noise.wav')
noiseProfile = MFCC(samplerate, sample)
[samplerate, sample] = wavfile.read ('profiles/ring.wav')
ringProfile = MFCC(samplerate, sample)
[samplerate, sample] = wavfile.read ('profiles/voice.wav')
voiceProfile = MFCC(samplerate, sample)
machineData = []
for noise in noiseProfile:
machineData.append(noise)
for voice in voiceProfile:
machineData.append(voice)
dataLabel = []
for i in range(0, len(noiseProfile)):
dataLabel.append (0)
for i in range(0, len(voiceProfile)):
dataLabel.append (1)
clf = svm.SVC()
clf.fit(machineData, dataLabel)
I want to know what alternative approach I could implement?
If you don't have to use scipy/numpy, you might checkout webrtvad, which is a Python wrapper around Google's excellent WebRTC Voice Activity Detection code. WebRTC uses Gaussian Mixture Models (GMMs), works well, and is very fast.
Here's an example of how you might use it:
import webrtcvad
# audio must be 16 bit PCM, at 8 KHz, 16 KHz or 32 KHz.
def audio_contains_voice(audio, sample_rate, aggressiveness=0, threshold=0.5):
# Frames must be 10, 20 or 30 ms.
frame_duration_ms = 30
# Assuming split_audio is a function that will split audio into
# frames of the correct size.
frames = split_audio(audio, sample_rate, frame_duration)
# aggressiveness tells the VAD how aggressively to filter out non-speech.
# 0 will have the most false-positives for speech, 3 the least.
vad = webrtc.Vad(aggressiveness)
num_voiced = len([f for f in frames if vad.is_voiced(f, sample_rate)])
return float(num_voiced) / len(frames) > threshold