| net :: flow. NET :: FLOW´Â NETFLOW / IPFIX µ¥ÀÌÅÍ ±×·¥À» µðÄÚµùÇÏ°í ÀÎÄÚµùÇÏ´Â µ¥ »ç¿ëµÇ´Â PERL ¸ðµâÀÔ´Ï´Ù. |
Áö±Ý ´Ù¿î·Îµå |
net :: flow. ¼øÀ§ ¹× ¿ä¾à
- ƯÇã:
- Perl Artistic License
- °Ô½ÃÀÚ À̸§:
- Atsushi Kobayashi
- °Ô½ÃÀÚ À¥»çÀÌÆ®:
- http://search.cpan.org/~akoba/Net-Flow-0.03/lib/Net/Flow.pm
net :: flow. ű×
net :: flow. ¼³¸í
net :: flow´Â netflow / ipfix µ¥ÀÌÅÍ ±×·¥À» µðÄÚµùÇÏ°í ÀÎÄÚµùÇÏ´Â µ¥ »ç¿ëµÇ´Â perl ¸ðµâÀÔ´Ï´Ù. Net :: Flow´Â NetFlow / IPFix DatagramÀ» µðÄÚµùÇÏ°í ÀÎÄÚµùÇÏ´Â µ¥ »ç¿ëµÇ´Â Perl ¸ðµâÀÔ´Ï´Ù. NetFlow V5, V9 ¹× IPFIXÀÇ Ãâ·Â È帧 ·¹ÄÚµå - ´ÙÀ½ ½ºÅ©¸³Æ®´Â NetFlow / IPFix µ¥ÀÌÅÍ ±×·¥À» µðÄÚµù ÇÑ ÈÄ¿¡ ¼ö½Å µÈ È帧 ·¹Äڵ带 Ãâ·ÂÇÕ´Ï´Ù. NetFlow V5, V9 ¹× IPFIX¸¦ ±¸¹® ºÐ¼® ÇÒ ¼ö ÀÖ½À´Ï´Ù. NetFlow v9 / ipfix µ¥ÀÌÅÍ ±×·¥À» ¹ÞÀ¸¸é NetFlow / IPFixÀÇ ¿©·¯ ÅÛÇø´À» ¹è¿ ÂüÁ¶·Î À¯ÁöÇÒ ¼ö ÀÖ½À´Ï´Ù $ TemplateArrayRef. ÀÔ·Â ¸Å°³ º¯¼ö·Î Ãß°¡ÇÏ¿© ÅÛÇø´¾øÀÌ NetFlow / IPFIX µ¥ÀÌÅÍ ±×·¥À» ±¸¹® ºÐ¼® ÇÒ ¼ö ÀÖ½À´Ï´Ù. ¼ö½Å µÈ ÆÐŶÀÌ µ¿ÀÏÇÑ ÅÛÇø´ ID¸¦ °®´Â °æ¿ìÀÌ ÅÛÇø´Àº »õ ÅÛÇø´À¸·Î µ¤¾î ¾¹´Ï´Ù. ¾ö°ÝÇÑ »ç¿ë; Net :: Flow QW (µðÄÚµå)¸¦ »ç¿ëÇϽʽÿÀ. IO :: Socket :: INET; MY $ RECERECE_PORT = 9993; ³» $ Packet = undef; ³» $ TemplateArrayRef = undef; ³» $ sock = io :: socke :: inet-> new (localport => $ secrect_port, proto => 'udp'); while ($ sock-> recv ($ Packet, 1548)) {My ($ headerhashref, $ templateArrayref, $ flowarrayref, $ erroryref) = net :: flow :: decode ($ ÆÐŶ, $ templateArrayref); grep {$ _n "} @ {$ ERRORSARRAYREF} (@ {$ ERRORSARRAYREF}); "n- Çì´õ Á¤º¸ -n"Àμâ; ³» $ Å° (Å° % {$ headerhashref} Á¤·Ä) {printf "% s = n", $ Å°, $ headerhashref -> {$ Å°}; } $ templateref (@ {$ templateArrayref}) {Àμâ "n--- ÅÛÇø´ Á¤º¸ --n"; $ TEMPKEY (% {$ TemplateRef} Á¤·Ä) {($ tempkey eq "ÅÛÇø´") {printf "% s = n", $ tempkey; foreach my $ ref (@ {$ templateRef -> {ÅÛÇø´}}) {foreach my $ key (Å° % {$ ref}) {printf "% s = d", $ Å°, $ ref -> {$ Å°} ...¿¡ } "n"À» ÀμâÇϽʽÿÀ; }} else {printf "% s = = n", $ tempkey, $ templateref -> {$ tempkey}; }}} $ flowref (@ {$ flowarrayref}) {print "n-- È帧 Á¤º¸ --n"; ³» $ ID (Å° % {$ flowref} Á¤·Ä) {($ ID eq "setID") {(Àμâ "$ ID = $ flowref -> {$ ID} n"; } else {printf "id = d °ª = % sn", $ id, unfack ( "h *", $ flowref -> {$ id}); }}}} ¿¹Á¦ # 2 - NetFlow V5¿¡¼ NetFlow V9·Î ÇÁ·ÎÅäÄÝÀ» º¯È¯ÇÕ´Ï´Ù. ´ÙÀ½ ½ºÅ©¸³Æ®´Â NetFlow V5¿¡¼ NetFlow V9¿¡¼ NetFlow V9·Î º¯È¯ÇÕ´Ï´Ù. óÀ½¿¡´Â NetFlow V5 µ¥ÀÌÅÍ ±×·¥À» µðÄÚµùÇÕ´Ï´Ù. ±× ÈÄ, ÀÌ·¯ÇÑ È帧 ·¹ÄÚµå´Â »ùÇøµ °£°Ý ¹× »ùÇøµ ¸ðµå¸¦ Æ÷ÇÔÇϴ ƯÁ¤ ÅÛÇø®Æ®¿¡ µû¶ó NetFlow V9·Î ÀÎÄÚµùµË´Ï´Ù. ±×¸®°í ±×µéÀº ´ÙÀ½ ¼öÁý±â·Î º¸³»Áý´Ï´Ù. ¾ö°ÝÇÑ »ç¿ë; Net :: Flow QW (µðÄÚµå ÀÎÄÚµù)¸¦ »ç¿ëÇϽʽÿÀ. IO :: Socket :: INET; ³» $ RECEENET_PORT = 9995; ³» $ send_port = 9996; ³» $ Packet = undef; MY $ TemplateRef = Undef; MY $ MYTEMPLATEREF = { 'setID'=> 0, 'templateID'=> 300, 'template'=> ,}; ³» @mytemplates = ($ mytemplateref); MY $ ENCODEHEADERHASHREF = { 'sourceID'=> 0, 'versionnum'=> 9, 'sequencenum'=> 0,}; MY $ r_sock = io :: socke :: inet-> new (localport => $ seignion_port, proto => 'udp'); ³» $ s_sock = io :: socket :: inet-> new (peeraddr => 127.0.0.1 ', peerport => $ send_port, proto =>'udp '); while ($ r_sock-> recv ($ Packet, 1548)) {my $ pktsarrayref = undef; My ($ headerhashref, Undef, $ flowarrayref, $ errorsArrayRef) = net :: flow :: decode ($ ÆÐŶ, undef); grep {$ _n "} @ {$ ERRORSARRAYREF} (@ {$ ERRORSARRAYREF}); foreach my $ hashref (@ {$ flowarrayref}) {$ hashref -> { "setId"} = 300; $ hashref -> { "34"} = ÆÑ ( "n", $ headerhashref -> { "samplingInterval"}) $ headerhashref -> { "samplinginterval"}; $ hashref -> { "35"} = pack ( "n", $ headerhashref -> { "»ùÇøµ ¸ðµå"}) Á¤ÀÇ µÈ $ headerhashref -> { "samplingmode"}; } $ encodeHeaderHashRef -> { "sysuptime"} = $ headerhashref -> { "sysuptime"}; $ encodeHeaderHashRef -> { "UnixSecs"} = $ headerhashref -> { "UnixSecs"}; $ encodeHeaderHashRef -> { "sequencenum"} + = 1; ($ encodeHeaderHashRef, $ pktsarrayref, $ errorsarrayref) = net :: flow :: encode ($ encodeheaderhashref, @MyTemplates, $ flowarrayref, 1400); grep {$ _n "} @ {$ ERRORSARRAYREF} (@ {$ ERRORSARRAYREF}); ³» $ REF (@ {$ pktsarrayref}) {$ s_sock-> send ($$ Ref); }} ¿ä±¸ »çÇ× : ¡¤ Perl ¿ä±¸ »çÇ× : ¡¤ Perl.
net :: flow. °ü·Ã ¼ÒÇÁÆ®¿þ¾î