Question

Write a C program that prints the default TCP, UDP, and SCTP send and receive buffer...

  1. Write a C program that prints the default TCP, UDP, and SCTP send and receive buffer sizes and run it on the systems to which you have access.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Solution

Code

#include <stdio.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <strings.h>
int main(int argc, char* argv[])
{
  
  
int socket_fd = socket(AF_INET, SOCK_STREAM, 0);

int receivebuffer;
int length = sizeof(receivebuffer);
int retu = getsockopt(socket_fd, SOL_SOCKET, SO_RCVBUF, &receivebuffer, &length);

int msg;
length = sizeof(msg);
getsockopt(socket_fd, IPPROTO_TCP, TCP_MAXSEG, &msg, &length);
printf("defaults: SO_RCVBUF: %d, TCP_MAXSEG: %d\n", receivebuffer, msg);

struct sockaddr_in serveraddress;
bzero(&serveraddress, sizeof(serveraddress));
serveraddress.sin_family = AF_INET;
serveraddress.sin_port = htons(13);
inet_pton(AF_INET, "127.0.0.1", &serveraddress.sin_addr);
connect(socket_fd, (struct sockaddr*)&serveraddress, sizeof(serveraddress));

length=sizeof(receivebuffer);
getsockopt(socket_fd, SOL_SOCKET, SO_RCVBUF, &receivebuffer, &length);
length = sizeof(msg);
getsockopt(socket_fd, IPPROTO_TCP, TCP_MAXSEG, &msg, &length);
printf("defaults: SO_RCVBUF: %d, TCP_MAXSEG: %d\n", receivebuffer, msg);
return 0;

}

Screenshot of the code

Output

---

all the best

Add a comment
Know the answer?
Add Answer to:
Write a C program that prints the default TCP, UDP, and SCTP send and receive buffer...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I need help with this. Thank you. Write a chat program to send/receive messages. The messages...

    I need help with this. Thank you. Write a chat program to send/receive messages. The messages will go through a server. The server should be able to handle up to 5 talks at the same time. Each talk will be between 2 clients. The server should log all messages. The project should be written in C and should be work on GNU/Linux systems.

  • 1. Which of the following commands will locate all of the program files on a computer...

    1. Which of the following commands will locate all of the program files on a computer on which the SUID bit is set? Select one: a. find / -type SUID b. find / -perm +4000 -type f c. find / -perm +SUID -type f d. find / -suid 2. A server/computer combination appears in both hosts.allow and hosts.deny. What's the result of this configuration when TCP wrappers runs? Select one: a. TCP wrappers refuses to run and logs an error...

  • Write a program that Reads a string from cin Prints the first and last letter without...

    Write a program that Reads a string from cin Prints the first and last letter without space in between, followed by endl For example, For an input seattle your program prints se(endl). For an input newyork your program prints nk (endl). You can assume that the length of the string is always greater than 1. LAB 0/10 ACTIVITY 1.9.1: Week2-4 Zip main.cpp Load default template. #include <iostream> using namespace std; 4int mainO 6 /* 8return Type your code here. /...

  • In this project,use java to write a chat program that enables real-time communication between 3 persons....

    In this project,use java to write a chat program that enables real-time communication between 3 persons. Specifically the program should permit chat sessions between 2 well as 3 persons,. In case of 3 persons, messages generated by one should reach the other two (Its a conferencing facility and not an individual chat facility). The chat program needs to allow a user to type messages, which should be conveyed to the other end(s) and displayed at the other end(s). The user...

  • 04. a) Write an 8051 C program to send values 00 through FFH to port Pl. b) Write an 8051 C program to send values -3 to +3 to port P1. c) Write an 8051 C program to toggle all bits of P1 (between 55...

    04. a) Write an 8051 C program to send values 00 through FFH to port Pl. b) Write an 8051 C program to send values -3 to +3 to port P1. c) Write an 8051 C program to toggle all bits of P1 (between 55H and AAH) with some delay d) A door sensor is connected to P1.1 and a buzzer to P1.7. Write an 8051 C program to monitor the sensor and when it opens (0') sound the buzzer...

  • 1. What would these iptables rules do? iptables -A INPUT -p tcp -m tcp --dport 80...

    1. What would these iptables rules do? iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT iptables -A INPUT -p tcp -m tcp --dport 443 -j ACCEPT Allow web server traffic Block web server traffic Force port 80 traffic to port 443 Allow traffic from both 80 and 443 using UDP protocols 2. Timestamps are important because can not be changed or deleted by attackers when configured properly, allows you to correlate events across the network can always...

  • Write a C program that prints the numbers from 1 to 100. But for multiples of...

    Write a C program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.

  • Write a C# program that prints a calendar for a given year. Call this program calendar....

    Write a C# program that prints a calendar for a given year. Call this program calendar. The program prompts the user for two inputs:       1) The year for which you are generating the calendar.       2) The day of the week that January first is on, you will use the following notation to set the day of the week:             0 Sunday                     1 Monday                   2 Tuesday                   3 Wednesday       4 Thursday                 5 Friday                      6 Saturday Your program should...

  • Using Python Please Question 1: Pine Tree Write a program that, prints a 'pine tree' consisting...

    Using Python Please Question 1: Pine Tree Write a program that, prints a 'pine tree' consisting of triangles of increasing sizes, filled with a character (' oror '$' etc). Your program should consist of three functions: 1. A function print_shifted_triangle (n, m, symbol). It prints an n-line triangle, filled with symbol characters, shifted m spaces from the left margin. For example, if we call print_shifted_triangle (3, 4, +"), the expected output is: +++ Left margin +++++ 4 spaces 2. A...

  • Write a C# program that prints a calendar for a given year. Call this program calendar....

    Write a C# program that prints a calendar for a given year. Call this program calendar. This program needs to use Switch Case in order to call the methods and format to print each month. The program prompts the user for two inputs:       1) The year for which you are generating the calendar.       2) The day of the week that January first is on, you will use the following notation to set the day of the week:      ...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT