def test_send_various_size_payloads_to_BPD(self): # ************************************************************************************************# # Test #3: Test with various length payload to BPD: # *************************************************************# print "Sending Test PAYLOAD_ZERO to BPD...\n" rc = Nm.nm_send_CPD_cmd(sendMode, IPV6, BPD_DUT, PAYLOAD_ZERO) print "Response Data for BPD cmd Payload of zero is: \n\%s\'\n" % rc self.assertTrue('Ok' in rc, "Did not get 'OK' message as expected") print "Sleep for set CPD-2-BPD POLLING INTERVAL SETTING OF: \'%s\' seconds ..." % ( CPD_2_BPD_POLLING_INTERVAL) time.sleep(CPD_2_BPD_POLLING_INTERVAL) print "Sending Test PAYLOAD_1000 to BPD...\n" rc = Nm.nm_send_CPD_cmd(sendMode, IPV6, BPD_DUT, PAYLOAD_1000) self.assertTrue('Ok' in rc, "Did not get 'OK' message as expected") print "Sleep for set CPD-2-BPD POLLING INTERVAL SETTING OF: \'%s\' seconds ..." % ( CPD_2_BPD_POLLING_INTERVAL) time.sleep(CPD_2_BPD_POLLING_INTERVAL) print "Sending Test PAYLOAD_1001 to BPD...\n" rc = retCode = Nm.nm_send_CPD_cmd(sendMode, IPV6, BPD_DUT, PAYLOAD_1001) self.assertTrue( 'Erroneous request' in rc, "Did not get received 'Erroneous Request' message as expected")
def test11_send_lls_nodeq_cmd_with_payload_to_request_FW_Version(self): # ************************************************************************************************# # Test #11: Test using lls_nodeq cmd at the Link Layer with payload that requests FW version # Verify imu_data last_read and fw version read back. # *************************************************************# Nm.nm_clear_logs(sendMode, IPV6) print "Testing BPD send raw payload for FW Version at LLS level...\n" rc = Nm.nm_send_CPD_cmd(sendMode, IPV6, BPD_DUT, PAYLOAD_FW_VER) print("Displaying the current BPD node security key...\n") Nm.nm_show_mac_sec_key(sendMode, IPV6, BPD_DUT, 1) # Take a read of stats after send: print "lls_nodeq data send statistic before send....\n" rc = Nm.nm_check_lls_enabled(sendMode, IPV6) self.assertTrue( BPD_DUT.lower() in rc, 'Did not get BPD under test Mac ID in lls_nodeq show all') print "Sleep for set CPD-2-BPD POLLING INTERVAL SETTING OF: \'%s\' seconds ..." % ( CPD_2_BPD_POLLING_INTERVAL) time.sleep(CPD_2_BPD_POLLING_INTERVAL) # Get resonse: rc = Nm.nm_get_latest_IMU_data_response(sendMode, IPV6) print "Response Data for BPD's FW Version is: \n\%s\'\n" % rc self.assertTrue(BPD_FW_VERSION in rc, "Did not get FW Version as expected")
def test05_send_1001_bytes_payload_to_BPD(self): # ************************************************************************************************# # Test #5: Test with 1001 bytes length payload to BPD: # *************************************************************# print "Sending Test PAYLOAD_1001 to BPD...\n" rc = Nm.nm_send_CPD_cmd(sendMode, IPV6, BPD_DUT, PAYLOAD_1001) self.assertTrue( 'Erroneous request' in rc, "Did not get received 'Erroneous Request' message as expected")
def test_send_raw_payload_to_BPD(self): # ************************************************************************************************# # Test #2: Send raw payload to the BPD: print "Sending Test PAYLOAD1 to BPD...\n" rc = Nm.nm_send_CPD_cmd(sendMode, IPV6, BPD_DUT, PAYLOAD1) print "Response Data for BPD cmd Payload is: \n\%s\'\n" % rc print "Sleep for set CPD-2-BPD POLLING INTERVAL SETTING OF: \'%s\' seconds ..." % ( CPD_2_BPD_POLLING_INTERVAL) time.sleep(CPD_2_BPD_POLLING_INTERVAL) self.assertTrue('Ok' in rc, "Did not get 'OK' message as expected")
def test04_send_1000_bytes_payload_to_BPD(self): # ************************************************************************************************# # Test #4: Test with 1000 bytes length payload to BPD: # *************************************************************# print "Sending Test PAYLOAD_1000 to BPD...\n" rc = Nm.nm_send_CPD_cmd(sendMode, IPV6, BPD_DUT, PAYLOAD_1000) self.assertTrue('Ok' in rc, "Did not get 'OK' message as expected") print "Sleep for set CPD-2-BPD POLLING INTERVAL SETTING OF: \'%s\' seconds ..." % ( CPD_2_BPD_POLLING_INTERVAL) time.sleep(CPD_2_BPD_POLLING_INTERVAL)
def test03_send_zero_bytes_payload_to_BPD(self): # ************************************************************************************************# # Test #3: Test with zero byte length payload to BPD: # *************************************************************# print "Sending Test PAYLOAD_ZERO to BPD...\n" rc = Nm.nm_send_CPD_cmd(sendMode, IPV6, BPD_DUT, PAYLOAD_ZERO) print "Response Data for BPD cmd Payload of zero is: \n\%s\'\n" % rc self.assertTrue('Ok' in rc, "Did not get 'OK' message as expected") print "Sleep for set CPD-2-BPD POLLING INTERVAL SETTING OF: \'%s\' seconds ..." % ( CPD_2_BPD_POLLING_INTERVAL) time.sleep(CPD_2_BPD_POLLING_INTERVAL)
def test08_send_package_with_mac_security_enabled(self): # ************************************************************************************************# # Test #8: Test with Mac security enabled 1000 bytes length payload to BPD: # *************************************************************# Nm.nm_clear_logs(sendMode, IPV6) print("Re-infecting default secure key on CPD for BPD....\n") Nm.nm_inject_security_key(sendMode, IPV6, DEFAULT_SECURITY_KEY, 1) # Take a read of stats before send: print "lls_nodeq data send statistic before send....\n" Nm.nm_check_lls_enabled(sendMode, IPV6) print "Sending Test PAYLOAD_1000 to BPD...\n" rc = Nm.nm_send_CPD_cmd(sendMode, IPV6, BPD_DUT, PAYLOAD_1000) self.assertTrue('Ok' in rc, "Did not get 'OK' message as expected") # TODO: Once Security is fully implemented, # Need to revisit this test and check and assert for SecLevel=6 # without requiring the [SecMode][Index] options. print "Sleep for set CPD-2-BPD POLLING INTERVAL SETTING OF: \'%s\' seconds ..." % ( CPD_2_BPD_POLLING_INTERVAL) time.sleep(CPD_2_BPD_POLLING_INTERVAL) # Take a read of stats after send: print "lls_nodeq data send statistic before send....\n" rc = Nm.nm_check_lls_enabled(sendMode, IPV6) self.assertTrue( BPD_DUT.lower() in rc, 'Did not get BPD under test Mac ID in lls_nodeq show all') #NOTE: Loac/inject security is no longer supported if Security is enable, since A3-Integration # Show current Secure Key: #print "Display current loaded secured key for BPD on CPD\n" #rc = Nm.nm_show_mac_sec_key(sendMode, IPV6, BPD_DUT, 1) #self.assertTrue(DEFAULT_SECURITY_KEY.lower() in rc, #'Did not get DEFAULT_SECURITY_KEY in mac_secmib show BPD_DUT') # Get event log for APP layer secure events: rc = Nm.nm_event( sendMode, IPV6) #Note: lls cmd is a link layer send, so wont see
def test09_test_send_secure_mode_1K_payload(self): # ************************************************************************************************# # Test #9: Test with Mac security enabled and Sec Mode=6 SAFE_SECURED_PAYLOAD length payload to BPD: # This test will not work after A3-Integration, since no more manual key injection # *************************************************************# Sec_Mode = 6 index = 1 Nm.nm_clear_logs(sendMode, IPV6) #rc1 = Nm.nm_get_TxFrameCounter(sendMode, IPV6, BPD_DUT, 1) #print "Tx Frame Counter before command is: \'%s\' \n" % rc1 #TODO: Figure out how to do security Key after A3-Integration, for the time, will use unsercure send. #print "Testing BPD secure send raw payload at LLS level, using key and Sec Mode set to 6 for the time being...\n" #rc = Nm.nm_send_secured_CPD_cmd(sendMode, IPV6, BPD_DUT, SAFE_SECURED_PAYLOAD, Sec_Mode, index) print "Testing BPD secure send raw payload at LLS level, using key and Sec Mode set to 6 for the time being...\n" rc = Nm.nm_send_CPD_cmd(sendMode, IPV6, BPD_DUT, SAFE_SECURED_PAYLOAD) self.assertTrue('Ok' in rc, "Did not get 'OK' message as expected") # Lls Rx Cmd: Len = 942, SecLvl = 6 # NOTE: Expect to see on COSEM DevBench for BPD's log as: # 2018/10/03 09:16:48.003 => Lls Rx BLS # 2018/10/03 09:16:48.065 => Lls Lw Pending Cmd # 2018/10/03 09:16:48.065 => MAC Rx Valid Frame Len: 966 # 2018/10/03 09:16:48.128 => MAC Rx Ack Sent # 2018/10/03 09:16:48.190 => Lls Rx Cmd: Len = 934, SecLvl = 6 # 2018/10/03 09:17:17.911 => LLS Lw: chan=39, dur=6.8ms, freqVar=0.0ppm, freqErr=0.1ppm # 2018/10/03 09:17:17.911 => MAC Rx Valid Frame Len: 18 print "Please Manually Check COSEM DevBench for proper SecLevel...\n" # TODO: Once Security is fully implemented and BPD's events are supported, # need to detect, SecLevel=6 and check and assert accorindgly. print "Sleep for set CPD-2-BPD POLLING INTERVAL SETTING OF: \'%s\' seconds ..." % ( CPD_2_BPD_POLLING_INTERVAL) time.sleep(CPD_2_BPD_POLLING_INTERVAL)
Nm.nm_conf_set_app_layer_idle_limit(sendMode, noOfDay, ipv6) if (0): # show various types of certs: birthCert = Nm.nm_show_cert(sendMode, ipv6, 2) # Birth print "BIRTH CERT: \n" + birthCert mfgCert = Nm.nm_show_cert(sendMode, ipv6, 3) # MFG print "MFG CERT: \n" + mfgCert # Test MAC Layer Security with hardcoded CCM secret Alpha2 Integreation #Assuming we currently have 2 sessions of COSEM DevBench for the 2 BPDs. cmdString = '' if bpd == BPD1_BRICK_MAC_ID: print "Sending Test PAYLOAD1 to BPD1...\n" Nm.nm_send_CPD_cmd(sendMode, ipv6, BPD1_BRICK_MAC_ID, PAYLOAD1) #cmdString = "-v lls_nodeq cmd " + BPD1_BRICK_MAC_ID + " " + PAYLOAD1 elif bpd == BPD2_BRICK_MAC_ID: print "Sending Test PAYLOAD2 to BPD2...\n" Nm.nm_send_CPD_cmd(sendMode, ipv6, BPD2_BRICK_MAC_ID, PAYLOAD2) #cmdString = "-v lls_nodeq cmd " + BPD2_BRICK_MAC_ID + " " + PAYLOAD2 else: pass print "Sleeping for CPD 2 BPD polling interval delay of \'%d\' Sec.... \n" % ( CPD_2_BPD_POLLING_INTERVAL) time.sleep(CPD_2_BPD_POLLING_INTERVAL) #Disabling this for now, the return cache is huge, with all the certs text printed out. #certsCache = Nm.nm_show_cert(sendMode, IPV6, 4) #Cert Cache