I am facing a situation when my sip client sends a deregister with call ID without IP address.
Call-ID: ZbTZ3VwsZoknVtlvROGGsOO8pt0hpFi.
This message is causing looping of the 200 OK responses as the via header of the next register message from same client is changed.
The situation is as follows
Request
deregister :LanClient--->Proxy-->Server
Response
Repeat:
100 trying :Server-->Proxy--xx->LanClient
200 Ok :Server-->Proxy--xx->Lanclient
goto Repeat
When one deregister message(i.e register message with expires=0) goes to the server the Via header contains the WAN IP of our proxy rather than LAN Client IP.This causes the respones from the server to go the WAN IP than the LAN IP.
What I am curious about is about that out of multiple clients registered with the server only the problem client messages have Call-ID field without an IP address.
I know that we can have call-ID without IP address. How would having an IP or not Having an IP in call ID make a difference in my scenario...
The value of the Call-Id header is just a string, at least from the perspective of the receiver of the request.
When a client deregisters, it should use the same Call-Id that was used for registration.
I don't understand the Via header part. Obviously, consequtive REGISTER requests (and other messages as well) has different Via headers since the branch parameter is new for every transaction.
Related
How do sip addresses work? Is every email address a sip address? Like can I just ask two people for their email address and create a sip session between them? Can I issue sip addresses by creating emails for users? Thanks.
SIP address (more precisely: SIP URI) looks like an e-mail address but indeed it has totally different meaning. For example:
sip:john#example.com
means that there is an account named john on SIP Proxy server example.com (or on SIP Proxy server resolved from example.com).
When user john starts own SIP client, it sends a register message to SIP Proxy server. Thanks to this, the SIP Proxy server knows whether john is registered as well as his current IP address.
When other SIP user intends to create session with sip:john#example.com the following steps are performed:
example.com is translated into domain name of SIP Proxy server using DNS SRV.
The INVITE message is send towards this SIP Proxy server.
If john is registered, the INVITE is transferred to his client. If not, 404 response is sent back to originate user.
According your questions:
Is every email address a sip address? Definitely no.
Like can I just ask two people for their email address and create a sip session
between them? No.
Can I issue SIP addresses by creating emails for users? No.
I am using a Linphone mobile app on android and a Freeswitch server for Audio/video calls.
Now when Linphone sends a Register request to server it gets multiple contact headers in the 200OK response from the Freeswitch Server.
**Contact:
;expires=3211
**Contact: ;expires=3303
**Contact: ;expires=3475
**Contact: ;expires=3600
Because of these bindings,server tries to send invite to multiple contacts for B-leg at the time of call.
Can somebody help me with the probable cause for multiple contact headers in 200OK from server side?
RFC 3261 states in 10.2.4 Refreshing Bindings:
The 200 (OK) response from the registrar contains a list of Contact fields enumerating all current bindings.
Multiple bindings for a single AOR can be registered
by different SIP instances, each registering their own contact address, and/or
by a single SIP instance when it has multiple contact addresses
by a single SIP instance when it registers its new contact address without first unregistering its previous (outdated) address
Looking at your comment it appears the same number (1008) is registered with multiple IP addresses. You should check the REGISTER request(s) your Linphone app sends:
If it contains multiple contact addresses then the host your app runs on is multihomed.
If it registers different contact addresses in subsequent sessions you could consider unregistering a contact address before ending a session.
Otherwise probably other SIP phones in the system register with the same number.
Update:
Extended answer to reflect comment by #artemy-vysotsky
I am currently working on a project that collect a users login and extension information through parsing SIP header messages after capturing packets. I am currently using PCAP.net and SIPSorcery libraries to accomplish this. The project is written in C#
How it works:
By using filters in PCAP.net I can zone in on the SIP related traffic. Each time a packet is captured an event is fired and I check for the packet type e.g. whether it is SIP or something else UDP related such as DNS. If this is a SIP message I parse the header pulling out the information I am interested in
The problem:
Some SIP endpoints generates multiple registration packets which contains the same UID. It is hard to keep track of a single session and when the endpoint is actually finally registered (i.e. receives the 200OK from the SIP Server). I tried using Dictionary with CallID and then checking when a packet is received if it is already in the Dictionary.
The question:
How do I keep track the session so I know when I receive the 200OK for that particular session, it is registered and stream is complete
A SIP endpoint sends a REGISTER request to bind its contact address(es) to an address-of-record. Such a registration is identified by the Call-ID header field.
Keep in mind that multiple REGISTER requests with the same Call-ID value can occur because:
the endpoint will periodically update its registration, since every registration has an expiration interval
a REGISTER request is challenged for authentication and the SIP endpoint sends a new request with authentication information.
retransmissions
Furthermore, a 200 response doesn't mean that the endpoint is registered. You should check the 'expires' header and/or contact parameter to know how long the registration will remain valid.
Call-ID field in the SIP message is used to track a SIP session. Check RFC 3261 to get more details about Call-ID.
Call-IDs act as unique identifier for a SIP session. In your case you can try searching the Call-ID from the SIP-REGISTER message to track the subsequent messages.
Suppose that I have to write a UDP server which should receive authentication token for each client in the first message and then receive different data after some period of time. This UDP server should obviously check whether certain client authenticated previously or not. How should I do it? Should I store "authenticated" flag for each (IP addr, port) pair? Is it ok? If so, what will happen if several clients will have the same IP address (for example, they share it from the same internet provider)?
I think you can't. You'll need to have the token in each message. Multiple requests can come from the same IP, such as a client connecting from behind a NAT.
This a rare case where you might want to use multiple UDP sockets at the server and connect() each of them to one authenticated client, so that you can only receive further messages on each one from each authenticated client. You'll have to send the first reply via hat socket,a denture client will have to be written to adjust its destination accordingly after receiving the first reply.
when client sends a request to server, one entry is inserted in nat table (in router). After client received response, this entry will be deleted. Server can't send message to client if client doesn't issue request (client is in private network)
However in case of bidirectional socket, how to accomplish this issue:
1. How does server actively sends message to client ?
[updated from comments]
I want to implement server-push architechture, so I need to know more about NAT.