Escolar Documentos
Profissional Documentos
Cultura Documentos
TCPyUDPatravsdeclienteandroid
Infraestructuradecomunicaciones
AnaMaraCrdenas(
am.cardenas926
),AndreaNavas(
a.navas380
)
201213021201125090
UniversidaddelosAndes,Bogot,Colombia
Fechadepresentacin:Septiembre20de2015
Contenido
Introduccin
DesarrolloServidorTCPyUDPenjava
Definicindelprotocolo
Arquitecturadelservidor
DesarrolloClienteAndroidTCPyUDP
Arquitectura
Interfazgrfica
Envodemensajesdeposicin
Envodemensajesdeprueba
PruebasdeJMETERsobreelservidor
Diseodelaspruebas
Resultadosdelaspruebas
PruebassobreelClienteAndroid
Diseodepruebas
ResultadosPruebas
Evaluacinyanlisisdeaplicacionesdelmercado
Waze
Netflix
Skype
Conclusiones
Bibliografa
1.
Introduccin
Enelsiguienteinformesepresentareldesarrollodeimplementacionesdeservicios
soportadosporprotocolostantoTCPcomoUDP.Paraelservicioseutilizaruna
arquitecturaclienteservidordondeelclienteestarimplementadoenAndroidyel
servidorenJava.Paralaejecucindelservicioseasumirquetantoelservidorcomo
elclienteestnenunamismaredylaIPdelservidorascomolospuertosdondese
exponeelserviciosonconocidosporelcliente.
Encadaunodeloscasosserealizarunanlisisdeldesempeoycapacidaddeun
serviciosegncadaprotocolo.Elinformebuscarrelacionarlainformacinobtenida
sobreeldesempeoconlaarquitecturadesarrolladaparalaaplicacinyparael
servidorascomolosprotocolosqueseutilizaronenlaspruebas.Elinformetambin
buscaraproximarseaescenariosdepruebaqueseanefectivosparamedirtantoel
desempeocomolacapacidaddelservidor.
2.
DesarrolloServidorTCPyUDPenjava
2.1.
Definicindelprotocolo
Lafuncionalidaddelaaplicacinquesedeseaeselregistrodeinformescada
segundodesdeunclientedentrodelservidor.Comonoseconoceelmomento
deinicionidefindelosmensajeselservidorsiempreestesperandoporun
clientequeseregistreyempieceaenviarlosmensajesalservidor.Estepuede
dejardeenviarmensajesencualquiermomento.Elprotocolovarasegnsi
losmensajescorrespondenalaspruebasdesdeelclienteoaunusuarioreal
queseregistraenlaaplicacin.
Ambosprotocolosseencuentranimplementadosenelclienteyseutilizan
segnlodefinidoporelusuario.
Protocolodecasodeusoreal:
Figura2.1.1Protocolodecasodeusoreal
Figura2.1.2Protocolodecasodepruebas
2.2.
Arquitecturadelservidor
Paraelcasodelservidorseimplementunservidorenjavaqueejecuta
threadsparacadaunodelosclientesqueseconectayenvamensajes.Parael
casodeUDPsetieneunDatagramPacketsobreelmismoDatagramSocket
cadavezqueunclientenuevoseconecta.ParaelcasodelThreadTCPsetiene
1porcadaclientequeseconectaconsurespectivoBufferedReader.
Figura2.2.1Arquitecturadelservidor
ParalaspruebasdeJMETERserealizunaimplementacinespecialdel
servidorqueenvamensajesderespuestaalclientecadavezquerecibeuna
solicituddeTCPconelfindepoderrealizarlasmedidasdedesempeoeneste
caso.
3.
DesarrolloClienteAndroidTCPyUDP
3.1.
Arquitectura
Paraelcasodeldesarrollodelclientesehizousodethreadsparamanejarel
envodemensajesdesdeTCPodeUDPascomoparalaejecucinde
Threads.Paraelcasodelenvodelaposicinsehizousode
LocationListener
elcualesimplementadopormainactivity.Parala
ejecucindelaaplicacinserequirieronpermisosdeAndroidtantopara
internetcomoparalosserviciosdeubicacin.
Figura3.1.1Arquitecturadelcliente
3.2.
Interfazgrfica
Paraeldesarrollodelaaplicacinserealizunainterfazquepermitiera
personalizarlaejecucinsegnelprotocoloysisedeseaonohacerpruebas.
Tambinseinformaalusuariosicambilaposicinyseactualizalainterfazy
selepermiteiniciarycancelarelenvodelaposicin.
Figura3.2.1Interfazgrficadelaaplicacin
3.3.
Envodemensajesdeposicin
Paraenviarlosmensajesdelaposicinsehizousodeuntimerquecada
segundoenvalamismadireccinsinosehamodificadooenvaunanuevaen
casodequeseactualiceatravsdelLocationListener.
privatevoid
sendPosition(){
Timertimer=
new
Timer()
timer.schedule(
new
TimerTask(){
@Override
publicvoid
run(){
if
((
tcp_sender
!=
null
||
udp_sender
!=
null
)&&
enviando
){
Log.
e
(
"TCP"
,
"enviamensajealservidor"
)
Stringmensaje=
nLatitud
+
":"
+
nLongitud
+
":"
+
nAltitud
+
":"
+
nVelocidad
if
(
tcp_sender
!=
null
)
tcp_sender
.enviarTCP(mensaje)
else
udp_sender
.enviarUDP(mensaje)
}
},
0
,
1000
)
//Updatetexteverysecond
}
3.4.
Envodemensajesdeprueba
Paraelenvodelosmensajesdepruebaseutilizaronthreadsqueenvanun
mensajedeterminadounnmerodeterminadodeveces.Elnmerodethreads
yelnmerodemensajesestndeterminadosporelusuariodesdelainterfaz.
Sinoseingresaunvalorseenvapordefecto10mensajesdesdeunnico
thread.Debidoaqueelrampupeselmismoparatodaslaspruebasse
encuentraelvalordentrodelcdigo.
4.
PruebasdeJMETERsobreelservidor
4.1.
Diseodelaspruebas
ParalaspruebasdeJMETERseejecutconunrampupconstantede1000ms
(1seg)aumentandoelnmerodethreadsqueseenviabaconunnico
mensaje.
Losresultadossedocumentaronatravsdegrficasderesponsetimeyreporte
agregado.Paraningncasosedeterminuntimeouty300threadsnofueron
suficientesparaobtenerthreadsdescartadosporpartedelservidor.
Figura4.1.1ConfiguracindepruebasdeTCPydeUDP
4.2.
Resultadosdelaspruebas
Enlasiguientegrficasepuedenotarladiferenciaentrelos2protocolos
dondeUDPescalamuchomejorqueTCP.Dadoquenohayprdidade
paquetesenestecasoUDPresultamejorqueTCPyaquellegandemanera
muchomsrpidalosmensajes.Sedebetenerencuentaqueelservicioest
corriendoenelmismocomputadorporlotantolostiemposderespuestano
tienenencuentaeldelaydelared.
Figura4.1.2ComparacindeTCPydeUDP
Acontinuacinsepresentalosresultadosobtenidosparatcpyudpparael
responsetimeyparalospromedios.
TCP50Threads
MEDIA:1
MEDIANA:1
%ERROR:0
KB/SEG:
0.01330342237
TCP100Threads
MEDIA:1
MEDIANA:1
%ERROR:0
KB/SEG:
0.3799854086
TCP300Threads
MEDIA:6
MEDIANA:2
%ERROR:0
KB/SEG:
1.059561483
TCP500Threads
MEDIA:80
MEDIANA:26
%ERROR:0
KB/SEG:
1.673628963
UDP50Threads
MEDIA:0
MEDIANA:0
%ERROR:0
KB/SEG:
0.0021034124
UDP100Threads
MEDIA:0
MEDIANA:0
%ERROR:0
KB/SEG:
0.007354009
UDP300Threads
MEDIA:0
MEDIANA:1
%ERROR:0
KB/SEG:
0.01985221
UDP500Threads
MEDIA:0
MEDIANA:1
%ERROR:0
KB/SEG:0.
039400231
5.
PruebassobreelClienteAndroid
5.1.
Diseodepruebas
SerepliclaconfiguracindelaspruebasrealizadasenJMETERenandroida
travsdelainterfazdesarrollada.Paralosresultadosdelaspruebasse
muestranlospromediosdelosresultadosobtenidosenambasiteraciones.
Pararealizarlaspruebasseenvauntimestampdesdeelclienteysevuelvea
tomareltimestampcuandollegaalservidordemaneraquesepuedecalcular
laduracindelenvodelmensaje.
Paradeterminarelporcentajedeprdidasseutilizaelnmerodemensajes
enviados,conocidosdesdeelclienteysedeterminaelporcentajesegnlos
mensajesdepositadosenellog.
5.2.
ResultadosPruebas
Figura5.2.1ComparacindeTCPydeUDP(media)enms
Figura5.2.2ComparacindeTCPydeUDP(mediana)enms
Figura5.2.3ComparacindeTCPydeUDP(moda)enms
ComosemuestraenlasgrficasdecomparacinUDPpresenta,engeneral,un
mejorcomportamientoqueTCPconuntiempoderespuestamenorparalas
peticionesdelosclientes.Seobservaunaexcepcinaestecomportamientoen
elcasode100threadsperoenestecasoladiferenciapudodebersea
condicionesdelaredcomocongestinyaquelaspruebasconelcelularsi
estnsometidasalascondicionesdelared.
Paraelcasodeprdidadepaquetes,enambosprotocolos,elnmerode
solicitudesatendidascorrespondial100%delassolicitudesenviadasporlo
quesepuededeterminarquenohaydiferenciasencuantoalasprdidaspara
estoscasosdeuso.
Figura5.2.4DatosnumricosderesultadosenMS
6.
Evaluacinyanlisisdeaplicacionesdelmercado
6.1.
Waze
Deacuerdoalapginadelaaplicacin
Wazeeslaaplicacindetrficoy
navegacinbasadaenlacomunidadmsgrandedelmundo.netealos
conductoresdetureaquecomparteneltrficoeinformacinderutaen
tiemporealahorrandotodostiempoydineroensusdesplazamientos
diarios.
.Deacuerdoaloquesehaconsideradoalolargodellaboratoriouna
aplicacindetiemporealessensiblealostiemposderespuestay
throughput
enlaspeticionessinqueprdidasdereportesenunsegundoenespecficosean
muyconsecuentesparalaexperienciadelusuario.
DeacuerdoaunartculodePCWorldenunaentrevistaaTobiasJeske,un
estudiantedoctoraldelInstituteforSecurityinDistributedApplicationsofthe
HamburgUniversityofTechnology:
Googlenavigationusesrealtimetraffic
informationinGoogleMapsformobile.Theprotocolusedtosendlocation
informationisprotectedbyaTLS(TransportLayerSecurity)tunnelthat
ensuresthedataintegritysothatitisimpossibleforanattackertomonitora
foreignphoneormodifyinformationwithoutbeingdetectedbyGoogle
1.TLS
seencuentraimplementadosobrelacapaTCP.Laseguridadesunfactormuy
importanteparaaplicacionescomoWazeporquelainformacindela
localizacindeunusuariosondatossensiblesypuedenponerenriesgola
privacidadyseguridaddelosusuariosdeWaze.
Deacuerdoaotrafuente
FloatingCarDatafromSmartphones:What
GoogleandWazeKnowAboutYouandHowHackersCanControl
Traffic
porTobiasJeske(entrevistadoenlafuenteanterior)
Today,
navigationdevicesfrequentlyreceivetrafficreportsontheTrafficMessage
Channel(TMC).TMCmessageshaveseveralsources:thepolice,permanently
installedsensorsliketrafficcamerasorinductiveloops,andtrafficreportsof
volunteers.2
Esteprotocolodetransmisinserealizaatravsderadioypor
lotantonotienerelacinconTCPoUDP
TMCisaspecificapplicationof
FMRDSusedforbroadcastingrealtimetrafficandweatherinformation.
DatamessagesarereceivedsilentlyanddecodedbyaTMCequipped
navigationsystem,anddeliveredtothedriver,typicallybyofferingdynamic
routeguidancealertingthedriverofaproblemontheplannedrouteand
calculatinganalternativeroutetoavoidtheincident.
3.Deacuerdoaesta
fuente
WazeisafreeGPSapplication,whichalsousesFCDofsmartphones
inordertogeneratetrafficinformation.
FDCesuntipodedatosdeposicin
generadodesdeelsistemaoperativoandroid
Googleusespositiondataof
smartphoneswiththeAndroidoperatingsystem,whichresultsina
significantlyfastermappingofthetrafficflow.Thisdataiscalledfloatingcar
http://www.pcworld.com/article/2030991/researcherhackerscancausetrafficjamsbymanipulating
realtimetrafficdata.html
.Pag1
2
https://media.blackhat.com/eu13/briefings/Jeske/bheu13floatingcardatajeskewp.pdf
3
http://tisa.org/technologies/tmc/
data(FCD).Positiondataisdeterminedbythenavigationsystemor,asinthe
caseofGoogleLiveTraffic,bythesmartphoneandistransmittedtothe
serviceproviderviaamobilephoneconnection.ComparedtoTMC,this
allowsthegenerationoftrafficinformationinrealtime.
EstasegundafuentetambincoincideconelusodeTLSparaelenvode
informacinsensibledelusuario.
Thetransmissionoflogininformationsuch
asusernameandpasswordisencryptedusingTLS.Iftheuserstartstheapp,
thelogininformationistransferredtotheWazeserver.Theusergetsaserver
IDandacookiefromtheserver.AllsubsequentmessagessenttotheWaze
servercontaintheIDandthecookie,bothofwhichareintroducedbythe
keywordUID
4
Figura6.1.1Wazerequestmessage
6.2.
Netflix
DadoqueNetflixconsisteenunserviciodestreamingsepuededeterminar,en
primerainstanciaquenoessensibleaprdidadeinformacin(puedereducir
lacalidaddelstreamingyperderinformacindealgunospxelesdela
imagen).Deigualmanerasepuedepensarqueesmsimportantegarantizar
unamayorvelocidaddelservicioquelagarantadellegadadelmensaje.
Otraveznuestrashiptesislleganaestarerradas.Segnelartculo
Unreeling
Netflix:UnderstandingandImprovingMultiCDNMovieDelivery
de
VijayKumarAdhikari:
NetflixusestheDASH(DynamicStreamingover
HTTP)protocolforstreaming.InDASH,eachvideoisencodedatseveral
differentqualitylevels,andisdividedintosmallchunksvideosegmentsof
nomorethanafewsecondsinlength.Theclientrequestsonevideochunkata
timeviaHTTP.Witheachdownload,itmeasuresthereceivedbandwidthand
runsaratedeterminationalgorithmtodeterminethequalityofthenextchunk
torequest.DASHallowstheplayertofreelyswitchbetweendifferentquality
levelsatthechunkboundaries.
5 .
ElprotocoloDASHcorresobreHTTPypor
lotantohaceusodeTCPcomoprotocolodetransporte.Elclientetambin
https://media.blackhat.com/eu13/briefings/Jeske/bheu13floatingcardatajeskewp.pdf
Pag5
http://wwwusers.cs.umn.edu/~viadhi/netflix.pdf
Pag1
hacelaspeticionesdecada
chunk
devideoatravsdeHTTPporlotantoen
estecasotambinsehaceusodeTCPparaelenvodemensajes.
EnelartculotambinseconfirmaelusodeTCPcuandoelautormenciona
queseenvanmenSajesdekeepalivedeTCP
Wealsosendkeepalive
messagestoeachservereverysecondwhennodataistransferredtomake
surethattheTCPsessionisaliveandsenderwindowsizedoesnotdrop
6
Figura6.2.1Wazerequestmessage
6.3.
Skype
ParaelcasodeSkypesepuedepensar,otravez,quelatransferenciadevozes
unservicioquepriorizalavelocidadsobrelaseguridaddellegadadela
informacinyporlotantosedeberausarUDP.
EnesteaspectolaWikideWireshark7nosdaunapista.Sedeclaraquees
difcilanalizarelprotocolodeSkypedadoqueesunprotocolopropietariosin
embargomuestraquesepuedefiltrarunpuertodeUDPparacapturardatos
intercambiadosporSkypelocualindicaraqueSkypeusaUDP.
Figura6.3.1CapturadeWiresharkWiki
6
http://wwwusers.cs.umn.edu/~viadhi/netflix.pdf
Pag7
https://wiki.wireshark.org/Skype
EnelartculodeWikipediasobreelSkypeProtocoltantoTCPcomoUDP
puedenserutilizadosparaunallamadadeSkype.Segnesteartculola
autenticacinesrealizadapormediodeTCP
A
TCP
connectionmustbe
established(i.e.toasupernode)otherwisetheloginwillfail.Herehcmeans
hostcachei.e.theinformationthataskypeclientstoresaboutthelistof
supernodes(sc)8
Figura6.3.3UDPPackets
7.
Conclusiones
7.1.
7.2.
7.3.
7.4.
LosserviciosprestadossobreTCPyUDPpresentandiferenciassignificativas
encuantoaltiempoderespuestaythroughputsiendoUDPmseficienteque
TCPalnotenerqueestablecerunaconexinnirealizarelprotocolode
Handshakeparaasegurarlallegadadepaquetes.
Apesardequelaprdidadepaquetesnopudoobservarseenellaboratorio
debidoaqueunadelaspruebasserealizconJMETERdentrodelmismo
hostdelservidorylaotraenunareddomsticapococongestionada,existen
diferenciassignificativasentrelatasadexitodeserviciosqueimplementan
sucomunicacinatravsdeTCPylosqueusanUDP.SiendoTCPel
protocoloquegarantizaunallegadaseguradelospaquetes.
ApesardequesepuedepensarqueaplicacionescomorastreodeGPSen
tiemporealsebeneficiandeunaimplementacinatravsdeUDPgraciasasu
velocidadesnecesariotenerencuentaquelaubicacinesunainformacin
sensibledelosusuariosquedebesertransportadademanerasegurayas
mismoexistenotrosprotocolosqueutilizanotrascapasfsicasydeenlacems
especficasparaestosprocedimientos(ComoTMC).
ApesardequesepuedepensarqueaplicacionescomostreamingdeVideose
beneficiandeUDPsedebeconsiderarqueestosserviciospuedengarantizar
distintosnivelesdecalidaddelvideoatravsdeTCP(usandoHTTPy
protocolosdestreaming)y,deestamanera,podercontrolarlavelocidadde
transmisinygarantizarunacalidadmnima.
https://en.wikipedia.org/wiki/Skype_protocol
7.5.
Losserviciospuedencorrersobremsdeunprotocolocomoeselcasode
Skypeparagarantizarlaejecucinendistintasplataformasypermitirtambin
unaconfiguracinptimadelservicio.
8.
VideosdeDEMO
LosvideosdedemodelaaplicacindesarrolladafueronsubidosaYoutubeyse
encuentranenlossiguientesLinks:
Videodeimplementacindepruebas:
https://youtu.be/0gE6PY8fyM
Videodeimplementacindelservicio:
https://youtu.be/bUfBodaUx50
9.
Bibliografa
[1]
Waze(n.d.).
RetrievedSept20,2015,from
https://www.waze.com/
[2]
UnreelingNetflix:UnderstandingandImprovingMultiCDNMovieDelivery
.
VijayKumarAdhikari
,YangGuo,FangHao,MatteoVarvello,VolkerHilt,
MoritzSteinerandZhiLiZhang
UniversityofMinnesota,
BellLabs/AlcatelLucent.RetrievedSept20,2015from
http://www.cs.columbia.edu/~library/TRrepository/reports/reports2004/cucs03904
.pdf
[3]
FloatingCarDatafromSmartphones:WhatGoogleandWazeKnowAbout
YouandHowHackersCanControlTraffic
TobiasJeske.RetrievedSept20,
2015from
https://media.blackhat.com/eu13/briefings/Jeske/bheu13floatingcardatajeskewp
.pdf
[4]
Skype.
RetrievedSept20,2015,
https://wiki.wireshark.org/Skype
[5]SkypeProtocolRetrievedSept20,2015,
https://en.wikipedia.org/wiki/Skype_protocol