summaryrefslogtreecommitdiffstats
path: root/Monitoring/MonitoringTool/PacketTracking/Monitoring/PassiveMonitoring.py
blob: 00187881083b2b79862891f853871fc8b9179d0c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
"""
Copyright (c) 2012, NOVI Consortium, European FP7 NOVI Project
Copyright according to BSD License
For full text of the license see: ./novi/Software/Monitoring/MonitoringTool/PacketTracking/license.txt

@author <a href="mailto:ramon.masek@fokus.fraunhofer.de">Ramon Masek</a>, Fraunhofer FOKUS
@author <a href="mailto:c.henke@tu-berlin.de">Christian Henke</a>, Technical University Berlin
@author <a href="mailto:carsten.schmoll@fokus.fraunhofer.de">Carsten Schmoll</a>, Fraunhofer FOKUS
@author <a href="mailto:Julian.Vetter@campus.tu-berlin.de">Julian Vetter</a>, Fraunhofer FOKUS
@author <a href="mailto:">Jens Krenzin</a>, Fraunhofer FOKUS
@author <a href="mailto:">Michael Gehring</a>, Fraunhofer FOKUS
@author <a href="mailto:">Tacio Grespan Santos</a>, Fraunhofer FOKUS
@author <a href="mailto:">Fabian Wolff</a>, Fraunhofer FOKUS
"""

from Task.Passive.Monitoring.Aggregator import Aggregator

class PassiveMonitoring(object):
    
    def __init__(self):
        self.__Aggregator = Aggregator()
            
    
    # PT Actions
    # 1.
    def getPtVolumeStats(self, startTime, stopTime, nodeList):
        """
        Function to retrieve the observed traffic in the time intervall defined
        between startTime and stopTime. Traffic means, packet/byte count for
        each node in the list.
        @type startTime:     struct_time
        @param startTime:    A sequence of 9 integers, as returned from
                             gmtime(), localtime() or strptime().
        @type stopTime:      struct_time
        @param stopTime:     A sequence of 9 integers, as returned from
                             gmtime(), localtime() or strptime().
        @type nodeList:      list
        @param nodeList:     List of nodes, whereby a node is one installed
                             monitoring probe.
        @rtype:              PtVolumeStats (list)
        @return:             (At least) number of packets and bytes observed by
                             a node.
        """
        return self.__Aggregator.getPtVolumeStats(startTime, stopTime, nodeList)
    
    # 2.
    def getPtHopStats(self, startTime, stopTime, nodeList2D):
        """
        Function to retrieve the observed traffic statistics in the time
        intervall defined between startTime and stopTime. Statistics mean
        packet/byte count and min/max/avg delay between each adjacent node/node
        pair.
        @type startTime:     struct_time
        @param startTime:    A sequence of 9 integers, as returned from
                             gmtime(), localtime() or strptime().
        @type StopTime:      struct_time
        @param StopTime:     A sequence of 9 integers, as returned from
                             gmtime(), localtime() or strptime().
        @type nodeList2D:    list
        @param nodeList2D:   A List of <first, second> Node pairs.
        @rtype:              PtHopStats (list)
        @return:             Packet tracking Hop statistics, i.e. delay/volume
                             statistics between two neighbor PT probes
        """
        return self.__Aggregator.getPtHopStats(startTime, stopTime, nodeList2D)
      
    # 3.
    def getPtPathStats(self, startTime, stopTime, nodeTuple):
        """
        Function to retrieve the observed traffic statistics in the time
        intervall defined between StartTime and StopTime. Statistics mean
        packet/byte count and min/max/avg delay between each node/node pair.
        @type startTime:     struct_time
        @param startTime:    A sequence of 9 integers, as returned from
                             gmtime(), localtime() or strptime().
        @type stopTime:      struct_time
        @param stopTime:     A sequence of 9 integers, as returned from
                             gmtime(), localtime() or strptime().
        @type nodeTuple:     tuple
        @param nodeTuple:    A pair of nodes represented as a 'tuple' datatype
        @rtype:              PtPathStats (list)
        @return:             Packet tracking Hop statistics, i.e. delay/volume
                             statistics between any two PT probes
        """
        return self.__Aggregator.getPtPathStats(startTime, stopTime, nodeTuple)
        
    # 4.
    def getPtActivity(self, startTime, stopTime, nodeList):
        """
        Returns the 'activity' for each node in the list. Activity is defined
        as a percentage [0-100%] of interval startTime to stopTime . If no
        packet is observed in this defined time interval the function returns
        zero, otherwise the function returns a positive non-zero value. It also
        depends on the configured activity threshold (timeout), which is set by
        the function 'setPtActivityThreshold'.
        @type startTime:     struct_time
        @param startTime:    A sequence of 9 integers, as returned from
                             gmtime(), localtime() or strptime().
        @type stopTime:      struct_time
        @param stopTime:     A sequence of 9 integers, as returned from
                             gmtime(), localtime() or strptime().
        @type nodeList:      list
        @param nodeList:     List of nodes, whereby a node is one installed
                             monitoring probe.
        @rtype:              PtActivity
        @return:             Amount of time when there was live traffic
                             observed at a node.
        """
        return self.__Aggregator.getPtActivity(startTime, stopTime, nodeList)
    
    # Pt Management (Impd4e + Collector)
    # 1.
    def restartPtCollector(self):
        """
        Method to restart the Collector.
        @rtype:              Status
        @return:             Placeholder for return error handling, i.e.
                             "Success" or specific Exception.
        """
        return self.__Aggregator.restartPtCollector()
    
    # 2.
    def restartPtProbes(self, nodeList):
        """
        Method to restart the probes on all the selected Nodes.
        @rtype:              Status
        @return:             Placeholder for return error handling, i.e.
                             "Success" or specific Exception.
        """
        return self.__Aggregator.restartPtProbes(nodeList)
    
    # 3.
    def purgePtDatabase(self, startTime, stopTime):
        """
        Function to purge the observed track information from the database
        (Only for administrative purposes).
        @type startTime:     struct_time
        @param startTime:    A sequence of 9 integers, as returned from
                             gmtime(), localtime() or strptime().
        @type stopTime:      struct_time
        @param stopTime:     A sequence of 9 integers, as returned from
                             gmtime(), localtime() or strptime().
        @rtype:              Status
        @return:             Placeholder for return error handling, i.e.
                             "Success" or specific Exception.
        """
        return self.__Aggregator.purgePtDatabase(startTime, stopTime)
     
    # 4.
    def setPtHashRange(self, range):
        """
        Sets the hash range for the hashing algorithm, value must be between 1
        and 100. The higher, the more packets are selected by the hashing
        function. 100 - Means, all packets are selected.
        @type range:         int
        @param range:        A value between 1 and 100.
        @rtype:              Status
        @return:             Placeholder for return error handling, i.e.
                             "Success" or specific Exception.
        """
        return self.__Aggregator.setPtHashRange(range)
    
    # 5.
    def setPtHashFunction(self, hashFunction):
        """
        The PT probe provides different hashing functions to do the packet
        selection. Possible parameters are: "BOB", "OAAT", "TWMX", "HSIEH
        @type hashFunction:  str
        @param hashFunction: A short string representing the hashing function.
        @rtype:              Status
        @return:             Placeholder for return error handling, i.e.
                             "Success" or specific Exception.
        """
        return self.__Aggregator.setPtHashFunction(hashFunction)
    
    # 6.
    def setPtActivityThreshold(self, timeMSec):
        """
        Function to adjust the activity threshold. Increasing this value in
        effect reduces the probability to receive a "0 - no activity" from the
        function 'getPtActivity'.
        @type timeMSec:        int
        @param timeMSec:       A time value in milliseconds.
        @rtype:                Status
        @return:               Placeholder for return error handling, i.e.
                               "Success" or specific Exception.
        """
        return self.__Aggregator.setPtActivityThreshold(timeMSec)
    
    # PT Visualization (Netview)
    # 1.
    def viewPtPathTracks(self, startTime, stopTime, nodeList):
        """
        Starts a GUI application and displays the path defined by the nodeList,
        in the time interval, defined by startTime and stopTime.
        @type startTime:     struct_time
        @param startTime:    A sequence of 9 integers, as returned from
                             gmtime(), localtime() or strptime().
        @type stopTime:      struct_time
        @param stopTime:     A sequence of 9 integers, as returned from
                             gmtime(), localtime() or strptime().
        @type nodeList:      list
        @param nodeList:     List of nodes, whereby a node is one installed
                             monitoring probe.
        @rtype:              Status
        @return:             Placeholder for return error handling, i.e.
                             "Success" or specific Exception.
        """
        return self.__Aggregator.viewPtPathTracks(startTime, stopTime, nodeList)
    
    # 2.
    def viewPtHopTracks(self, startTime, stopTime, nodeList2D):
        """
        Starts a GUI application and displays the hop defined by the node
        vector, in the time interval, defined by startTime and stopTime.
        @type startTime:     struct_time
        @param startTime:    A sequence of 9 integers, as returned from
                             gmtime(), localtime() or strptime().
        @type stopTime:      struct_time
        @param StopTime:     A sequence of 9 integers, as returned from
                             gmtime(), localtime() or strptime().
        @type nodeList2D:    list
        @param nodeList2D:   A List of node tuples (src, dst).
        @rtype:              Status
        @return:             Placeholder for return error handling, i.e.
                             "Success" or specific Exception.
        """
        return self.__Aggregator.viewPtHopTracks(startTime, stopTime, nodeList2D)

    # 3.
    def plotPtPathStats(self, startTime, stopTime, nodeList):
        """
        Plots the delay stats in a X/Y-plot for a hop between two nodes given
        by the nodeList, in the time interval defined by startTime and stopTime.
        @type startTime:     struct_time
        @param startTime:    A sequence of 9 integers, as returned from
                             gmtime(), localtime() or strptime().
        @type stopTime:      struct_time
        @param stopTime:     A sequence of 9 integers, as returned from
                             gmtime(), localtime() or strptime().
        @type nodeList:      list
        @param nodeList:     List of nodes, whereby a node is one installed
                             monitoring probe.
        @rtype:              Status
        @return:             Placeholder for return error handling, i.e.
                             "Success" or specific Exception.
        """
        return self.__Aggregator.plotPtPathStats(startTime, stopTime, nodeList)
    
    # 4.
    def plotPtHopStats(self, startTime, stopTime, nodeList2D):
        """
        Plots the delay stats in a X/Y-plot for a path between multiple nodes
        given by the nodeList, in the time interval defined by startTime and
        stopTime.
        @type startTime:     struct_time
        @param startTime:    A sequence of 9 integers, as returned from
                             gmtime(), localtime() or strptime().
        @type stopTime:      struct_time
        @param stopTime:     A sequence of 9 integers, as returned from
                             gmtime(), localtime() or strptime().
        @type nodeList2D:    list
        @param nodeList2D:   A List of <first, second> Node pairs.
        @rtype:              Status
        @return:             Placeholder for return error handling, i.e.
                             "Success" or specific Exception.
        """
        return self.__Aggregator.plotPtHopStats(startTime, stopTime, nodeList2D)