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

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

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

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

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

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();

}

publicbooleanisCallbackOrderingPrereq(OFTypetype,Stringname){

//TODOAuto-generatedmethodstub

returnfalse;

publicbooleanisCallbackOrderingPostreq(OFTypetype,Stringname){

publicCollection<

Class<

?

extendsIFloodlightService>

>

getModuleServices(){

returnnull;

publicMap<

IFloodlightService>

getServiceImpls(){

returnnull;

getModuleDependencies(){

Collection<

l=

newArrayList<

();

l.add(IFloodlightProviderService.class);

returnl;

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"

String,Object>

retrieve(){

StringcounterTitle=

(String)getRequestAttributes().get("

counterTitle"

);

Map<

model=newHashMap<

String,Object>

CounterValuev;

if(counterTitle.equalsIgnoreCase("

all"

)){

String,ICounter>

counters=this.counterStore.getAll();

if(counters!

=null){

Iterator<

Map.Entry<

it=

counters.entrySet().iterator();

while(it.hasNext()){

Entry<

entry=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!

v=counter.getCounterValue();

v=newCounterValue(CounterValue.CounterType.LONG);

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

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

returnmodel;

protectedvoiddoInit()throwsResourceException{

super.doInit();

counterStore=

(ICounterStoreService)getContext().getAttributes().

get(ICounterStoreService.class.getCanonicalName());

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

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

returnCommand.CONTINUE;

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

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

代码如下:

returnTrafficAnalyser.class.getSimpleName();

publicCollection<

publicvoidstartUp(FloodlightModuleContextcontext){

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

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

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

(ICounterStoreService)getContext().getAttributes().

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

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

main]ControllerrolesettoMASTER

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

main]Flushswitchesonreconnect--Disabled

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.<

init>

(JavaDBStorageEngine.java:

106)~[bin/:

na]

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

116)~[bin/:

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

184)[bin/:

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

85)~[bin/:

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

37)

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

当前位置:首页 > PPT模板 > 动物植物

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

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