# 6. - SIP Messages

SIP messages are the communication units used by SIP endpoints to establish, modify, and terminate multimedia sessions. SIP messages are exchanged between SIP user agents, proxy servers, and redirect servers, and are used to initiate and control communication sessions between two or more parties. The messages consist of a request or response line, message headers, and a message body, and are used to exchange information about the session, including media types, codecs, addresses, and authentication credentials. SIP messages can be sent over UDP, TCP, or TLS transport protocols.

Here are some examples of a SIP message

SIP Invite Message

```
INVITE sip:user@example.com SIP/2.0
Via: SIP/2.0/UDP 192.168.1.100:5060;branch=z9hG4bK123456789
From: Alice <sip:alice@example.com>;tag=987654321
To: Bob <sip:bob@example.com>
Call-ID: 123456789@192.168.1.100
CSeq: 1 INVITE
Contact: <sip:alice@192.168.1.100>
Max-Forwards: 70
Content-Type: application/sdp
Content-Length: 100

v=0
o=- 123456789 123456789 IN IP4 192.168.1.100
s=Session
c=IN IP4 192.168.1.100
t=0 0
m=audio 5004 RTP/AVP 0
a=rtpmap:0 PCMU/8000

```

SIP OK Message

```
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.1.100:5060;branch=z9hG4bK123456789;received=192.168.1.100
From: Alice <sip:alice@example.com>;tag=987654321
To: Bob <sip:bob@example.com>;tag=123456789
Call-ID: 123456789@192.168.1.100
CSeq: 1 INVITE
Contact: <sip:bob@192.168.1.101>
Content-Type: application/sdp
Content-Length: 100

v=0
o=- 123456789 123456789 IN IP4 192.168.1.101
s=Session
c=IN IP4 192.168.1.101
t=0 0
m=audio 5004 RTP/AVP 0
a=rtpmap:0 PCMU/8000

```

SIP Notify Message

```
NOTIFY sip:alice@example.com SIP/2.0
Via: SIP/2.0/UDP 192.168.1.101:5060;branch=z9hG4bK987654321
From: Bob <sip:bob@example.com>;tag=123456789
To: Alice <sip:alice@example.com>;tag=987654321
Call-ID: 987654321@192.168.1.101
CSeq: 1 NOTIFY
Event: message-summary
Subscription-State: terminated;reason=noresource
Content-Length: 0

```

SIP Prack Message

```
PRACK sip:bob@example.com SIP/2.0
Via: SIP/2.0/UDP 192.168.1.100:5060;branch=z9hG4bK123456789
From: Alice <sip:alice@example.com>;tag=987654321
To: Bob <sip:bob@example.com>;tag=123456789
Call-ID: 123456789@192.168.1.100
CSeq: 1 PRACK
Max-Forwards: 70
Content-Length: 0

```