network-programming

What is the difference between synchronous and asynchronous transmission in TCP/ IP socket programming?

寵の児 提交于 2020-01-13 08:41:26
问题 I am new to C++ and I am trying to develop a client-server application based on the boost::asio library. I am (still) not able to understand properly the difference between sync and async modes. I've previously studied web protocol services such as HTTP and AJAX. From this explanation, it's clear that HTTP is synchronous and AJAX is asynchronous. What is the difference in TCP socket communication in terms of sync and async? And which mode is better from the perspective of enterprise-level

Why I get the gateway IP as source address in Docker bridge networking?

半腔热情 提交于 2020-01-13 07:06:09
问题 I'm originally doing some composition with Docker bridge network, and noticed that instead of the whitelisted local IP, the requests are always sent from the gateway IP. To reproduce it with minimal effort, I used two Python containers to run a HTTP server and client: docker run -it --rm python:alpine sh On the server side: python -m http.server On the client side: wget 172.17.0.3:8000 Expected output, is that the request comes from the container IP: Serving HTTP on 0.0.0.0 port 8000 (http:/

Why I get the gateway IP as source address in Docker bridge networking?

本秂侑毒 提交于 2020-01-13 07:04:19
问题 I'm originally doing some composition with Docker bridge network, and noticed that instead of the whitelisted local IP, the requests are always sent from the gateway IP. To reproduce it with minimal effort, I used two Python containers to run a HTTP server and client: docker run -it --rm python:alpine sh On the server side: python -m http.server On the client side: wget 172.17.0.3:8000 Expected output, is that the request comes from the container IP: Serving HTTP on 0.0.0.0 port 8000 (http:/

How to perform packet pair probing by sending multiple packets rather than just one pair ? (method for taking average)

夙愿已清 提交于 2020-01-13 06:39:31
问题 Generally in a packet pair estimation, you are supposed to send multiple bursts of packet pairs and take an average of the bandwidths. Say, you send 4 packets, calculate the time difference between the first two packets(1&2), time difference between the next two packets(3&4). Calculate bandwidth for each of these two and then take average. Or Calculate the time difference between (1&2), time difference between (3&2), time difference between (4&3)... and then take an average out of these

How to perform packet pair probing by sending multiple packets rather than just one pair ? (method for taking average)

痴心易碎 提交于 2020-01-13 06:39:19
问题 Generally in a packet pair estimation, you are supposed to send multiple bursts of packet pairs and take an average of the bandwidths. Say, you send 4 packets, calculate the time difference between the first two packets(1&2), time difference between the next two packets(3&4). Calculate bandwidth for each of these two and then take average. Or Calculate the time difference between (1&2), time difference between (3&2), time difference between (4&3)... and then take an average out of these

What have you used to test (functional/load/stress) your network service with its custom protocol?

◇◆丶佛笑我妖孽 提交于 2020-01-12 08:23:14
问题 I recently created a turn-based game server that can accept 10s of thousands of simultaneous client connections (long story short - epoll on Linux). Communication is based on a simple, custom, line-based protocol. This server allows clients to connect, seek for other players in game matches, play said games (send moves, chat messages, etc.), and be notified when the game has ended. What I'm looking to do now is test the server by simulating client connections. I'm hoping to support 10s of

Simulate network latency on specific port using tc

我怕爱的太早我们不能终老 提交于 2020-01-12 06:04:48
问题 I'm trying to simulate a fixed time latency on tcp packets coming from source port 7000 using the tc command on ubuntu. The commands I'm using are: sudo tc qdisc add dev eth1 root handle 1: prio sudo tc qdisc add dev eth1 parent 1:1 handle 2: netem delay 3000ms sudo tc filter add dev eth1 parent 1:0 protocol ip u32 match ip sport 7000 0xffff flowid 2:1 There doesn't appear to be any delay caused by this filter, could someone please point out where I'm going wrong? Also, is there any way I can

Simulate network latency on specific port using tc

元气小坏坏 提交于 2020-01-12 06:03:32
问题 I'm trying to simulate a fixed time latency on tcp packets coming from source port 7000 using the tc command on ubuntu. The commands I'm using are: sudo tc qdisc add dev eth1 root handle 1: prio sudo tc qdisc add dev eth1 parent 1:1 handle 2: netem delay 3000ms sudo tc filter add dev eth1 parent 1:0 protocol ip u32 match ip sport 7000 0xffff flowid 2:1 There doesn't appear to be any delay caused by this filter, could someone please point out where I'm going wrong? Also, is there any way I can

How to copy a file from a network share to local disk with variables?

我只是一个虾纸丫 提交于 2020-01-12 01:55:53
问题 If I use the following line: shutil.copyfile(r"\\mynetworkshare\myfile.txt","C:\TEMP\myfile.txt") everything works fine. However, what I can't seem to figure out is how to use a variable with the network share path, because I need the 'r' (relative?) flag. The end result I would imagine would be something like: source_path = "\\mynetworkshare" dest_path = "C:\TEMP" file_name = "\\myfile.txt" shutil.copyfile(r source_path + file_name,dest_path + file_name) But I have had no luck with different

Over TCP communication in C, how can you indicate to stop calling read() for a request without knowing any prior information about the data?

怎甘沉沦 提交于 2020-01-11 13:20:12
问题 I am currently programming a server in C that communicates over sockets using TCP. The client is supposed to send {filename\n} + {file contents\n} and the server will store that information and then send a response on success. However, we can't be sure the client will actually send the proper information in a structured protocol. Often in simpler situations, we know a specified amount of bytes to be sent before and can wait until that specified number has been reached. In this case, we don't