osip user manual文档格式.docx
《osip user manual文档格式.docx》由会员分享,可在线阅读,更多相关《osip user manual文档格式.docx(43页珍藏版)》请在冰点文库上搜索。
![osip user manual文档格式.docx](https://file1.bingdoc.com/fileroot1/2023-5/10/4fe165c9-da60-447e-8589-8e6ed098e6fa/4fe165c9-da60-447e-8589-8e6ed098e6fa1.gif)
SIPtransactions
SIPsessions
Serverbehavior
3.TheoSIPLibrary
Thegoals
Thedevelopmentlevel
Theparser
Thestatemachines
Thetransactionmanager
WhowillbenefitfromoSIP
Availableports
4.TheoSIPparser
files
SIP-URL
Definitionandpurpose
APIforSIP-URL
APIforurl_param_tandurl_header_t
SIPheaders
CommonAPIforallimplementedheader.
SpecificAPIfor"
To"
header
APIforgenericparam
SIPmessages
definitionandpurpose
APIforSIPmessage
MACROs
TheparserHOW-TO.
Initialisetheparser
Allocateastructure
createaURLandaRequest-URI.
Addheadersinamessage
makeastringfromastructure
freeresourceinastructure
Howtoimprovetheparserperformance
5.TheoSIPstatemachines
Transactionandevents
Definitionandpurposeoftransaction
Definitionandpurposeofsipevent
API
Thecallbacks.
UsefulMACROs.
ThefinitestatemachinesHOW-TO
Initialisetheosipstack
Allocateandinitializeanosip_telement
Sendeventstocontroltransaction
Notesforproxyimplementation
Buildyourownarchitecture
Bibliography
Chapter1.TheSIPprotocol
SIPisasignalingprotocolusedtoinitiateandcontrolmultimediasessions.ItisalreadypublishedbyIETF(www.ietf.org)astherfc2543.
SIPispartoftheIETFefforttobringtelephonyontheIPnetwork.ItisabouttobecomethestandardusedbytheemergingIPtelephonyindustry.Assimpleasthemailprotocol,itmaybecomeaspopular...
SIPisindependentofmedia
Thetraditionaltelephonywasbasedononemedia.Now,it'
sover.YourphonewillbeabletoconnecttoaTV,toacamera,toothersphoneswithdifferentqualitiesanddifferentcodecs.Hopefully,SIPisindependentofanymediausedbytheapplications.SIPisabletonegotiatemediausedwithinsessions.Anymultimediaapplication(games,distancelearningapplication)canuseSIPtosetupsessions.
SIPisindependentofthetransportlayer
SIPisnottighttoanytransportprotocol.Thisaspectwillminimizeeffortstointeroperatewithnewthirdgenerationnetworks.Wirelessphonesarealsoconcerned.ASIPstackperfectlyfitsthesignalingneedsofthenewcellulars'
generation.
SIPisextensible
Therfc2543defines6typesoftransaction(INVITE,BYE,CANCEL...).Thosetransactionsareusedtonegotiatemedia,setup,modifyandterminatecalls.ManyservicesarealreadyprovidedthiswaybutSIPisdesignedforextensibilityandthetransactionalmodelcanbereused(transparentlyforservers)bynewtypeoftransactiontocreatesomesupplementaryservices.Hereisalistofpossibleservices:
MESSAGEforinstantmessaging
SUBSCRIBE/NOTIFYforpresencemanagement
REFERforcall-transfermanagement
SIPtransparentlysupportsnamemappingandredirectionservices,allowingtheimplementationofISDNandIntelligentNetworktelephonysubscriberservices.Thesefacilitiesalsoenablepersonalmobility."
rfc2543.txt(Section1.1)
SIPserversareusedtolocateusersanddistributelocation(throughurls)ondemand.Thisway,enduseragentshaveveryminimalrequirementsandstillhaveaccesstoawidevarietyofservices.
Manyextensionsarealreadyavailableasdraft.Yourcanalsoaddyourpersonalphonecapabilitiesandremaininteroperablewithexistingservers.
Chapter2.SIPoverview
ThissectiondoesnotintendtofullydescribetheRFC.Itisafastandincompleteoverviewoftheprotocolsyntaxandbehavior.
SIPsyntax
SIPisatextprotocolbasedonutf8encoding.(makingitmorereadableandeasiertodebug)SIPdescribesasyntaxforSIPrequests,URL,responsesandtheirheaders.ThefullsyntaxisavailableatColumbiainanaugmentedBNFform.
ThesyntaxisborrowedfromtheMAILandHTTPsyntax.6typesofrequestsaredefinedbySIP.Thebasicavailablemethodsare:
INVITE
ACK
CANCEL
BYE
INFO
OPTIONS
AsyoucanseeintheBNFdefinitionofrequest(seerfc2543.txtsection3),SIPisnotlimitedtothisshortlistofmethodsandincludesinitsdefinitiontheextension-methodtoken.AnyotherrequestcanbehandledbyoSIP.NOTIFYandSUBSCRIBEaregoodexamplesofnewpossiblemethods.TheseonesareusedspecificallytoprovidepresencecapabilitiestoyourSIPphonewithoutmucheffort.
Example2-1.INVITErequest
INVITErequestsareusedtoinitiateandmodifysessions.Here,chafromiscallingjackatdomainatosc.org.Thisrequestshouldbesenttotheproxyservermanagingatosc.org,itwillforwardthecalltojackathisrealIPaddress.
INVITEsip:
jacK@atosc.orgSIP/2.0
Via:
SIP/2.0/UDPhome.sipworld.org
To:
sip:
From:
cha@sipworld.org
Call-ID:
35778645354@home.sipworld.org
CSeq:
1INVITE
Contact:
cha@home.sipworld.org
Content-type:
application/sdp
Content-length:
267
v=0
o=user1536557652353687637INIP4128.3.4.5
s=MboneAudio
i=DiscussionofMboneEngineeringIssues
e=mbone@
c=INIP4128.3.4.5
t=00
m=audio3456RTP/AVP0
a=rtpmap:
0PCMU/8000
SIPtransactions
Inordertocontrolsessions,SIPusestransactions.Transactions(INVITE,CANCEL,BYE...)usuallyresultinamodificationofacurrentsession.Someothertransactions(SUBSCRIBE,NOTIFY...)arenotboundtoasession.Atransactioniscomposedofonerequestanditsresponses(manyinformationalresponsesandonefinalresponse).Thefollowingheaders:
To,From,Call-IDandCSeqareusedtoidentifymessageswithinatransaction.
AsSIPcanuseunreliabletransportprotocol(UDPisrecommendedontheIPnetwork),SIPalsodefinesretransmissionrulesformessageswithinatransaction.
Example2-2.INVITEtransaction
Thisisthemostbasiccallflowshowingtheinitiationofasession.OnlytwoSIPUserAgents(UAC/UAS)areinvolved.(retransmissionsarehidden)
UAC1UAS2
jacks|INVITE|
initiatea|----------------->
|Bob'
s
call||Phonestarts
|180Ringing|ringing
|<
-----------------|
|180Ringing|
|<
|200OK|
|ACK|
|----------------->
|
SIPsessions
Transactionsareusedbyuseragentasmeanstocontrolsessions.AsessionisalwaysinitiatedbyanINVITE.SIPdefinesalargesetofanswercodes.Aproxymayansweryouthewellknown"
404UserNotfound"
asforanHTTPerror.Errorshavedifferentlevels.Atransactioncanfailbutstillproposesnewlocationstotry.Responsesfromclass3xxserveasredirectionmechanism.4xx,5xxand6xxresponsesarerespectivelyreservedforclienterror,servererrorandglobalfailure.
Example2-3.Acompletesession
First,bothuseragentsmustsendaREGISTERtoaregistrar.Inthefollowingexample,theproxyalsosupportregistration.
ThissessionisinitiatedwithanINVITEtransactiontojoinjackat.Aredirectiontojack'
sofficeismadebytheredirectserverof.UA1understandstheredirectionandsendsanewINVITEtowardstherealUserAgent(UA2)currentlyusedbyjackatoffice.atosc.org.UA2firstringsandjackacceptsthecallwitha200OKresponse.Afterseveralminutes,jackandbobwanttousetheirnewcameras.ThesessionismodifiedwithanINVITEsentbyjacktonegotiatenewparametersforvideo.Thesessionisfinallyendedbybob.
BOBJack(atosc.org)
UA1PROXYUA2
|REGISTER|.
|-------------->
|.
|200OK|.
--------------|.
...
later......
.|REGISTER|
.|<
--------------|
.|200OK|
.|-------------->
|INVITEjack@.
|302Movedtemporarily.
|ACK|.
|INVITEjack@office.atosc.org|
|audio|
|------------------------------>
|180Ringing|
------------------------------|
|ACKjack@office.atosc.org|
..
later..
|INVITEbob@|
|audio+video|
|ACKbob@bob.home.org|
|BYEjack@office.atosc.org|
||
SIPdefinesbehaviorsforproxy,redirectandregistrarserver.Forcompleteinformation,pleasereadtheRFC...
Usually,auseragentsendsitsrequeststoanoutboundproxy.Asusersdonotknowthecurrentlocationoftheircorrespondent,theyuseforthesipurlausernameandadomain.Theoutboundproxy(wherefirewallcapabilitiescanbeinserted)usesDNSSRVRECORDStofindserversbelongingtotherequesteddomain.Oncetheserverisfound,therequestisforwarded.Thisserveristheinboundproxyofthecorrespondent.Iftheuserisavailable,itsapplicationmusthaveregistereditslocationbefore,sotheproxyisnowabletoforwardtherequestto