Chap 1 Foundation Broadcasting Chap 20
Introduction Use of broadcasting to know server address on the local subnet: resource discovery to minimize network traffic on a LAN Internet applications ARP(Address Resolution Protocol) BOOTP(Bootstrap Protocol) NTP(Network Time Protocol) Routing daemons: broadcast routing table
Broadcast Addresses Subnet-directed: [subnetid, -1] Normally routers do not forward these broadcasts most commonly used today E.g.) ping 203.253.70.255 Limited broadcast: 255.255.255.255 must not forwarded by a router Some systems do not understand a subnet-directed broadcast address and only interpret 255.255.255.255 as a broadcast TFTP and BOOTP use this address to know IP address of its diskless workstation on bootstrapping procedure
Unicast versus Broadcast
dg_cli Function using Broadcasting Before broadcasting, set SO_BROADCAST socket option const int on = 1; setsockopt(sockfd, SOL_SOCKET, SO_BROADCAST, &on, sizeof(on)); First example dg_cli: Figure 20.5 bcast/dgclibcast1.c SIFALRM signal이 blocked system call(recvfrom)이외에서 deliver되면 loop을 빠져 나오지 못함 Race Condition: shared data를 여러 process들이 동시에 access할 때 time-dependent error 발생 Case 1: shared data(global variable) among threads Case 2: dealing with signals signal handler도 일종의 thread로 봐야 dg_cli with blocked signal: Figure 20.6 bcast/dgclibcast3.c Still has race condition problem
dg_cli Function that broadcasts bcast/dgclibcast1.c 문제점 SIFALRM signal이 blocked system call(recvfrom)이외에서 deliver되면 loop을 빠져 나오지 못함 Race Condition: shared data를 여러 process들이 동시에 access할 때 time-dependent error 발생 Case 1: shared data(global variable) among threads Case 2: dealing with signals signal handler도 일종의 thread로 봐야
Correct Solutions for Avoiding Race Condition bcast/dgclibcast5.c