@@ -57,7 +57,7 @@ def plotFromPandas(panda, pdf, opts):
57
57
58
58
# Check is there is Value on top of the charts
59
59
if opts ['barValues' ] is not None :
60
- for ind , value in enumerate (yarray ):
60
+ for ind , value in enumerate (opts [ 'barValues' ] ):
61
61
plt .text (ind , value , str (value ), fontsize = opts ['textSize' ], horizontalalignment = 'center' )
62
62
63
63
# Check id the grid has been set
@@ -81,7 +81,7 @@ def plotStackBarsFromArrays(xarray, yarray, pdf, opts):
81
81
82
82
fig , ax = plt .subplots (figsize = opts ['figSize' ])
83
83
84
- colors = ['mediumseagreen' , 'indianred' , 'goldenrod' ,'cornflowerblue' ]
84
+ colors = ['mediumseagreen' , 'springgreen' , ' indianred' , 'goldenrod' , 'cornflowerblue' ]
85
85
legends = []
86
86
auxI = 0
87
87
bottom = [0 ,0 ] # done by hand
@@ -526,14 +526,12 @@ def main():
526
526
# End of plotting variables
527
527
csvFile = sys .argv [1 ]
528
528
peerstoreFile = sys .argv [2 ]
529
- extraMetrics = sys .argv [3 ]
530
- outputFigsFolder = sys .argv [4 ]
529
+ outputFigsFolder = sys .argv [3 ]
531
530
532
531
pdfFile = outputFigsFolder + "/MetricsSummary.pdf"
533
532
534
533
peerstorePanda = getPandaFromPeerstoreJson (peerstoreFile )
535
534
rumorMetricsPanda = pd .read_csv (csvFile )
536
- extraPeerData = pd .read_csv (extraMetrics )
537
535
538
536
539
537
# ---------- PLOT SECUENCE -----------
@@ -553,7 +551,7 @@ def main():
553
551
cnt9000 = 0
554
552
cntOthers = 0
555
553
noAddrs = 0
556
-
554
+
557
555
peerstoreLen = len (peerstore )
558
556
metricsLen = len (rumorMetricsPanda )
559
557
print ()
@@ -569,10 +567,25 @@ def main():
569
567
except :
570
568
noAddrs = noAddrs + 1
571
569
570
+ # Unknown Peers with 13000 port
571
+ unk13000 = 0
572
+ tcp13000 = 0
573
+ cunk1300 = 0
574
+ for index , row in rumorMetricsPanda .iterrows ():
575
+
576
+ if '/13000' in str (row ['Address' ]):
577
+ tcp13000 = tcp13000 + 1
578
+ if row ['Client' ] == 'Unknown' :
579
+ unk13000 = unk13000 + 1
580
+ if row ['Connected' ] == True :
581
+ cunk1300 = cunk1300 + 1
582
+ print (tcp13000 , unk13000 , cunk1300 )
583
+
572
584
print ('Number of clients with the TPC port at 13000:' , cnt13000 )
573
585
print ('Number of clients with the TPC port at 9000: ' , cnt9000 )
574
586
print ('Number of clients with other TCP ports: ' , cntOthers )
575
587
print ('Number of clients without address: ' , noAddrs )
588
+ print ('Number of Unknown clients with 13000 TCP port:' , unk13000 )
576
589
summ = cnt13000 + cnt9000 + cntOthers + noAddrs
577
590
noPrysmPort = cnt9000 + cntOthers + noAddrs
578
591
if summ != peerstoreLen :
@@ -694,11 +707,15 @@ def main():
694
707
nonAttempted = 0
695
708
succeed = 0
696
709
failed = 0
710
+ connected = 0
697
711
698
- print ("extra metrics len:" , len (extraPeerData ))
699
- for index , row in extraPeerData .iterrows ():
712
+ print ("extra metrics len:" , len (rumorMetricsPanda ))
713
+ for index , row in rumorMetricsPanda .iterrows ():
700
714
if row ['Attempted' ] == False :
701
- nonAttempted = nonAttempted + 1
715
+ if row ['Connected' ] == True :
716
+ connected = connected + 1
717
+ else :
718
+ nonAttempted = nonAttempted + 1
702
719
else :
703
720
if row ['Succeed' ] == False :
704
721
failed = failed + 1
@@ -708,59 +725,26 @@ def main():
708
725
print ("Not tried from the last peerstore copy:" ,nonAttempted )
709
726
print ("Tried and succeed:" , succeed )
710
727
print ("Tried and failed" , failed )
711
- nonAttempted = nonAttempted + (peerstoreLen - (len (extraPeerData )))
728
+ print ("Incoming connections:" , connected )
729
+ nonAttempted = nonAttempted + (peerstoreLen - (len (rumorMetricsPanda )))
712
730
print ("Total Not tried from the entrire peerstore" , nonAttempted )
713
731
714
732
# get length of the peerstore
715
733
peerstoreSize = getLengthOfPanda (peerstorePanda )
716
734
peerMetricsSize = getLengthOfPanda (rumorMetricsPanda )
717
735
718
- print ("Attempted and succeed" , succeed , "| On the metrics" , peerMetricsSize )
719
-
720
- if succeed < peerMetricsSize :
721
- print ("- Dismatch on the extra metrics and metrics -" )
722
- for idx , row in rumorMetricsPanda .iterrows ():
723
- index = extraPeerData .index [extraPeerData ['Peer Id' ] == row ['Peer Id' ]]
724
- extraPeerData .loc [index , 'Attempted' ] = True
725
- extraPeerData .loc [index , 'Succeed' ] = True
726
- extraPeerData .loc [index , 'Error' ] = "None"
727
- # plot the metrics gathered on the extra-metrics
728
- nonAttempted = 0
729
- succeed = 0
730
- failed = 0
731
- print ("\n -- Updating extra-results -- \n " )
732
- print ("extra metrics len:" , len (extraPeerData ))
733
- for index , row in extraPeerData .iterrows ():
734
- if row ['Attempted' ] == False :
735
- nonAttempted = nonAttempted + 1
736
- else :
737
- if row ['Succeed' ] == False :
738
- failed = failed + 1
739
- else :
740
- succeed = succeed + 1
741
-
742
- print ("Not tried from the last peerstore copy:" ,nonAttempted )
743
- print ("Tried and succeed:" , succeed )
744
- print ("Tried and failed" , failed )
745
- nonAttempted = nonAttempted + (peerstoreLen - (len (extraPeerData )))
746
- print ("Total Not tried from the entrire peerstore" , nonAttempted )
747
-
748
-
749
- print ("Attempted and succeed" , succeed , "| On the metrics" , peerMetricsSize )
750
- if succeed != peerMetricsSize :
751
- print ("----> WARN: Random connected peers and peers on the metrics don't match" )
752
-
736
+ print ("Peers in metrics" , peerMetricsSize , "| On the peerstore" , peerstoreSize )
737
+ if peerMetricsSize != peerstoreSize :
738
+ print ("----> WARN: Peers in Peerstore and peers on the metrics don't match" )
739
+
753
740
## -- website code --
754
741
print ("\n " )
755
742
print ("Results from crawler run on [month] running for [crawling time].\n <br>Total amount of peers on the peerstore:" , peerstoreLen ,".\n <br>Number of clients with the TPC port at 13000 (Prysm?):" , cnt13000 ,".\n <br>Percentage of 'Prysm' peers from the peerstore (based on the TCP port):" , round ((cnt13000 * 100 )/ peerstoreLen ,2 ),"%.\n <br>We manage to connect with" , succeed ,"peers from the peerstore.\n <br>This would be the distribution." )
756
743
print ("\n " )
757
-
758
-
759
-
760
-
761
- xarray = [[0 , succeed ], [0 , failed ], [0 , nonAttempted ], [peerstoreLen , 0 ]]
744
+
745
+ xarray = [[0 , succeed ], [0 , connected ], [0 , failed ], [0 , nonAttempted ], [peerstoreLen , 0 ]]
762
746
yarray = ['Peerstore' , 'Peering Results' ]
763
- labels = ['connected' , 'failed' , 'not attempted ' , 'peerstore' ]
747
+ labels = ['connected' , 'incoming' , ' failed' , 'not tried ' , 'peerstore' ]
764
748
barColor = ['tab:blue' , 'tab:green' ]
765
749
766
750
@@ -793,18 +777,24 @@ def main():
793
777
794
778
## Classify the non connected peers by error
795
779
796
- errorList = getItemsFromColumn (extraPeerData , 'Error' )
797
- errorList .remove ('None' )
798
- auxxarray , auxyarray = getDataFromPanda (extraPeerData , None , "Error" , errorList , 'counter' )
780
+ errorList = getItemsFromColumn (rumorMetricsPanda , 'Error' )
781
+ try :
782
+ errorList .remove ('None' )
783
+ except :
784
+ pass
785
+ auxxarray , auxyarray = getDataFromPanda (rumorMetricsPanda , None , "Error" , errorList , 'counter' )
799
786
xarray , yarray = sortArrayMaxtoMin (auxxarray , auxyarray )
800
787
# Get Color Grid
801
788
barColor = GetColorGridFromArray (yarray )
802
789
803
790
print ()
791
+ """
804
792
for idx,item in enumerate(xarray):
805
793
print(item, ',', yarray[idx])
806
794
807
795
print()
796
+ """
797
+
808
798
809
799
plotHorizontalBarsFromArrays (xarray , yarray , pdf , opts = {
810
800
'figSize' : (12 ,7 ),
@@ -833,12 +823,27 @@ def main():
833
823
'tickRotation' : 0 ,
834
824
'show' : False })
835
825
826
+ # Subgenerate a panda only with the peers that we did exchange metadata before
827
+ indexToDrop = []
828
+ counter = 0
829
+ auxMetricsPanda = rumorMetricsPanda .copy ()
830
+ for index , row in auxMetricsPanda .iterrows ():
831
+ if row ['Request Metadata' ] == False : # If we didn't exchange metadata with them, remove them from the panda copy
832
+ indexToDrop .append (index )
833
+ else :
834
+ counter += 1
835
+ #print(index, row['Client'])
836
+
837
+ auxMetricsPanda .drop (indexToDrop , axis = 0 , inplace = True )
838
+ #print(auxMetricsPanda)
839
+ print ("\n Org. Metrics:" , len (rumorMetricsPanda ), "Should have:" , counter , "Filtered:" , len (auxMetricsPanda ), "\n " )
840
+
836
841
clientCounter = []
837
842
types = []
838
843
typesCounter = []
839
844
840
845
for idx , item in enumerate (clientList ):
841
- tcnt , tp , tpc = getTypesPerName (rumorMetricsPanda , item , 'Client' , 'Version' )
846
+ tcnt , tp , tpc = getTypesPerName (auxMetricsPanda , item , 'Client' , 'Version' )
842
847
clientCounter .append (tcnt )
843
848
types .append (tp )
844
849
typesCounter .append (tpc )
@@ -847,6 +852,10 @@ def main():
847
852
yarray = typesCounter
848
853
namesarray = clientList
849
854
855
+ print (clientCounter )
856
+ print (types )
857
+ print (typesCounter )
858
+
850
859
plotDoublePieFromArray (yarray , pdf , opts = {
851
860
'figsize' : figSize ,
852
861
'figtitle' : 'PeersPerClient.png' ,
@@ -895,10 +904,14 @@ def main():
895
904
# Delete Prysm from the extrapoling
896
905
del clientsCnt ['Prysm' ]
897
906
print (clientsCnt )
907
+ # Get number of unknown peers that has the 13000 port
908
+ print ('Number of unknown with 13000 port' , unk13000 )
898
909
# Get total of non prysm peers
899
910
nonPrysmObserved = 0
900
911
for k in clientsCnt :
901
912
nonPrysmObserved = nonPrysmObserved + clientsCnt [k ]
913
+ # Remove Unknown with 13000 port from nonPrysmObserved
914
+ nonPrysmObserved = nonPrysmObserved
902
915
# Get for each of the clients the extrapolation to the peerstore
903
916
extrapolatedClientList = {}
904
917
for k in clientsCnt :
@@ -950,7 +963,7 @@ def main():
950
963
auxxarray , auxyarray = getDataFromPanda (rumorMetricsPanda , None , "Country" , countriesList , 'counter' )
951
964
print ("Number of different Countries hosting Eth2 clients:" , len (auxxarray ))
952
965
# Remove the Countries with less than X peers
953
- countryLimit = 10
966
+ countryLimit = 60
954
967
xarray = []
955
968
yarray = []
956
969
for idx , item in enumerate (auxyarray ):
0 commit comments