Starting from:

$24.99

UCS413 Assignment#6 Solution


1. WAP to implement broadcasting using connectionless socket programming.
Each network segment has a corresponding broadcast address. Take the class C network segment 192.168.1.x as an example, where the smallest address 192.168.1.0 represents the network segment; and the largest address 192.168.1.255 is the broadcast address in the network segment. When we want to send a data packet to this address, all hosts on the network segment will receive and process it.



Broadcast packets are sent and received through UDP sockets. The broadcast packet sending process is as follows:
a. Create a UDP socket; socket(AF_INET, SOCK_DGRAM, 0)
b. Fill the broadcast information structure; struct sockaddr_in
c. Set socket options to allow broadcast packets to be sent; setsockopt(,----
,SO_BROADCAST,----------)
d. Send data packet; sendto()
The broadcast packet receiving process is as follows:
a. Create a UDP socket; socket(AF_INET, SOCK_DGRAM, 0)
b. Fill the broadcast information structure; struct sockaddr_in
c. Bind address and port; bind()
d. Receive data packet; recvfrom()

More products