| 1 |
|
| #!/usr/local/bin/perl |
| 2 |
|
| # |
| 3 |
|
| # Elisa Jasinska <elisa@bigwaveit.org> |
| 4 |
|
| # 12/19/2014 |
| 5 |
|
| # |
| 6 |
|
| # |
| 7 |
|
| # Copyright (c) 2006 - 2015 AMS-IX B.V. |
| 8 |
|
| # |
| 9 |
|
| # This package is free software and is provided "as is" without express |
| 10 |
|
| # or implied warranty. It may be used, redistributed and/or modified |
| 11 |
|
| # under the terms of the Perl Artistic License (see |
| 12 |
|
| # http://www.perl.com/perl/misc/Artistic.html) |
| 13 |
|
| # |
| 14 |
|
| |
| 15 |
|
| use strict; |
| 16 |
|
| use warnings; |
| 17 |
|
| |
| 18 |
|
| # command line options |
| 19 |
|
| use Getopt::Std; |
| 20 |
|
| |
| 21 |
|
| # to read a pcap file |
| 22 |
|
| use Net::Pcap; |
| 23 |
|
| |
| 24 |
|
| # to decode the packet |
| 25 |
|
| use NetPacket::Ethernet; |
| 26 |
|
| use NetPacket::IP; |
| 27 |
|
| use NetPacket::UDP; |
| 28 |
|
| |
| 29 |
|
| # sFlow module |
| 30 |
|
| use Net::sFlow; |
| 31 |
|
| |
| 32 |
|
| # to listen to socket |
| 33 |
|
| use IO::Socket::INET6; |
| 34 |
|
| |
| 35 |
|
| |
| 36 |
|
| |
| 37 |
|
| ############################################################################# |
| 38 |
|
| |
| 39 |
|
| # options |
| 40 |
|
| my %options = (); |
| 41 |
|
| |
| 42 |
|
| getopts("i:f:p:h", \%options) |
| 43 |
|
| or &usage; |
| 44 |
|
| |
| 45 |
|
| |
| 46 |
|
| # print the help |
| 47 |
|
| &usage if $options{h}; |
| 48 |
|
| |
| 49 |
|
| |
| 50 |
|
| # prepare arrays for print order |
| 51 |
|
| my $orderHashRef = &preparePrint; |
| 52 |
|
| |
| 53 |
|
| |
| 54 |
|
| # if switch -f read from pcap file |
| 55 |
|
| if (defined($options{f})) { |
| 56 |
|
| &readFile($orderHashRef); |
| 57 |
|
| } |
| 58 |
|
| |
| 59 |
|
| |
| 60 |
|
| # else just open udp socket |
| 61 |
|
| else { |
| 62 |
|
| &listenPort($orderHashRef); |
| 63 |
|
| } |
| 64 |
|
| |
| 65 |
|
| |
| 66 |
|
| |
| 67 |
|
| ############################################################################# |
| 68 |
|
| ################################# sub's ##################################### |
| 69 |
|
| ############################################################################# |
| 70 |
|
| |
| 71 |
|
| |
| 72 |
|
| sub usage { |
| 73 |
|
| |
| 74 |
|
| print |
| 75 |
|
| qq{usage: sFluxDebug.pl -h | -f filename | -p port -i (4|6) |
| 76 |
|
| -h : this (help) message |
| 77 |
|
| -f <file> : read from pcap file <file> |
| 78 |
|
| -i (4|6) : listen on v4 or v6 address |
| 79 |
|
| -p <port> : listen to port <port>\n}; |
| 80 |
|
| exit; |
| 81 |
|
| |
| 82 |
|
| } |
| 83 |
|
| |
| 84 |
|
| |
| 85 |
|
| ############################################################################# |
| 86 |
|
| |
| 87 |
|
| |
| 88 |
|
| sub readFile { |
| 89 |
|
| |
| 90 |
|
| my $orderHashRef = shift; |
| 91 |
|
| |
| 92 |
|
| my $err = undef; |
| 93 |
|
| |
| 94 |
|
| my $pcap = Net::Pcap::open_offline($options{f}, \$err) |
| 95 |
|
| or die "Can't read '$options{f}': $err\n"; |
| 96 |
|
| |
| 97 |
|
| Net::Pcap::loop($pcap, 0, \&processPcap, $orderHashRef); |
| 98 |
|
| Net::Pcap::close($pcap); |
| 99 |
|
| } |
| 100 |
|
| |
| 101 |
|
| |
| 102 |
|
| ############################################################################# |
| 103 |
|
| |
| 104 |
|
| |
| 105 |
|
| # in case of a pcap file we also use the pcap data |
| 106 |
|
| sub processPcap { |
| 107 |
|
| |
| 108 |
|
| my($orderHashRef, $header, $pcapPacket) = @_; |
| 109 |
|
| |
| 110 |
|
| print "\n\n-------------------------------------------------------------------------------\n"; |
| 111 |
|
| print "PCAP length: $header->{len} timestamp in sec: $header->{tv_sec}\n"; |
| 112 |
|
| |
| 113 |
|
| my %sFlowPacket = (); |
| 114 |
|
| |
| 115 |
|
| # unpack ethernet header |
| 116 |
|
| my $ethObj = NetPacket::Ethernet->decode($pcapPacket); |
| 117 |
|
| |
| 118 |
|
| $sFlowPacket{srcMac} = $ethObj->{src_mac}; |
| 119 |
|
| $sFlowPacket{destMac} = $ethObj->{dest_mac}; |
| 120 |
|
| $sFlowPacket{type} = $ethObj->{type}; |
| 121 |
|
| |
| 122 |
|
| # who came up with the idea to decode the ether type as 'n' in NetPacket?!?!?!? |
| 123 |
|
| if ($ethObj->{type} eq '33024') { |
| 124 |
|
| # cut off the vlan tag |
| 125 |
|
| ($sFlowPacket{vlanTag}, |
| 126 |
|
| $sFlowPacket{type}) = unpack ('nH4',$ethObj->{data}); |
| 127 |
|
| $ethObj->{data} = substr($ethObj->{data},4); |
| 128 |
|
| } |
| 129 |
|
| |
| 130 |
|
| # unpack ip header |
| 131 |
|
| my $ipObj = NetPacket::IP->decode($ethObj->{data}); |
| 132 |
|
| $sFlowPacket{srcIP} = $ipObj->{src_ip}; |
| 133 |
|
| $sFlowPacket{destIP} = $ipObj->{dest_ip}; |
| 134 |
|
| |
| 135 |
|
| # unpack udp header |
| 136 |
|
| my $udpObj = NetPacket::UDP->decode($ipObj->{data}); |
| 137 |
|
| $sFlowPacket{srcPort} = $udpObj->{src_port}; |
| 138 |
|
| $sFlowPacket{destPort} = $udpObj->{dest_port}; |
| 139 |
|
| |
| 140 |
|
| # more debug: |
| 141 |
|
| # print HexDump $udpObj->{data}; |
| 142 |
|
| |
| 143 |
|
| &processPacket(\%sFlowPacket, $udpObj->{data}, $orderHashRef); |
| 144 |
|
| } |
| 145 |
|
| |
| 146 |
|
| ############################################################################# |
| 147 |
|
| |
| 148 |
|
| |
| 149 |
|
| sub listenPort { |
| 150 |
|
| |
| 151 |
|
| my $orderHashRef = shift; |
| 152 |
|
| |
| 153 |
|
| my $port = undef; |
| 154 |
|
| my $packet = undef; |
| 155 |
|
| my $sock = undef; |
| 156 |
|
| |
| 157 |
|
| if (defined($options{p})) { |
| 158 |
|
| |
| 159 |
|
| $options{p} =~ /^\d+$/ and $options{p} > 0 |
| 160 |
|
| |
| 161 |
|
| or print("Port must be an integer > 0\n"), |
| 162 |
|
| &usage; |
| 163 |
|
| |
| 164 |
|
| $port = $options{p}; |
| 165 |
|
| } |
| 166 |
|
| |
| 167 |
|
| else { |
| 168 |
|
| $port = '6343'; |
| 169 |
|
| } |
| 170 |
|
| |
| 171 |
|
| if (defined($options{i}) and $options{i} eq "6") { |
| 172 |
|
| |
| 173 |
|
| $sock = IO::Socket::INET6->new( Domain => AF_INET6, |
| 174 |
|
| LocalPort => $port, |
| 175 |
|
| Proto => 'udp') |
| 176 |
|
| or die "Can't bind : $!\n"; |
| 177 |
|
| |
| 178 |
|
| } else { |
| 179 |
|
| |
| 180 |
|
| $sock = IO::Socket::INET6->new( Domain => AF_INET, |
| 181 |
|
| LocalPort => $port, |
| 182 |
|
| Proto => 'udp') |
| 183 |
|
| or die "Can't bind : $!\n"; |
| 184 |
|
| |
| 185 |
|
| } |
| 186 |
|
| |
| 187 |
|
| print "Port: $port\n"; |
| 188 |
|
| print "Listening...\n"; |
| 189 |
|
| |
| 190 |
|
| while ($sock->recv($packet,1548)) { |
| 191 |
|
| &processPacket(undef, $packet, $orderHashRef); |
| 192 |
|
| } |
| 193 |
|
| die "Socket recv: $!"; |
| 194 |
|
| |
| 195 |
|
| } |
| 196 |
|
| |
| 197 |
|
| |
| 198 |
|
| ############################################################################# |
| 199 |
|
| |
| 200 |
|
| |
| 201 |
|
| sub processPacket { |
| 202 |
|
| |
| 203 |
|
| my $sFlowPacketDataHashRef = shift; |
| 204 |
|
| my $sFlowPacket = shift; |
| 205 |
|
| my $orderHashRef = shift; |
| 206 |
|
| |
| 207 |
|
| my ($sFlowDatagramHashRef, $sFlowSamplesArrayRef, $errorsArrayRef) = |
| 208 |
|
| Net::sFlow::decode($sFlowPacket); |
| 209 |
|
| |
| 210 |
|
| &stdout($sFlowPacketDataHashRef, $sFlowDatagramHashRef, $sFlowSamplesArrayRef, $orderHashRef); |
| 211 |
|
| |
| 212 |
|
| foreach my $error (@{$errorsArrayRef}) { |
| 213 |
|
| print "$error\n"; |
| 214 |
|
| } |
| 215 |
|
| |
| 216 |
|
| } |
| 217 |
|
| |
| 218 |
|
| |
| 219 |
|
| |
| 220 |
|
| ############################################################################# |
| 221 |
|
| |
| 222 |
|
| |
| 223 |
|
| sub preparePrint { |
| 224 |
|
| |
| 225 |
|
| my @packetOrder = ( |
| 226 |
|
| "srcMac", |
| 227 |
|
| "destMac", |
| 228 |
|
| "vlanTag", |
| 229 |
|
| "type", |
| 230 |
|
| "srcIP", |
| 231 |
|
| "destIP", |
| 232 |
|
| "srcPort", |
| 233 |
|
| "destPort" |
| 234 |
|
| ); |
| 235 |
|
| |
| 236 |
|
| my @datagramOrder = ( |
| 237 |
|
| "sFlowVersion", |
| 238 |
|
| "AgentIpVersion", |
| 239 |
|
| "AgentIp", |
| 240 |
|
| "subAgentId", |
| 241 |
|
| "datagramSequenceNumber", |
| 242 |
|
| "agentUptime", |
| 243 |
|
| "samplesInPacket" |
| 244 |
|
| ); |
| 245 |
|
| |
| 246 |
|
| my @sampleOrder = ( |
| 247 |
|
| "sampleType", |
| 248 |
|
| |
| 249 |
|
| "sampleTypeEnterprise", |
| 250 |
|
| "sampleTypeFormat", |
| 251 |
|
| "sampleLength", |
| 252 |
|
| |
| 253 |
|
| "FoundryFlags", |
| 254 |
|
| "FoundryGroupID", |
| 255 |
|
| |
| 256 |
|
| "sampleSequenceNumber", |
| 257 |
|
| "sourceIdType", |
| 258 |
|
| "sourceIdIndex", |
| 259 |
|
| "samplingRate", |
| 260 |
|
| "samplePool", |
| 261 |
|
| "drops", |
| 262 |
|
| "inputInterface", |
| 263 |
|
| "outputInterface", |
| 264 |
|
| |
| 265 |
|
| "inputInterfaceFormat", |
| 266 |
|
| "inputInterfaceValue", |
| 267 |
|
| "outputInterfaceFormat", |
| 268 |
|
| "outputInterfaceValue", |
| 269 |
|
| |
| 270 |
|
| "packetDataType", |
| 271 |
|
| "extendedDataInSample", |
| 272 |
|
| |
| 273 |
|
| "counterSamplingInterval", |
| 274 |
|
| "countersVersion", |
| 275 |
|
| "counterDataLength", |
| 276 |
|
| |
| 277 |
|
| "flowRecordsCount", |
| 278 |
|
| |
| 279 |
|
| "HEADERDATA", |
| 280 |
|
| "HeaderProtocol", |
| 281 |
|
| "HeaderFrameLength", |
| 282 |
|
| "HeaderStrippedLength", |
| 283 |
|
| "HeaderSizeByte", |
| 284 |
|
| "HeaderSizeBit", |
| 285 |
|
| "HeaderEtherSrcMac", |
| 286 |
|
| "HeaderEtherDestMac", |
| 287 |
|
| "HeaderType", |
| 288 |
|
| "HeaderVer", |
| 289 |
|
| "HeaderTclass", |
| 290 |
|
| "HeaderFlabel", |
| 291 |
|
| "HeaderDatalen", |
| 292 |
|
| "HeaderNexth", |
| 293 |
|
| "HeaderProto", |
| 294 |
|
| "HeaderHlim", |
| 295 |
|
| "HeaderSrcIP", |
| 296 |
|
| "HeaderDestIP", |
| 297 |
|
| "HeaderTCPSrcPort", |
| 298 |
|
| "HeaderTCPDestPort", |
| 299 |
|
| "HeaderUDPSrcPort", |
| 300 |
|
| "HeaderUDPDestPort", |
| 301 |
|
| "HeaderICMP", |
| 302 |
|
| "NoTransportLayer", |
| 303 |
|
| |
| 304 |
|
| "ETHERNETFRAMEDATA", |
| 305 |
|
| "EtherMacPacketlength", |
| 306 |
|
| "EtherSrcMac", |
| 307 |
|
| "EtherDestMac", |
| 308 |
|
| "EtherPackettype", |
| 309 |
|
| |
| 310 |
|
| "IPv4DATA", |
| 311 |
|
| "IPv4Packetlength", |
| 312 |
|
| "IPv4NextHeaderProtocol", |
| 313 |
|
| "IPv4srcIp", |
| 314 |
|
| "IPv4destIp", |
| 315 |
|
| "IPv4srcPort", |
| 316 |
|
| "IPv4destPort", |
| 317 |
|
| "IPv4tcpFlags", |
| 318 |
|
| "IPv4tos", |
| 319 |
|
| |
| 320 |
|
| "IPv6DATA", |
| 321 |
|
| "IPv6Packetlength", |
| 322 |
|
| "IPv6NextHeaderProto", |
| 323 |
|
| "IPv6srcIp", |
| 324 |
|
| "IPv6destIp", |
| 325 |
|
| "IPv6srcPort", |
| 326 |
|
| "IPv6destPort", |
| 327 |
|
| "IPv6tcpFlags", |
| 328 |
|
| "IPv6Priority", |
| 329 |
|
| |
| 330 |
|
| "SWITCHDATA", |
| 331 |
|
| "SwitchSrcVlan", |
| 332 |
|
| "SwitchSrcPriority", |
| 333 |
|
| "SwitchDestVlan", |
| 334 |
|
| "SwitchDestPriority", |
| 335 |
|
| |
| 336 |
|
| "ROUTERDATA", |
| 337 |
|
| "RouterIpVersionNextHopRouter", |
| 338 |
|
| "RouterIpAddressNextHopRouter", |
| 339 |
|
| "RouterSrcMask", |
| 340 |
|
| "RouterDestMask", |
| 341 |
|
| |
| 342 |
|
| "GATEWAYDATA", |
| 343 |
|
| "GatewayIpVersionNextHopRouter", |
| 344 |
|
| "GatewayIpAddressNextHopRouter", |
| 345 |
|
| "GatewayAsRouter", |
| 346 |
|
| "GatewayAsSource", |
| 347 |
|
| "GatewayAsSourcePeer", |
| 348 |
|
| "GatewayDestAsPathsCount", |
| 349 |
|
| "GatewayDestAsPaths", |
| 350 |
|
| "GatewayLengthCommunitiesList", |
| 351 |
|
| "GatewayCommunities", |
| 352 |
|
| "localPref", |
| 353 |
|
| |
| 354 |
|
| "USERDATA", |
| 355 |
|
| "UserSrcCharset", |
| 356 |
|
| "UserLengthSrcString", |
| 357 |
|
| "UserSrcString", |
| 358 |
|
| "UserDestCharset", |
| 359 |
|
| "UserLengthDestString", |
| 360 |
|
| "UserDestString", |
| 361 |
|
| |
| 362 |
|
| "URLDATA", |
| 363 |
|
| "UrlDirection", |
| 364 |
|
| "UrlLength", |
| 365 |
|
| "Url", |
| 366 |
|
| "UrlHostLength", |
| 367 |
|
| "UrlHost", |
| 368 |
|
| |
| 369 |
|
| "MPLSDATA", |
| 370 |
|
| "MplsIpVersionNextHopRouter", |
| 371 |
|
| "MplsIpAddressNextHopRouter", |
| 372 |
|
| "MplsInLabesStackCount", |
| 373 |
|
| # MplsInLabelStackArray |
| 374 |
|
| "MplsOutLabelStackCount", |
| 375 |
|
| # MplsOutLabelStackArray |
| 376 |
|
| |
| 377 |
|
| "NATDATA", |
| 378 |
|
| "NatIpVersionSrcAddress", |
| 379 |
|
| "NatSrcAddress", |
| 380 |
|
| "NatIpVersionDestAddress", |
| 381 |
|
| "NatDestAddress", |
| 382 |
|
| |
| 383 |
|
| "MPLSTUNNEL", |
| 384 |
|
| "MplsTunnelNameLength", |
| 385 |
|
| "MplsTunnelName", |
| 386 |
|
| "MplsTunnelId", |
| 387 |
|
| "MplsTunnelCosValue", |
| 388 |
|
| |
| 389 |
|
| "MPLSVC", |
| 390 |
|
| "MplsVcInstanceNameLength", |
| 391 |
|
| "MplsVcInstanceName", |
| 392 |
|
| "MplsVcId", |
| 393 |
|
| "MplsVcLabelCosValue", |
| 394 |
|
| |
| 395 |
|
| "MPLSFEC", |
| 396 |
|
| "MplsFtnDescrLength", |
| 397 |
|
| "MplsFtnDescr", |
| 398 |
|
| "MplsFtnMask", |
| 399 |
|
| |
| 400 |
|
| "MPLSLPVFEC", |
| 401 |
|
| "MplsFecAddrPrefixLength", |
| 402 |
|
| |
| 403 |
|
| "VLANTUNNEL", |
| 404 |
|
| "VlanTunnelLayerStackCount", |
| 405 |
|
| # VlanTunnelLayerStackArray |
| 406 |
|
| |
| 407 |
|
| "COUNTERGENERIC", |
| 408 |
|
| "ifIndex", |
| 409 |
|
| "ifType", |
| 410 |
|
| "ifSpeed", |
| 411 |
|
| "ifDirection", |
| 412 |
|
| "ifAdminStatus", |
| 413 |
|
| "ifOperStatus", |
| 414 |
|
| "ifInOctets", |
| 415 |
|
| "ifInUcastPkts", |
| 416 |
|
| "ifInMulticastPkts", |
| 417 |
|
| "ifInBroadcastPkts", |
| 418 |
|
| "ifInDiscards", |
| 419 |
|
| "ifInErrors", |
| 420 |
|
| "ifInUnknownProtos", |
| 421 |
|
| "ifOutOctets", |
| 422 |
|
| "ifOutUcastPkts", |
| 423 |
|
| "ifOutMulticastPkts", |
| 424 |
|
| "ifOutBroadcastPkts", |
| 425 |
|
| "ifOutDiscards", |
| 426 |
|
| "ifOutErrors", |
| 427 |
|
| "ifPromiscuousMode", |
| 428 |
|
| |
| 429 |
|
| "COUNTERETHERNET", |
| 430 |
|
| "dot3StatsAlignmentErrors", |
| 431 |
|
| "dot3StatsFCSErrors", |
| 432 |
|
| "dot3StatsSingleCollisionFrames", |
| 433 |
|
| "dot3StatsMultipleCollisionFrames", |
| 434 |
|
| "dot3StatsSQETestErrors", |
| 435 |
|
| "dot3StatsDeferredTransmissions", |
| 436 |
|
| "dot3StatsLateCollisions", |
| 437 |
|
| "dot3StatsExcessiveCollisions", |
| 438 |
|
| "dot3StatsInternalMacTransmitErrors", |
| 439 |
|
| "dot3StatsCarrierSenseErrors", |
| 440 |
|
| "dot3StatsFrameTooLongs", |
| 441 |
|
| "dot3StatsInternalMacReceiveErrors", |
| 442 |
|
| "dot3StatsSymbolErrors", |
| 443 |
|
| |
| 444 |
|
| "COUNTERTOKENRING", |
| 445 |
|
| "dot5StatsLineErrors", |
| 446 |
|
| "dot5StatsBurstErrors", |
| 447 |
|
| "dot5StatsACErrors", |
| 448 |
|
| "dot5StatsAbortTransErrors", |
| 449 |
|
| "dot5StatsInternalErrors", |
| 450 |
|
| "dot5StatsLostFrameErrors", |
| 451 |
|
| "dot5StatsReceiveCongestions", |
| 452 |
|
| "dot5StatsFrameCopiedErrors", |
| 453 |
|
| "dot5StatsTokenErrors", |
| 454 |
|
| "dot5StatsSoftErrors", |
| 455 |
|
| "dot5StatsHardErrors", |
| 456 |
|
| "dot5StatsSignalLoss", |
| 457 |
|
| "dot5StatsTransmitBeacons", |
| 458 |
|
| "dot5StatsRecoverys", |
| 459 |
|
| "dot5StatsLobeWires", |
| 460 |
|
| "dot5StatsRemoves", |
| 461 |
|
| "dot5StatsSingles", |
| 462 |
|
| "dot5StatsFreqErrors", |
| 463 |
|
| |
| 464 |
|
| "COUNTERVG", |
| 465 |
|
| "dot12InHighPriorityFrames", |
| 466 |
|
| "dot12InHighPriorityOctets", |
| 467 |
|
| "dot12InNormPriorityFrames", |
| 468 |
|
| "dot12InNormPriorityOctets", |
| 469 |
|
| "dot12InIPMErrors", |
| 470 |
|
| "dot12InOversizeFrameErrors", |
| 471 |
|
| "dot12InDataErrors", |
| 472 |
|
| "dot12InNullAddressedFrames", |
| 473 |
|
| "dot12OutHighPriorityFrames", |
| 474 |
|
| "dot12OutHighPriorityOctets", |
| 475 |
|
| "dot12TransitionIntoTrainings", |
| 476 |
|
| "dot12HCInHighPriorityOctets", |
| 477 |
|
| "dot12HCInNormPriorityOctets", |
| 478 |
|
| "dot12HCOutHighPriorityOctets", |
| 479 |
|
| |
| 480 |
|
| "COUNTERVLAN", |
| 481 |
|
| "vlan_id", |
| 482 |
|
| "octets", |
| 483 |
|
| "ucastPkts", |
| 484 |
|
| "multicastPkts", |
| 485 |
|
| "broadcastPkts", |
| 486 |
|
| "discards", |
| 487 |
|
| |
| 488 |
|
| "COUNTERLAG", |
| 489 |
|
| "dot3adAggPortActorSystemID", |
| 490 |
|
| "dot3adAggPortPartnerOperSystemID", |
| 491 |
|
| "dot3adAggPortAttachedAggID", |
| 492 |
|
| "dot3adAggPortActorAdminState", |
| 493 |
|
| "dot3adAggPortActorOperState", |
| 494 |
|
| "dot3adAggPortPartnerAdminState", |
| 495 |
|
| "dot3adAggPortPartnerOperState", |
| 496 |
|
| "dot3adAggPortStatsLACPDUsRx", |
| 497 |
|
| "dot3adAggPortStatsMarkerPDUsRx", |
| 498 |
|
| "dot3adAggPortStatsMarkerResponsePDUsRx", |
| 499 |
|
| "dot3adAggPortStatsUnknownRx", |
| 500 |
|
| "dot3adAggPortStatsIllegalRx", |
| 501 |
|
| "dot3adAggPortStatsLACPDUsTx", |
| 502 |
|
| "dot3adAggPortStatsMarkerPDUsTx", |
| 503 |
|
| "dot3adAggPortStatsMarkerResponsePDUsTx", |
| 504 |
|
| |
| 505 |
|
| "COUNTERPROCESSOR", |
| 506 |
|
| "cpu5s", |
| 507 |
|
| "cpu1m", |
| 508 |
|
| "cpu5m", |
| 509 |
|
| "memoryTotal", |
| 510 |
|
| "memoryFree" |
| 511 |
|
| ); |
| 512 |
|
| |
| 513 |
|
| my %orderHash = ( |
| 514 |
|
| 'packetOrder' => \@packetOrder, |
| 515 |
|
| 'datagramOrder' => \@datagramOrder, |
| 516 |
|
| 'sampleOrder' => \@sampleOrder |
| 517 |
|
| ); |
| 518 |
|
| |
| 519 |
|
| return(\%orderHash); |
| 520 |
|
| |
| 521 |
|
| } |
| 522 |
|
| |
| 523 |
|
| |
| 524 |
|
| |
| 525 |
|
| ############################################################################# |
| 526 |
|
| |
| 527 |
|
| |
| 528 |
|
| sub stdout { |
| 529 |
|
| |
| 530 |
|
| my $sFlowPacketDataHashRef = shift; |
| 531 |
|
| my $sFlowDatagramHashRef = shift; |
| 532 |
|
| my $sFlowSamplesArrayRef = shift; |
| 533 |
|
| my $orderHashRef = shift; |
| 534 |
|
| |
| 535 |
|
| if (defined($sFlowPacketDataHashRef)) { |
| 536 |
|
| print "\n"; |
| 537 |
|
| print "===PcapData===\n"; |
| 538 |
|
| foreach my $packetOrder (@{$orderHashRef->{packetOrder}}) { |
| 539 |
|
| if (defined($sFlowPacketDataHashRef->{$packetOrder})) { |
| 540 |
|
| print "$packetOrder => $sFlowPacketDataHashRef->{$packetOrder}\n"; |
| 541 |
|
| } |
| 542 |
|
| } |
| 543 |
|
| } |
| 544 |
|
| |
| 545 |
|
| print "\n\n"; |
| 546 |
|
| print "===Datagram===\n"; |
| 547 |
|
| foreach my $datagramOrder (@{$orderHashRef->{datagramOrder}}) { |
| 548 |
|
| if (defined($sFlowDatagramHashRef->{$datagramOrder})) { |
| 549 |
|
| print "$datagramOrder => $sFlowDatagramHashRef->{$datagramOrder}\n"; |
| 550 |
|
| } |
| 551 |
|
| } |
| 552 |
|
| |
| 553 |
|
| foreach my $sFlowSampleHashRef (@{$sFlowSamplesArrayRef}) { |
| 554 |
|
| print "\n"; |
| 555 |
|
| print "---Sample---\n"; |
| 556 |
|
| foreach my $sampleOrder (@{$orderHashRef->{sampleOrder}}) { |
| 557 |
|
| |
| 558 |
|
| if (defined($sFlowSampleHashRef->{$sampleOrder})) { |
| 559 |
|
| |
| 560 |
|
| if ($sampleOrder eq "GatewayDestAsPaths") { |
| 561 |
|
| foreach my $GatewayDestAsPath (@{$sFlowSampleHashRef->{$sampleOrder}}) { |
| 562 |
|
| print " asPathSegmentType => $GatewayDestAsPath->{asPathSegmentType}\n"; |
| 563 |
|
| print " lengthAsList => $GatewayDestAsPath->{lengthAsList}\n"; |
| 564 |
|
| foreach my $as (@{$GatewayDestAsPath->{AsPath}}) { |
| 565 |
|
| print " as nr. => $as\n"; |
| 566 |
|
| } |
| 567 |
|
| } |
| 568 |
|
| } |
| 569 |
|
| |
| 570 |
|
| elsif ($sampleOrder eq "GatewayCommunities") { |
| 571 |
|
| print " GatewayCommunities => @{$sFlowSampleHashRef->{GatewayCommunities}}\n"; |
| 572 |
|
| } |
| 573 |
|
| |
| 574 |
|
| elsif ($sampleOrder eq "HeaderEtherSrcMac") { |
| 575 |
|
| my ($sm_hi, $sm_lo) = unpack("Nn",$sFlowSampleHashRef->{HeaderEtherSrcMac}); |
| 576 |
|
| $sFlowSampleHashRef->{HeaderEtherSrcMac} = sprintf("%08x%04x", $sm_hi, $sm_lo); |
| 577 |
|
| print "HeaderEtherSrcMac => $sFlowSampleHashRef->{HeaderEtherSrcMac}\n"; |
| 578 |
|
| } |
| 579 |
|
| |
| 580 |
|
| elsif ($sampleOrder eq "HeaderEtherDestMac") { |
| 581 |
|
| my ($dm_hi, $dm_lo) = unpack("Nn",$sFlowSampleHashRef->{HeaderEtherDestMac}); |
| 582 |
|
| $sFlowSampleHashRef->{HeaderEtherDestMac} = sprintf("%08x%04x", $dm_hi, $dm_lo); |
| 583 |
|
| print "HeaderEtherDestMac => $sFlowSampleHashRef->{HeaderEtherDestMac}\n"; |
| 584 |
|
| } |
| 585 |
|
| |
| 586 |
|
| else { |
| 587 |
|
| print "$sampleOrder => $sFlowSampleHashRef->{$sampleOrder}\n"; |
| 588 |
|
| } |
| 589 |
|
| } |
| 590 |
|
| } |
| 591 |
|
| } |
| 592 |
|
| |
| 593 |
|
| } |
| 594 |
|
| |