sdnのfloodlight控制器的流量数目统计.docx

上传人:b****6 文档编号:7017807 上传时间:2023-01-16 格式:DOCX 页数:17 大小:78.18KB
下载 相关 举报
sdnのfloodlight控制器的流量数目统计.docx_第1页
第1页 / 共17页
sdnのfloodlight控制器的流量数目统计.docx_第2页
第2页 / 共17页
sdnのfloodlight控制器的流量数目统计.docx_第3页
第3页 / 共17页
sdnのfloodlight控制器的流量数目统计.docx_第4页
第4页 / 共17页
sdnのfloodlight控制器的流量数目统计.docx_第5页
第5页 / 共17页
点击查看更多>>
下载资源
资源描述

sdnのfloodlight控制器的流量数目统计.docx

《sdnのfloodlight控制器的流量数目统计.docx》由会员分享,可在线阅读,更多相关《sdnのfloodlight控制器的流量数目统计.docx(17页珍藏版)》请在冰豆网上搜索。

sdnのfloodlight控制器的流量数目统计.docx

sdnのfloodlight控制器的流量数目统计

在floodlight控制器中统计进入packed-in数量的代码:

packageedu.wzu.steve.trafficanalyser;

importjava.util.ArrayList;

importjava.util.Collection;

importjava.util.HashMap;

importjava.util.Iterator;

importjava.util.Map;

importjava.util.Map.Entry;

 

importorg.restlet.resource.ResourceException;

importorg.restlet.resource.ServerResource;

importnet.floodlightcontroller.counter.CounterValue;

importnet.floodlightcontroller.counter.ICounter;

importorg.restlet.resource.Get;

importnet.floodlightcontroller.core.FloodlightContext;

importnet.floodlightcontroller.core.IFloodlightProviderService;

importnet.floodlightcontroller.core.IOFMessageListener;

importnet.floodlightcontroller.core.IOFSwitch;

importnet.floodlightcontroller.core.module.FloodlightModuleContext;

importnet.floodlightcontroller.core.module.FloodlightModuleException;

importnet.floodlightcontroller.core.module.IFloodlightModule;

importnet.floodlightcontroller.core.module.IFloodlightService;

importnet.floodlightcontroller.counter.ICounterStoreService;

 

importorg.openflow.protocol.OFMessage;

importorg.openflow.protocol.OFType;

importorg.slf4j.Logger;

importorg.slf4j.LoggerFactory;

 

publicclassTrafficAnalyserextendsServerResourceimplementsIOFMessageListener,IFloodlightModule{

 

protectedICounterStoreServicecounterStore;

protectedIFloodlightProviderServicefloodlightProvider;

protectedstaticLoggerlogger;

@Override

publicStringgetName(){

//TODOAuto-generatedmethodstub

returnTrafficAnalyser.class.getSimpleName();

}

@Override

publicbooleanisCallbackOrderingPrereq(OFTypetype,Stringname){

//TODOAuto-generatedmethodstub

returnfalse;

}

@Override

publicbooleanisCallbackOrderingPostreq(OFTypetype,Stringname){

//TODOAuto-generatedmethodstub

returnfalse;

}

@Override

publicCollection

extendsIFloodlightService>>getModuleServices(){

//TODOAuto-generatedmethodstub

returnnull;

}

@Override

publicMap

extendsIFloodlightService>,IFloodlightService>getServiceImpls(){

//TODOAuto-generatedmethodstub

returnnull;

}

@Override

publicCollection

extendsIFloodlightService>>getModuleDependencies(){

//TODOAuto-generatedmethodstub

Collection

extendsIFloodlightService>>l=

newArrayList

extendsIFloodlightService>>();

l.add(IFloodlightProviderService.class);

returnl;

}

@Override

publicvoidinit(FloodlightModuleContextcontext)

throwsFloodlightModuleException{

this.floodlightProvider=context.getServiceImpl(IFloodlightProviderService.class);

this.counterStore=context.getServiceImpl(ICounterStoreService.class);

logger=LoggerFactory.getLogger(TrafficAnalyser.class);

}

@Override

publicvoidstartUp(FloodlightModuleContextcontext){

floodlightProvider.addOFMessageListener(OFType.PACKET_IN,this);

}

@Get("json")

publicMapretrieve(){

StringcounterTitle=

(String)getRequestAttributes().get("counterTitle");

Mapmodel=newHashMap();

CounterValuev;

if(counterTitle.equalsIgnoreCase("all")){

Mapcounters=this.counterStore.getAll();

if(counters!

=null){

Iterator>it=

counters.entrySet().iterator();

while(it.hasNext()){

Entryentry=it.next();

StringcounterName=entry.getKey();

v=entry.getValue().getCounterValue();

if(CounterValue.CounterType.LONG==v.getType()){

model.put(counterName,v.getLong());

}elseif(v.getType()==CounterValue.CounterType.DOUBLE){

model.put(counterName,v.getDouble());

}

}

}

}else{

ICountercounter=this.counterStore.getCounter(counterTitle);

if(counter!

=null){

v=counter.getCounterValue();

}else{

v=newCounterValue(CounterValue.CounterType.LONG);

}

if(CounterValue.CounterType.LONG==v.getType()){

model.put(counterTitle,v.getLong());

}elseif(v.getType()==CounterValue.CounterType.DOUBLE){

model.put(counterTitle,v.getDouble());

}

}

returnmodel;

}

protectedvoiddoInit()throwsResourceException{

super.doInit();

counterStore=

(ICounterStoreService)getContext().getAttributes().

get(ICounterStoreService.class.getCanonicalName());

}

@Override

publicnet.floodlightcontroller.core.IListener.Commandreceive(IOFSwitchsw,OFMessagemsg,FloodlightContextcntx){

System.out.println(retrieve().toString());

returnCommand.CONTINUE;

}

}

这歌代码没有报错,可是,控制器只能连接到ovs,在mininet中用hosts去pingall的时候就会一下连接,一下断开,无法ping通。

于是就简化了一下代码,去掉觉得有bug的代码,抛出的异常是没有实例化;

 

代码如下:

packageedu.wzu.steve.trafficanalyser;

importjava.util.ArrayList;

importjava.util.Collection;

importjava.util.HashMap;

importjava.util.Iterator;

importjava.util.Map;

importjava.util.Map.Entry;

 

importorg.restlet.resource.ResourceException;

importorg.restlet.resource.ServerResource;

importnet.floodlightcontroller.counter.CounterValue;

importnet.floodlightcontroller.counter.ICounter;

importorg.restlet.resource.Get;

importnet.floodlightcontroller.core.FloodlightContext;

importnet.floodlightcontroller.core.IFloodlightProviderService;

importnet.floodlightcontroller.core.IOFMessageListener;

importnet.floodlightcontroller.core.IOFSwitch;

importnet.floodlightcontroller.core.module.FloodlightModuleContext;

importnet.floodlightcontroller.core.module.FloodlightModuleException;

importnet.floodlightcontroller.core.module.IFloodlightModule;

importnet.floodlightcontroller.core.module.IFloodlightService;

importnet.floodlightcontroller.counter.ICounterStoreService;

 

importorg.openflow.protocol.OFMessage;

importorg.openflow.protocol.OFType;

importorg.slf4j.Logger;

importorg.slf4j.LoggerFactory;

 

