IPFIX数据通过UDP C#

编程入门 行业动态 更新时间:2024-10-15 12:38:26
本文介绍了IPFIX数据通过UDP C# - 我可以对数据进行解码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已经从MSDN网站上的代码示例创建为我试图从防火墙收到IPFIX / NetFlow数据,然后与我接收数据工作UDP监听/客户端。 的代码不工作,并开始reveive数据,但它的专业术语(见下文),所以我想我不能正确解码它。

I have a code sample from the MSDN website to create a UDP listener/client as I am trying to receive IPFIX/Netflow data from a firewall and then work with the data I receive. The code does work and starts to reveive data but its jargon (see below) so I guess I am not decoding it correctly.

有没有人有任何想法?我需要做的是能够得到正确格式的数据。

Does anyone have any ideas what I need to do to be able to get the data in the correct format?

我使用的代码是:

using System; using System.Net; using System.Net.Sockets; using System.Text; public class ConsoleApplication2 { private const int listenPort = 2055; private static void StartListener() { bool done = false; UdpClient listener = new UdpClient(listenPort); IPEndPoint groupEP = new IPEndPoint(IPAddress.Any, listenPort); try { while (!done) { Console.WriteLine("Waiting for broadcast"); byte[] bytes = listener.Receive(ref groupEP); Console.WriteLine("Received broadcast from {0} :\n {1}\n", groupEP.ToString(), Encoding.ASCII.GetString(bytes, 0, bytes.Length)); } } catch (Exception e) { Console.WriteLine(e.ToString()); } finally { listener.Close(); } } public static int Main() { StartListener(); return 0; } }

和数据我得到的回复是:

And the data I get back is:

?m?▼? '$▬+? ?☺☺中号▼??? k` 和;?????? _ 07 ???? Q 20êüĴ♥☻结果♠P♣点¯x♣►♥ →♦☼?m?▼ - M +▼? 1♠►?结果? ☺

?M?▼? '$▬+? ☺☺ ?M?▼???k` &??_?07????Q??E?U?j ♥ ☻ ♠ P ♣ x ♣ ► ♥ → ♦ ☼?M?▼?M?▼? 1♠ ►? ? ☺

由于提前,

詹姆斯

推荐答案

您是假定接收到的数据是ASCII格式的时候,其实它正是如此结构:的看到这里。这些消息有头和数据集等,你需要评估依据的数据在标准,而不是仅仅一个直的文本转换

You're assuming that the data being received is in ASCII format when in fact it's structured thusly: See here. The messages have a header and data sets etc. You need to evaluate the data based on the standard, not just a straight text conversion.

在此,例如是邮件标题的格式。文本转换,根本不会做这样的事情:

Here, for example is the message header format. A text conversion simply won't do anything with this:

3.1。邮件标题格式

The format of the IPFIX Message Header is shown in Figure F. 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Version Number | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Export Time | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Sequence Number | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Observation Domain ID | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

更多推荐

IPFIX数据通过UDP C#

本文发布于:2023-11-30 02:22:29,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1648402.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据   IPFIX   UDP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!