iovisor / iovisor/bcc

All len(str(packet_cnt_output[i][0])) in my computer are 29 not 30

Open
#3,948 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
22.7k
Forks
4.1k
Avg merge
10d 4h
Merged PRs (30d)
3

Description

why `len(str(packet_cnt_output[i][0]))` is 30?

I modify the code like below, can not the the info

```python3
try:
while True :
time.sleep(OUTPUT_INTERVAL)
packet_cnt_output = packet_cnt.items()
output_len = len(packet_cnt_output)
print('\n')
print(output_len)
for i in range(0,output_len):
print('len')
print(len(str(packet_cnt_output[i][0])))
print(str(packet_cnt_output[i][0]))
if (len(str(packet_cnt_output[i][0]))) != 30:
# if (len(str(packet_cnt_output[i][0]))) != 29:
continue
# packet_cnt_output[i][0] = packet_cnt_output[i][0] << 1
temp = int(str(packet_cnt_output[i][0])[8:-2]) # initial output omitted from the kernel space program
temp = int(str(bin(temp))[2:]) # raw file
src = int(str(temp)[:32],2) # part1
dst = int(str(temp)[32:],2)
pkt_num = str(packet_cnt_output[i][1])[7:-1]
print('src')
print(repr(src))

print('dst')
print(repr(dst))

print('pkt_num')
print(repr(pkt_num))

monitor_result = 'source address : ' + decimal_to_human(str(src)) + ' ' + 'destination address : ' + \
decimal_to_human(str(dst)) + ' ' + pkt_num + ' ' + 'time : ' + str(time.localtime()[0])+\
';'+str(time.localtime()[1]).zfill(2)+';'+str(time.localtime()[2]).zfill(2)+';'+\
str(time.localtime()[3]).zfill(2)+';'+str(time.localtime()[4]).zfill(2)+';'+\
str(time.localtime()[5]).zfill(2)
print(monitor_result)

# time.time() outputs time elapsed since 00:00 hours, 1st, Jan., 1970.
packet_cnt.clear() # delete map entires after printing output. confiremd it deletes values and keys too

```

```
6
len
29
c_ulong(12402711946994873185)
len
29
c_ulong(12402711414418917887)
len
29
c_ulong(12402711440188721663)
len
29
c_ulong(12402758762138388685)
len
29
c_ulong(12402712003699802363)
len
29
c_ulong(12402711144706343163
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.