Networking basics
Highlighted from Developing High-Frequency Trading Systems
Open Systems Interconnection (OSI) model
- Seven independent layers, all have specific functions and communicate with their adjacent layers only and don’t communicate with all the other layers.
The session, presentation, and application layers:
- These three layers can be regrouped (to simplify) because these are the layers that we will use at the software level. In HFTs, we focus on the following four layers because they give advanced optimization opportunities.
Transport layer:
- This manages the delivery and also contains errors in data packets.
- Sequencing, packet size, and transfer of data between systems are the responsibility of the network layer.
- In finance, we mainly use two protocols: the Transmission Control Protocol (TCP) and the User Datagram Protocol (UDP).
Network layer:
- This receives frames from the data link layer and delivers them to the intended destinations using logical addresses.
- We will use the addressing protocol called Internet Protocol (IP). Unlike IP version 6 (IPv6), IP version 4 (IPv4) is a light and user-friendly protocol and is the most widely used protocol in the financial sector.
Data link layer:
- This layer corrects errors that may have occurred at the physical layer by detecting errors with techniques such as parity checks or cyclic redundancy checks (CRCs).
Physical layer:
- This is the media that two machines use to communicate, including optical fiber, copper cable, and satellite.
- All these media have different characteristics (latency, bandwidth, and attenuations). Based on the type of application we want to build we will leverage one versus the other.
- This physical layer is considered the lowest layer of the OSI model. It is concerned with delivering raw unstructured data bits across the network, either electrically or optically, from the sender’s physical layer to the receiver’s physical layer.
- Network hubs, cabling, repeaters, network adapters, and modems are examples of physical resources found at the physical layer.
We often refer to several of them simultaneously. For example, we may refer to
- layers 5-7 as the software layer and
- layers 1-3 as the hardware layer,
- with layer 4 getting mixed between the two. (Or say, layers 3-4 are the TCP/IP layer)
Bandwidth, throughput, and packet rate/size
The bandwidth is the theoretical number of packets exchanged between two hosts.
The pace at which communications reach their intended destination is referred to as throughput.
- The key distinction between the two is that the throughput measures real packet delivery rather than theoretical packet delivery.
- You can see how many packets arrive at their destination by looking at the average data throughput.
- When assessing and measuring the performance of networks, packet size and packet rate are two crucial criteria to take into account.
- The throughput value rises in proportion to packet size, then falls until it reaches the saturated value. When the maximum throughput of an interface is reached, multiple ingress interfaces trying to submit outbound packets to the same egress interface can lead to buffering.
Network address translation
- The process of converting private IP addresses into public addresses is known as network address translation (NAT).
- Most routers employ NAT to allow many devices to share a single IP address.
- When a machine communicates with the exchange, it looks for directions to the exchange. This request is sent as a packet from a machine to the router, forwarding it to the business.
- The router must first transform the source IP address from a private local address to a public one.
- The receiving server will not know where to send the information back if the packet contains a private address.
- The information will be returned to the laptop using the router’s public address rather than the laptop’s private address, thanks to NAT.
- NAT is a resource-intensive operation for any device that uses it. This is because NAT requires reading and writing to the header and payload information of every IP packet to accomplish address translation, which is a time-consuming process.
- It increases the consumption of the central processing unit (CPU) and memory, which might reduce throughput and increase packet delay.
- As a result, while installing NAT in a live network, knowing the performance impact of NAT on a network device (specifically, a router) becomes critical, especially for HFT. Most modern switches can perform at least static NAT in an ASIC, but an increasing number can also do dynamic NAT with a little performance penalty.
Last updated on