近期在工作中,为了避免写一堆的C代码,想用Linux现成的工具对文本文件的内容逐行进行处理,于是就想到了SED,在使用info查询文档时,却意外发现了与OpenFlow这个新兴的技术有一定的相似性。

从info sed的如下文档可以看出:

sed' operates by performing the following cycle on each lines of input: first,sed' reads one line from the input stream, removes any trailing newline, and places it in the pattern space. Then commands are executed; each command can have an address associated to it: addresses are a kind of condition code, and a command is only executed if the condition is verified before the command is to be executed.

从上面的描述中,我们做如下对比:

one line --- packet(网络报文)

address --- match criteria(流表匹配条件)

command --- action(流表行为)

当我想通了这个道理后,便发现sed这个上古神器并非那么的难以理解了,于是很快用三行sed命令,实现了以前同事约100行C代码实现的功能,真是要感谢OpenFlow这项技术,同时我觉得在技术间做类比可能会是掌握新技术的好办法。


Comments

comments powered by Disqus