diff --git a/ZodiacFX/src/command.c b/ZodiacFX/src/command.c index 7e60610..13f402d 100644 --- a/ZodiacFX/src/command.c +++ b/ZodiacFX/src/command.c @@ -451,6 +451,9 @@ void command_root(char *command, char *param1, char *param2, char *param3) // Force OpenFlow version reset_config.of_version = 0; // Force version disabled + + //How often to retrieve stats from switch + reset_config.stats_interval = 1; // Default 1 second memcpy(&reset_config.MAC_address, &Zodiac_Config.MAC_address, 6); // Copy over existing MAC address so it is not reset memcpy(&Zodiac_Config, &reset_config, sizeof(struct zodiac_config)); @@ -485,6 +488,7 @@ void command_root(char *command, char *param1, char *param2, char *param3) } if (Zodiac_Config.ethtype_filter == 1) printf(" EtherType Filtering: Enabled\r\n"); if (Zodiac_Config.ethtype_filter != 1) printf(" EtherType Filtering: Disabled\r\n"); + printf(" Port Stats Interval: %d\r\n" , Zodiac_Config.stats_interval); printf("\r\n\n"); return; } @@ -589,6 +593,7 @@ void command_config(char *command, char *param1, char *param2, char *param3) } if (Zodiac_Config.ethtype_filter == 1) printf(" EtherType Filtering: Enabled\r\n"); if (Zodiac_Config.ethtype_filter != 1) printf(" EtherType Filtering: Disabled\r\n"); + printf(" Port Stats Interval: %d\r\n" , Zodiac_Config.stats_interval); printf("\r\n-------------------------------------------------------------------------\r\n\n"); return; } @@ -942,6 +947,9 @@ void command_config(char *command, char *param1, char *param2, char *param3) // Force OpenFlow version reset_config.of_version = 0; // Force version disabled + //How often to retrieve stats from switch + reset_config.stats_interval = 1; // Default 1 second + memcpy(&reset_config.MAC_address, &Zodiac_Config.MAC_address, 6); // Copy over existng MAC address so it is not reset memcpy(&Zodiac_Config, &reset_config, sizeof(struct zodiac_config)); saveConfig(); @@ -998,7 +1006,23 @@ void command_config(char *command, char *param1, char *param2, char *param3) } return; } + + // Set port stats update interval + if (strcmp(command, "set")==0 && strcmp(param1, "stats-interval")==0) + { + int interval; + sscanf(param2, "%d", &interval); + if (interval < 31 && interval > -1) + { + Zodiac_Config.stats_interval = interval; + printf("Port stats interval set to %d\r\n" , Zodiac_Config.stats_interval); + } else { + printf("Invalid value\r\n"); + } + return; + } + // Unknown Command printf("Unknown command\r\n"); return; @@ -1934,6 +1958,7 @@ void printhelp(void) printf(" delete vlan-port \r\n"); printf(" set of-version \r\n"); printf(" set ethertype-filter \r\n"); + printf(" set stats-interval \r\n"); printf(" factory reset\r\n"); printf(" exit\r\n"); printf("\r\n"); diff --git a/ZodiacFX/src/command.h b/ZodiacFX/src/command.h index bee2417..6da5813 100644 --- a/ZodiacFX/src/command.h +++ b/ZodiacFX/src/command.h @@ -72,6 +72,7 @@ struct zodiac_config { uint8_t failstate; uint8_t of_version; uint8_t ethtype_filter; + uint8_t stats_interval; } PACK_STRUCT_STRUCT; PACK_STRUCT_END diff --git a/ZodiacFX/src/config/config_zodiac.h b/ZodiacFX/src/config/config_zodiac.h index 273d66c..5c68505 100644 --- a/ZodiacFX/src/config/config_zodiac.h +++ b/ZodiacFX/src/config/config_zodiac.h @@ -31,7 +31,7 @@ #define CONFIG_ZODIAC_H_ -#define VERSION "0.84" // Firmware version number +#define VERSION "0.85" // Firmware version number #define TOTAL_PORTS 4 // Total number of physical ports on the Zodiac FX @@ -48,7 +48,6 @@ #define MAX_BUCKETS 4 // Maximum number of group action buckets for OpenFlow 1.3 and higher #define HB_INTERVAL 2 // Number of seconds between heartbeats - #define HB_TIMEOUT 6 // Number of seconds to wait when there is no response from the controller #define MAX_OF_STATS 15 // Maximum number of flows to send to controller diff --git a/ZodiacFX/src/http.c b/ZodiacFX/src/http.c index cb24118..c9400a2 100644 --- a/ZodiacFX/src/http.c +++ b/ZodiacFX/src/http.c @@ -746,6 +746,9 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err // Force OpenFlow version reset_config.of_version = 0; // Force version disabled + + //How often to retrieve stats from switch + reset_config.stats_interval = 1; // Default 1 second memcpy(&reset_config.MAC_address, &Zodiac_Config.MAC_address, 6); // Copy over existing MAC address so it is not reset memcpy(&Zodiac_Config, &reset_config, sizeof(struct zodiac_config)); diff --git a/ZodiacFX/src/main.c b/ZodiacFX/src/main.c index 4010674..f24607d 100644 --- a/ZodiacFX/src/main.c +++ b/ZodiacFX/src/main.c @@ -139,6 +139,7 @@ int main (void) membag_init(); loadConfig(); // Load Config + if (Zodiac_Config.stats_interval > 30) Zodiac_Config.stats_interval = 1; // If this value has never been set make it the default of 1 IP4_ADDR(&x_ip_addr, Zodiac_Config.IP_address[0], Zodiac_Config.IP_address[1],Zodiac_Config.IP_address[2], Zodiac_Config.IP_address[3]); IP4_ADDR(&x_net_mask, Zodiac_Config.netmask[0], Zodiac_Config.netmask[1],Zodiac_Config.netmask[2], Zodiac_Config.netmask[3]); diff --git a/ZodiacFX/src/openflow/of_helper.c b/ZodiacFX/src/openflow/of_helper.c index c740f01..9976c6d 100644 --- a/ZodiacFX/src/openflow/of_helper.c +++ b/ZodiacFX/src/openflow/of_helper.c @@ -68,7 +68,8 @@ extern uint8_t *ofp13_oxm_inst[MAX_FLOWS_13]; extern uint16_t ofp13_oxm_inst_size[MAX_FLOWS_13]; // Local Variables -uint8_t timer_alt; +uint8_t timer_alt = 0; +uint8_t update_interval = 0; static uint16_t VLAN_VID_MASK = 0x0fff; static inline uint64_t (htonll)(uint64_t n) @@ -139,21 +140,24 @@ void nnOF_timer(void) { totaltime ++; // Because this is called every 500ms totaltime is actually 2 x the real time // Round robin the timer events so they don't have such a big impact on switching - if (timer_alt == 0){ - update_port_stats(); - timer_alt = 1; - } else if (timer_alt == 1){ - update_port_status(); - // If port status has changed send a port status message - for (int x=0;x Zodiac_Config.stats_interval) + { + if (timer_alt == 0){ + if (Zodiac_Config.stats_interval > 0) update_port_stats(); + timer_alt = 1; + } else if (timer_alt == 1){ + flow_timeouts(); + if (Zodiac_Config.stats_interval > 0) update_port_status(); + // If port status has changed send a port status message + for (int x=0;xxid); + echo_reply(ofph, size, len); break; default: @@ -259,15 +259,12 @@ void OF_hello(void) * @param xid - transaction ID * */ -void echo_reply(uint32_t xid) +void echo_reply(struct ofp_header *ofph, int size, int len) { - struct ofp_header echo; - echo.version = OF_Version; - echo.length = HTONS(sizeof(echo)); - echo.type = OFPT10_ECHO_REPLY; - echo.xid = xid; + // Change the message type to Echo Reply and return any data that was sent + ofph->type = OFPT10_ECHO_REPLY; TRACE("openflow.c: Sent ECHO reply"); - sendtcp(&echo, sizeof(echo), 1); + sendtcp(ofph, len, 1); return; }