Alex Xu Profile picture
Nov 14 โ€ข 9 tweets โ€ข 3 min read
How is data sent over the network? Why do we need so many layers in the OSI model?

The diagram below shows how data is encapsulated and de-encapsulated when transmitting over the network.

1/9 Image
๐Ÿ”น Step 1: When Device A sends data to Device B over the network via the HTTP protocol, it is first added an HTTP header at the application layer.

2/9 Image
๐Ÿ”น Step 2: Then a TCP or a UDP header is added to the data. It is encapsulated into TCP segments at the transport layer. The header contains the source port, destination port, and sequence number.

3/9 Image
๐Ÿ”น Step 3: The segments are then encapsulated with an IP header at the network layer. The IP header contains the source/destination IP addresses.

4/9 Image
๐Ÿ”น Step 4: The IP datagram is added a MAC header at the data link layer, with source/destination MAC addresses.

๐Ÿ”น Step 5: The encapsulated frames are sent to the physical layer and sent over the network in binary bits.

5/9 Image
๐Ÿ”น Steps 6-10: When Device B receives the bits from the network, it performs the de-encapsulation process, which is a reverse processing of the encapsulation process. The headers are removed layer by layer, and eventually, Device B can read the data.

6/9 Image
We need layers in the network model because each layer focuses on its own responsibilities. Each layer can rely on the headers for processing instructions and does not need to know the meaning of the data from the last layer.

7/9 Image
๐Ÿ‘‰ Over to you: Do you know which layer is responsible for resending lost data?

8/9
Subscribe to our weekly newsletter to learn something new every week:

bit.ly/3FEGliw

9/9

โ€ข โ€ข โ€ข

Missing some Tweet in this thread? You can try to force a refresh
ใ€€

Keep Current with Alex Xu

Alex Xu Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @alexxubyte

Nov 16
Code First v.s. API First - A change of software development philosophy.

The diagram below shows the differences between code-first development and API-first development. Why do we want to consider API first design?

1 of 10 Image
๐Ÿ”นMicroservices increase system complexity

We have separate services to serve different functions of the system. While this kind of architecture facilitates decoupling and segregation of duty, we need to handle the various communications among services.

2 of 10
It is better to think through the system's complexity before writing the code and carefully defining the boundaries of the services.

3 of 10
Read 10 tweets
Nov 15
YouTube channel milestone: 200,000.

Here are the 10 most popular ones: ๐Ÿ‘‡

Subscribe here: youtube.com/c/ByteByteGo

1 of 12 Image
System Design: Why is Kafka fast?


2 of 12 Image
HTTP/1 to HTTP/2 to HTTP/3


3 of 12 Image
Read 12 tweets
Nov 11
/1 How do we ensure ๐œ๐จ๐ฆ๐ฉ๐š๐ญ๐ข๐›๐ข๐ฅ๐ข๐ญ๐ฒ when performing ๐๐š๐ญ๐š ๐ฆ๐ข๐ ๐ซ๐š๐ญ๐ข๐จ๐ง?

The diagram below shows how Apache Avro manages the schema evolution during data migration. Image
/2 Avro was started in 2009, initially as a subproject of Apache Hadoop to address Thriftโ€™s limitation in Hadoop use cases. Avro is mainly used for two things: Data serialization and RPC.
/3 Key points in the diagram:

๐Ÿ”นWe can export the data to ๐จ๐›๐ฃ๐ž๐œ๐ญ ๐œ๐จ๐ง๐ญ๐š๐ข๐ง๐ž๐ซ ๐Ÿ๐ข๐ฅ๐ž๐ฌ, where schema sits together with the data blocks. Avro ๐๐ฒ๐ง๐š๐ฆ๐ข๐œ๐š๐ฅ๐ฅ๐ฒ generates the schemas based on the columns, so if the schema is changed, a new schema is generated.
Read 5 tweets
Nov 9
/1 Deploying or upgrading services is risky. In this post, we explore risk mitigation strategies.

The diagram below illustrates the common ones.
/2 ๐Œ๐ฎ๐ฅ๐ญ๐ข-๐’๐ž๐ซ๐ฏ๐ข๐œ๐ž ๐ƒ๐ž๐ฉ๐ฅ๐จ๐ฒ๐ฆ๐ž๐ง๐ญ

In this model, we deploy new changes to multiple services simultaneously. This approach is easy to implement. But since all the services are upgraded at the same time, it is hard to manage, test dependencies, and rollback.
/3 ๐๐ฅ๐ฎ๐ž-๐†๐ซ๐ž๐ž๐ง ๐ƒ๐ž๐ฉ๐ฅ๐จ๐ฒ๐ฆ๐ž๐ง๐ญ

With blue-green deployment, we have two identical environments: one is staging (blue) and the other is production (green). The staging environment is one version ahead of production.
Read 10 tweets
Nov 8
/1 Have you heard of Domain-Driven Design (DDD), a major software design approach?
/2 DDD was introduced in Eric Evansโ€™ classic book โ€œDomain-Driven Design: Tackling Complexity in the Heart of Softwareโ€. It explained a methodology to model a complex business. In this book, there is a lot of content, so I'll summarize the basics.
/3 ๐“๐ก๐ž ๐œ๐จ๐ฆ๐ฉ๐จ๐ฌ๐ข๐ญ๐ข๐จ๐ง ๐จ๐Ÿ ๐๐จ๐ฆ๐š๐ข๐ง ๐จ๐›๐ฃ๐ž๐œ๐ญ๐ฌ:

๐Ÿ”นEntity: a domain object that has ID and life cycle.
๐Ÿ”นValue Object: a domain object without ID.
๐Ÿ”นAggregate: a collection of Entities that are bounded together by Aggregate Root (which is also an entity).
Read 7 tweets
Nov 7
/1 How does ๐ ๐‘๐๐‚ work?

RPC (Remote Procedure Call) is called โ€œ๐ซ๐ž๐ฆ๐จ๐ญ๐žโ€ because it enables communications between remote services when services are deployed to different servers. From the userโ€™s point of view, it acts like a local function call Image
/2 The diagram below illustrates the overall data flow for ๐ ๐‘๐๐‚.

Step 1: A REST call is made from the client. The request body is usually in JSON format. Image
/3 Steps 2 - 4: The order service (gRPC client) receives the REST call, transforms it, and makes an RPC call to the payment service. gPRC encodes the ๐œ๐ฅ๐ข๐ž๐ง๐ญ ๐ฌ๐ญ๐ฎ๐› into a binary format and sends it to the low-level transport layer. Image
Read 7 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(