Introduction to Stream Control Transmission Protocol
Listing 3. read_sctp_msg.c
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <stdlib.h>
#include <netinet/sctp.h>
/* call by
nread = read_sctp_msg(sockfd, &msg)
*/
int read_sctp_msg(int sockfd, uint8_t **p_msg) {
int rcv_buf_size;
int rcv_buf_size_len = sizeof(rcv_buf_size);
uint8_t *buf;
struct sockaddr_in peeraddr;
int peer_len = sizeof(peeraddr);
struct sctp_sndrcvinfo sri;
int total_read = 0;
*p_msg = NULL; /* default fail value */
if (getsockopt(sockfd, SOL_SOCKET, SO_RCVBUF,
&rcv_buf_size, &rcv_buf_size_len) == -1) {
return -1;
}
if ((buf = malloc(rcv_buf_size)) == NULL) {
return -1;
}
while (1) {
int nread;
int flags;
nread = sctp_recvmsg(sockfd, buf+total_read,rcv_buf_size,
(struct sockaddr *) &peeraddr,&peer_len,
&sri, &flags);
if (nread < 0) {
return nread;
}
total_read += nread;
if (flags & MSG_EOR) {
/* trim the buf and return msg */
printf("Trimming buf to %d\n", total_read);
*p_msg = realloc(buf, total_read);
return total_read;
}
buf = realloc(buf, total_read + rcv_buf_size);
}
/* error to get here? */
free(buf);
return -1;
}
SCTP has full support out of the box for IPv6 as well as IPv4. You simply need to use IPv6 socket addresses instead of IPv4 socket addresses. If you create an IPv4 socket, SCTP will deal only with IPv4 addresses. But, if you create an IPv6 socket, SCTP will handle both IPv4 and IPv6 addresses.
This article provides a brief introduction to the IETF Stream Control Transmission Protocol and explains how it can be used as a replacement for TCP. In future articles, we will examine additional features of SCTP and show their use.
Resources
The Principal Site for SCTP (contains pointers to the RFCs and Internet Drafts for SCTP): www.sctp.org
The Linux Kernel Project Home Page: https://lists.sourceforge.net/lists/listinfo/lksctp-developers.
Stream Control Transmission Protocol (SCTP): A Reference Guide by Randall Stewart and Qiaobing Xie, Addison-Wesley.
Unix Network Programming (volume 1, 3rd ed.) by W. Richard Stevens, et al., has several chapters on SCTP, although some of it is out of date.
Jan Newmarch is Honorary Senior Research Fellow at Monash University. He has been using Linux since kernel 0.98. He has written four books and many papers and also has given courses on many technical topics, concentrating on network programming for the last six years. His Web site is jan.newmarch.name.
- « first
- ‹ previous
- 1
- 2
- 3
- 4
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Sponsored by AMD
If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.
Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.
Sponsored by ActiveState
| Speed Up Your Web Site with Varnish | Jun 19, 2013 |
| Non-Linux FOSS: libnotify, OS X Style | Jun 18, 2013 |
| Containers—Not Virtual Machines—Are the Future Cloud | Jun 17, 2013 |
| Lock-Free Multi-Producer Multi-Consumer Queue on Ring Buffer | Jun 12, 2013 |
| Weechat, Irssi's Little Brother | Jun 11, 2013 |
| One Tail Just Isn't Enough | Jun 07, 2013 |
- Speed Up Your Web Site with Varnish
- Containers—Not Virtual Machines—Are the Future Cloud
- Linux Systems Administrator
- Lock-Free Multi-Producer Multi-Consumer Queue on Ring Buffer
- Senior Perl Developer
- Technical Support Rep
- RSS Feeds
- Non-Linux FOSS: libnotify, OS X Style
- UX Designer
- Web & UI Developer (JavaScript & j Query)
- So when they found it hard to
51 min 49 sec ago - yea
1 hour 14 min ago - Reply to comment | Linux Journal
1 hour 36 min ago - Android has been dominating
1 hour 40 min ago - It is quiet helping
4 hours 26 min ago - Technology
4 hours 43 min ago - Reachli - Amplifying your
6 hours 3 sec ago - excellent
6 hours 48 min ago - good point!
6 hours 51 min ago - Varnish works!
7 hours 49 sec ago
Featured Jobs
| Linux Systems Administrator | Houston and Austin, Texas | Host Gator |
| Senior Perl Developer | Austin, Texas | Host Gator |
| Technical Support Rep | Houston and Austin, Texas | Host Gator |
| UX Designer | Austin, Texas | Host Gator |
| Web & UI Developer (JavaScript & j Query) | Austin, Texas | Host Gator |
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?




Comments
Excellent!
An excellent article concerning introduction to SCTP.
Very good!
/Best regards
J