Software Defined Networking
1753989 Members
6588 Online
108811 Solutions
New Discussion

Re: How to send the FlowMod message to Controller !!!

 
Yuanxiance
Occasional Contributor

How to send the FlowMod message to Controller !!!

// flow already created  and i'm sure it correct, created flowmod                      //    message codes are from HP VAN SDN Controller Programming Guide.pdf on Page 27-29. 

              //    when i run the codes, the statement "System.out.println(mf)" output null in Eclipse Console.

By the way, other functions such as getAllDataPathInfo(), getDataPathInfo(DataPathId dpid); they all return null .i use HP-2920 switch, and Contrlloer version is 2.0 , API document  and hp-sdn-sdk version are both 2.0!!!

 

 

/-------------------------------------------------------------------------------

Below are the steps to send the FlowMod message

 

// Construct OfmMutableFlowMod 

OfmMutableFlowMod mod = (OfmMutableFlowMod) MessageFactory .create(pv, MessageType.FLOW_MOD);

 

// Assemble the match fields

 

// Add the values to flow mod

 

//Convert to Immutable

OfmFlowMod flow = (OfmFlowMod)mod.toImmutable();

 

//Call the method

cs.sendFlowMod(flow, dpInfo.dpid());     // Here dpInfo is of type DataPathInfo and cs is of type ControllerService

-------------------------------------------------------------------------------------------------------------------/

5 REPLIES 5
sdnindia
Trusted Contributor

Re: How to send the FlowMod message to Controller !!!

Hello Yuanxiance,

 

Since sendFlowMod() function is returning null so please check if the argument for this function i.e. flow as well as dpid have proper values.Also  getAllDataPathInfo(), getDataPathInfo(DataPathId dpid) functions are returning null so it looks like dpid is not having some proper value.

 

As per Programming guide page 31 you can use  

 private ControllerService cs = ...;

 

You can have private static ControllerService mControllerService;  in your class and initialize that member and call sendFlowMod function.

 

If you still face the issue please share the code for flow creation and for dpid initialization.

 

Thanks,

HP SDN Team

harcy
Occasional Visitor

Re: How to send the FlowMod message to Controller !!!

Hi,sdnindia!

    I want to know this statement  "private ControllerService cs = ...;" mean. In Programming guide page 31, How to understand "it is assumed that a reference to the controller service implementation has been stored in the field cs" , Can you give some example codes to help me ? How to initialize it's member? In my class ,i  initialize  ControllerService by invoke ControllerServiceAdapter constructor! i use statement

"ControllerService cs = new ControllerServiceAdapter() "; Below codes in main function, when i run i can't get DataPathInfo,

"

 

--------------------------------------------------------------------

System.out.println(cs.getDataPathInfo(dpid));     //return NULL, what's the problem?

--------------------------------------------------------

sdnindia
Trusted Contributor

Re: How to send the FlowMod message to Controller !!!

Hello harcy,

In some class(for e.g. OfMonitorComponent as in below ) there can be a data member cs of type ControllerService   and some function  for e.g. bindControllerService which initialize the data member cs  as below-
public class OfMonitorComponent implements OfMonitor {

private volatile ControllerService cs;


protected void bindControllerService(ControllerService service) {
        cs = service;
    }

..
}

In your code cs.getDataPathInfo(dpid) is returning NULL so please make sure both cs and dpid have soem value.

Please try as per above code snippets and let us know if this solve your problem or you still face the issue.

Thanks,
HP SDN Team

Chethan_R
Occasional Advisor

Re: How to send the FlowMod message to Controller !!!

Hi All,
 
Please note that We have also tried with
 
ControllerService cs = new ControllerServiceAdapter();
logger.info("DataPath Info: {}", cs.getAllDataPathInfo());
 
what you have suggested in the above post, but still we are getting null;
 
Request to please advice me on this,
 
Thanks in advance.
 
Regards,
Chethan
ssrirama
Advisor

Re: How to send the FlowMod message to Controller !!!

Try compiling and deploying the attached application. It is a very minimal application that activates and deactivates the controllerservice object. After deploying the application on the controller try to put some traffic across the network, then post the related lines from the log located at /opt/sdn/virgo/serviceability/logs/log.log. Note, you will need sudo access to get to the log.