ALL
When no need 3 handshakes in TCP?
OverviewIn the previous article titled Why TCP needs 3 handshakes simple answers were provided to the following three questions:Can application data be carried during the first handshake?Can application data be carried during the second handshake?Can application data be carried during the third handshake?Briefly, traditional TCP requires a three-way handshake to establish a connection, and during these three handshakes, only simple SYN and ACK packets are sent.From the perspective of utilizing network bandwidth resources, the TCP header at the transport layer plus the IP header at the net...
1,426 0 NETWORK TCP REASON EXPLANATION
Why TCP needs 3 handshakes
Prerequisite KnowledgeFirst, let's look at the control bits and state machine of TCP, which form the basis for understanding the three-way handshake of TCP.TCP Packet Control BitsThe control bits in the TCP packet header are used to control the status of the TCP connection and can indicate various control information such as connection establishment, termination, reset, etc.There are six common control bits:SYN (Synchronize Sequence Numbers): Requests to establish a connection (part of the three-way handshake). It is set in the initial packet during connection establishment, indicating that th...
90,836 2 NETWORK HANDSHAKE REASON EXPLANATION TCP
Difference between localhost and 127.0.0.1
Lots of people would think what the address 127.0.0.1 is when first seeing this address. In fact, 127.0.0.1 is a loopback address which refers to the local machine. It is generally used for local testing. When typing ping 127.0.0.1 on local command console, it will send network packets to local IP/TCP layer to test whether IP/TCP works properly or not. To those who are used to use localhost, it is actually mapped to 127.0.0.1 by default. There are hosts files in the system which store this mapping. Hence normally these two can be interchanged.# localhost name resolution is handled within ...
30,865 2 LINUX NETWORK LOCALHOST 127.0.0.1 LOCALHOST VS 127.0.0.1
Handle NXDomain error when resolving IP address in Ruby DNS resolver
In another post, we covered how to resolve SystemStackError when resolving IP address in Ruby. In this post, we would cover another common issue where a NXDomain error is returned when resolving an IP address. The NXDomain error means that the queried domain name does not exist in the DNS.In Ruby, DNS resolver library will use /etc/resolv.conf by default get the name servers to resolve the domain name. There are multiple DNS name servers can be specified in /etc/resolv.conf with below format.nameserver nameserver nameserver ...By default, only the top MAXNS name servers(3 in Linux by...
4,494 0 RUBY RUBY ON RAILS NETWORK DNS NXDOMAIN
Resolve SystemStackError issue when resolving IP address in Ruby
In Ruby, Resolv is the default DNS resolution implementation. It can be used to resolve IP address of a hostname. To use it, one just needs to require 'resolv' in the code. But sometimes, a user would want to check /etc/hosts first or some other mechanisms to resolve an IP address. In this case, one can require 'resolv-replace' and then replace the default DNS resolvers with customized DNS resolvers.For example, using resolv-replace, one would writerequire 'resolv-replace'Resolv::DefaultResolver.replace_resolvers([Resolv::Hosts.new, Resolv::DNS.new])Resolv.getaddress 'some-site.com'In this cas...
5,687 0 RUBY RUBY ON RAILS NETWORK
Configure static IP for Linux
When a Linux server is running, it has to have an IP so that other machines can talk to it. It is often desired that the server would own a static IP so that every time other machines want to connect to it, the same IP address would be used. This is extremely useful when there are virtual machines installed on a host machine where the virtual machine would start and stop now and then. To configure static IP address for a Linux server, the /etc/network/interfaces needs to be updated. Assuming there is a host only network is created for a network interface named eth1. The configuration woul...
Create host only network on VirtualBox
Previously we showed how to install Ubuntu in VirtualBox. What if we want to communicate with the host OS from within the Guest OS on VirtualBox? There are a few ways to do this. For example, bridged network, Host only networks. Today we will show you how to enable network communication between host OS and guest OS using host only networks.A host only network will not need to access the physical network interface of the host OS. It will create a network between different virtual machines and the host machine. This is very useful if you want to set up a network of machines which just need to co...
11,046 1 VIRTUALBOX NETWORK VIRTUAL MACHINE HOST-ONLY
gethostbyname vs getaddrinfo
getaddrinfo is slower than ping when resolving domain names. I think ping uses gethostbyname to resolve a domain name. The question becomes whether getaddrinfo is slower than gethostbyname. After testing with both functions, we find that getaddrinfo is really slow compared to gethostbyname. By strace tracking, we find getaddrinfo will communicate with DNS server 10 times and gethostbyname will communicate with DNS server communication twice.gethostbyname is an old way to resolve domain name, The disadvantage of it is that it does not support IPV6, so there is a gethostbyname2 which repla...