I have implemented SIP calls over TCP.
Now I intend to extrapolate it to REGISTRATION over TCP.
I have a reference PCAP with the following flow:
Logic for Sequence number and Acknowledgement number for initial registration:
A------------------------------------B Seq - Ack - Size
REGISTER
----------------------------------→ 1 - 1 - 709
100 Giving a Try
<---------------------------------- 1 - 710 - 358
401 Unauthorized
<---------------------------------- 359 - 710 - 459
REGISTER
----------------------------------→ 710 - 818 - 931
100 Giving a Try
<---------------------------------- 818 - 1641 - 358
200OK
<---------------------------------- 1176 - 1641 - 450
sequence number of current leg= (sequence number of previous leg in same direction+window size of previous leg in same direction.)
Ack number of current leg =(Ack number of previous leg) {if current leg is in same direction as previous one}
=(sequence number of previous leg)+(window size of previous leg ) {else}
I am trying to understand the following:
Should the refresh instance be part of the same TCP stream?
Which means should the Src and dest IP addresses and Src and Dest Port addresses of the refresh instance be the same as the initial registration?
What logic should be applied to the Seq and Ack numbers?
Should they be in continuation to the previous messages (initial registration attempt) or should these values be as if a new instance is being generated between the given devices?
PS: I am working on a tool that generates calls among devices, so src and dest message code is within my realm.
SIP registrations are independent of the used transport protocol. If you want to update an existing SIP registration that was established over a TCP connection you can send the registration update request over the same TCP connection, another TCP connection or even via UDP. As long as the request is sent to the same registrar the update request will be treated as such.
More information on the use of seq numbers and SIP registration (update) in the Registration section of RFC 3261.
More information SIP registration paths and the use of (different) transport protocols in RFC 5626.
Related
Say there are 2 nodes - A and B. Each of them maintains a state, which is a number in their memory. If A sends an increment somehow to B, then B will return 1. A sends an increment again, B will return 2. And so on. Same for B. And both A and B can update its state atomically.
For sending the increment, let's say B starts a TCP server to accept connections, and A is the client that establishes the connection with B. A can send increment to B through that established TCP connection.
Now, the question is: Can B also send increment to A through the same connection, and can A respond back with its own state through that connection?
Moreover, can A and B both send increments and respond to each other concurrently through the same connection? So that if A and B send increment simultaneously to each other, they can respond back with 1.
It’s an easy problem if A and B establish 2 connections - one for A as the client to send increment to B, and the other for A as the server to respond increment from B. And since there are 2 connections, A and B can send “increment” concurrently. But I wonder if it’s possible for A and B to exchange data with only one TCP connection? Does any protocol support this?
Yes, it's possible. A and B can both exchange data through the same connection. However, one of them will act as a server and the other as a client. In fact, even if A tries to connect to B and B to A at the same exact time, TCP is designed so that scenario results in only one connection. This situation is called simultaneous opening. Keep in mind that the classic concept of client and server don't exist per se in the TCP specs (they're just peers), although is intuitive and helpful to regard the peer that performs the active opening as a client and the one that perform the passive opening as a server.
As per data exchange, both can send increment messages to each other through the same connection. Check RFC 675 and RFC 793(The TCP reference) for more detailed in depth info.
I have a very simple question which answer seems impossible to find as I want it. Let’s suppose I have a tcp connection between a client and a sever and the client made a request for a page that contains 2 files. We assume that the http connection is persisted and with pipeline so the 2 requests for the files are send in one tcp segment to the from the client to the server. Now suppose the files that the client wants are like 4500 bytes and 3000 bytes and the MSS of tcp is 1460 bytes because we are using ethernet, so the first file should be divided in 3 segments of 1460 and one of 120 while the second file is divided in 2 segments of 1460 and one of 80 (at least this is what happen if tcp send one file only).
In this situations how many segments tcp will send? The first 4 of the first file and the 3 of the second file or it will “merge” the 2 file together at first and then send that file divided? In the second case we would have a file of 7500, 5 MSS + 200 bytes.
I can’t find anywhere informations about this problem. So in the end my question how is the pattern of the segments send by tcp:
3 MSS -> 120 bytes -> 2 MSS -> 80 bytes
Or
5 MSS -> 200 bytes
I can’t understand how tcp could send a segment containing bytes of 2 different files.
I can’t understand how tcp could send a segment containing bytes of 2 different files.
From the perspective of a user application TCP is just a byte stream and nothing is known how these bytes were delivered in packets. At the TCP itself there is no idea of files or HTTP requests and responses. The distinction between these is done at the application level instead, i.e. in this case at the level of the HTTP protocol.
The HTTP protocol defines that each request and response consists of a header and a body which are distinguished by an empty line. The size of the body or body parts are known up-front, i.e. either given in the header (using the content-length field) or given before each body chunk (with transfer-encoding: chunked). This way the end of the body and thus the beginning of the next request/response can be determined by the HTTP protocol parser. And it does not matter at all how these data are packetized at the underlying TCP layer.
I am using Wireshark to capture TCP communication packets in my experiment (using Mininet Simulation). The experiment involves a client (10.0.0.2) who requests HTTP page from the server (10.0.0.1). The following screenshot shows the capturing number 75 when the client sends HTTP GET and capturing number 89 when the server responds. Between them, I don't know what these packets are. Are they important in terms of TCP communication?
Thank you
depends on what you are analyzing. If you are concerned with the HTTP conversation then right click on one of the http rows and click- follow TCP stream. This lets you see entire http session. If you are having issues with the underlying TCP connection then those in-between rows become important.
The Windows registry has a key TcpAckFrequency (default 2), which sets the number of TCP packets received before sending back an ACK packet. Also, there is a TcpDelAckTicks key defining the delay (default 2 i.e. 2 * 100 ms = 200 ms) after which an acknowledgment is sent anyway, even if TcpAckFrequency is not reached.
Is there any way to change (temporarily) these parameters using WinSock API or other APIs, but without modifying the registry?
Thank you very much in advance.
What is the maximum size of HTTP packets? I am interested in the size of the response to an HTTP GET request (Not this! This question is about the request size). Is there a size at all? If I download a 1GiB file, does that end up as just 1 HTTP GET request? (Intuitively, I do not think this happens - Also, partial downloads / multi threaded downloaders would not work).
I know that there is a maximum length of an IP packet and TCP packets that are longer than that are fragmented across multiple IP packets. Does such a thing happen with HTTP as well? The reason I am looking for an answer to this question is to figure out the AWS S3 billing scheme which charges 1c / 10K get requests. So how many GET requests are begin served for 1GiB.
I got an answer on AWS S3 Forum by Seungyoung Kim
If you download the 5GiB file using GET request. S3's billing system
will count it as 1 GET request and 5GiB data transfer. FYI, if you
stop downloading file at 2GiB out of 5GiB, then they will count only
2GiB data transfer.
GET request is not fragmented normally unless you split up the call
into several consecutive GET range calls.
So, if you issue 5 individual GET requests using range header for each
1GiB data block, they will count it as 5 GET request but still same
5GiB(1GiB x 5 times) data transfer. Technically little more than 5GiB
due to additional HTTP protocol headers.
If this is right, there is no packet fragmentation of HTTP GET Response (although they come across several TCP packets and a lost TCP packet is handled by TCP and does not illicit another GET request to resume)