Index: /branches/rel_apv_10_7_4/usr/src/sys/click/netinet/click_udp.c
===================================================================
--- /branches/rel_apv_10_7_4/usr/src/sys/click/netinet/click_udp.c	(revision 40161)
+++ /branches/rel_apv_10_7_4/usr/src/sys/click/netinet/click_udp.c	(working copy)
@@ -14,6 +14,7 @@
 #include <sys/smp.h>
 #include <sys/proc.h>
 #include <sys/pcpu.h>
+#include <sys/time.h>
 #include <net/route.h>
 #include <net/if.h>
 #include <net/netisr.h>
@@ -100,6 +101,14 @@
 #define REASS_FREE_MBUF	-1
 #define REASS_CSUM_FAIL	-2
 
+// TWSD-1620 Define the maximum number of SNMP packets to receive per second
+// Based on our lab testing, the APV's capacity for receiving SNMP packets is approximately 500 pps / 800 Kbps.
+// SNMP flooding attacks below this threshold will not exhaust the APV's memory or trigger swap memory usage.
+#define MAX_SNMP_PKTS_PER_SEC 500
+static time_t last_snmp_time = 0;
+static int snmp_pkt_count = 0;
+
+
 extern int sipudp_dispatcher;
 extern int numa_enable;
 extern int rts_enable;
@@ -1046,10 +1055,32 @@
 		if (IN6_IS_ADDR_UNSPECIFIED(&ip6->ip6_src) || IN6_IS_ADDR_UNSPECIFIED(&ip6->ip6_dst) || 
 			(udp->uh_sport == 0) || (udp->uh_dport == 0)) {
 			pcb = NULL;
-			goto bad;			
-		} 
+			goto bad;
+		}
 	}
-	
+
+        // TWSD-1620 SNMP Rate Limiting Logic
+        if (ntohs(udp->uh_dport) == 161) {
+            // Use the current system time in seconds (time_second)
+            if (time_second != last_snmp_time) {
+                // Entered a new second, reset the counter and update the time
+                last_snmp_time = time_second;
+                snmp_pkt_count = 1;
+            } else {
+                // Within the same second, increment the counter
+                snmp_pkt_count++;
+
+                // If the counter exceeds the maximum packets per second limit, drop the packet directly
+                if (snmp_pkt_count > MAX_SNMP_PKTS_PER_SEC) {
+                    if (freembuf) {
+                        m_freem(m);
+                    }
+                    // Return immediately to stop processing this packet
+                    clicktcp_leave_func_void();
+                }
+            }
+        }
+
 	ww_result = clickudp_webwall_check(isipv6, ip, ip6, m);
 
 	pcb = clickudp_find_pcb(ww_result, isipv6, ip, ip6, udp);
