اعتبارًا من 27 آذار (مارس) 2025، ننصحك باستخدام android-latest-release
بدلاً من aosp-main
لإنشاء AOSP والمساهمة فيه. لمزيد من المعلومات، يُرجى الاطّلاع على التغييرات في AOSP.
تحسين تجربة مستخدم شبكة VPN
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
تقدّم هذه الصفحة إرشادات لمشغّلي الشبكات لضمان أن تقدّم تطبيقات الشبكات الافتراضية الخاصة (VPN) للأفراد والشركات تجربة جيدة للمستخدم النهائي في شبكاتهم. يوفّر نظام التشغيل Android فئة
VpnManager
للمطوّرين من أجل إنشاء حلول VPN التي يستخدمها المستهلكون و
المؤسسات لتشفير اتصالاتهم أو توجيهها إلى شبكات مختلفة.
ننصح مشغّلي الشبكات باتّباع الإرشادات التالية:
- إتاحة حزم بروتوكول IPv6 Encapsulating Security Payload (ESP) (العنوان التالي
50) على شبكتك، ما يضمن أنّ أداء هذه البيانات مماثل لأداء اتصالات بروتوكول مخطط بيانات المستخدم (UDP) أو بروتوكول التحكم في الإرسال (TCP) يجب السماح بجلسات ESP الواردة إلى
الأجهزة، أو ضبطها على مهلات زمنية عالية جدًا، وإعادة توجيهها بمعدّل الخط.
- ضبط مهلات ترجمة عناوين الشبكة (NAT) وجدار الحماية الذي يتتبّع حالة الاتصال
لتكون 600 ثانية على الأقل لاتصالات بروتوكول بيانات المستخدم (UDP) على المنفذ 4500 لضمان
أنّ حلول VPN يمكنها الحفاظ على اتصال موثوق بدون تكبد تكاليف طاقة
مفرطة
تنسيق الحزمة Encapsulating Security Payload (ESP) هو تنسيق الحزمة المحدَّد كجزء من مجموعة بروتوكولات Internet Protocol Security (IPSec) لتشفير الحزم ومصادقتها في حلّ VPN. ينفِّذ نظام التشغيل Android بروتوكول أمان
هذا في حلّ VPN المضمّن.
في الشبكات المتوافقة مع IPv6، يتم نقل حزم ESP مباشرةً في حزم IPv6 باستخدام
حقل "العنوان التالي" الذي يُمثّل القيمة 50. إذا كانت الشبكة لا تتوافق بشكل صحيح مع هذين النوعين من
الحِزم، قد يؤدي ذلك إلى عدم إمكانية الاتصال بحلول VPN التي تهدف إلى استخدام
هذا البروتوكول بدون المزيد من التفاف الحِزم. قد تُسقط الشبكة
هذه الحِزم بسبب إعدادات جدار الحماية. أو قد تصطدم حزم ESP
بمسارات بطيئة على الشبكة، ما يؤدي إلى انخفاض كبير في أداء معدل نقل البيانات مقارنةً باتصالات TCP أو UDP.
تنصح مجموعة مهندسي شبكة الإنترنت (IETF) بالسماح بمرور بروتوكول IPsec من خلال بوابات الحماية التي تستخدمها خدمات الوصول إلى الإنترنت للمستهلكين. على سبيل المثال، راجِع
القسم 3.2.4 من RFC 6092.
يمكن السماح بحزم ESP بأمان من خلال جدران الحماية في كلا الاتجاهين لأنّه
إذا تلقّى جهاز حزمة ESP ليست جزءًا من ربط أمان
حالي، يسقط الجهاز الحزمة. نتيجةً لذلك، لا يحتاج الجهاز
إلى إرسال حزم keepalive للحفاظ على الاتصال عبر شبكة VPN، ما يحافظ بدوره على
عمر البطارية. ننصحك بأن تسمح الشبكات بحزم ESP للأجهزة في جميع
الأوقات، أو أن تضبط مهلة لجلسات ESP بعد فترات طويلة من عدم النشاط فقط (مثل
30 دقيقة).
ننصح مشغّلي الشبكات بتفعيل حزم بروتوكول ESP (حزم IPv6 التي تحتوي على العنوان التالي 50) على شبكاتهم وإعادة توجيه هذه الحزم في الأجهزة بمعدّل السرعة على الشبكة. يضمن ذلك عدم مواجهة حلول VPN لمشاكل في الاتصال و
تقديم أداء مماثل لاتصالات UDP أو TCP.
ضبط مهلات كافية لميزة "ترجمة عنوان الشبكة" وجدار الحماية الذي يتتبّع حالة الاتصال
للحفاظ على موثوقية الاتصال، يجب أن يحافظ حلّ شبكة VPN على اتصال دائم بالخادم الذي يقدّم اتصالاً ثنائي الاتجاه (مثلاً، لتلقّي الإشعارات الفورية الواردة ورسائل المحادثة والمكالمات الصوتية أو مكالمات الفيديو). تستخدم معظم تطبيقات VPN التي تستخدم بروتوكول IPsec بروتوكول ESP المُغلف في حزم IPv4 UDP التي تستخدم المنفذ الوجهة 4500، كما هو موضّح في RFC 3948.
للحفاظ على هذا الاتصال، يجب أن يرسل الجهاز الحِزم بصفة دورية إلى
الخادم. ويجب إرسال هذه الحِزم بمعدّل تكرار أعلى من مهلة ترجمة عنوان الشبكة
وجدار الحماية التي يفرضها مشغّل الشبكة. إنّ عمليات الاحتفاظ بالاتصال المتكررة تستهلك طاقة
بشكل كبير من جانب العميل، ولها تأثير كبير في عمر البطارية. وتؤدي هذه الأجهزة أيضًا إلى توليد عدد كبير من إشارات الشبكة، حتى إذا كان الجهاز في وضعٍ "غير نشِط".
ننصح مشغّلي الشبكة برفع مهلة NAT والجدار الناري الذي يتضمّن حالة اتصال عالية بما يكفي
لتجنّب التأثير في البطارية. إنّ مهلة IPsec UDP encapsulation
(المنفذ 4500) المقترَحة هي 600 ثانية أو أكثر.
في الشبكات الجوّالة، غالبًا ما يتم ضبط مهلات UDP NAT على قيم منخفضة لأنّ قلة عناوين IPv4 تفرض عوامل إعادة استخدام المنافذ العالية. ومع ذلك، عند إنشاء شبكة VPN،
لا تحتاج شبكة الجهاز إلى إتاحة اتصالات TCP طويلة الأمد، مثل
تلك المستخدَمة لإرسال الإشعارات الواردة. وبالتالي، فإنّ عدد عمليات الربط التي تحتاج الشبكة إلى إتاحتها لفترة طويلة هو نفسه أو أقل عندما تكون شبكة VPN مفعّلة مقارنةً بحال إيقافها.
يخضع كل من المحتوى وعيّنات التعليمات البرمجية في هذه الصفحة للتراخيص الموضحّة في ترخيص استخدام المحتوى. إنّ Java وOpenJDK هما علامتان تجاريتان مسجَّلتان لشركة Oracle و/أو الشركات التابعة لها.
تاريخ التعديل الأخير: 2025-07-27 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","easyToUnderstand","thumb-up"],["ساعَدني المحتوى في حلّ مشكلتي.","solvedMyProblem","thumb-up"],["غير ذلك","otherUp","thumb-up"]],[["لا يحتوي على المعلومات التي أحتاج إليها.","missingTheInformationINeed","thumb-down"],["الخطوات معقدة للغاية / كثيرة جدًا.","tooComplicatedTooManySteps","thumb-down"],["المحتوى قديم.","outOfDate","thumb-down"],["ثمة مشكلة في الترجمة.","translationIssue","thumb-down"],["مشكلة في العيّنات / التعليمات البرمجية","samplesCodeIssue","thumb-down"],["غير ذلك","otherDown","thumb-down"]],["تاريخ التعديل الأخير: 2025-07-27 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["# Improve VPN user experience\n\nThis page provides guidelines for network operators to ensure that consumer and\nenterprise virtual private network (VPN) apps provide a good end-user experience\nin their networks. Android provides the\n[`VpnManager`](https://developer.android.com/reference/android/net/VpnManager)\nclass for developers to create VPN solutions, which are used by consumers and\nenterprises to encrypt their communications or route them to different networks.\n\nWe recommend network operators follow these guidelines:\n\n- **Support IPv6 Encapsulating Security Payload (ESP) protocol (Next Header\n 50) packets on your network**, ensuring this traffic has comparable performance to user datagram protocol (UDP) or transmission control protocol (TCP) connections. ESP sessions should be allowed inbound to devices, or set to very high timeouts, and forwarded at line rate.\n- **Set network address translation (NAT) and stateful firewall timeouts** that are a minimum of 600 seconds for UDP connections on port 4500 to ensure VPN solutions can maintain reliable connectivity without incurring excessive power costs.\n\nSupport IPv6 ESP protocol (Next Header 50) packets\n--------------------------------------------------\n\nEncapsulating Security Payload (ESP) is the packet format defined as part of the\nInternet Protocol Security (IPSec) set of protocols to encrypt and authenticate\npackets in a VPN solution. The Android OS implements this standard security\nprotocol in its built-in VPN solution.\n\nOn IPv6-capable networks, ESP packets are carried directly in IPv6 packets with\na Next Header field of 50. If a network doesn't properly support these types of\npackets, it can cause a lack of connectivity for VPN solutions that aim to use\nthis protocol without further encapsulation of the packets. The network might\ndrop these packets due to firewall configuration. Or ESP packets might\nhit slow paths on the network, with severely degraded throughput performance\ncompared to TCP or UDP connections.\n\nThe Internet Engineering Task Force (IETF) recommends allowing IPsec through\nfirewalls used by consumer internet access services. For example, see\n[RFC 6092 section 3.2.4](https://www.rfc-editor.org/rfc/rfc6092.html#section-3.2.4).\nESP packets can be safely allowed through firewalls in both directions because\nif a device receives an ESP packet that isn't part of an existing security\nassociation, the device drops the packet. As a result, the device doesn't need\nto send keepalive packets to maintain VPN connectivity, which saves battery\nlife. We recommend that networks either allow ESP packets to devices at all\ntimes, or time out ESP sessions only after long periods of inactivity (for\nexample, 30 minutes).\n\nWe recommend network operators support ESP protocol packets (IPv6 packets with a\nNext Header of 50) on their networks and forward those packets in hardware at\nline rate. This ensures VPN solutions don't encounter connectivity issues and\nprovide performance comparable to UDP or TCP connections.\n\nSet sufficient NAT and stateful firewall timeouts\n-------------------------------------------------\n\nTo maintain connection reliability, a VPN solution needs to maintain a\nlong-lived connection to the VPN server that provides outbound and inbound\nconnectivity (for example, to receive incoming push notifications, chat\nmessages, and audio or video calls). Most IPsec VPN apps use ESP encapsulated in\nIPv4 UDP packets with destination port 4500, as described in\n[RFC 3948](https://www.rfc-editor.org/rfc/rfc3948.html).\n\nTo maintain this connection, the device needs to periodically send packets to\nthe server. These packets must be sent at a higher frequency than the NAT and\nfirewall timeouts imposed by the network operator. Frequent keepalives are power\nintensive on the client side, and have a major impact on battery life. They also\ngenerate substantial signaling traffic on the network, even if the device is\notherwise idle.\n\nWe recommend that operators raise NAT and stateful firewall timeouts high enough\nto avoid battery impact. The recommended timeout for IPsec UDP encapsulation\n(port 4500) is 600 seconds or greater.\n\nIn mobile networks, UDP NAT timeouts are often kept low because IPv4 address\nscarcity imposes high port reuse factors. However, when a VPN is established,\nthe device network doesn't need to support long-lived TCP connections, such as\nthose used to deliver inbound notifications. So the number of long-lived\nconnections that the network needs to support is the same or lower when a VPN is\nrunning compared to when a VPN isn't running."]]