CSC461-CN-Lecture-8-Jan-30-2013
-
Upload
manishya-krishna -
Category
Documents
-
view
213 -
download
0
Transcript of CSC461-CN-Lecture-8-Jan-30-2013
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
1/96
BITS PilaniPilani | Dubai | Goa | Hyderabad
Programming for the
Networked EnvironmentsLecture-8, January 30, 2013Rahul Banerjee, PhD (CSE)
Professor, Department of Computer Science & Information Systems
E-mail: [email protected]
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
2/96
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Simple basics that go into programming for thenetwork-based applications: Generic and Socket
APIs
Briefly revisiting the TCP/IP Architecture Current State-of-the-art and Evolving Research
Directions From Clusters and Grids to Clouds Wearable Computing Ubiquitous or Pervasive Computing
Select References to the literature Summary
Interaction Points
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
3/96
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Simplest way to understand this is to look at theway applications are expected to communicate
over the network. Lets assume that we need to write a simple application that
could work for getting some data over the network!
Example-1: A rudimentary short data transfer application andinvolved logic
Example-2: An elementary large data transfer application andinvolved logic
Lets next see the way things get done in realsystems!
How do we write simpleprograms for the networks?
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
4/96
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
The application-processes of the simplest kind mightinvolve a client-server relationship.
APIs help! All network-capable Operating Systems have some
application programming interface (API) that makesapplication-to-application communication possible over
networks without necessarily knowing intricate details of
the underlying mechanisms.
University of California at Berkeleys BSD Socket API isone of the most common APIs in use for writing such
applications
Lets us see how things work in this case, fromprogrammers point of view!
Simple Basics of Programmingfor Network-based Applications
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
5/96
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Server-side operations Client-side operations In each case, in the world of the Internet, we have,
often, two basic choices to make: Octet-stream-oriented reliable communication Datagram-oriented so-called unreliable communication
Lets see the first type first! Create a socket or an end-point on the server side Associate a transport port or a local address at which the application
shall listen to incoming requests
Enable and announce that server is ready to listen at this port withqueue-size
Accept any incoming (passive) connection request
Basic Operations Involved
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
6/96
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
At client-side: Create a socket or an end-point Send (passive) connection request to serverOverall:
Connect
Send
Receive
.
Close
Basic Operations Involved
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
7/96BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Lets take a closer look at theentire matter!
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
8/96
Network Architecture of the Internet
Wednesday, 30 January 13 8(c)Dr.RahulBanerjee,BITS-Pilani,INDIA
LLC Sub-layer
MAC Sub-layer
Physical layer
TheInternetLayer
TCP(Transport)Layer
ApplicaonLayer
TheHost-to-Network
Interface Link-Layerasper
OSIReference
Model
Physical-Layeras
perOSIReference
Model
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
9/96
9
A Simplified Network Reference
Model
Host-1 Host-2
Application Layer Application Layer
UpperLayer-to-LowerLayerInterface UpperLayer-to-LowerLayerInterface
UpperLayer-to-LowerLayerInterfaceUpperLayer-to-LowerLayerInterface
UpperLayer-to-LowerLayerInterfaceUpperLayer-to-LowerLayerInterface
Same Layer -to- Same Layer
Virtual Communication Interface
Same Layer -to- Same LayerVirtual Communication Interface
Same Layer -to- Same LayerVirtual Communication Interface
Same Layer -to- Same Layer
Virtual Communication Interface
Same Layer -to- Same LayerPhysical Communication Interface
(c)Dr.RahulBanerjee,BITS-Pilani,INDIA
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
10/96
Copyright: Dr. Rahul BanerjeeBITS, Pilani (India)
10
IPv4: The Header Structure
0 31
Identification16-bit Flags 3-bit Fragment Offset 13-bit
Ver. 4-bit IHL 4-bit Type of Service 8-bit Total Length 16-bit
Source Address 32-bit
Destination Address 32-bit
TTL 8-bit Protocol Type 8-bit Header Checksum 16-bit
Options + Padding
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
11/96
Copyright: Dr. Rahul BanerjeeBITS, Pilani (India)
11
IPv6: The Header Structure
0 4 16 31
Payload Length Next Header Hop Limit(16-bit) (8-bit) (8-bit)
Source Address (128-bit)
Destination Address (128-bit)
Ver. TClass Flow Label
(4-bit) (8-bit) (20-bit)
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
12/96
Intheworldofsockets:Telephony
Analogy
Socket()Endpointforcommunicaon Bind()-Assignauniquetelephonenumber. Listen()Waitforacaller. Connect()-Dialanumber. Accept()Receiveacall. Send(),Recv()Talk. Close()Hangup.
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
13/96
ATCPServerClientInteracon
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
14/96
DataStructuresInvolved
ThedatastructuresusedtoholdalltheaddressInformaon:
Structsockaddr{unsignedshortsa_family;charsa_data[14];}
Structsockaddr_in{shortsin_family;unsignedshortsin_port;//PortNumberstructin_addrsin_addr;//IPAddresscharsin_zero[8];
}
Structin_addr{unsignedlongs_addr;//4byteslong}
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
15/96
ByteOrdering,asdiscussedinthe
morningsession! Byteorderingisthea^ributeofasystemwhichindicateswhetherintegers
arestored/representedletorightorrighttole.
Example1:shortintx=0xAABB(hex)Thiscanbestoredinmemoryas2adjacentbytesaseither(0xaa,0xbb)or
as(0xbb,0xaa).BigEndian:ByteValue:[0xAA][0xBB]Memory:[0][1]
Li^leEndian:ByteValue:[0xBB][0xAA]Memory:[0][1]
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
16/96
ByteOrdering
Example2:intx=0xAABBCCDDThis4bytelongintegercanberepresentedinthesame2orderings:BigEndian:
ByteValue:[0xAA][0xBB][0xCC][0xDD]Memory:[0][1][2][3]Li^leEndian:ByteValue:[0xDD][0xCC][0xBB][0xAA]Memory:[0][1][2][3]
AllNetworkdataissentinBigEndianformat. InthenetworkingworldwecallthisrepresentaonasNetworkByteOrder
andnaverepresentaononthehostasHostByteOrder.
Whereneeded,weconvertalldataintoNetworkByteOrderbeforetransmission.
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
17/96
CommonSixoftheManyUlityFuncons
ByteOrdering:HostByteOrdertoNetworkByteOrder: htons(),htonl()
NetworkByteOrdertoHostByteOrder: ntohs(),ntohl()
IPAddressformat:
Asciido^edtoBinary:inet_aton()BinarytoAsciido^ed:inet_ntoa()
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
18/96
InvolvedSystemCalls:Summary
Socket() Bind() Listen()Accept() Connect()
Read()/Send()/Sendto() Write()/Recv()/Recvfrom() Close()
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
19/96
Socket()forCreangaConneconEndpoint
Thiscreatesanendpointforanetworkconnecon.IntSocket(intdoman,inttype,intprotocol)domain=PF_INET(IPv4communicaon)
type=SOCK_STREAM(TCP),SOCK_DGRAM(UDP)protocol=0(arandomchoicehereforthisclass!)
Example:socket(PF_INET,SOCK_STREAM,0);
ThiscreatesaTCPsocket.
ThecallreturnsasocketdescriptoronsuccessOR-1onanerror.
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
20/96
Bind()forA^achingtoanIPandPortAserverprocesscallsbindtoa^achitselftoaspecificportandIPaddress.
IntBind(intsockfd,structsockaddr*my_addr,socklen_taddrlen)sockfd=socketdescriptorreturnedbysocket()my_addr=pointertoavalidsockaddr_instructurecastasasockaddr*pointeraddrlen=lengthofthesockaddr_instructure
Example:
structsockaddr_inmy;
my.sin_family=PF_INET;my.sin_port=htons(80);my.sin_addr.s_addr=INADDR_ANY;bzero(&my,8)bind(sock,(structsockaddr*)&my,sizeof(my));
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
21/96
Listen()formakingServerWaitfora
connecon
Theserverprocesscallslistentotellthekerneltoinializeawaitqueueofconneconsforthissocket.IntListen(intsock,intbacklog)
sock=socketreturnedbysocket()backlog=Maximumlengthofthependingconneconsqueue
Example:Listen(sock,10);Thiswillallowamaximumof10conneconstobeinpendingstate.
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
22/96
Accept()foranewconnecon!
AcceptiscalledbyaServerprocesstoacceptnewconneconsfromnewclientstryingtoconnecttotheserver.IntAccept(intsocket,(structsockaddr*)&client,socklen_t*client_len)socket=thesocketinlistenstate
client=willholdthenewclientsinformaonwhenacceptreturns
client_len=pointertosizeoftheclientstructure
Example:structsockaddr_inclient;
intlen=sizeof(client);Accept(sock,(structsockaddr*)&client,&len);
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
23/96
Connect()forconnecngtoaservice
Connectiscalledbyaclienttoconnecttoaserverport.IntConnect(intsock,(structsockaddr*)&server_addr,socklen_tlen)sock:asocketreturnedbysocket()server_addr:asockaddr_instructpointerfilledwithalltheremoteserver
detailsandcastasasockaddrstructpointerlen:sizeoftheserver_addrstruct
Example:
connect(sock,(structsockaddr*)server_addr,len);
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
24/96
Send/RecvforDataTransfer Send(),Recv(),Read(),Write()etccallsareusedtosendandreceive
data.
Intsend(intsock,void*mesg,size_tlen,intflags)Intrecv(intsock,void*mesg,size_tlen,intflags)sock=Aconnectedsocketmesg=Pointertoabuffertosend/receivedatafrom/in.
len=Sizeofthemessagebufferflags=0(forourpurpose)Thereturnvalueisthenumberofbytesactuallysent/received.
Example:charsend_buffer[1024];charrecv_buffer[1024];intsent_bytes;intrecvd_bytes;sent_bytes=send(sock,send_buffer,1024,0);
recvd_bytes=recv(sock,recv_buffer,1024,0);
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
25/96
Close()forClosingtheConnecon
Closesignalstheendofcommunicaonbetweenaserver-clientpair.Thiseffecvelyclosesthesocket.Intclose(intsock)sock=thesockettoclose
Example:
close(sock);
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
26/96
SummarizingNetworkingin
LinuxEnvironment SupportMechanismmaybeof
Network-orientedcommunicaonInter-ProcessCommunicaon
Mayinvolve:ASpecialKindofPipeSupportforrequiredAddress FamilySupportforrequiredProtocolFamily&Socket
Type
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
27/96
AddressFamily
Description
UNIX Unix domain sockets
INET Internet address family support TCP(UDP)/IP
AX25 Amateur radio X25
IPX Novell IPX
APPLETALK Appletalk DDP
INET6Internet address family support TCP(UDP)/
IPv6
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
28/96
Socket Type Description
Stream Reliable, Sequenced, LikeTCP
Datagram Unreliable, Not sequenced,Like UDP
Reliable DeliveredMessages
Like datagram but reliable
Sequenced Packet Like Stream but fixed sizepacket
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
29/96
BSD Sockets
INET Sockets
TCP UDP
IP
PPP SLIP Ethernet
ARP
User
Kernel
Network
Applications
Socket Interface
Protocol Layers
Network Devices
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
30/96
TheINETLayer
BSDSocketApartofVFSinodeAsocketcanbeoperatedjustthesameasafileby
systemcallread(),write(),lseek()
INETLayerusesockdatastructuretohandleBSDsocket
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
31/96
LetslookatsomeCcodethatwas
usedforcreaonofaTCP-basedEcho
Serverprogram!
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
32/96
ATCP-basedEchoServer,wri^eninC
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
33/96
ATCP-basedEchoServer.
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
34/96
ATCP-basedEchoServer.
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
35/96
LetslookatsomemoreCcode
thatwasusedforcreaonofaTCP-basedEchoClientprogram!
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
36/96
ThisishowaCprogramforNSlookup
maylooklike!
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
37/96
ATCP-basedEchoClient,wri^eninC
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
38/96
ATCP-basedEchoClient
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
39/96
Wheretofindmorehelp?
AgoodintroducontosocketsprogramminginCisTCP/IPSocketsinC,byMichaelJ.DonahooandKennethL.Calvert(Morgan-Kaufmann,2001).
TheUNIXSystemsSupportGroupdocumentNetworkLayersexplainsthefunconsofthelowernetworklayers.
TheTransmissionControlProtocol(TCP)iscoveredinRFC793.
TheUserDatagramProtocol(UDP)isthesubjectofRFC768.
YoucanfindalistofwidelyusedportassignmentsattheIANA(InternetAssignedNumbersAuthority)Website. And,then,youhavebooksbyW.RichardStevensandDoug
Comerasdiscussedinthemorningsession!
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
40/96
AUDPServerClientInteracon
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
41/96
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
42/96
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Briefly revisiting the TCP/IP Architecture Current State-of-the-art and Evolving Research
Directions From Clusters and Grids to Clouds Wearable Computing Ubiquitous or Pervasive Computing
Select References to the literature Summary
Interaction Points
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
43/96
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Current State-of-the-art and Evolving ResearchDirections
From Clusters and Grids to Clouds Wearable Computing Ubiquitous or Pervasive Computing
Select References to the literature Summary
Interaction Points
Of Cl G id d Cl d A
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
44/96
OfClusters,GridsandCloudsA
briefintroducon Networks: Asetofautonomouscompute/communicaonnodesinterconnectedforthe
purposeofmeaningfulresourcesharing,requiresupporngprotocolstacks,not
transparenttotheusers
Clusters Homogeneous(plaorm/OS),allinvolvednodesoenbelongtoasingleenty
andfrequentlydesignedforhigh-performancecompung,maybelimitedtoone
ormorerackswithinthesameroom(example:HPCclusters),easiesttodeploy
andmanage
Grids Oenheterogeneous(plaorm/OS),Frequentlyspreadovermulplenetworks
andnetworktypes,mayinvolvesingleormulpleorganizaons,requiregreatereffortindeploymentandadministraon
Clouds Maybepublic,privateandhybrid,supportmulplelevelsofabstracons/
virtualizaon,typicallyspreadoverwideareas,expectedtobetransparenttothe
user,offerthehighestlevelsofredundancy/availability,
Janu
ary
30
,2013
(c
)D
r.
Ra
hu
lBaner
jee
,BITSPilan
i,
INDIA
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
45/96
Afewpointsofsignificance
Virtualizaonistheunderlyingcommontechnologyinvolvedinallthethreeparadigms
Networkingisthekeyenableringredientineachofthesecases
Cost-effecveness,robustnessandscalabilityimproveaswemovefromclustertocloudbut
overheadsandinternalcomplexityaddup
Janu
ary
30
,2013
(c
)D
r.
Ra
hu
lBaner
jee
,BITSPi
lan
i,
INDIA
Types of Clouds & Associated
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
46/96
TypesofClouds&Associated
Virtualizaon
TypesofClouds:Classificaon-1 PublicClouds(mul-tenancy,widevariaons,mul-
service,on-demandcapacityaddionacommonfeature)
PrivateClouds(singletenancy,limitedvariaons,highercapitalinvestments,greatercontrol,moresecure)
HybridClouds(near-opmalbestofbothworlds,ifconfiguredwell)
TypesofClouds:Classificaon-2 InfrastructureCloud,ComputaonalCloudetc.
TypesofClouds:Classificaon-3 Plaormasaservice,Sowareasaservice,Storageasa
service,Collaboraon&SharingServicesetc.
Janu
ary
30
,2013
(c
)D
r.
Ra
hu
lBaner
jee
,BITSPi
lan
i,
INDIA
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
47/96
Case-StudyofofaNetwork-BasedMul-siteCollaboraonSystemDesign
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
48/96
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Project BITS-Connect 2.0
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
49/96
WearableCompungElements
January30,2013 (c)Dr.RahulBanerjee,BITSPilani,INDIA
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
50/96
Paradiso&StarnersShoesfor
ElectricalEnergyGeneraon
January30,2013 (c)Dr.RahulBanerjee,BITSPilani,INDIA
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
51/96
PervasiveCompungwithAR
January30,2013 (c)Dr.RahulBanerjee,BITSPilani,INDIA
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
52/96
References
Larry L. Peterson & Bruce S. Davie: Computer Networks: A Systems Approach,Fifth Edition, Morgan Kaufmann / Elsevier, New Delhi, 2011.
S. Keshav: Computer Networking: An Engineering Approach, PearsonEducation, New Delhi, 1997.
A. S. Tanenbaum: Computer Networks, Fifth Edition, Pearson Education, NewDelhi, 2012.
Y. Zheng and S. Akhtar: Networks for Computer Scientists and Engineers,Oxford University Press, New York, 2002.
A. Leon Garcia and I. Widjaja: Communication Networks: FundamentalConcepts and Key Architectures, Second Edition, Tata McGraw-Hill, New Delhi,2004.
Mohammed G. Gouda: Elements of Network Protocol Design, Wiley StudentEdition, John Wiley & Sons (Pte.) Ltd., Singapore, 2004. Thomas G. Robertazzi: Computer Networks and Systems: Queuing Theory andPerformance Evaluation, Third Edition, Springer-Verlag, New York, 2000.
30/01/13 (c)Dr.RahulBanerjee,BITSPilani,INDIA 52
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
53/96
What is next?
Subsequentlecturesshallintroduceyoutothefollowingtopics:
Topologiesinvolved Performance
QualityofService Reliability Security
ProtocolsandMechanismsinvolvedMethodsofSimulaonSengupaphysicalsystemandconfiguringitNetworkAnalysis
30/01/13 (c)Dr.RahulBanerjee,BITSPilani,INDIA 53
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
54/96
References
Larry L. Peterson & Bruce S. Davie: Computer Networks: A Systems Approach,Fifth Edition, Morgan Kaufmann / Elsevier, New Delhi, 2011.
S. Keshav: Computer Networking: An Engineering Approach, PearsonEducation, New Delhi, 1997.
A. S. Tanenbaum: Computer Networks, Fifth Edition, Pearson Education, NewDelhi, 2012.
Y. Zheng and S. Akhtar: Networks for Computer Scientists and Engineers,Oxford University Press, New York, 2002.
A. Leon Garcia and I. Widjaja: Communication Networks: FundamentalConcepts and Key Architectures, Second Edition, Tata McGraw-Hill, New Delhi,2004.
Mohammed G. Gouda: Elements of Network Protocol Design, Wiley StudentEdition, John Wiley & Sons (Pte.) Ltd., Singapore, 2004.
Thomas G. Robertazzi: Computer Networks and Systems: Queuing Theory andPerformance Evaluation, Third Edition, Springer-Verlag, New York, 2000.
Dr. Rahul Banerjee, BITS, Pilani (India)30/01/13 (c)Dr.RahulBanerjee,BITSPilani,INDIA 54
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
55/96
BITS PilaniPilani | Dubai | Goa | Hyderabad
Rahul Banerjee
Thank you for your kind attention!
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
56/96
CreangaBSDSocket
Forbothclientandserver:
Syntaxtakestheform:intsocket(intfamily,inttype,intprotocol)
e.g.
fd=Socket(AF_INET,SOCK_STREAM,0);
files struct
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
57/96
files_structcount
close_on_exec
open_fs
fd[0]
fd[1]
fd[255]
filef_mode
f_pos
f_flags
f_count
f_owner
f_op
f_inode
f_version
inode
sock
socket
type
protocol
data (sk)
typeprotocol
socket
SOCK_STREAM
SOCK_STREAM
Address Family
socket operations
BSD Socket
File Operationslseekreadwriteselectioctlclosefasync
Linux BSD Socket Data Structure
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
58/96
BindinganAddress
OnlyforServer:
Intbind(intsockfd,conststructsockaddr*address,size_tadd_len)
PortNumberisoponalforbinding socket.socket_state=TCP_CLOSE;Theboundsocketcantbeusedforothercommunicaon
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
59/96
BindinganAddress(cont.)
Theboundaddrwassavedinsock.rcv_saddr UDPmaintainsahashtableudp_hashtoallocateUDPport
TCPdoesntaddthebindingsocktohashtableduringbindingoperaon
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
60/96
Listening
Onlyforserver:
intlisten(intsockfd,intqueue_size) socket.socket_state=TCP_LISTEN;
Addsthesocktotcp_bound_hashandtcp_listening_hash
Aerreceivingclientsrequest:
ServerbuildsanewsockServerclonestheincomingsk_buffandqueuesittothelisteningsock.receive_queue
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
61/96
Connecng
Onlyforclient:
Beforeconnecng,socket.socket_state=SS_UNCONNECTED;
Intconnect(intcsockfd,conststructsockaddr*address,size_tadd_len)
Addsthesocktotcp_listening_hashwaingforserversresponse
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
62/96
Accepng
Onlyforserver: intaccept(intsockfd,structsockaddr*address,size_t*add_len)
Anewsocketgetsclonedfromthelisteningsocket
IftherearenoincomingconnecontoacceptNon-Blockingacceptoperaonfailedandthrow
awaythenewsocketBlockingacceptoperaonwasaddedtothewait
queue
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
63/96
next
prev
dev
head
data
tailend
Packet to be
transmitted
sk_bufferstructure
truesizelen
PushPullPutTrim
How does a WAN Look Like?
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
64/96
30/01/13 (c)Dr.RahulBanerjee,BITSPilani,INDIA 64
HowdoesaWANLookLike?
Architecture of the Internet 1 f 2
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
65/96
30/01/13 (c)Dr.RahulBanerjee,BITSPilani,INDIA 65
ArchitectureoftheInternet1of2
Brief Historical Notes: Initiated by the US Department of Defense (DoD) through its
Advanced Research Project Agency (ARPA) and was hence calledARPANet.
Originally, it was a point-to-point WAN involving only four nodesacross the USA.
Original architecture that led to ARPANET has evolved over the yearsthat have passed by.
In later years, ARPA / DARPA dissociated with it and allowed to this tobe blossomed into the Global Public Internet as we see it now.
Current Status: It is loosely hierarchical.
Has no single body that owns it or rigidly controls it. ---Mostly run through volunteer efforts and by consensus.
Runs several services, in a distributed manner, includingthe immensely popular World-Wide Web.
Is helped by global cooperation including those fromgovernments and corporates apart from academia
A hit t f th I t t
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
66/96
30/01/13 (c)Dr.RahulBanerjee,BITSPilani,INDIA 66
ArchitectureoftheInternet2of2
Currently, Internet architecture is designed for the best-effort delivery and is largely governed by the IAB of theInternet Society (ISoc). ISoc has many sub-organs which facilitate evolution and
coordinated maintenance of the Internet. IESG steers the ISoc in a general way the engineering issues
are resolved. IETF workgroups do the ground work and by a democratic
process helps community in building up engineering solutionsthrough IETF drafts and standards (RFCs) etc.
Currently, the TCP/IP stack is the dominant protocolstack over which the Internet runs.
Keeping the needs of expansion and improvement, thisprotocol family has continually evolved over last 30+years. Current version of IP is IPv6, although IPv4 is still dominant in
use.
Wh t i th I t t t d ?
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
67/96
30/01/13 (c)Dr.RahulBanerjee,BITSPilani,INDIA 67
WhatistheInternettoday?
Wide Area Network of variety of networks Global Public Not transparent, as yet Hybrid topology but largely hierarchical No single controller Internet Society (ISoc) oversees, assists ---
does not control QoS, Security continue to have issues partly at
least Web, mail, commerce, education, entertainment,
sharing continue to dominate its applicationspace
Project BITS-Connect 2 0
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
68/96
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Project BITS-Connect 2.0
The Immersive Tele-presence Rooms
This is how an18-seater
immersive tele-
presence room
looks like at all
the Indiancampuses.
Chancellorsofficeisequippedwith
onetwo-seatersystem
A F M N ki T
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
69/96
(c)Dr.RahulBanerjee,BITS,
Pilani,India 69
A Few More Networking Terms
Repeaters / Repeater Hubs / Shared Hubs: where usually Physicallayer / level exist with L1-protocol data unit (raw bits) regeneration andonward transmission
Managed Hubs / Layer-2 Switching Hubs: where Physical and Data Linklayers / levels exist with ability to handle and deliver Layer-2-protocoldata unit (frame)
Bridges: where Physical and Data Link layers / levels exist with L2-protocol data unit (frame) processing and forwarding Switches: where Physical and Data Link and / or Network (sometimeseven higher) layers / levels exist with Layer-2 and / or Layer-3-protocoldata unit (frame / packet) processing, switched routing / forwarding
Routers: where Physical and Data Link and Network layers / levels existwith L3-protocol data unit (packet) processing, routing and forwarding
Gateways: where two or more different networks meet and may requireprotocol / message translation capabilities Clouds: abstraction of node connectivity in the networking context
A Bus Topology based Computer
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
70/96
70
ABusTopologybasedComputer
Network
SHAREDBUS
(c) Dr. Rahul Banerjee, BITS-Pilani,INDIA
N1 N2 N3 N4
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
71/96
Robert Metcafes Ethernet The original Ethernet protocol proposed and
implemented by Robert Metcafe was actually basedon 1-p CSMA/CD protocol
It did have a scheme that allowed greedy access tothe channel by a station which led to lower efficiency
Schemes like Random Back-off / Exponential Back-off were devised to improve the efficiency to a certainextent
30/01/13(c) Dr. Rahul Banerjee, SDET Unit,
BITS-Pilani, INDIA 71
An Ethernet LAN
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
72/96
AnEthernetLAN
72(c) Dr. Rahul Banerjee,
BITS, Pilani, India
PersonalComputer
Workstaon
WorkstaonWorkstation
A Star Topology based Computer
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
73/96
73
AStarTopologybasedComputer
Network
C
C
C
Switch
(c) Dr. Rahul Banerjee, BITS-Pilani,INDIA
S
N1
N2
N3
N4
An Example of a Hybrid Switching Fabric
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
74/96
Fixed
Lasers
Electronic
SwitchesGxG
MEMS
Group1
LxM
Crossbar
Linecard 1
Linecard 2
LinecardL
Group 2
LxM
Crossbar
Linecard 1
Linecard 2
LinecardL
LxM
Crossbar
Linecard 1
Linecard 2
LinecardL
Group G
MxL
Crossbar
Linecard 1
Linecard 2
LinecardL
Electronic
Switches
Optical
Receivers
Group 1
MxL
Crossbar
Linecard1
Linecard2
LinecardL
Group 2
MxL
Crossbar
Linecard1
Linecard 2
LinecardL
Group G
GxG
MEMS
GxG
MEMS
GxG
MEMS
1
2
3
M
Static
MEMS
1
2
3
M
1
2
3
M
1
2
3
M
1
2
3
M
1
2
3
M
1
2
3
M
AnExampleofaHybridSwitchingFabric
Dr. Nick McKeown, Stanford University
Another Form of Ethernet LAN
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
75/96
AnotherFormofEthernetLAN
75(c) Dr. Rahul Banerjee,
BITS, Pilani, India
TheEthernetSwitch
PersonalComputer
NetworkPrinter
Workstaon
Workstaon
LaptopComputer
Workstaon
TabletPC
A Tree Topology based Computer
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
76/96
76
ATreeTopologybasedComputer
Network
NC1 NC2
NC11
NR
NC21
NC22
NC12
(c) Dr. Rahul Banerjee, BITS-Pilani,INDIA
A Ring Topology based Computer
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
77/96
77
ARingTopologybasedComputer
Network
C
C
C
C
C
(c) Dr. Rahul Banerjee, BITS-Pilani,INDIA
A Ring Topology based Computer
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
78/96
78
ARingTopologybasedComputer
Network
C
C
C
C
C
(c) Dr. Rahul Banerjee, BITS-Pilani,INDIA
S f N t k T l i
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
79/96
(c) Dr. Rahul Banerjee, BITS, Pilani, India 79
SummaryofNetworkTopologies
Bus Topology Shared Switched
Tree Topology Ring Topology
Single Double
Star Topology Irregular Topology Complete Topology
Frames: Link Layer (L 2) Data Units
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
80/96
Frames:LinkLayer(L-2)DataUnits
Frame TheunitofDataasexpressedattheDataLinkLayer(Layer-2oftheHypothecalmodelusedforinstrucon)isconvenonallycalledaFrame.
Framescantakedifferentformatsandsizesdependingupontheprotocolinqueson
Framesdoincludefieldslikesynchronizaon,addressing,payload,control-informaonetc.
FrameForwarding Theprocessofmovingframesfromoneporttoanotherinabridgeorswitch.
80
(c) Dr. Rahul Banerjee,
BITS, Pilani, India
Frames: Factors that ma^er!
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
81/96
Frames:Factorsthatma^er!
Synchronization: Transmitter & Receiver need tobe in sync
Start Delimiter: Required to mark starting bit End Delimiter: Required to mark the end bit Control Information: Information suggesting datahandling and interpretation Error Detection / Correction / Retransmission Flow Control: Required for avoiding data loss
due to overflow at receiving end Data Length: Needed if data-field is not of fixed
size
81
(c) Dr. Rahul Banerjee,
BITS, Pilani, India
A S l F F t
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
82/96
ASampleFrameFormat
n-BytePreambleStart-of-FrameDelimiterDesnaonAdd.SourceAddress
LengthofData
DataField PadField
Checksum
82
(c) Dr. Rahul Banerjee,
BITS, Pilani, India
Logical View of a 10-Gbps Unit
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
83/96
LogicalViewofa10 GbpsUnit
h^p://www.ovislinkcorp.co.uk/linkd.GIF
7 1 6 6 246=
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
84/96
SummaryofDifferencesBetweenL 2Switches,
Routers(L-3)andL-3Switches
BridgesandLayer-2switchesdividethenetworkintosegmentsormicro-segments
(apartfromhelpinginLayer-2protocol
translaon,management,securityetc.) Ineffect,wecansaythat
Layer-2Switches/Bridgesseparatecollisiondomains
Layer-2Switches/Bridgescancarryoutprotocoltranslaons
30/01/13
(c)Dr.RahulBanerjee,SDETUnit,BITS-
Pilani,INDIA 84
Summary of Differences Between L-2 Switches,
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
85/96
SummaryofDifferencesBetweenL 2Switches,
Routers(L-3)andL-3Switches
RoutersareLayer-3deviceswhohandleLayer-3packetroungwithinandoutsidethelocalnetwork/internetworkandthereforeeffecvely
separatebroadcastdomainswhichendatitsdifferentnetworkinterfaces
eachofwhichcarriesaseparateSubnet-idenfier/Subnet-address(apart
fromLayer-3protocoltranslaon,monitoring,securityandmanagement)
Thus,ineffect,wecansaythat: RoutersSeparatebroadcastdomains(eachofsuchbroadcastdomainswhich
endatitsdifferentnetworkinterfaceseachofwhichcarriesaseparate
Subnet-idenfier/Subnet-address)
Routerscancarryoutinteriorroungand/orexteriorroung,dependingupontheirlocaoninthenetwork
Routerscancarryoutprotocoltranslaons(intermsofprotocol-specificpacketformatsaswellasintermsofallowingappropriatelyforma^ed
selecvedataspecifictoroungprotocolstheymaysupport).
30/01/13
(c)Dr.RahulBanerjee,SDETUnit,BITS-
Pilani,INDIA 85
Summary of Differences Between L-2 Switches,
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
86/96
SummaryofDifferencesBetweenL 2Switches,
Routers(L-3)andL-3Switches
Layer-3switchesaredeviceswhichcanhandleallfunconaliesofLayer-2Switchesaswellasfast(oenbasedonheader/tag/labelswitching)Layer-3packetroungwithinbutnotoutsidethelocalnetwork/internetwork;and
therefore,effecvelyseparatebroadcastdomainswhichendatitsdifferent
LANinterfaceseachofwhichcarriesaseparateSubnet-idenfier/Subnet-
address(apartfromoponalLayer-3protocoltranslaon,monitoring,securityandmanagement)
Thus,ineffect,wecansaythat: L-3SwitchesSeparatebroadcastdomains(eachofsuchbroadcastdomainswhich
endatitsdifferentLANinterfaceseachofwhichcarriesaseparateSubnet-
idenfier/Subnet-address)
L-3Switchescancarryoutfastinteriorroung/packet-switchingoenbasedonheader/tag/labelswitching
Layer-3Switches,oponally,cancarryoutprotocoltranslaons(intermsofprotocol-specificpacketformats).
30/01/13
(c)Dr.RahulBanerjee,SDETUnit,BITS-
Pilani,INDIA 86
Inside a Layer-2 Switch
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
87/96
InsideaLayer-2Switch
ElementsofaLayer-2Switch Processors(Front-endProcessorsonLineCards)for
FrameRoung
MulpleBuffersforMulpleQueues SharedI/OBusorRing(1st/2ndGen.)/Switching
Fabric(3rdGen.)
I/PLineControllers(ILC)
O/PLineControllers(OLC)
87
(c)Dr.RahulBanerjee,BITS,
Pilani,India
Some More Terms of Relevance
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
88/96
SomeMoreTermsofRelevance Collision Domain
The set of all stations connected to a networkwhere faithful detection of a collision can occur.
A collision domain terminates at a switch port. Late Collision
A failure of the network in which the collisionindication arrives too late in the frametransmission to be automatically dealt with by themedium access control (MAC) Protocol.
The defective frame may not be detected by allstations requiring that the application layer detectand retransmit the lost frame, resulting in greatlyreduced throughput.
CRCCyclic Redundancy Check is an error-checking
technique used to ensure the fidelity of receiveddata.
88 (c) Dr. Rahul Banerjee, BITS, Pilani, India
E F b i f W bl G t
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
89/96
E-FabricofaWearableGarment
January30,2013 (c)Dr.RahulBanerjee,BITSPilani,INDIA
Wi l C i i W bl
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
90/96
WirelessCommunicaoninWearables
January30,2013 (c)Dr.RahulBanerjee,BITSPilani,INDIA
U I t f & S
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
91/96
UserInterface&Sensors
January30,2013 (c)Dr.RahulBanerjee,BITSPilani,INDIA
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
92/96
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
93/96
TCP/IP M d l
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
94/96
TCP/IPModel
OSI TCP/IP
Application
Presentation
Session
Transport
Network
Data Link
Physical
Application
Transport
Internet
Host-to-Network
7
6
5
4
3
2
1
TCP
IP
TCP O i
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
95/96
TCPOverview
TCP(TransmissionControlProtocol)Connecon-OrientedReliableProtocol
UDP(UserDatagramProtocol)ConneconlessUnreliableProtocol
IP Overview
-
7/28/2019 CSC461-CN-Lecture-8-Jan-30-2013
96/96
IPOverview
32-bitUniqueIPAddressNetworkAddressSubnetAddressHostAddress
140.112.28.XX 140.112.30.XX
Gateway
(Router)