> For the complete documentation index, see [llms.txt](https://chenyuxiang0425.gitbook.io/cs-notebook/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://chenyuxiang0425.gitbook.io/cs-notebook/cs144/section1/cs144_1.7.md).

# 1.7 Principle: Encapsulation

Encapsulation allows you to layer recursively.\
(比如TCP segment可以在另一个TCP segment，应用VPN(virtual private network))

带VPN的封装：\
Ethernet link frame → IP to VPN gateway → TCP to VPN gateway → TLS to VPN gateway → IP to web server → TCP to web server → HTTP

Encapsulation is how layering manifests(体现) in data representation(数据表示；数据的度表示).\
封装是 layer 如何体现在 data 上的。\
Help separation of concerns\
帮助分离关注点\
Help enforce boundaries/layering\
帮助执行边界/分层\
Simplify layer implementations\
简化 layer 实现
