open system interconnection (OSI) reference model

defiantneedlessΔίκτυα και Επικοινωνίες

23 Οκτ 2013 (πριν από 3 χρόνια και 10 μήνες)

96 εμφανίσεις

cisc3120
designandimplementationofsoftwareapplicationsI
spring2012
lecture#III.2:communication-sockets
topics:
•networkprotocols
•sockets
cisc3120-spring12-ozgelen-lecIII.21
opensysteminterconnection(OSI)referencemodel
•alsocalledthe7-layermodel:
1.applicationlayer(displaysdata,communicateswiththelowerlayersviapresentation
layer)
2.presentationlayer(linkbetweentheappandlowerlayers;convertsapplicationlayer
datatoformsunderstandablebyotherlayers,andback;translatesthe“meaning”of
thebits)
3.sessionlayer(exchangeofdatabetweenapplications-“dialog”-andsynchronization
betweenapplications)
4.transportlayer(transferofdatathroughnetwork;effectsflowcontrol;providessome
errorrecovery)
5.networklayer(physicalroutingofdatafromonecomputertoanother;facilitates
senderfindingreceiver)
6.datalinklayer(managestransmissionsoflow-leveldata;detectsandcorrects
transmissionerrors)
7.physicallayer(sendselectronicsignals,or“bits”-0’sand1’s)
cisc3120-spring12-ozgelen-lecIII.22
•Here’aaphrasetorememberthelayers“Allpeopleseemtoneeddataprocessing”where
thefirstletterofeachwordreferstoalayer(above)
•informationformats:
–“informationunits”arepassedfromonelayertoanother;“headers”areaddedas
informationpassesfromuppertolowerlayer
–terminologyisdefinedbelow(itisoftennotusedclearlyorprecisely):
∗frame=informationunitwhosesourceanddestinationarethedatalinklayer
∗packet=informationunitwhosesourceanddestinationarethenetworklayer
∗segment=informationunitwhosesourceanddestinationarethetransportlayer
∗message=informationunitwhosesourceanddestinationaretheapplicationlayer
∗datagram=informationunitina“connectionless”network
cisc3120-spring12-ozgelen-lecIII.23
tcp/iparchitecture
•TCP/IPwithalayeredmodel,itisviewedasbeingcomposedoffewerlayersthanthe
sevenusedintheOSImodel:
Layer
transmissionstructure
Application
stream
Transport(TCP/UDP)
segment
Internet(IP)
datagram
NetworkAccess(Ethernet)
frame
•ThelayeredstructureofTCP/IPisseeninthewaydataishandledasitpassesdownthe
protocolstackfromtheApplicationLayertotheunderlyingphysicalnetwork.
•Eachlayerhasitsownindependentdatastructures.
•Eachlayerinthestackaddscontrolinformationtoensureproperdelivery.
•Thiscontrolinformationiscalledaheaderbecauseitisplacedinfrontofthedatatobe
transmitted.
cisc3120-spring12-ozgelen-lecIII.24
ip–internetprotocol
•TheInternetProtocolisthebuildingblockoftheInternet
–Definingthedatagram,whichisthebasicunitoftransmissionintheInternet
–Routingdatagramstoremotehosts
–Performingfragmentationandre-assemblyofdatagrams
∗Asadatagramisroutedthroughdifferentnetworks,itmaybedividedintosmaller
pieces.
∗Eachtypeofnetworkhasamaximumtransmissionunit(MTU),whichisthelargest
packetthatitcantransfer.
–MovingdatabetweentheNetworkAccessLayerandtheTransportLayer
–DefiningtheInternetaddressingscheme
cisc3120-spring12-ozgelen-lecIII.25
internetaddressesanddomainnames
•IPaddress=InternetProtocoladdress
•everycomputerontheinternethasauniqueaddress
•dottedquadnotation=fournumbersseparatedbydots(.);e.g.,146.245.250.131(which
istheaddressoftheCISdeptwebserver...)
•addresscanbestoredin32bits;therearefourformats,dependingonthesizeofthe
network(i.e.,thesizeofeachofthenumbersinthedottedquadnotationisdefinedbythe
format...)
•“subnetting”isastandard(definedin1985)todividealargenetworkintoanumberof
smallernetworks(thisiswhatarouterdoes)
•example:
network
subnet
host
prefix
number
number
IPaddress130.5.5.25→
130.5.
.5
.25
•domainnames
–providesamoreconvenientwaytoaddressacomputerontheinternetthanthe
numericIPaddress
cisc3120-spring12-ozgelen-lecIII.26
–structuredhierarchically(e.g.,treestructure)
–example:www.sci.brooklyn.cuny.edu
–commondomainnames:com,edu,gov,ukandothercountry-baseddomains
–nameserver:maintainscorrespondancebetweennumericIPaddressanddomain
names;
–DNS=internetdomainnamesystem=groupofdomainnameservers
cisc3120-spring12-ozgelen-lecIII.27
tcp–transmissioncontrolprotocol
•TCPprovidesreliabledatadeliveryservicewithend-to-enderrordetectionandcorrection.
–connection-oriented
∗likeatelephone
∗firstaconnectionmustbeestablished,thendataistransferred,finallythe
connectionisclosed.
–reliable
∗verifiesthatdataisdeliveredacrossthenetworkaccuratelyandintheproper
sequence
∗ifthedatasegmentisdamaged,thereceiverdiscardsit.
∗afteranappropriatetimeoutperiod,thesendingTCPmodulere-transmitsdamaged
segment
•TCPisalsoresponsiblefordeliveringdatareceivedfromIPtothecorrectapplication.
•Theapplicationthatthedataisboundforisidentifiedbya16-bitnumbercalledtheport.
cisc3120-spring12-ozgelen-lecIII.28
udp–userdatagramprotocol
•UDPprovideslow-overhead,connectionlessdatagramdeliveryservice.
–connectionless
∗likesendingaletterinthemail
∗thereisnoguaranteethattherecipientevergetstheletter
–unreliable
∗therearenotechniquesintheprotocolforverifyingthatthedatareachedtheother
endofthenetworkcorrectly
∗Iftheamountofdatabeingtransmittedissmall,theoverheadofcreating
connectionsandensuringreliabledeliverymaybegreaterthantheworkof
re-transmittingtheentiredataset.
cisc3120-spring12-ozgelen-lecIII.29
socket
•asocketenablescommunicationbetweenaclientandaserverprocessandmaybeeither
connection-orientedorconnectionless.
•asocketisoneendpointofatwo-waycommunicationlinkbetweentwoprogramsrunning
onthenetwork.
•asocketisboundtoaportnumbersothattheTCPlayercanidentifytheapplicationthat
dataisdestinedtobesent.
•aclientsocketinonecomputerusesanaddresstocallaserversocketonanother
computer.
cisc3120-spring12-ozgelen-lecIII.210
socketsandports
•socket:
–anetworkconnectionimplementedinsoftware
–i.e.,aprogramhastoopena“socket”onacomputer(usinganIPaddressandaport
number)toreachanotherprogramonanothercomputer
•port
–networkconduitonacomputerthroughwhichaconnectionto/fromothercomputersis
made
–certainnumbersarecommonlyassociatedwithcertainservices;e.g.,port80→http
–allowstwo-waycommunication
–NOTahardwareconcept(NOTlike“USBport”or“printerport”)
–userscandefinetheirownnetworkportsandusethemforuser-specificapplications
cisc3120-spring12-ozgelen-lecIII.211
socketprogramming
•Howaclientprogramcanreadfromandwritetoasocket:
Stringaddress="echo-server";
intport=4444;
Socketsocket=newSocket(address,port);
PrintWriterout=newPrintWriter(socket.getOutputStream(),true);
BufferedReaderin=newBufferedReader(
newInputStreamReader(socket.getInputStream()));
•Howaserverprogramcanacceptandprocessclientrequeststhroughsocket:
intport=4444;
ServerSocketserver=newServerSocket(port);
SocketclientSocket=server.accept();
PrintWriterout=newPrintWriter(
clientSocket.getOutputStream(),true);
out.println("Respond");
cisc3120-spring12-ozgelen-lecIII.212