资源简介
Cbench 安装,Controller Benchmarker,openflow,oflops ,测试openflow控制器性能工具,发送packet-in消息,统计及计算性能指标
代码片段和文件信息
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include “channel_info.h“
#include “utils.h“
int channel_info_init(struct channel_info * channel char * dev)
{
struct ifreq ifr;
int dumb;
char *tmp;
bzero(channel sizeof(channel_info));
if((tmp = index(dev ‘:‘)) != NULL) {
*tmp = ‘\0‘;
tmp++;
channel->of_port = atoi(tmp);
} else {
channel->of_port = -1;
}
channel->inOID_len = MAX_OID_LEN;
channel->outOID_len = MAX_OID_LEN;
channel->dev = strdup(dev);
channel->pcap_fd = -1;
channel->raw_sock = -1;
channel->sock = -1;
channel->dump = NULL;
/* Not sure why I need a socket to do this */
dumb = socket(AF_INET SOCK_STREAM 0);
/*retrieve ethernet interface index*/
strncpy(ifr.ifr_name dev IFNAMSIZ);
if (ioctl(dumb SIOCGIFINDEX &ifr) == -1)
perror_and_exit(“SIOCGIFINDEX“1);
channel->ifindex = ifr.ifr_ifindex;
channel->packet_len = 0;
channel->outgoing = msgbuf_new(4096); // will get resized
channel->det = NULL;
close(dumb);
return 0;
}
/****************************************************
* query module if they want pcap and set it up for them if yes
* also create a raw_socket bound to each device if we have the
* device set
*/
void setup_channel(oflops_context *ctx test_module *mod oflops_channel_name ch )
{
char buf[BUFLEN];
char errbuf[PCAP_ERRBUF_SIZE];
struct bpf_program filter;
bpf_u_int32 mask=0 net=0;
channel_info *ch_info = &ctx->channels[ch];
if(ch_info->dev==NULL) // no device specified
{
ch_info->dev = pcap_lookupdev(errbuf);
fprintf(stderr“%s channel %i not configured; guessing device: “
((ch==OFLOPS_CONTROL)?“Control“:“Data“) ch);
if(ch_info->dev)
fprintf(stderr“%s“ch_info->dev);
else
{
fprintf(stderr “ pcap_lookup() failed: %s ; exiting....\n“ errbuf);
exit(1);
}
}
// setup pcap filter if wanted
if( mod->get_pcap_filter(ctxchbufBUFLEN) <=0)
{
fprintf(stderr “Test %s: No pcap filter for channel %d on %s\n“
mod->name() ch ch_info->dev);
ch_info->pcap_handle=NULL;
return;
}
assert(ch_info->dev); // need to have someting here
fprintf(stderr“Test %s: Starting pcap filter \“%s\“ on dev %s for channel %d\n“
mod->name() buf ch_info->dev ch);
errbuf[0]=0;
if(ch != OFLOPS_CONTROL) {
ch_info->pcap_handle = pcap_open_live(
ch_info->dev
ctx->snaplen
1 // promisc
0 // read timeout (ms)
errbuf // for error messages
);
} else {
ch_info->pcap_handle = pcap_open_live(ch_info->dev6500010errbuf);
if(ctx->dump_controller) {
ch_info->dump = pcap_dump_open(ch_info->pcap_handle “controller.pcap“);
printf(“XXXXXXXXXXXXXXXX Dumping controller channel to to file\n“);
} else {
ch_info->dump = NULL;
printf(“XXXXXXXXXXXXXX not dumping con
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2016-06-03 08:44 oflops\
文件 695 2016-06-02 13:16 oflops\TODO
目录 0 2016-06-02 13:16 oflops\m4\
文件 271 2016-06-02 13:16 oflops\m4\ac_pkg_doxygen.m4
文件 3759 2016-06-02 13:16 oflops\msgbuf.c
目录 0 2016-06-02 13:16 oflops\doc\
文件 1557 2016-06-02 13:16 oflops\doc\Makefile
文件 63661 2016-06-02 13:16 oflops\doc\doxygen.conf.in
文件 938 2016-06-02 13:16 oflops\channel_info.h
文件 977 2016-06-02 13:16 oflops\config-openvswitch-flow-stats.cfg
文件 163 2016-06-02 13:16 oflops\.gitmodules
目录 0 2016-06-03 08:47 oflops\netfpga-packet-generator-c-library\
目录 0 2016-06-03 08:47 oflops\netfpga-packet-generator-c-library\src\
文件 1532 2016-06-03 08:47 oflops\netfpga-packet-generator-c-library\src\util.c
文件 440 2016-06-03 08:47 oflops\netfpga-packet-generator-c-library\src\util.h
文件 16186 2016-06-03 08:47 oflops\netfpga-packet-generator-c-library\src\nf2.h
文件 264 2016-06-03 08:47 oflops\netfpga-packet-generator-c-library\src\Makefile.am
文件 1916 2016-06-03 08:47 oflops\netfpga-packet-generator-c-library\src\nf2util.h
文件 21220 2016-06-03 08:47 oflops\netfpga-packet-generator-c-library\src\nf2util.c
文件 57165 2016-06-03 08:47 oflops\netfpga-packet-generator-c-library\src\reg_defines_packet_generator.h
文件 1010 2016-06-03 08:47 oflops\netfpga-packet-generator-c-library\src\constants.h
文件 47420 2016-06-03 08:47 oflops\netfpga-packet-generator-c-library\src\reg_defines.h
文件 47308 2016-06-03 08:47 oflops\netfpga-packet-generator-c-library\src\nf_pktgen.c
目录 0 2016-06-03 08:47 oflops\netfpga-packet-generator-c-library\include\
文件 0 2016-06-03 08:47 oflops\netfpga-packet-generator-c-library\include\nf_cap.h
文件 1535 2016-06-03 08:47 oflops\netfpga-packet-generator-c-library\include\nf_pktgen.h
文件 0 2016-06-03 08:47 oflops\netfpga-packet-generator-c-library\include\nf_gen.h
文件 2377746 2016-06-03 08:47 oflops\netfpga-packet-generator-c-library\oflops_packet_generator.bit
文件 97 2016-06-03 08:47 oflops\netfpga-packet-generator-c-library\Makefile.am
文件 770 2016-06-03 08:47 oflops\netfpga-packet-generator-c-library\configure.in
文件 99 2016-06-03 08:47 oflops\netfpga-packet-generator-c-library\autogen.sh
............此处省略1205个文件信息
- 上一篇:协作通信的蒙特卡洛仿真方法
- 下一篇:电机测速传感器槽型光耦模块
评论
共有 条评论