publicclassTrafficAnalyserextendsServerResourceimplementsIOFMessageListener,IFloodlightModule{

 

protectedICounterStoreServicecounterStore;

protectedIFloodlightProviderServicefloodlightProvider;

protectedstaticLoggerlogger;

@Override

publicStringgetName(){

//TODOAuto-generatedmethodstub

returnTrafficAnalyser.class.getSimpleName();

}

@Override

publicbooleanisCallbackOrderingPrereq(OFTypetype,Stringname){

//TODOAuto-generatedmethodstub

returnfalse;

}

@Override

publicbooleanisCallbackOrderingPostreq(OFTypetype,Stringname){

//TODOAuto-generatedmethodstub

returnfalse;

}

@Override

publicCollection

extendsIFloodlightService>>getModuleServices(){

//TODOAuto-generatedmethodstub

returnnull;

}

@Override

publicMap

extendsIFloodlightService>,IFloodlightService>getServiceImpls(){

//TODOAuto-generatedmethodstub

returnnull;

}

@Override

publicCollection

extendsIFloodlightService>>getModuleDependencies(){

//TODOAuto-generatedmethodstub

Collection

extendsIFloodlightService>>l=

newArrayList

extendsIFloodlightService>>();

l.add(IFloodlightProviderService.class);

returnl;

}

@Override

publicvoidinit(FloodlightModuleContextcontext)

throwsFloodlightModuleException{

this.floodlightProvider=context.getServiceImpl(IFloodlightProviderService.class);

this.counterStore=context.getServiceImpl(ICounterStoreService.class);

logger=LoggerFactory.getLogger(TrafficAnalyser.class);

}

@Override

publicvoidstartUp(FloodlightModuleContextcontext){

floodlightProvider.addOFMessageListener(OFType.PACKET_IN,this);

}

@Get("json")

publicMapretrieve(){

Mapmodel=newHashMap();

CounterValuev;

Mapcounters=this.counterStore.getAll();

if(counters!

=null){

Iterator>it=

counters.entrySet().iterator();

while(it.hasNext()){

Entryentry=it.next();

StringcounterName=entry.getKey();

v=entry.getValue().getCounterValue();

if(CounterValue.CounterType.LONG==v.getType()){

model.put(counterName,v.getLong());

}elseif(v.getType()==CounterValue.CounterType.DOUBLE){

model.put(counterName,v.getDouble());

}

}

}

returnmodel;

}

protectedvoiddoInit()throwsResourceException{

super.doInit();

counterStore=

(ICounterStoreService)getContext().getAttributes().

get(ICounterStoreService.class.getCanonicalName());

}

@Override

publicnet.floodlightcontroller.core.IListener.Commandreceive(IOFSwitchsw,OFMessagemsg,FloodlightContextcntx){

System.out.println(retrieve().toString());

returnCommand.CONTINUE;

}

}

 

sudomn--toposingle,3--mac--switchovsk--controller=remote,ip=10.0.2.15,port=6633

建立hosts去pingall

 

eclipse中控制台出来的信息截图如上,完整信息如下:

 

00:

58:

01.133INFO[n.f.c.m.FloodlightModuleLoader:

main]Loadingdefaultmodules

00:

58:

01.846INFO[n.f.c.i.Controller:

main]ControllerrolesettoMASTER

00:

58:

01.869INFO[n.f.c.i.Controller:

main]Flushswitchesonreconnect--Disabled

00:

58:

02.968ERROR[o.s.s.i.c.DelegatingCCProvider:

main]Failedtoinitializeproviderorg.sdnplatform.sync.internal.config.SyncStoreCCProvider

org.sdnplatform.sync.error.PersistException:

Couldnotinitializepersistentstorage

atorg.sdnplatform.sync.internal.store.JavaDBStorageEngine.(JavaDBStorageEngine.java:

106)~[bin/:

na]

atorg.sdnplatform.sync.internal.StoreRegistry.register(StoreRegistry.java:

116)~[bin/:

na]

atorg.sdnplatform.sync.internal.SyncManager.registerPersistentStore(SyncManager.java:

184)[bin/:

na]

atorg.sdnplatform.sync.internal.config.SyncStoreCCProvider.init(SyncStoreCCProvider.java:

85)~[bin/:

na]

atorg.sdnplatform.sync.internal.config.DelegatingCCProvider.init(DelegatingCCProvider.java:

37)

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 总结汇报

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1