diff --git a/simics-workspace/modules/afdxES/afdxES.dml b/simics-workspace/modules/afdxES/afdxES.dml
index 22265f9..2c239bd 100644
--- a/simics-workspace/modules/afdxES/afdxES.dml
+++ b/simics-workspace/modules/afdxES/afdxES.dml
@@ -20,6 +20,7 @@ import "pci-action.dml";
 import "pci-register.dml";
 import "change_endian.dml";
 import "tomiddleware.dml";
+import "rm-handler.dml";

 connect phyA {
 	parameter documentation = "Send data to the second ARINC664 card";
@@ -39,76 +40,42 @@ connect phyB {
     }
 }

+
 implement ieee_802_3_mac {
 	method send_frame(uint8 *data, uint32 size) {
         local rm_cfg_cam item;
-        item.VL_ID = data[4];
-        local uint8 position;
-		local bool crc;
-		local RX_MIB rx_mib_temp;
+        local uint8 rm_index;
+		local bool is_crc_ok;
+        local RM_INFO rm_info;

-	    call $recv_crc_check(data,size,$Table)->(crc);
+	    call $recv_crc_check(data,size,$Table)->(is_crc_ok);

-		if(crc == false) {
+		if (is_crc_ok == false) {
 			log "info":"crc check failed";
             return;
 		}

-		call $change_endian(data,size);
-
-        log "info" : "The $rm_cfg_cam_index = %d", $rm_cfg_cam_index;
+		call $change_endian(data, size);

-        call $BinarySearchRMCfgCamArray($rm_cfg_cam_array, item) -> (position);
-        position = $rm_cfg_cam_array[position].address;
-
-        log "info" : "The position is %d", position;
-
-        local uint8 VL_ENABLE = $rm_cfg_ram_array[position].ram_data.VL_ENABLE;
-        local uint8 RM_ENABLE = $rm_cfg_ram_array[position].ram_data.RM_ENABLE;
-        local uint8 NETWORK_A_IC_ENABLE = $rm_cfg_ram_array[position].ram_data.NETWORK_A_IC_ENABLE;
-        local uint8 NETWORK_B_IC_ENABLE = $rm_cfg_ram_array[position].ram_data.NETWORK_B_IC_ENABLE;
-        local uint8 NETWORK_A_ENABLE = $rm_cfg_ram_array[position].ram_data.NETWORK_A_ENABLE;
-        local uint8 NETWORK_B_ENABLE = $rm_cfg_ram_array[position].ram_data.NETWORK_B_ENABLE;
-        local uint8 A_Interface_ID;
-        local uint8 B_Interface_ID;
-
-
-        if (VL_ENABLE == 0) {
-            return;
-        }
-
-        local uint8 frame_sn = data[size-5];
-		local uint8 interface_id;
-		interface_id = data[11] >> 5;
-		log "info" : "interace_ido = %d", interface_id;
-
-        if (NETWORK_A_ENABLE == 1) {
-            A_Interface_ID = 1;
+        item.VL_ID = data[4];
+        call $BinarySearchRMCfgCamArray($rm_cfg_cam_array, item) -> (rm_index);
+        if (rm_index == -1) {
+            log "error" : "Can't find this conf in current rm cfg cam table, please check!";
         } else {
-            A_Interface_ID = 0;
+            rm_index = $rm_cfg_cam_array[rm_index].address;
         }
+
+        call $Init_RM_INFO(&rm_info, rm_index, size);

-        if (NETWORK_B_ENABLE == 1) {
-            B_Interface_ID = 2;
-        } else {
-            B_Interface_ID = 0;
-        }
-
-		if((interface_id ==1) && (A_Interface_ID ==0))
-			$rx_mib.disable_A_filt_count++;
-		if((interface_id ==2) && (B_Interface_ID ==0))
-			$rx_mib.disable_B_filt_count++;
-
-        if ((frame_sn == $recv_vl[position].expect_sn) && ((interface_id == A_Interface_ID) || (interface_id == B_Interface_ID))) {
-			$rx_mib.size = size;
+		local uint8 interface_id = data[11] >> 5;
+        local uint8 frame_sn = data[size-5];
+        local bool is_rm_ok;
+
+        call $RM_Handler(&rm_info, interface_id, frame_sn) -> (is_rm_ok);
+        if (is_rm_ok) {
             call $unpacket_frame(data, size)->($rx_mib);
-            $recv_vl[position].expect_sn++;
-            $recv_vl[position].expect_sn %= 256;
-			if(interface_id == A_Interface_ID) call $mib_in_sum(&($maca_mib),size);
-			else if(interface_id == B_Interface_ID) call $mib_in_sum(&($macb_mib),size);
         } else {
-			log "info" : "Send from error network";
-            return;
+			log "error" : "Send from unkown network";
         }
 	}
 }
@@ -133,10 +100,8 @@ attribute is_cfg_done "If true, don't change cfg table index and write cfg table
 method post_init() {
     call $pci_config.update_all_mappings();
 	call $gen_normal_table($Table);
-    memset($udp_first,1,PORT_SIZE);
     call $init_port_queue();
     call $init_middleware_mode();
+    call $init_udp_flag();
     call $init_vl_cfg();
-
-	$phy_max_bandwidth = 200;
 }
diff --git a/simics-workspace/modules/afdxES/packet-description.dml b/simics-workspace/modules/afdxES/packet-description.dml
index 83ab20a..c1ffc9d 100644
--- a/simics-workspace/modules/afdxES/packet-description.dml
+++ b/simics-workspace/modules/afdxES/packet-description.dml
@@ -11,168 +11,157 @@ struct Udp_Header_Structure {
 }

 struct IP_Header_Structure {
-	uint8  VERSION_IHL;
-	uint8  TYPE_OF_SERVICE;
-	uint16 TOTAL_LENGTH;
-	uint16 FRAGMENT_IDENTIFICATION;
-	uint16	CONTROL_FRAGMENT;
-	uint8  TIME_TO_LIVE;
-	uint8  PROTOCAL;
-	uint16 HEADER_CHECKSUM;
-	uint32 IP_SOURCE_ADDRESS;
-	uint32 IP_DESTINATION_ADDRESS;
+   uint8  VERSION_IHL;
+   uint8  TYPE_OF_SERVICE;
+   uint16 TOTAL_LENGTH;
+   uint16 FRAGMENT_IDENTIFICATION;
+   uint16	CONTROL_FRAGMENT;
+   uint8  TIME_TO_LIVE;
+   uint8  PROTOCAL;
+   uint16 HEADER_CHECKSUM;
+   uint32 IP_SOURCE_ADDRESS;
+   uint32 IP_DESTINATION_ADDRESS;
 }

 struct MAC_Header_Structrue {
-	uint32 CONSTANT_FIELD_1;
-	uint16 VIRTUAL_LINK_IDENTIFER;
-	uint8 CONSTANT_FIELD_2;
-	uint8 CONSTANT_FIELD_3;
-	uint8 CONSTANT_FIELD_4;
-	uint8 USER_DEFINED_ID;
-	uint8 USER_DEFINED_ID_2;
-	uint8 INTERFACE_CONSTANT;
+   uint32 CONSTANT_FIELD_1;
+   uint16 VIRTUAL_LINK_IDENTIFER;
+   uint8 CONSTANT_FIELD_2;
+   uint8 CONSTANT_FIELD_3;
+   uint8 CONSTANT_FIELD_4;
+   uint8 USER_DEFINED_ID;
+   uint8 USER_DEFINED_ID_2;
+   uint8 INTERFACE_CONSTANT;
 }

 struct Afdx_Data{
-	uint8 *data;
-	uint32 length;
+   uint8 *data;
+   uint32 length;
 }

 struct Send_Frame_Packet{
-	uint32 	header_length;			//mac header, ip header ,ipv4sign ,sn ,crc
-	uint32  afdx_payload_length;    //send packet data size
-	uint32 	send_frame_length;
-	uint32 	first;
-	uint32	udp_offset; 			//udp offset
+   uint32	header_length;			//mac header, ip header ,ipv4sign ,sn ,crc
+   uint32  afdx_payload_length;	   //send packet data size
+   uint32	send_frame_length;
+   uint32	first;
+   uint32	udp_offset;				//udp offset
 }

 struct Afdx_Frame_Packet{
-	Udp_Header_Structure 	udp_header_structure;     // UDP header
-	IP_Header_Structure		ip_header_structure;      // IP  header
-	MAC_Header_Structrue 	mac_header_structure;	  // MAC header
-	Afdx_Data 				afdx_data;				  //send data and send data length
-	Send_Frame_Packet		send_frame_packet;		  //send frame ,max, min length
+    Udp_Header_Structure	udp_header_structure;	  // UDP header
+    IP_Header_Structure		ip_header_structure;	  // IP	 header
+    MAC_Header_Structrue	mac_header_structure;	  // MAC header
+    Afdx_Data				afdx_data;				  //send data and send data length
+    Send_Frame_Packet		send_frame_packet;		  //send frame ,max, min length
 }

 //for queue
 struct Item {
-	uint8 frame[DATA_SIZE];    // ×֡´óС
-	uint32 size;              // ÓÐЧ֡³¤¶È
+    uint8 frame[DATA_SIZE];    // ×֡´óС
+    uint32 size;              // ÓÐЧ֡³¤¶È
 }

 struct Queue {
-	uint32 front;
-	uint32 rear;
+    uint32 front;
+    uint32 rear;

-	Item item[ITEM_NUM];         // Õâ¸öÓÃ8K³ýÒÔ×îСµÄ֡³¤¶È64
+    Item item[ITEM_NUM];         // Õâ¸öÓÃ8K³ýÒÔ×îСµÄ֡³¤¶È64

-	uint32 item_num;         // ÓÃÓڴ洢µ±ǰÒѾ­´洢Á˶àÉÙÏî
-	uint32 frame_size;       // ´洢µÄËùÓÐ֡ºϲ¢ÔÚһÆðµĴóС
+    uint32 item_num;         // ÓÃÓڴ洢µ±ǰÒѾ­´洢Á˶àÉÙÏî
+    uint32 frame_size;       // ´洢µÄËùÓÐ֡ºϲ¢ÔÚһÆðµĴóС
 }

 //for port queue
-struct QueueItem
-{
-	uint8 *buffer;
-	int32 whole_size;
-	int32 single_size;
-	int32 last;
-	uint32 dest_ip;
-	uint32 src_ip;
+struct QueueItem {
+    uint8 *buffer;
+    int32 whole_size;
+    int32 single_size;
+    int32 last;
+    uint32 dest_ip;
+    uint32 src_ip;
     uint16 dest_udp;
-	QueueItem *prev_whole;
-	QueueItem *next;
+    QueueItem *prev_whole;
+    QueueItem *next;
 }

-struct UDP_Item
-{
-	uint8* buffer;
-	uint32 udp_length;
-	uint32 udp_packet_size;
-	uint1 mf;
-	uint32 dest_ip;
-	uint32 src_ip;
-	uint2 port_type;
+struct UDP_Item {
+    uint8* buffer;
+    uint32 udp_length;
+    uint32 udp_packet_size;
+    uint1 mf;
+    uint32 dest_ip;
+    uint32 src_ip;
+    uint2 port_type;
     uint16 dest_udp;
 }
-
-struct PortItem
-{
-	uint8 *frame;
-	uint32 size;
-	uint32 dest_ip;
-	uint32 src_ip;
+
+struct PortItem {
+    uint8 *frame;
+    uint32 size;
+    uint32 dest_ip;
+    uint32 src_ip;
     uint16 dest_udp;
 }

-struct PortQueue
-{
-	QueueItem *head;
-	QueueItem *tail;
-	int32 item_length;
-	int32 queue_size;
-	int32 queue_full;
+struct PortQueue {
+    QueueItem *head;
+    QueueItem *tail;
+    int32 item_length;
+    int32 queue_size;
+    int32 queue_full;
 }

 // for MIB
-struct MAC_MIB
-{
-		uint32 crc_error;   				//crc checksum error
-		uint32 delete_little_64;  			//delete the frame that size is little than 64B
-		uint32 delete_big_1518;   			//delete the frame that size is bigger than 1518B
-		uint32 input_frame_count;  			// input frame count
-		uint32 input_64_127_count;			//input frame size between 64 and 127
-		uint32 input_128_255_count;			//input frame size between 128 and 255
-		uint32 input_256_511_count;			//input frame size between 256 and 511
-		uint32 input_512_1023_count;		//input frame size between 512 and 1023
-		uint32 input_1024_1518_count;		//input frame size between 1024 and 1023
-		uint32 input_frame_byte_count; 		// input frame byte count
-		uint32 output_frame_count;  		// output frame byte count
-		uint32 output_64_127_count;			//output frame size between 64 and 127
-		uint32 output_128_255_count;		//output frame size between 128 and 255
-		uint32 output_256_511_count;		//output frame size between 256 and 511
-		uint32 output_512_1023_count;		//output frame size between 512 and 1023
-		uint32 output_1024_1518_count;		//output frame size between 1024 and 1023
-		uint32 output_frame_byte_count;  	// output frame byte count
-		uint32 first_bit_error_count;		//first bit error
-		uint32 ipchecksum_error_count;		//ip checksum error
-		uint32 delete_bit_2048_count;		//delete the frame bigger than 2048
+struct MAC_MIB {
+    uint32 crc_error;   				//crc checksum error
+    uint32 delete_little_64;  			//delete the frame that size is little than 64B
+    uint32 delete_big_1518;   			//delete the frame that size is bigger than 1518B
+    uint32 input_frame_count;  			// input frame count
+    uint32 input_64_127_count;			//input frame size between 64 and 127
+    uint32 input_128_255_count;			//input frame size between 128 and 255
+    uint32 input_256_511_count;			//input frame size between 256 and 511
+    uint32 input_512_1023_count;		//input frame size between 512 and 1023
+    uint32 input_1024_1518_count;		//input frame size between 1024 and 1023
+    uint32 input_frame_byte_count; 		// input frame byte count
+    uint32 output_frame_count;  		// output frame byte count
+    uint32 output_64_127_count;			//output frame size between 64 and 127
+    uint32 output_128_255_count;		//output frame size between 128 and 255
+    uint32 output_256_511_count;		//output frame size between 256 and 511
+    uint32 output_512_1023_count;		//output frame size between 512 and 1023
+    uint32 output_1024_1518_count;		//output frame size between 1024 and 1023
+    uint32 output_frame_byte_count;  	// output frame byte count
+    uint32 first_bit_error_count;		//first bit error
+    uint32 ipchecksum_error_count;		//ip checksum error
+    uint32 delete_bit_2048_count;		//delete the frame bigger than 2048
 }

-struct RX_MIB
-{
-		uint32 disable_A_filt_count;
-		uint32 disable_B_filt_count;
-		uint32 A_integrated_filt_count;
-		uint32 B_integrated_filt_count;
-		uint32 vl_id_filt_count;
-		uint32 redunt_filt_count;
-		uint32 port_filt_count;
-	   	uint32 ip_checksum_filt_count;
-		uint32 ip_length_error_filt_count;
-		uint32 udp_length_error_filt_count;
-		uint32 ip_fragment_error_filt_count ;
-		uint32 overflow_count;
-		uint32 rx_icmp_reback_count;
-		uint32 rx_ip_data_count;
-		uint32 rx_udp_data_count;
-	    uint32 rx_icmp_data_count;
-		uint32 icmp_overflow_count;
-		uint32 rx_icmp_big_max_count;
-		uint32 rx_buffer_clear_delete_count;
-		uint32 size;
+struct RX_MIB {
+    uint32 disable_A_filt_count;
+    uint32 disable_B_filt_count;
+    uint32 A_integrated_filt_count;
+    uint32 B_integrated_filt_count;
+    uint32 vl_id_filt_count;
+    uint32 redunt_filt_count;
+    uint32 port_filt_count;
+    uint32 ip_checksum_filt_count;
+    uint32 ip_length_error_filt_count;
+    uint32 udp_length_error_filt_count;
+    uint32 ip_fragment_error_filt_count ;
+    uint32 overflow_count;
+    uint32 rx_icmp_reback_count;
+    uint32 rx_ip_data_count;
+    uint32 rx_udp_data_count;
+    uint32 rx_icmp_data_count;
+    uint32 icmp_overflow_count;
+    uint32 rx_icmp_big_max_count;
+    uint32 rx_buffer_clear_delete_count;
+    uint32 size;
 }
-
-struct TX_MIB
-{
-		uint32 tx_ip_count;
-		uint32 tx_udp_count;
-		uint32 tx_icmp_count;
+
+struct TX_MIB {
+    uint32 tx_ip_count;
+    uint32 tx_udp_count;
+    uint32 tx_icmp_count;
 }
-
-
-
-
diff --git a/simics-workspace/modules/afdxES/tomiddleware.c b/simics-workspace/modules/afdxES/tomiddleware.c
index 5429006..577cd95 100644
--- a/simics-workspace/modules/afdxES/tomiddleware.c
+++ b/simics-workspace/modules/afdxES/tomiddleware.c
@@ -66,8 +66,8 @@ int socket_recv(unsigned char *recvbuf, int size) {
             memset(recvbuf, 0, size);

             len = recv(client_socket, (char *)recvbuf, size, 0);
-            if (len == size) {
-                fprintf(stdout, "Socket recv sucessfully!\n", WSAGetLastError());
+            if (len > 0) {
+                fprintf(stdout, "Socket recv sucessfully, send %d sizes!\n", len);
             } else {
                 fprintf("Socket recv failed, error code is %d.\n", WSAGetLastError());
             }
diff --git a/simics-workspace/modules/afdxES/unpacket_frame.dml b/simics-workspace/modules/afdxES/unpacket_frame.dml
index 89b20d9..cc6b6ef 100644
--- a/simics-workspace/modules/afdxES/unpacket_frame.dml
+++ b/simics-workspace/modules/afdxES/unpacket_frame.dml
@@ -10,6 +10,10 @@ import "packet-description.dml";

 data uint8 udp_first[PORT_SIZE];   //init with 1;

+method init_udp_flag() {
+    memset($udp_first,1,PORT_SIZE);
+}
+
 method unpacket_frame(uint8 *buffer,uint32 size)->(RX_MIB rx_mib) {
 	log "info" : "called by ARINC2 to unpacket_frame";