186 | | The mgmtFromNetworkLayer_callback extends previous codes that have processed mangement structures because this callback process the traffic struct and the new node commands. |
187 | | |
188 | | Because the nodes are on the same ethernet network, the managmenet callback checks if the ethernet type is from the server to node or vice-versa. |
189 | | If a packet is a NODE2SVR, the node has received an ack packet or stat packet from the other node. |
| 186 | The mgmtFromNetworkLayer_callback extends previous codes that have processed management structures because this callback processes the traffic struct and the new node commands. |
| 187 | |
| 188 | Because the nodes are on the same Ethernet network, the management callback checks if the Ethernet type is from the server to node or vice-versa. |
| 189 | If a packet is a NODE2SVR, the node has received an ack packet or stat packet from the other node. Because both nodes are on the same network and can see all traffic, in the implementation for SVR2NODE nodes checks the nodeID in the structs to determine whether the command is meant for it. |
| 190 | |
| 191 | In the NODECMD, check the cmdStruct->cmdID for the IDs of NODECMD_RESETSTATS, NODECMD_START, NODECMD_STOP, and NODECMC_REQUESTSTATS: |
| 192 | |
| 193 | NODECMD_RESETSTATS needs to reset all values in myStats and send an ack packet if requested: |
| 194 | {{{ |
| 195 | case NODECMD_RESETSTATS: |
| 196 | if( (cmdStruct->nodeID) == myID) |
| 197 | { |
| 198 | //Reset the good/bad pkt counts and Rx/Tx byte counts |
| 199 | for(i=0; i<WARPNET_NUMNODES; i++) |
| 200 | { |
| 201 | myStats[i].goodPackets = 0; |
| 202 | myStats[i].partnerBadPackets = 0; |
| 203 | myStats[i].otherBadPackets = 0; |
| 204 | myStats[i].txBytes = 0; |
| 205 | myStats[i].rxBytes = 0; |
| 206 | myStats[i].time = 0; |
| 207 | } |
| 208 | //Send Ack Packet |
| 209 | if(rxSeqNum > 0) sendAck(rxSeqNum); |
| 210 | } |
| 211 | }}} |
| 212 | |
| 213 | NODECMD_START sets a xtime variable start_timer and begins packet generation if the traffic struct had set Mode to TRANSMIT: |
| 214 | {{{ |
| 215 | case NODECMD_START: |
| 216 | XTime_GetTime(&start_timer); |
| 217 | if (Mode==TRANSMIT){ |
| 218 | warpmac_startPacketGeneration(packetlength,Time); //second argument is interval in usec |
| 219 | } |
| 220 | }}} |
| 221 | |
| 222 | NODECMD_STOP stops packet generation, calculates the time difference, updates the time variable in myStats, and sends an ack if requested: |
| 223 | {{{ |
| 224 | case NODECMD_STOP: |
| 225 | //xil_printf("NODECMC_STOP \r\n"); |
| 226 | warpmac_stopPacketGeneration(); |
| 227 | |
| 228 | XTime_GetTime(&end_timer); |
| 229 | long long xtime=0; |
| 230 | xtime=end_timer-start_timer; |
| 231 | for(i=0; i<WARPNET_NUMNODES; i++) |
| 232 | { |
| 233 | myStats[i].time = xtime; |
| 234 | } |
| 235 | |
| 236 | if((cmdStruct->nodeID) == myID) |
| 237 | { |
| 238 | //Send Ack Packet |
| 239 | if(rxSeqNum > 0) sendAck(rxSeqNum); |
| 240 | } |
| 241 | }}} |
| 242 | |
| 243 | NODECMC_REQUESTSTATS sends the stats packet and ack packet if requested: |
| 244 | case NODECMC_REQUESTSTATS: |
| 245 | if( (cmdStruct->nodeID) == myID) |
| 246 | { |
| 247 | sendStatsPacket(rxSeqNum); |
| 248 | |
| 249 | //Send Ack Packet |
| 250 | if(rxSeqNum > 0) sendAck(rxSeqNum); |
| 251 | } |
| 262 | }}} |
| 263 | |
| 264 | The new design implements a STRUCTID_NODETRAFFIC, which updates the interval between packets, the transmission mode, and packet length: |
| 265 | {{{ |
| 266 | case STRUCTID_NODETRAFFIC: //This is for a traffic struct |
| 267 | trafficStruct = (warpnodeTraffic*)(payload+rxPktOffset); |
| 268 | |
| 269 | if((trafficStruct->nodeID) == myID) |
| 270 | { |
| 271 | //Send Ack Packet |
| 272 | if(rxSeqNum > 0) sendAck(rxSeqNum); |
| 273 | |
| 274 | Time=trafficStruct->txInterval; |
| 275 | Mode=trafficStruct->trafficMode; |
| 276 | packetlength=trafficStruct->txPacketLen; |
| 277 | } |
| 278 | rxPktOffset += sizeof(warpnodeTraffic); |
215 | | In the main function, global values need to be initialized. |
216 | | First, warpmac_enableDataFromNetwork, warpmac_setBaseRate, and warpmac_enableDummyPacketMode. For this application, the boards will be left in DummyPacketMode because to prevent them from transmitting information from the wire. (Due to the nature of the set up with routers, the TCP ack packets sent from the TCL-client computer to the server computer will be sent over the wireless channel. This can create problem because the computers will retransmit the data when they don't receive TCP-acks) |
217 | | |
218 | | Certain global variables need to be set to default values: |
| 294 | In the main function, set warpmac_enableDataFromNetwork, warpmac_setBaseRate, and warpmac_enableDummyPacketMode. For this application, the boards will be left in DummyPacketMode because to prevent them from transmitting information from the wire. (Due to the nature of the set up with routers, the TCP ack packets sent from the TCL-client computer to the server computer will be sent over the wireless channel. This can create problem because the computers will retransmit the data when they don't receive TCP-acks) |
| 295 | |
| 296 | Set these global variables to default values: |