Comment #3 on issue 2278 by [email protected]: the "branch" parameter in
Via header duplicated in different SIP transaction
http://code.google.com/p/mobicents/issues/detail?id=2278
Hi~
The output of my program is started at line 19064 in attach
file "server.log", and I attached the trace file of tcpdump.
The load of server is 1 http requests/per second, and continues 5 sec. Each
http request would create 3 pairs B2BUA so we have 6 SipSession per second.
The senario is that the program initiates a INIVITE from a HttpServlet
program, and send the INVITE to a Confernce Server.
When receving the 200ok(with SDP of confernce server) from conference
server, create a new INVITE with the sdp of receving 200ok from confernce,
and send the INVITE to user A.
When receving the 200ok(with SDP of user A) from User A, send back ACK(no
SDP) from user A, and send a ACK(with SDP of User A) to
conference server. Now, user A can communicate with the conference server.
The program in SIPAS uses a general B2BUA model.
In the wireshark trace file, The 172.28.18.237 is SIPAS, and 172.28.18.217
is conference server, 172.28.18.231 is a user pool, which contains a lot
users. Because the program get "Transaction exists error" as trying to send
the INVITE for User A, this INIVTE does not be sent and doesn't show in the
attached trace file.
The program try to create a conference for these three users:
00001-00002-00003, so we would have a tree pairs B2BUAs - conference-00001,
conference-00002, and conference-00003.
In the next run, the program would try to create a conference for
00004-00005-00006, and so on.
I use the following code to create a Invite message:
===== code start =====
/**
* Send Invite(no sdp) to confernece server.
*
* @param callee_lists
* @param conference_number
* @param parallel_call true
* @param req HttpServletRequest object
* @throws ServletException
* @throws IOException
*/
public void makeCall(List<String> callee_lists, String
conference_number, boolean parallel_call, HttpServletRequest req)
throws ServletException, IOException {
ConvergedHttpSession chs = (ConvergedHttpSession) req.getSession();
//create a new SipApplicationSession
SipApplicationSession sas = chs.getApplicationSession();
ServletContext sc = getServletContext(); // application object in
jsp page;
SipFactory sipFactory = (SipFactory)
sc.getAttribute(SipServlet.SIP_FACTORY);
SipServletRequest confernce_invite_req = null;
SipSession confernce_invite_session = null;
Address from_address = null;
Address conference_address = null;
Leg conferenceLeg = null;
Enumeration<String> e = new ListEnumeration<String>(callee_lists);
String callee_number = e.nextElement();
sas.setAttribute("sipas_phone_number", SIP_AS_PHONE_NUMBER);
sas.setAttribute("callee_enumeration_lists", e);
sas.setAttribute("conference_number", conference_number);
sas.setAttribute("isParallelCall", new Boolean(parallel_call));
//Call the first callee -- confernece 主席
from_address = sipFactory.createAddress("sip:"+SIP_AS_PHONE_NUMBER);
conference_address =
sipFactory.createAddress("sip:"+conference_number);
confernce_invite_req = sipFactory.createRequest(sas, "INVITE",
from_address, conference_address);
confernce_invite_session = confernce_invite_req.getSession();
confernce_invite_session.setAttribute("session_name",
callee_number+"_ConferenceLeg");
confernce_invite_session.setAttribute("isPresident", new
Boolean(true));
conferenceLeg = new ConferenceLeg(confernce_invite_session );
//ConferenceLeg
conferenceLeg.init(getServletConfig());
conferenceLeg.setInviteRequest(confernce_invite_req);
debug("confernce_invite_req = " + confernce_invite_req);
confernce_invite_req.send();
}
===== code end ======
When SIPAS received the 200ok (with SDP) of conference server, exeute the
following code:
===== code start =====
public void doSuccessResponse(SipServletResponse resp) throws
ServletException, IOException {
if (resp.getMethod().equals("INVITE")) {
inviteResponse = resp;
SipApplicationSession sas = resp.getApplicationSession();
SipSession conference_session = resp.getSession();
String conference_number =
(String)sas.getAttribute("conference_number");
String session_name =
(String)conference_session.getAttribute("session_name");
String callee_number =
session_name.replace("_ConferenceLeg", "");
debug("callee_number="+callee_number);
//call president of this conference.
Address from_address =
sipFactory.createAddress("sip:"+conference_number);
Address request_to_address =
sipFactory.createAddress("sip:"+callee_number);
SipServletRequest callee_invite_req =
sipFactory.createRequest(sas, "INVITE", from_address, request_to_address);
Boolean isPresident =
(Boolean)conference_session.getAttribute("isPresident");
SipSession callee_session = callee_invite_req.getSession();
Leg calleeLeg = new CalleeLeg(callee_session);
calleeLeg.init(getServletConfig());
calleeLeg.setInviteRequest(callee_invite_req);
//set the peer leg in session object
conference_session.setAttribute("CalleeLeg", calleeLeg);
callee_session.setAttribute("ConferenceLeg", this);
callee_session.setAttribute("isPresident", isPresident);
callee_session.setAttribute("session_name",
callee_number+"_CalleeLeg");
debug("send Invite(sdp(conference)) to callee");
//copy the SDP from resp, and send the callee_invite_req
sendWithCopiedContent(callee_invite_req, resp);
} else if (resp.getMethod().equals("BYE")) {
debug("receive 200 OK of BYE from conference");
//resp.getApplicationSession().invalidate();
}
debug("send ACK(sdp(caller)) to callee: "+new java.util.Date());
}
protected void sendWithCopiedContent(SipServletRequest res,
SipServletResponse orig)
throws IOException, ServletException {
String type = orig.getContentType();
if (type != null)
res.setContent(orig.getRawContent(), type);
res.send();
}
===== code end ======
When SIPAS received the 200ok (with SDP of user A), send ACK to user A, and
send ACK with SDP to conference server.
===== code start =====
protected void doSuccessResponse(SipServletResponse resp) throws
ServletException, IOException {
//receive 200 ok from callee, reinvite caller.
debug("doSuccessResponse(): "+resp.getMethod());
debug("receving 200 ok from callee");
SipApplicationSession sas = resp.getApplicationSession();
if (resp.getMethod().equals("INVITE")) {
inviteResponse = resp;
debug("send Ack of 200ok to ConfernceLeg..");
Leg confernceLeg = getLeg("ConferenceLeg");
SipServletRequest ack_to_conference =
confernceLeg.inviteResponse.createAck();
//copy the SDP from resp, and send the ack_to_conference
sendWithCopiedContent(ack_to_conference, resp);
debug("send Ack of 200ok to CalleeLeg..");
SipServletRequest ack_to_callee = inviteResponse.createAck();
ack_to_callee.send();
} else if (resp.getMethod().equals("BYE")) {
debug("receive 200 OK of BYE from callee:"
+resp.getSession().getAttribute("session_name"));
Leg confernceLeg = getLeg("ConferenceLeg");
debug("send BYE to ConferenceLog");
confernceLeg.session.createRequest("BYE").send();
}
}
===== code end =====
Attachments:
server.log 7.6 MB
transaction_exists_20110119.pcap 291 KB